mirror of
https://github.com/reactos/reactos
synced 2025-10-06 16:32:42 +02:00
Compare commits
6 Commits
netstat_cr
...
backups/ha
Author | SHA1 | Date | |
---|---|---|---|
|
95e0fa9313 | ||
|
2cf308079f | ||
|
b0b68753ff | ||
|
5d915742e5 | ||
|
98dd342a5e | ||
|
9c6c715330 |
329
inc_w32k/bitmaps.h
Normal file
329
inc_w32k/bitmaps.h
Normal file
@@ -0,0 +1,329 @@
|
||||
|
||||
#ifndef __WIN32K_BITMAPS_H
|
||||
#define __WIN32K_BITMAPS_H
|
||||
|
||||
/* GDI logical bitmap object */
|
||||
typedef struct _BITMAPOBJ
|
||||
{
|
||||
SURFOBJ SurfObj;
|
||||
FLONG flHooks;
|
||||
FLONG flFlags;
|
||||
SIZE dimension; /* For SetBitmapDimension(), do NOT use
|
||||
to get width/height of bitmap, use
|
||||
bitmap.bmWidth/bitmap.bmHeight for
|
||||
that */
|
||||
#ifdef NTOS_MODE_USER
|
||||
PVOID BitsLock;
|
||||
#else
|
||||
PFAST_MUTEX BitsLock; /* You need to hold this lock before you touch
|
||||
the actual bits in the bitmap */
|
||||
#endif
|
||||
|
||||
/* For device-independent bitmaps: */
|
||||
DIBSECTION *dib;
|
||||
HPALETTE hDIBPalette;
|
||||
} BITMAPOBJ, *PBITMAPOBJ;
|
||||
|
||||
#define BITMAPOBJ_IS_APIBITMAP 0x1
|
||||
|
||||
/* Internal interface */
|
||||
|
||||
#define BITMAPOBJ_AllocBitmap() \
|
||||
((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))
|
||||
#define BITMAPOBJ_FreeBitmap(hBMObj) \
|
||||
GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
|
||||
/* NOTE: Use shared locks! */
|
||||
#define BITMAPOBJ_LockBitmap(hBMObj) (PBITMAPOBJ)EngLockSurface((HSURF)hBMObj)
|
||||
#define BITMAPOBJ_UnlockBitmap(pBMObj) EngUnlockSurface(&pBMObj->SurfObj)
|
||||
BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody);
|
||||
|
||||
BOOL INTERNAL_CALL BITMAPOBJ_InitBitsLock(BITMAPOBJ *pBMObj);
|
||||
#define BITMAPOBJ_LockBitmapBits(pBMObj) ExAcquireFastMutex((pBMObj)->BitsLock)
|
||||
#define BITMAPOBJ_UnlockBitmapBits(pBMObj) ExReleaseFastMutex((pBMObj)->BitsLock)
|
||||
void INTERNAL_CALL BITMAPOBJ_CleanupBitsLock(BITMAPOBJ *pBMObj);
|
||||
|
||||
INT FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
|
||||
HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
|
||||
INT FASTCALL DIB_GetDIBWidthBytes (INT width, INT depth);
|
||||
int STDCALL DIB_GetDIBImageBytes (INT width, INT height, INT depth);
|
||||
INT FASTCALL DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
|
||||
INT STDCALL BITMAP_GetObject(BITMAPOBJ * bmp, INT count, LPVOID buffer);
|
||||
HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice);
|
||||
|
||||
HBITMAP FASTCALL IntCreateCompatibleBitmap(PDC Dc, INT Width, INT Height);
|
||||
|
||||
/* User Entry Points */
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiBitBlt (
|
||||
HDC hDCDest,
|
||||
INT XDest,
|
||||
INT YDest,
|
||||
INT Width,
|
||||
INT Height,
|
||||
HDC hDCSrc,
|
||||
INT XSrc,
|
||||
INT YSrc,
|
||||
DWORD ROP
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateBitmap (
|
||||
INT Width,
|
||||
INT Height,
|
||||
UINT Planes,
|
||||
UINT BitsPerPel,
|
||||
CONST VOID * Bits
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateCompatibleBitmap (
|
||||
HDC hDC,
|
||||
INT Width,
|
||||
INT Height
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateBitmapIndirect (
|
||||
CONST BITMAP * BM
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateDIBitmap (
|
||||
HDC hDC,
|
||||
CONST BITMAPINFOHEADER * bmih,
|
||||
DWORD Init,
|
||||
CONST VOID * bInit,
|
||||
CONST BITMAPINFO * bmi,
|
||||
UINT Usage
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateDIBSection (
|
||||
HDC hDC,
|
||||
CONST BITMAPINFO * bmi,
|
||||
UINT Usage,
|
||||
VOID * Bits,
|
||||
HANDLE hSection,
|
||||
DWORD dwOffset
|
||||
);
|
||||
HBITMAP
|
||||
STDCALL
|
||||
NtGdiCreateDiscardableBitmap (
|
||||
HDC hDC,
|
||||
INT Width,
|
||||
INT Height
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiExtFloodFill (
|
||||
HDC hDC,
|
||||
INT XStart,
|
||||
INT YStart,
|
||||
COLORREF Color,
|
||||
UINT FillType
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiFloodFill (
|
||||
HDC hDC,
|
||||
INT XStart,
|
||||
INT YStart,
|
||||
COLORREF Fill
|
||||
);
|
||||
LONG
|
||||
STDCALL
|
||||
NtGdiGetBitmapBits (
|
||||
HBITMAP hBitmap,
|
||||
LONG Buffer,
|
||||
LPVOID Bits
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetBitmapDimensionEx (
|
||||
HBITMAP hBitmap,
|
||||
LPSIZE Dimension
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetDIBColorTable (
|
||||
HDC hDC,
|
||||
UINT StartIndex,
|
||||
UINT Entries,
|
||||
RGBQUAD * Colors
|
||||
);
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiGetDIBits (
|
||||
HDC hDC,
|
||||
HBITMAP hBitmap,
|
||||
UINT StartScan,
|
||||
UINT ScanLines,
|
||||
LPVOID Bits,
|
||||
LPBITMAPINFO bi,
|
||||
UINT Usage
|
||||
);
|
||||
COLORREF
|
||||
STDCALL
|
||||
NtGdiGetPixel (
|
||||
HDC hDC,
|
||||
INT XPos,
|
||||
INT YPos
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGradientFill (
|
||||
HDC hdc,
|
||||
PTRIVERTEX pVertex,
|
||||
ULONG uVertex,
|
||||
PVOID pMesh,
|
||||
ULONG uMesh,
|
||||
ULONG ulMode
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiMaskBlt (
|
||||
HDC hDCDest,
|
||||
INT XDest,
|
||||
INT YDest,
|
||||
INT Width,
|
||||
INT Height,
|
||||
HDC hDCSrc,
|
||||
INT XSrc,
|
||||
INT YSrc,
|
||||
HBITMAP hMaskBitmap,
|
||||
INT xMask,
|
||||
INT yMask,
|
||||
DWORD ROP
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPlgBlt (
|
||||
HDC hDCDest,
|
||||
CONST POINT * Point,
|
||||
HDC hDCSrc,
|
||||
INT XSrc,
|
||||
INT YSrc,
|
||||
INT Width,
|
||||
INT Height,
|
||||
HBITMAP hMaskBitmap,
|
||||
INT xMask,
|
||||
INT yMask
|
||||
);
|
||||
LONG
|
||||
STDCALL
|
||||
NtGdiSetBitmapBits (
|
||||
HBITMAP hBitmap,
|
||||
DWORD Bytes,
|
||||
CONST VOID * Bits
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetBitmapDimensionEx (
|
||||
HBITMAP hBitmap,
|
||||
INT Width,
|
||||
INT Height,
|
||||
LPSIZE Size
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiSetDIBColorTable (
|
||||
HDC hDC,
|
||||
UINT StartIndex,
|
||||
UINT Entries,
|
||||
CONST RGBQUAD * Colors
|
||||
);
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiSetDIBits (
|
||||
HDC hDC,
|
||||
HBITMAP hBitmap,
|
||||
UINT StartScan,
|
||||
UINT ScanLines,
|
||||
CONST VOID * Bits,
|
||||
CONST BITMAPINFO * bmi,
|
||||
UINT ColorUse
|
||||
);
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiSetDIBitsToDevice (
|
||||
HDC hDC,
|
||||
INT XDest,
|
||||
INT YDest,
|
||||
DWORD Width,
|
||||
DWORD Height,
|
||||
INT XSrc,
|
||||
INT YSrc,
|
||||
UINT StartScan,
|
||||
UINT ScanLines,
|
||||
CONST VOID * Bits,
|
||||
CONST BITMAPINFO * bmi,
|
||||
UINT ColorUse
|
||||
);
|
||||
COLORREF
|
||||
STDCALL
|
||||
NtGdiSetPixel (
|
||||
HDC hDC,
|
||||
INT X,
|
||||
INT Y,
|
||||
COLORREF Color
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetPixelV (
|
||||
HDC hDC,
|
||||
INT X,
|
||||
INT Y,
|
||||
COLORREF Color
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiStretchBlt (
|
||||
HDC hDCDest,
|
||||
INT XOriginDest,
|
||||
INT YOriginDest,
|
||||
INT WidthDest,
|
||||
INT HeightDest,
|
||||
HDC hDCSrc,
|
||||
INT XOriginSrc,
|
||||
INT YOriginSrc,
|
||||
INT WidthSrc,
|
||||
INT HeightSrc,
|
||||
DWORD ROP
|
||||
);
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiStretchDIBits (
|
||||
HDC hDC,
|
||||
INT XDest,
|
||||
INT YDest,
|
||||
INT DestWidth,
|
||||
INT DestHeight,
|
||||
INT XSrc,
|
||||
INT YSrc,
|
||||
INT SrcWidth,
|
||||
INT SrcHeight,
|
||||
CONST VOID * Bits,
|
||||
CONST BITMAPINFO * BitsInfo,
|
||||
UINT Usage,
|
||||
DWORD ROP
|
||||
);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiTransparentBlt(
|
||||
HDC hdcDst,
|
||||
INT xDst,
|
||||
INT yDst,
|
||||
INT cxDst,
|
||||
INT cyDst,
|
||||
HDC hdcSrc,
|
||||
INT xSrc,
|
||||
INT ySrc,
|
||||
INT cxSrc,
|
||||
INT cySrc,
|
||||
COLORREF TransColor
|
||||
);
|
||||
|
||||
#endif
|
||||
|
112
inc_w32k/brush.h
Normal file
112
inc_w32k/brush.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef __WIN32K_BRUSH_H
|
||||
#define __WIN32K_BRUSH_H
|
||||
|
||||
#include <win32k/gdiobj.h>
|
||||
|
||||
/* Internal interface */
|
||||
|
||||
#define NB_HATCH_STYLES 6
|
||||
|
||||
/*
|
||||
* The layout of this structure is taken from "Windows Graphics Programming"
|
||||
* book written by Feng Yuan.
|
||||
*
|
||||
* DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON
|
||||
* A MAILING LIST FIRST.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG AttrFlags;
|
||||
COLORREF lbColor;
|
||||
} BRUSHATTR, *PBRUSHATTR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG ulStyle;
|
||||
HBITMAP hbmPattern;
|
||||
HANDLE hbmClient;
|
||||
ULONG flAttrs;
|
||||
|
||||
ULONG ulBrushUnique;
|
||||
BRUSHATTR *pBrushAttr;
|
||||
BRUSHATTR BrushAttr;
|
||||
POINT ptOrigin;
|
||||
ULONG bCacheGrabbed;
|
||||
COLORREF crBack;
|
||||
COLORREF crFore;
|
||||
ULONG ulPalTime;
|
||||
ULONG ulSurfTime;
|
||||
PVOID ulRealization;
|
||||
ULONG Unknown4C[3];
|
||||
POINT ptPenWidth;
|
||||
ULONG ulPenStyle;
|
||||
DWORD *pStyle;
|
||||
ULONG dwStyleCount;
|
||||
ULONG Unknown6C;
|
||||
} GDIBRUSHOBJ, *PGDIBRUSHOBJ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BRUSHOBJ BrushObject;
|
||||
PGDIBRUSHOBJ GdiBrushObject;
|
||||
XLATEOBJ *XlateObject;
|
||||
} GDIBRUSHINST, *PGDIBRUSHINST;
|
||||
|
||||
/* GDI Brush Attributes */
|
||||
|
||||
#define GDIBRUSH_NEED_BK_CLR 0x0002 /* Background color is needed */
|
||||
#define GDIBRUSH_DITHER_OK 0x0004 /* Allow color dithering */
|
||||
#define GDIBRUSH_IS_SOLID 0x0010 /* Solid brush */
|
||||
#define GDIBRUSH_IS_HATCH 0x0020 /* Hatch brush */
|
||||
#define GDIBRUSH_IS_BITMAP 0x0040 /* DDB pattern brush */
|
||||
#define GDIBRUSH_IS_DIB 0x0080 /* DIB pattern brush */
|
||||
#define GDIBRUSH_IS_NULL 0x0100 /* Null/hollow brush */
|
||||
#define GDIBRUSH_IS_GLOBAL 0x0200 /* Stock objects */
|
||||
#define GDIBRUSH_IS_PEN 0x0400 /* Pen */
|
||||
#define GDIBRUSH_IS_OLDSTYLEPEN 0x0800 /* Geometric pen */
|
||||
#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transparent mask (?) */
|
||||
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000
|
||||
|
||||
#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH))
|
||||
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
|
||||
#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
|
||||
#define BRUSHOBJ_UnlockBrush(pBrush) GDIOBJ_UnlockObjByPtr(pBrush)
|
||||
BOOL INTERNAL_CALL BRUSH_Cleanup(PVOID ObjectBody);
|
||||
|
||||
HBRUSH STDCALL
|
||||
NtGdiCreateBrushIndirect(
|
||||
CONST LOGBRUSH *LogBrush);
|
||||
|
||||
HBRUSH STDCALL
|
||||
NtGdiCreateDIBBrush(
|
||||
CONST BITMAPINFO *BitmapInfoAndData,
|
||||
UINT ColorSpec,
|
||||
UINT BitmapInfoSize,
|
||||
CONST VOID *PackedDIB);
|
||||
|
||||
HBRUSH STDCALL
|
||||
NtGdiCreateHatchBrush(
|
||||
INT Style,
|
||||
COLORREF Color);
|
||||
|
||||
HBRUSH STDCALL
|
||||
NtGdiCreatePatternBrush(
|
||||
HBITMAP hBitmap);
|
||||
|
||||
HBRUSH STDCALL
|
||||
NtGdiCreateSolidBrush(
|
||||
COLORREF Color);
|
||||
|
||||
BOOL STDCALL
|
||||
NtGdiFixBrushOrgEx(
|
||||
VOID);
|
||||
|
||||
BOOL STDCALL
|
||||
NtGdiSetBrushOrgEx(
|
||||
HDC hDC,
|
||||
INT XOrg,
|
||||
INT YOrg,
|
||||
LPPOINT Point);
|
||||
|
||||
#endif
|
64
inc_w32k/callback.h
Normal file
64
inc_w32k/callback.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef __INCLUDE_USER32_CALLBACK_H
|
||||
#define __INCLUDE_USER32_CALLBACK_H
|
||||
|
||||
#define USER32_CALLBACK_WINDOWPROC (0)
|
||||
#define USER32_CALLBACK_SENDASYNCPROC (1)
|
||||
#define USER32_CALLBACK_LOADSYSMENUTEMPLATE (2)
|
||||
#define USER32_CALLBACK_LOADDEFAULTCURSORS (3)
|
||||
#define USER32_CALLBACK_HOOKPROC (4)
|
||||
#define USER32_CALLBACK_MAXIMUM (4)
|
||||
|
||||
typedef struct _WINDOWPROC_CALLBACK_ARGUMENTS
|
||||
{
|
||||
WNDPROC Proc;
|
||||
BOOL IsAnsiProc;
|
||||
HWND Wnd;
|
||||
UINT Msg;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
INT lParamBufferSize;
|
||||
LRESULT Result;
|
||||
/* char Buffer[]; */
|
||||
} WINDOWPROC_CALLBACK_ARGUMENTS, *PWINDOWPROC_CALLBACK_ARGUMENTS;
|
||||
|
||||
typedef struct _SENDASYNCPROC_CALLBACK_ARGUMENTS
|
||||
{
|
||||
SENDASYNCPROC Callback;
|
||||
HWND Wnd;
|
||||
UINT Msg;
|
||||
ULONG_PTR Context;
|
||||
LRESULT Result;
|
||||
} SENDASYNCPROC_CALLBACK_ARGUMENTS, *PSENDASYNCPROC_CALLBACK_ARGUMENTS;
|
||||
|
||||
typedef struct _HOOKPROC_CALLBACK_ARGUMENTS
|
||||
{
|
||||
INT HookId;
|
||||
INT Code;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
HOOKPROC Proc;
|
||||
BOOLEAN Ansi;
|
||||
UINT ModuleNameLength;
|
||||
WCHAR ModuleName[1];
|
||||
} HOOKPROC_CALLBACK_ARGUMENTS, *PHOOKPROC_CALLBACK_ARGUMENTS;
|
||||
|
||||
typedef struct _HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS
|
||||
{
|
||||
CREATESTRUCTW Cs; /* lpszName and lpszClass replaced by offsets */
|
||||
HWND WndInsertAfter;
|
||||
/* WCHAR szName[] */
|
||||
/* WCHAR szClass[] */
|
||||
} HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS, *PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS;
|
||||
|
||||
NTSTATUS STDCALL
|
||||
User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength);
|
||||
NTSTATUS STDCALL
|
||||
User32CallSendAsyncProcForKernel(PVOID Arguments, ULONG ArgumentLength);
|
||||
NTSTATUS STDCALL
|
||||
User32LoadSysMenuTemplateForKernel(PVOID Arguments, ULONG ArgumentLength);
|
||||
NTSTATUS STDCALL
|
||||
User32SetupDefaultCursors(PVOID Arguments, ULONG ArgumentLength);
|
||||
NTSTATUS STDCALL
|
||||
User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength);
|
||||
|
||||
#endif /* __INCLUDE_USER32_CALLBACK_H */
|
23
inc_w32k/caret.h
Normal file
23
inc_w32k/caret.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: include/win32k/caret.h
|
||||
* PURPOSE: GDI32/Win32k Caret interface
|
||||
* PROGRAMMER:
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WIN32K_CARET_H_INCLUDED
|
||||
#define WIN32K_CARET_H_INCLUDED
|
||||
|
||||
typedef struct _THRDCARETINFO
|
||||
{
|
||||
HWND hWnd;
|
||||
HBITMAP Bitmap;
|
||||
POINT Pos;
|
||||
SIZE Size;
|
||||
BYTE Visible;
|
||||
BYTE Showing;
|
||||
} THRDCARETINFO, *PTHRDCARETINFO;
|
||||
|
||||
#endif /* WIN32K_FONT_H_INCLUDED */
|
81
inc_w32k/cliprgn.h
Normal file
81
inc_w32k/cliprgn.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef _WIN32K_CLIPRGN_H
|
||||
#define _WIN32K_CLIPRGN_H
|
||||
|
||||
HRGN WINAPI SaveVisRgn(HDC hdc);
|
||||
INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn);
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtGdiExcludeClipRect (
|
||||
HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiExtSelectClipRgn (
|
||||
HDC hDC,
|
||||
HRGN hrgn,
|
||||
int fnMode
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiGetClipBox (
|
||||
HDC hDC,
|
||||
LPRECT rc
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiGetMetaRgn (
|
||||
HDC hDC,
|
||||
HRGN hrgn
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiIntersectClipRect (
|
||||
HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiOffsetClipRgn (
|
||||
HDC hDC,
|
||||
int XOffset,
|
||||
int YOffset
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPtVisible (
|
||||
HDC hDC,
|
||||
int X,
|
||||
int Y
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiRectVisible (
|
||||
HDC hDC,
|
||||
CONST PRECT rc
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSelectClipPath (
|
||||
HDC hDC,
|
||||
int Mode
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiSelectClipRgn (
|
||||
HDC hDC,
|
||||
HRGN hrgn
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiSetMetaRgn (
|
||||
HDC hDC
|
||||
);
|
||||
#endif
|
116
inc_w32k/color.h
Normal file
116
inc_w32k/color.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#ifndef __WIN32K_COLOR_H
|
||||
#define __WIN32K_COLOR_H
|
||||
|
||||
#ifndef CLR_INVALID
|
||||
#define CLR_INVALID 0xffffffff
|
||||
#endif
|
||||
#define PC_SYS_USED 0x80 /* palentry is used (both system and logical) */
|
||||
#define PC_SYS_RESERVED 0x40 /* system palentry is not to be mapped to */
|
||||
#define PC_SYS_MAPPED 0x10 /* logical palentry is a direct alias for system palentry */
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiAnimatePalette (
|
||||
HPALETTE hpal,
|
||||
UINT StartIndex,
|
||||
UINT Entries,
|
||||
CONST PPALETTEENTRY ppe
|
||||
);
|
||||
HPALETTE
|
||||
STDCALL
|
||||
NtGdiCreateHalftonePalette (
|
||||
HDC hDC
|
||||
);
|
||||
HPALETTE
|
||||
STDCALL
|
||||
NtGdiCreatePalette (
|
||||
CONST PLOGPALETTE lgpl
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetColorAdjustment (
|
||||
HDC hDC,
|
||||
LPCOLORADJUSTMENT ca
|
||||
);
|
||||
COLORREF
|
||||
STDCALL
|
||||
NtGdiGetNearestColor (
|
||||
HDC hDC,
|
||||
COLORREF Color
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetNearestPaletteIndex (
|
||||
HPALETTE hpal,
|
||||
COLORREF Color
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetPaletteEntries (
|
||||
HPALETTE hpal,
|
||||
UINT StartIndex,
|
||||
UINT Entries,
|
||||
LPPALETTEENTRY pe
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetSystemPaletteEntries (
|
||||
HDC hDC,
|
||||
UINT StartIndex,
|
||||
UINT Entries,
|
||||
LPPALETTEENTRY pe
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetSystemPaletteUse (
|
||||
HDC hDC
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiRealizePalette (
|
||||
HDC hDC
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiResizePalette (
|
||||
HPALETTE hpal,
|
||||
UINT Entries
|
||||
);
|
||||
HPALETTE
|
||||
STDCALL
|
||||
NtGdiSelectPalette (
|
||||
HDC hDC,
|
||||
HPALETTE hpal,
|
||||
BOOL ForceBackground
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetColorAdjustment (
|
||||
HDC hDC,
|
||||
CONST LPCOLORADJUSTMENT ca
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiSetPaletteEntries (
|
||||
HPALETTE hpal,
|
||||
UINT Start,
|
||||
UINT Entries,
|
||||
CONST LPPALETTEENTRY pe
|
||||
);
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiSetSystemPaletteUse (
|
||||
HDC hDC,
|
||||
UINT Usage
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiUnrealizeObject (
|
||||
HGDIOBJ hgdiobj
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiUpdateColors (
|
||||
HDC hDC
|
||||
);
|
||||
#endif
|
151
inc_w32k/coord.h
Normal file
151
inc_w32k/coord.h
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef __WIN32K_COORD_H
|
||||
#define __WIN32K_COORD_H
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiCombineTransform (
|
||||
LPXFORM XformResult,
|
||||
CONST LPXFORM xform1,
|
||||
CONST LPXFORM xform2
|
||||
);
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
IntDPtoLP ( PDC dc, LPPOINT Points, INT Count );
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
CoordDPtoLP ( PDC Dc, LPPOINT Point );
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiDPtoLP (
|
||||
HDC hDC,
|
||||
LPPOINT Points,
|
||||
int Count
|
||||
);
|
||||
|
||||
int
|
||||
FASTCALL
|
||||
IntGetGraphicsMode ( PDC dc );
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtGdiGetGraphicsMode ( HDC hDC );
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetWorldTransform (
|
||||
HDC hDC,
|
||||
LPXFORM Xform
|
||||
);
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
CoordLPtoDP ( PDC Dc, LPPOINT Point );
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
IntLPtoDP ( PDC dc, LPPOINT Points, INT Count );
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiLPtoDP (
|
||||
HDC hDC,
|
||||
LPPOINT Points,
|
||||
int Count
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiModifyWorldTransform (
|
||||
HDC hDC,
|
||||
CONST LPXFORM Xform,
|
||||
DWORD Mode
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiOffsetViewportOrgEx (
|
||||
HDC hDC,
|
||||
int XOffset,
|
||||
int YOffset,
|
||||
LPPOINT Point
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiOffsetWindowOrgEx (
|
||||
HDC hDC,
|
||||
int XOffset,
|
||||
int YOffset,
|
||||
LPPOINT Point
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiScaleViewportExtEx (
|
||||
HDC hDC,
|
||||
int Xnum,
|
||||
int Xdenom,
|
||||
int Ynum,
|
||||
int Ydenom,
|
||||
LPSIZE Size
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiScaleWindowExtEx (
|
||||
HDC hDC,
|
||||
int Xnum,
|
||||
int Xdenom,
|
||||
int Ynum,
|
||||
int Ydenom,
|
||||
LPSIZE Size
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiSetGraphicsMode (
|
||||
HDC hDC,
|
||||
int Mode
|
||||
);
|
||||
int
|
||||
STDCALL
|
||||
NtGdiSetMapMode (
|
||||
HDC hDC,
|
||||
int MapMode
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetViewportExtEx (
|
||||
HDC hDC,
|
||||
int XExtent,
|
||||
int YExtent,
|
||||
LPSIZE Size
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetViewportOrgEx (
|
||||
HDC hDC,
|
||||
int X,
|
||||
int Y,
|
||||
LPPOINT Point
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetWindowExtEx (
|
||||
HDC hDC,
|
||||
int XExtent,
|
||||
int YExtent,
|
||||
LPSIZE Size
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetWindowOrgEx (
|
||||
HDC hDC,
|
||||
int X,
|
||||
int Y,
|
||||
LPPOINT Point
|
||||
);
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetWorldTransform (
|
||||
HDC hDC,
|
||||
CONST LPXFORM Xform
|
||||
);
|
||||
#endif
|
95
inc_w32k/cursoricon.h
Normal file
95
inc_w32k/cursoricon.h
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
#ifndef __WIN32K_CURSORICON_H
|
||||
#define __WIN32K_CURSORICON_H
|
||||
|
||||
#include <pshpack1.h>
|
||||
|
||||
/* Structures for reading icon/cursor files and resources */
|
||||
// Structures for reading icon files and resources
|
||||
typedef struct _ICONIMAGE
|
||||
{
|
||||
BITMAPINFOHEADER icHeader; // DIB header
|
||||
RGBQUAD icColors[1]; // Color table
|
||||
BYTE icXOR[1]; // DIB bits for XOR mask
|
||||
BYTE icAND[1]; // DIB bits for AND mask
|
||||
} ICONIMAGE, *LPICONIMAGE;
|
||||
|
||||
typedef struct _CURSORIMAGE
|
||||
{
|
||||
BITMAPINFOHEADER icHeader; // DIB header
|
||||
RGBQUAD icColors[1]; // Color table
|
||||
BYTE icXOR[1]; // DIB bits for XOR mask
|
||||
BYTE icAND[1]; // DIB bits for AND mask
|
||||
} CURSORIMAGE, *LPCURSORIMAGE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE bWidth;
|
||||
BYTE bHeight;
|
||||
BYTE bColorCount;
|
||||
BYTE bReserved;
|
||||
} ICONRESDIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wWidth;
|
||||
WORD wHeight;
|
||||
} CURSORRESDIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wPlanes; // Number of Color Planes in the XOR image
|
||||
WORD wBitCount; // Bits per pixel in the XOR image
|
||||
} ICONDIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wXHotspot; // Number of Color Planes in the XOR image
|
||||
WORD wYHotspot; // Bits per pixel in the XOR image
|
||||
} CURSORDIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE bWidth; // Width, in pixels, of the icon image
|
||||
BYTE bHeight; // Height, in pixels, of the icon image
|
||||
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
|
||||
BYTE bReserved; // Reserved ( must be 0)
|
||||
union
|
||||
{ ICONDIR icon;
|
||||
CURSORDIR cursor;
|
||||
} Info;
|
||||
DWORD dwBytesInRes; // How many bytes in this resource?
|
||||
DWORD dwImageOffset; // Where in the file is this image?
|
||||
} CURSORICONDIRENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD idReserved; // Reserved (must be 0)
|
||||
WORD idType; // Resource Type (1 for icons, 0 for cursors)
|
||||
WORD idCount; // How many images?
|
||||
CURSORICONDIRENTRY idEntries[1]; // An entry for idCount number of images
|
||||
} CURSORICONDIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{ ICONRESDIR icon;
|
||||
CURSORRESDIR cursor;
|
||||
} ResInfo;
|
||||
WORD wPlanes; // Color Planes
|
||||
WORD wBitCount; // Bits per pixel
|
||||
DWORD dwBytesInRes; // how many bytes in this resource?
|
||||
WORD nID; // the ID
|
||||
} GRPCURSORICONDIRENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD idReserved; // Reserved (must be 0)
|
||||
WORD idType; // Resource type (1 for icons)
|
||||
WORD idCount; // How many images?
|
||||
GRPCURSORICONDIRENTRY idEntries[1]; // The entries for each image
|
||||
} GRPCURSORICONDIR;
|
||||
|
||||
#include <poppack.h>
|
||||
|
||||
#endif
|
236
inc_w32k/dc.h
Normal file
236
inc_w32k/dc.h
Normal file
@@ -0,0 +1,236 @@
|
||||
|
||||
#ifndef __WIN32K_DC_H
|
||||
#define __WIN32K_DC_H
|
||||
|
||||
typedef struct _WIN_DC_INFO
|
||||
{
|
||||
int flags;
|
||||
HRGN hClipRgn; /* Clip region (may be 0) */
|
||||
HRGN hVisRgn; /* Visible region (must never be 0) */
|
||||
HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
|
||||
HPEN hPen;
|
||||
HBRUSH hBrush;
|
||||
HFONT hFont;
|
||||
HBITMAP hBitmap;
|
||||
HBITMAP hFirstBitmap; /* Bitmap selected at creation of the DC */
|
||||
|
||||
/* #if 0 */
|
||||
HANDLE hDevice;
|
||||
HPALETTE hPalette;
|
||||
|
||||
GdiPath path;
|
||||
/* #endif */
|
||||
|
||||
WORD ROPmode;
|
||||
WORD polyFillMode;
|
||||
WORD stretchBltMode;
|
||||
WORD relAbsMode;
|
||||
WORD backgroundMode;
|
||||
COLORREF backgroundColor;
|
||||
COLORREF textColor;
|
||||
|
||||
short brushOrgX;
|
||||
short brushOrgY;
|
||||
|
||||
WORD textAlign; /* Text alignment from SetTextAlign() */
|
||||
short charExtra; /* Spacing from SetTextCharacterExtra() */
|
||||
short breakTotalExtra; /* Total extra space for justification */
|
||||
short breakCount; /* Break char. count */
|
||||
short breakExtra; /* breakTotalExtra / breakCount */
|
||||
short breakRem; /* breakTotalExtra % breakCount */
|
||||
|
||||
RECT totalExtent;
|
||||
BYTE bitsPerPixel;
|
||||
|
||||
INT MapMode;
|
||||
INT GraphicsMode; /* Graphics mode */
|
||||
INT DCOrgX; /* DC origin */
|
||||
INT DCOrgY;
|
||||
|
||||
#if 0
|
||||
FARPROC lpfnPrint; /* AbortProc for Printing */
|
||||
#endif
|
||||
|
||||
INT CursPosX; /* Current position */
|
||||
INT CursPosY;
|
||||
INT ArcDirection;
|
||||
|
||||
XFORM xformWorld2Wnd; /* World-to-window transformation */
|
||||
XFORM xformWorld2Vport; /* World-to-viewport transformation */
|
||||
XFORM xformVport2World; /* Inverse of the above transformation */
|
||||
BOOL vport2WorldValid; /* Is xformVport2World valid? */
|
||||
} WIN_DC_INFO;
|
||||
|
||||
/* DC flags */
|
||||
#define DC_MEMORY 0x0001 /* It is a memory DC */
|
||||
#define DC_SAVED 0x0002 /* It is a saved DC */
|
||||
#define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
|
||||
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
|
||||
|
||||
#define GDI_DC_TYPE (1)
|
||||
|
||||
typedef struct _DC
|
||||
{
|
||||
HDC hSelf;
|
||||
HDC hNext;
|
||||
DHPDEV PDev;
|
||||
HSURF FillPatternSurfaces[HS_DDI_MAX];
|
||||
PGDIINFO GDIInfo;
|
||||
PDEVINFO DevInfo;
|
||||
HDEV GDIDevice;
|
||||
|
||||
DRIVER_FUNCTIONS DriverFunctions;
|
||||
UNICODE_STRING DriverName;
|
||||
HANDLE DeviceDriver;
|
||||
|
||||
INT wndOrgX; /* Window origin */
|
||||
INT wndOrgY;
|
||||
INT wndExtX; /* Window extent */
|
||||
INT wndExtY;
|
||||
INT vportOrgX; /* Viewport origin */
|
||||
INT vportOrgY;
|
||||
INT vportExtX; /* Viewport extent */
|
||||
INT vportExtY;
|
||||
|
||||
CLIPOBJ *CombinedClip;
|
||||
|
||||
XLATEOBJ *XlateBrush;
|
||||
XLATEOBJ *XlatePen;
|
||||
|
||||
INT saveLevel;
|
||||
BOOL IsIC;
|
||||
|
||||
WIN_DC_INFO w;
|
||||
} DC, *PDC;
|
||||
|
||||
typedef struct _GDIPOINTER /* should stay private to ENG */
|
||||
{
|
||||
/* private GDI pointer handling information, required for software emulation */
|
||||
BOOL Enabled;
|
||||
POINTL Pos;
|
||||
SIZEL Size;
|
||||
POINTL HotSpot;
|
||||
XLATEOBJ *XlateObject;
|
||||
HSURF ColorSurface;
|
||||
HSURF MaskSurface;
|
||||
HSURF SaveSurface;
|
||||
|
||||
/* public pointer information */
|
||||
RECTL Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */
|
||||
PGD_MOVEPOINTER MovePointer;
|
||||
ULONG Status;
|
||||
} GDIPOINTER, *PGDIPOINTER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE Handle;
|
||||
DHPDEV PDev;
|
||||
DEVMODEW DMW;
|
||||
HSURF FillPatterns[HS_DDI_MAX];
|
||||
GDIINFO GDIInfo;
|
||||
DEVINFO DevInfo;
|
||||
DRIVER_FUNCTIONS DriverFunctions;
|
||||
#ifdef NTOS_MODE_USER
|
||||
PVOID VideoFileObject;
|
||||
#else
|
||||
PFILE_OBJECT VideoFileObject;
|
||||
#endif
|
||||
BOOLEAN PreparedDriver;
|
||||
ULONG DisplayNumber;
|
||||
|
||||
GDIPOINTER Pointer;
|
||||
|
||||
/* Stuff to keep track of software cursors; win32k gdi part */
|
||||
UINT SafetyRemoveLevel; /* at what level was the cursor removed?
|
||||
0 for not removed */
|
||||
UINT SafetyRemoveCount;
|
||||
} GDIDEVICE;
|
||||
|
||||
/* Internal functions */
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
|
||||
#define DC_LockDc(hDC) \
|
||||
((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
|
||||
#define DC_UnlockDc(pDC) \
|
||||
GDIOBJ_UnlockObjByPtr (pDC)
|
||||
|
||||
HDC FASTCALL RetrieveDisplayHDC(VOID);
|
||||
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
|
||||
VOID FASTCALL DC_InitDC(HDC DCToInit);
|
||||
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
|
||||
VOID FASTCALL DC_FreeDC(HDC DCToFree);
|
||||
BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
|
||||
HDC FASTCALL DC_GetNextDC (PDC pDC);
|
||||
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
|
||||
VOID FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
|
||||
|
||||
VOID FASTCALL DC_UpdateXforms(PDC dc);
|
||||
BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
|
||||
|
||||
#endif
|
||||
|
||||
/* User entry points */
|
||||
|
||||
BOOL STDCALL NtGdiCancelDC(HDC hDC);
|
||||
HDC STDCALL NtGdiCreateCompatableDC(HDC hDC);
|
||||
HDC STDCALL NtGdiCreateDC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW InitData);
|
||||
HDC STDCALL NtGdiCreateIC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW DevMode);
|
||||
BOOL STDCALL NtGdiDeleteDC(HDC hDC);
|
||||
BOOL STDCALL NtGdiDeleteObject(HGDIOBJ hObject);
|
||||
INT STDCALL NtGdiDrawEscape(HDC hDC,
|
||||
INT nEscape,
|
||||
INT cbInput,
|
||||
LPCSTR lpszInData);
|
||||
|
||||
INT STDCALL NtGdiEnumObjects(HDC hDC,
|
||||
INT ObjectType,
|
||||
GOBJENUMPROC ObjectFunc,
|
||||
LPARAM lParam);
|
||||
|
||||
COLORREF STDCALL NtGdiGetBkColor(HDC hDC);
|
||||
INT STDCALL NtGdiGetBkMode(HDC hDC);
|
||||
BOOL STDCALL NtGdiGetBrushOrgEx(HDC hDC, LPPOINT brushOrg);
|
||||
HRGN STDCALL NtGdiGetClipRgn(HDC hDC);
|
||||
HGDIOBJ STDCALL NtGdiGetCurrentObject(HDC hDC, UINT ObjectType);
|
||||
VOID FASTCALL IntGetCurrentPositionEx (PDC dc, LPPOINT currentPosition);
|
||||
BOOL STDCALL NtGdiGetCurrentPositionEx(HDC hDC, LPPOINT currentPosition);
|
||||
BOOL STDCALL NtGdiGetDCOrgEx(HDC hDC, LPPOINT Point);
|
||||
HDC STDCALL NtGdiGetDCState(HDC hDC);
|
||||
INT STDCALL NtGdiGetDeviceCaps(HDC hDC, INT Index);
|
||||
INT STDCALL NtGdiGetMapMode(HDC hDC);
|
||||
INT STDCALL NtGdiGetObject(HGDIOBJ hGDIObj,
|
||||
INT BufSize,
|
||||
LPVOID Object);
|
||||
DWORD STDCALL NtGdiGetObjectType(HGDIOBJ hGDIObj);
|
||||
INT STDCALL NtGdiGetPolyFillMode(HDC hDC);
|
||||
INT STDCALL NtGdiGetRelAbs(HDC hDC);
|
||||
INT STDCALL NtGdiGetROP2(HDC hDC);
|
||||
HGDIOBJ STDCALL NtGdiGetStockObject(INT Object);
|
||||
INT STDCALL NtGdiGetStretchBltMode(HDC hDC);
|
||||
COLORREF STDCALL NtGdiGetTextColor(HDC hDC);
|
||||
UINT STDCALL NtGdiGetTextAlign(HDC hDC);
|
||||
BOOL STDCALL NtGdiGetViewportExtEx(HDC hDC, LPSIZE viewportExt);
|
||||
BOOL STDCALL NtGdiGetViewportOrgEx(HDC hDC, LPPOINT viewportOrg);
|
||||
BOOL STDCALL NtGdiGetWindowExtEx(HDC hDC, LPSIZE windowExt);
|
||||
BOOL STDCALL NtGdiGetWindowOrgEx(HDC hDC, LPPOINT windowOrg);
|
||||
HDC STDCALL NtGdiResetDC(HDC hDC, CONST DEVMODEW *InitData);
|
||||
BOOL STDCALL NtGdiRestoreDC(HDC hDC, INT SavedDC);
|
||||
INT STDCALL NtGdiSaveDC(HDC hDC);
|
||||
HGDIOBJ STDCALL NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj);
|
||||
INT STDCALL NtGdiSetBkMode(HDC hDC, INT backgroundMode);
|
||||
VOID STDCALL NtGdiSetDCState ( HDC hDC, HDC hDCSave );
|
||||
WORD STDCALL NtGdiSetHookFlags(HDC hDC, WORD Flags);
|
||||
INT STDCALL NtGdiSetPolyFillMode(HDC hDC, INT polyFillMode);
|
||||
INT STDCALL NtGdiSetRelAbs(HDC hDC, INT relAbsMode);
|
||||
INT STDCALL NtGdiSetROP2(HDC hDC, INT ROPmode);
|
||||
INT STDCALL NtGdiSetStretchBltMode(HDC hDC, INT stretchBltMode);
|
||||
COLORREF STDCALL NtGdiSetTextColor(HDC hDC, COLORREF color);
|
||||
|
||||
#endif
|
192
inc_w32k/driver.h
Normal file
192
inc_w32k/driver.h
Normal file
@@ -0,0 +1,192 @@
|
||||
|
||||
#ifndef __WIN32K_DRIVER_H
|
||||
#define __WIN32K_DRIVER_H
|
||||
|
||||
#include <ddk/winddi.h>
|
||||
|
||||
typedef BOOL (STDCALL *PGD_ENABLEDRIVER)(ULONG, ULONG, PDRVENABLEDATA);
|
||||
typedef DHPDEV (STDCALL *PGD_ENABLEPDEV)(DEVMODEW *,
|
||||
LPWSTR,
|
||||
ULONG,
|
||||
HSURF *,
|
||||
ULONG,
|
||||
ULONG *,
|
||||
ULONG,
|
||||
DEVINFO *,
|
||||
LPWSTR,
|
||||
LPWSTR,
|
||||
HANDLE);
|
||||
typedef VOID (STDCALL *PGD_COMPLETEPDEV)(DHPDEV, HDEV);
|
||||
typedef VOID (STDCALL *PGD_DISABLEPDEV)(DHPDEV);
|
||||
typedef HSURF (STDCALL *PGD_ENABLESURFACE)(DHPDEV);
|
||||
typedef VOID (STDCALL *PGD_DISABLESURFACE)(DHPDEV);
|
||||
typedef BOOL (STDCALL *PGD_ASSERTMODE)(DHPDEV, BOOL);
|
||||
typedef BOOL (STDCALL *PGD_OFFSET)(SURFOBJ*, LONG, LONG, FLONG);
|
||||
typedef BOOL (STDCALL *PGD_RESETPDEV)(DHPDEV, DHPDEV);
|
||||
typedef VOID (STDCALL *PGD_DISABLEDRIVER)(VOID);
|
||||
typedef HBITMAP (STDCALL *PGD_CREATEDEVICEBITMAP)(DHPDEV, SIZEL, ULONG);
|
||||
typedef VOID (STDCALL *PGD_DELETEDEVICEBITMAP)(DHSURF);
|
||||
typedef BOOL (STDCALL *PGD_ALPHABLEND)(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, RECTL*, BLENDOBJ*);
|
||||
typedef BOOL (STDCALL *PGD_REALIZEBRUSH)(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*,
|
||||
XLATEOBJ*, ULONG);
|
||||
typedef ULONG (STDCALL *PGD_DITHERCOLOR)(DHPDEV, ULONG, ULONG, PULONG);
|
||||
typedef BOOL (STDCALL *PGD_STROKEPATH)(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*,
|
||||
BRUSHOBJ*, POINTL*, PLINEATTRS, MIX);
|
||||
typedef BOOL (STDCALL *PGD_FILLPATH)(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*,
|
||||
POINTL*, MIX, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_STROKEANDFILLPATH)(SURFOBJ*, PATHOBJ*, CLIPOBJ*,
|
||||
XFORMOBJ*, BRUSHOBJ*, PLINEATTRS,
|
||||
BRUSHOBJ*, POINTL*, MIX, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_PAINT)(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||||
typedef BOOL (STDCALL *PGD_BITBLT)(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*,
|
||||
XLATEOBJ*, RECTL*, POINTL*, POINTL*, BRUSHOBJ*,
|
||||
POINTL*, ROP4);
|
||||
typedef BOOL (STDCALL *PGD_TRANSPARENTBLT)(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||||
RECTL*, RECTL*, ULONG, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_COPYBITS)(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||||
RECTL*, POINTL*);
|
||||
typedef BOOL (STDCALL *PGD_STRETCHBLT)(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*,
|
||||
XLATEOBJ*, COLORADJUSTMENT*, POINTL*,
|
||||
RECTL*, RECTL*, POINTL*, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_STRETCHBLTROP)(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*,
|
||||
XLATEOBJ*, COLORADJUSTMENT*, POINTL*,
|
||||
RECTL*, RECTL*, POINTL*, ULONG,
|
||||
BRUSHOBJ*, DWORD);
|
||||
typedef BOOL (STDCALL *PGD_SETPALETTE)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_TEXTOUT)(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*,
|
||||
RECTL*, BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||||
typedef ULONG (STDCALL *PGD_ESCAPE)(SURFOBJ*, ULONG, ULONG, PVOID *, ULONG, PVOID *);
|
||||
typedef ULONG (STDCALL *PGD_DRAWESCAPE)(SURFOBJ*, ULONG, CLIPOBJ*, RECTL*, ULONG,
|
||||
PVOID *);
|
||||
typedef PIFIMETRICS (STDCALL *PGD_QUERYFONT)(DHPDEV, ULONG, ULONG, PULONG);
|
||||
typedef PVOID (STDCALL *PGD_QUERYFONTTREE)(DHPDEV, ULONG, ULONG, ULONG, PULONG);
|
||||
typedef LONG (STDCALL *PGD_QUERYFONTDATA)(DHPDEV, FONTOBJ*, ULONG, HGLYPH, GLYPHDATA*,
|
||||
PVOID, ULONG);
|
||||
typedef ULONG (STDCALL *PGD_SETPOINTERSHAPE)(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
|
||||
LONG, LONG, LONG, LONG, RECTL*, ULONG);
|
||||
typedef VOID (STDCALL *PGD_MOVEPOINTER)(SURFOBJ*, LONG, LONG, RECTL*);
|
||||
typedef BOOL (STDCALL *PGD_LINETO)(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, LONG, LONG, LONG,
|
||||
LONG, RECTL*, MIX);
|
||||
typedef BOOL (STDCALL *PGD_SENDPAGE)(SURFOBJ*);
|
||||
typedef BOOL (STDCALL *PGD_STARTPAGE)(SURFOBJ*);
|
||||
typedef BOOL (STDCALL *PGD_ENDDOC)(SURFOBJ*, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_STARTDOC)(SURFOBJ*, PWSTR, DWORD);
|
||||
typedef ULONG (STDCALL *PGD_GETGLYPHMODE)(DHPDEV, FONTOBJ*);
|
||||
typedef VOID (STDCALL *PGD_SYNCHRONIZE)(DHPDEV, RECTL*);
|
||||
typedef ULONG (STDCALL *PGD_SAVESCREENBITS)(SURFOBJ*, ULONG, ULONG, RECTL*);
|
||||
typedef ULONG (STDCALL *PGD_GETMODES)(HANDLE, ULONG, PDEVMODEW);
|
||||
typedef VOID (STDCALL *PGD_FREE)(PVOID, ULONG);
|
||||
typedef VOID (STDCALL *PGD_DESTROYFONT)(FONTOBJ*);
|
||||
typedef LONG (STDCALL *PGD_QUERYFONTCAPS)(ULONG, PULONG);
|
||||
typedef ULONG (STDCALL *PGD_LOADFONTFILE)(ULONG, PVOID, ULONG, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_UNLOADFONTFILE)(ULONG);
|
||||
typedef ULONG (STDCALL *PGD_FONTMANAGEMENT)(SURFOBJ*, FONTOBJ*, ULONG, ULONG, PVOID,
|
||||
ULONG, PVOID);
|
||||
typedef LONG (STDCALL *PGD_QUERYTRUETYPETABLE)(ULONG, ULONG, ULONG, PTRDIFF, ULONG,
|
||||
PBYTE);
|
||||
typedef LONG (STDCALL *PGD_QUERYTRUETYPEOUTLINE)(DHPDEV, FONTOBJ*, HGLYPH, BOOL,
|
||||
GLYPHDATA*, ULONG, TTPOLYGONHEADER*);
|
||||
typedef PVOID (STDCALL *PGD_GETTRUETYPEFILE)(ULONG, PULONG);
|
||||
typedef LONG (STDCALL *PGD_QUERYFONTFILE)(ULONG, ULONG, ULONG, PULONG);
|
||||
typedef BOOL (STDCALL *PGD_QUERYADVANCEWIDTHS)(DHPDEV, FONTOBJ*, ULONG, HGLYPH *,
|
||||
PVOID *, ULONG);
|
||||
typedef BOOL (STDCALL *PGD_SETPIXELFORMAT)(SURFOBJ*, LONG, ULONG);
|
||||
typedef LONG (STDCALL *PGD_DESCRIBEPIXELFORMAT)(DHPDEV, LONG, ULONG,
|
||||
PPIXELFORMATDESCRIPTOR);
|
||||
typedef BOOL (STDCALL *PGD_SWAPBUFFERS)(SURFOBJ*, PWNDOBJ);
|
||||
typedef BOOL (STDCALL *PGD_STARTBANDING)(SURFOBJ*, POINTL*);
|
||||
typedef BOOL (STDCALL *PGD_NEXTBAND)(SURFOBJ*, POINTL*);
|
||||
|
||||
typedef BOOL (STDCALL *PGD_GETDIRECTDRAWINFO)(DHPDEV, PDD_HALINFO, PDWORD, VIDEOMEMORY*, PDWORD, PDWORD);
|
||||
typedef BOOL (STDCALL *PGD_ENABLEDIRECTDRAW)(DHPDEV, PDD_CALLBACKS, PDD_SURFACECALLBACKS, PDD_PALETTECALLBACKS);
|
||||
typedef VOID (STDCALL *PGD_DISABLEDIRECTDRAW)(DHPDEV);
|
||||
|
||||
typedef LONG (STDCALL *PGD_QUERYSPOOLTYPE)(DHPDEV, LPWSTR);
|
||||
|
||||
typedef BOOL (STDCALL *PGD_GRADIENTFILL)(SURFOBJ*, CLIPOBJ*, XLATEOBJ*, TRIVERTEX*, ULONG, PVOID, ULONG, RECTL*, POINTL*, ULONG);
|
||||
|
||||
typedef VOID (STDCALL *PGD_SYNCHRONIZESURFACE)(SURFOBJ*, RECTL *, FLONG);
|
||||
|
||||
typedef struct _DRIVER_FUNCTIONS
|
||||
{
|
||||
PGD_ENABLEDRIVER EnableDriver;
|
||||
PGD_ENABLEPDEV EnablePDEV;
|
||||
PGD_COMPLETEPDEV CompletePDEV;
|
||||
PGD_DISABLEPDEV DisablePDEV;
|
||||
PGD_ENABLESURFACE EnableSurface;
|
||||
PGD_DISABLESURFACE DisableSurface;
|
||||
PGD_ASSERTMODE AssertMode;
|
||||
PGD_OFFSET Offset;
|
||||
PGD_RESETPDEV ResetPDEV;
|
||||
PGD_DISABLEDRIVER DisableDriver;
|
||||
PGD_CREATEDEVICEBITMAP CreateDeviceBitmap;
|
||||
PGD_DELETEDEVICEBITMAP DeleteDeviceBitmap;
|
||||
PGD_REALIZEBRUSH RealizeBrush;
|
||||
PGD_DITHERCOLOR DitherColor;
|
||||
PGD_STROKEPATH StrokePath;
|
||||
PGD_FILLPATH FillPath;
|
||||
PGD_STROKEANDFILLPATH StrokeAndFillPath;
|
||||
PGD_PAINT Paint;
|
||||
PGD_BITBLT BitBlt;
|
||||
PGD_TRANSPARENTBLT TransparentBlt;
|
||||
PGD_COPYBITS CopyBits;
|
||||
PGD_STRETCHBLT StretchBlt;
|
||||
PGD_STRETCHBLTROP StretchBltROP;
|
||||
PGD_SETPALETTE SetPalette;
|
||||
PGD_TEXTOUT TextOut;
|
||||
PGD_ESCAPE Escape;
|
||||
PGD_DRAWESCAPE DrawEscape;
|
||||
PGD_QUERYFONT QueryFont;
|
||||
PGD_QUERYFONTTREE QueryFontTree;
|
||||
PGD_QUERYFONTDATA QueryFontData;
|
||||
PGD_SETPOINTERSHAPE SetPointerShape;
|
||||
PGD_MOVEPOINTER MovePointer;
|
||||
PGD_LINETO LineTo;
|
||||
PGD_SENDPAGE SendPage;
|
||||
PGD_STARTPAGE StartPage;
|
||||
PGD_ENDDOC EndDoc;
|
||||
PGD_STARTDOC StartDoc;
|
||||
PGD_GETGLYPHMODE GetGlyphMode;
|
||||
PGD_SYNCHRONIZE Synchronize;
|
||||
PGD_SAVESCREENBITS SaveScreenBits;
|
||||
PGD_GETMODES GetModes;
|
||||
PGD_FREE Free;
|
||||
PGD_DESTROYFONT DestroyFont;
|
||||
PGD_QUERYFONTCAPS QueryFontCaps;
|
||||
PGD_LOADFONTFILE LoadFontFile;
|
||||
PGD_UNLOADFONTFILE UnloadFontFile;
|
||||
PGD_FONTMANAGEMENT FontManagement;
|
||||
PGD_QUERYTRUETYPETABLE QueryTrueTypeTable;
|
||||
PGD_QUERYTRUETYPEOUTLINE QueryTrueTypeOutline;
|
||||
PGD_GETTRUETYPEFILE GetTrueTypeFile;
|
||||
PGD_QUERYFONTFILE QueryFontFile;
|
||||
PGD_QUERYADVANCEWIDTHS QueryAdvanceWidths;
|
||||
PGD_SETPIXELFORMAT SetPixelFormat;
|
||||
PGD_DESCRIBEPIXELFORMAT DescribePixelFormat;
|
||||
PGD_SWAPBUFFERS SwapBuffers;
|
||||
PGD_STARTBANDING StartBanding;
|
||||
PGD_NEXTBAND NextBand;
|
||||
PGD_GETDIRECTDRAWINFO GetDirectDrawInfo;
|
||||
PGD_ENABLEDIRECTDRAW EnableDirectDraw;
|
||||
PGD_DISABLEDIRECTDRAW DisableDirectDraw;
|
||||
PGD_QUERYSPOOLTYPE QuerySpoolType;
|
||||
PGD_GRADIENTFILL GradientFill;
|
||||
PGD_SYNCHRONIZESURFACE SynchronizeSurface;
|
||||
PGD_ALPHABLEND AlphaBlend;
|
||||
} DRIVER_FUNCTIONS, *PDRIVER_FUNCTIONS;
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
|
||||
BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver);
|
||||
PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name);
|
||||
PFILE_OBJECT DRIVER_FindMPDriver(ULONG DisplayNumber);
|
||||
BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED,
|
||||
PDRIVER_FUNCTIONS DF);
|
||||
BOOL DRIVER_UnregisterDriver(LPCWSTR Name);
|
||||
INT DRIVER_ReferenceDriver (LPCWSTR Name);
|
||||
INT DRIVER_UnreferenceDriver (LPCWSTR Name);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
68
inc_w32k/fillshap.h
Normal file
68
inc_w32k/fillshap.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef __WIN32K_FILLSHAP_H
|
||||
#define __WIN32K_FILLSHAP_H
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiChord(HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect,
|
||||
int XRadial1,
|
||||
int YRadial1,
|
||||
int XRadial2,
|
||||
int YRadial2);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiEllipse(HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPie(HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect,
|
||||
int XRadial1,
|
||||
int YRadial1,
|
||||
int XRadial2,
|
||||
int YRadial2);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPolygon(HDC hDC,
|
||||
CONST PPOINT Points,
|
||||
int Count);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPolyPolygon(HDC hDC,
|
||||
CONST LPPOINT Points,
|
||||
CONST LPINT PolyCounts,
|
||||
int Count);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiRectangle(HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiRoundRect(HDC hDC,
|
||||
int LeftRect,
|
||||
int TopRect,
|
||||
int RightRect,
|
||||
int BottomRect,
|
||||
int Width,
|
||||
int Height);
|
||||
|
||||
#endif
|
||||
|
103
inc_w32k/float.h
Normal file
103
inc_w32k/float.h
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef __WIN32K_FLOAT_H
|
||||
#define __WIN32K_FLOAT_H
|
||||
|
||||
#include <win32k/math.h>
|
||||
#include <win32k/dc.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
typedef struct tagFLOAT_POINT
|
||||
{
|
||||
FLOAT x, y;
|
||||
} FLOAT_POINT;
|
||||
|
||||
/* Rounds a floating point number to integer. The world-to-viewport
|
||||
* transformation process is done in floating point internally. This function
|
||||
* is then used to round these coordinates to integer values.
|
||||
*/
|
||||
static inline INT GDI_ROUND(FLOAT val)
|
||||
{
|
||||
return (int)floor(val + 0.5);
|
||||
}
|
||||
|
||||
/* Performs a world-to-viewport transformation on the specified point (which
|
||||
* is in floating point format).
|
||||
*/
|
||||
static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
|
||||
{
|
||||
FLOAT x, y;
|
||||
|
||||
/* Perform the transformation */
|
||||
x = point->x;
|
||||
y = point->y;
|
||||
point->x = x * dc->w.xformWorld2Vport.eM11 +
|
||||
y * dc->w.xformWorld2Vport.eM21 +
|
||||
dc->w.xformWorld2Vport.eDx;
|
||||
point->y = x * dc->w.xformWorld2Vport.eM12 +
|
||||
y * dc->w.xformWorld2Vport.eM22 +
|
||||
dc->w.xformWorld2Vport.eDy;
|
||||
}
|
||||
|
||||
/* Performs a viewport-to-world transformation on the specified point (which
|
||||
* is in integer format). Returns TRUE if successful, else FALSE.
|
||||
*/
|
||||
#if 0
|
||||
static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point)
|
||||
{
|
||||
FLOAT_POINT floatPoint;
|
||||
|
||||
/* Perform operation with floating point */
|
||||
floatPoint.x=(FLOAT)point->x;
|
||||
floatPoint.y=(FLOAT)point->y;
|
||||
if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
|
||||
return FALSE;
|
||||
|
||||
/* Round to integers */
|
||||
point->x = GDI_ROUND(floatPoint.x);
|
||||
point->y = GDI_ROUND(floatPoint.y);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Performs a world-to-viewport transformation on the specified point (which
|
||||
* is in integer format).
|
||||
*/
|
||||
static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
|
||||
{
|
||||
FLOAT_POINT floatPoint;
|
||||
|
||||
/* Perform operation with floating point */
|
||||
floatPoint.x=(FLOAT)point->x;
|
||||
floatPoint.y=(FLOAT)point->y;
|
||||
INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
|
||||
|
||||
/* Round to integers */
|
||||
point->x = GDI_ROUND(floatPoint.x);
|
||||
point->y = GDI_ROUND(floatPoint.y);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define MulDiv( x, y, z ) EngMulDiv( x, y, z )
|
||||
|
||||
#define XDPTOLP(dc,x) \
|
||||
(MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
|
||||
#define YDPTOLP(dc,y) \
|
||||
(MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
|
||||
#define XLPTODP(dc,x) \
|
||||
(MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
|
||||
#define YLPTODP(dc,y) \
|
||||
(MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
|
||||
|
||||
/* Device <-> logical size conversion */
|
||||
|
||||
#define XDSTOLS(dc,x) \
|
||||
MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
|
||||
#define YDSTOLS(dc,y) \
|
||||
MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
|
||||
#define XLSTODS(dc,x) \
|
||||
MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
|
||||
#define YLSTODS(dc,y) \
|
||||
MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
|
||||
|
||||
#endif
|
25
inc_w32k/font.h
Normal file
25
inc_w32k/font.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: include/win32k/font.h
|
||||
* PURPOSE: GDI32/Win32k font interface
|
||||
* PROGRAMMER:
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WIN32K_FONT_H_INCLUDED
|
||||
#define WIN32K_FONT_H_INCLUDED
|
||||
|
||||
typedef struct tagFONTFAMILYINFO
|
||||
{
|
||||
ENUMLOGFONTEXW EnumLogFontEx;
|
||||
NEWTEXTMETRICEXW NewTextMetricEx;
|
||||
DWORD FontType;
|
||||
} FONTFAMILYINFO, *PFONTFAMILYINFO;
|
||||
|
||||
int STDCALL NtGdiGetFontFamilyInfo(HDC Dc, LPLOGFONTW LogFont, PFONTFAMILYINFO Info, DWORD Size);
|
||||
BOOL STDCALL NtGdiTranslateCharsetInfo(PDWORD Src, LPCHARSETINFO CSI, DWORD Flags);
|
||||
DWORD STDCALL NtGdiGetFontData(HDC,DWORD,DWORD,LPVOID,DWORD);
|
||||
|
||||
#endif /* WIN32K_FONT_H_INCLUDED */
|
125
inc_w32k/gdiobj.h
Normal file
125
inc_w32k/gdiobj.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* GDI object common header definition
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __WIN32K_GDIOBJ_H
|
||||
#define __WIN32K_GDIOBJ_H
|
||||
|
||||
/* base address where the handle table is mapped to */
|
||||
#define GDI_HANDLE_TABLE_BASE_ADDRESS (0x400000)
|
||||
|
||||
/* gdi handle table can hold 0x4000 handles */
|
||||
#define GDI_HANDLE_COUNT 0x4000
|
||||
|
||||
#define GDI_GLOBAL_PROCESS (0x0)
|
||||
|
||||
#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1)
|
||||
#define GDI_HANDLE_TYPE_MASK 0x007f0000
|
||||
#define GDI_HANDLE_STOCK_MASK 0x00800000
|
||||
#define GDI_HANDLE_REUSE_MASK 0xff000000
|
||||
|
||||
#define GDI_HANDLE_REUSECNT_SHIFT 24
|
||||
|
||||
#define GDI_HANDLE_CREATE(i, t) ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) & GDI_HANDLE_TYPE_MASK)))
|
||||
#define GDI_HANDLE_GET_INDEX(h) (((ULONG_PTR)(h)) & GDI_HANDLE_INDEX_MASK)
|
||||
#define GDI_HANDLE_GET_TYPE(h) (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)
|
||||
#define GDI_HANDLE_IS_TYPE(h, t) ((t) == (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK))
|
||||
#define GDI_HANDLE_IS_STOCKOBJ(h) (0 != (((ULONG_PTR)(h)) & GDI_HANDLE_STOCK_MASK))
|
||||
#define GDI_HANDLE_SET_STOCKOBJ(h) ((h) = (HANDLE)(((ULONG_PTR)(h)) | GDI_HANDLE_STOCK_MASK))
|
||||
|
||||
|
||||
/*! \defgroup GDI object types
|
||||
*
|
||||
* GDI object types
|
||||
*
|
||||
*/
|
||||
/*@{*/
|
||||
#define GDI_OBJECT_TYPE_DC 0x00010000
|
||||
#define GDI_OBJECT_TYPE_REGION 0x00040000
|
||||
#define GDI_OBJECT_TYPE_BITMAP 0x00050000
|
||||
#define GDI_OBJECT_TYPE_PALETTE 0x00080000
|
||||
#define GDI_OBJECT_TYPE_FONT 0x000a0000
|
||||
#define GDI_OBJECT_TYPE_BRUSH 0x00100000
|
||||
#define GDI_OBJECT_TYPE_EMF 0x00210000
|
||||
#define GDI_OBJECT_TYPE_PEN 0x00300000
|
||||
#define GDI_OBJECT_TYPE_EXTPEN 0x00500000
|
||||
/* Following object types made up for ROS */
|
||||
#define GDI_OBJECT_TYPE_METADC 0x00710000
|
||||
#define GDI_OBJECT_TYPE_METAFILE 0x00720000
|
||||
#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00730000
|
||||
#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000
|
||||
#define GDI_OBJECT_TYPE_MEMDC 0x00750000
|
||||
#define GDI_OBJECT_TYPE_DCE 0x00770000
|
||||
#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000
|
||||
/** Not really an object type. Forces GDI_FreeObj to be silent. */
|
||||
#define GDI_OBJECT_TYPE_SILENT 0x80000000
|
||||
/*@}*/
|
||||
|
||||
typedef PVOID PGDIOBJ;
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
typedef BOOL (INTERNAL_CALL *GDICLEANUPPROC)(PVOID ObjectBody);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* GDI object header. This is a part of any GDI object
|
||||
*/
|
||||
typedef struct _GDIOBJHDR
|
||||
{
|
||||
#ifdef NTOS_MODE_USER
|
||||
PVOID LockingThread;
|
||||
#else
|
||||
PETHREAD LockingThread; /* only assigned if a thread is holding the lock! */
|
||||
#endif
|
||||
ULONG Locks;
|
||||
#ifdef GDI_DEBUG
|
||||
const char* createdfile;
|
||||
int createdline;
|
||||
const char* lockfile;
|
||||
int lockline;
|
||||
#endif
|
||||
} GDIOBJHDR, *PGDIOBJHDR;
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
|
||||
BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
|
||||
void INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
|
||||
void INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
|
||||
BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
|
||||
VOID INTERNAL_CALL GDIOBJ_UnlockObjByPtr(PGDIOBJ Object);
|
||||
|
||||
#define GDIOBJ_GetObjectType(Handle) \
|
||||
GDI_HANDLE_GET_TYPE(Handle)
|
||||
|
||||
#ifdef GDI_DEBUG
|
||||
|
||||
/* a couple macros for debugging GDIOBJ locking */
|
||||
#define GDIOBJ_AllocObj(ty) GDIOBJ_AllocObjDbg(__FILE__,__LINE__,ty)
|
||||
#define GDIOBJ_FreeObj(obj,ty) GDIOBJ_FreeObjDbg(__FILE__,__LINE__,obj,ty)
|
||||
#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty)
|
||||
#define GDIOBJ_ShareLockObj(obj,ty) GDIOBJ_ShareLockObjDbg(__FILE__,__LINE__,obj,ty)
|
||||
|
||||
HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObjDbg(const char* file, int line, ULONG ObjectType);
|
||||
BOOL INTERNAL_CALL GDIOBJ_FreeObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);
|
||||
|
||||
#else /* !GDI_DEBUG */
|
||||
|
||||
HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(ULONG ObjectType);
|
||||
BOOL INTERNAL_CALL GDIOBJ_FreeObj (HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType);
|
||||
|
||||
#endif /* GDI_DEBUG */
|
||||
|
||||
PVOID INTERNAL_CALL GDI_MapHandleTable(PEPROCESS Process);
|
||||
|
||||
#endif
|
||||
|
||||
#define GDIOBJFLAG_DEFAULT (0x0)
|
||||
#define GDIOBJFLAG_IGNOREPID (0x1)
|
||||
#define GDIOBJFLAG_IGNORELOCK (0x2)
|
||||
|
||||
#endif
|
81
inc_w32k/icm.h
Normal file
81
inc_w32k/icm.h
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
#ifndef __WIN32K_ICM_H
|
||||
#define __WIN32K_ICM_H
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiCheckColorsInGamut(HDC hDC,
|
||||
LPVOID RGBTriples,
|
||||
LPVOID Buffer,
|
||||
UINT Count);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiColorMatchToTarget(HDC hDC,
|
||||
HDC hDCTarget,
|
||||
DWORD Action);
|
||||
|
||||
HCOLORSPACE
|
||||
STDCALL
|
||||
NtGdiCreateColorSpace(LPLOGCOLORSPACEW LogColorSpace);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiDeleteColorSpace(HCOLORSPACE hColorSpace);
|
||||
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiEnumICMProfiles(HDC hDC,
|
||||
LPWSTR lpstrBuffer,
|
||||
UINT cch );
|
||||
|
||||
HCOLORSPACE
|
||||
STDCALL
|
||||
NtGdiGetColorSpace(HDC hDC);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetDeviceGammaRamp(HDC hDC,
|
||||
LPVOID Ramp);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetICMProfile(HDC hDC,
|
||||
LPDWORD NameSize,
|
||||
LPWSTR Filename);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGetLogColorSpace(HCOLORSPACE hColorSpace,
|
||||
LPLOGCOLORSPACEW Buffer,
|
||||
DWORD Size);
|
||||
|
||||
HCOLORSPACE
|
||||
STDCALL
|
||||
NtGdiSetColorSpace(HDC hDC,
|
||||
HCOLORSPACE hColorSpace);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetDeviceGammaRamp(HDC hDC,
|
||||
LPVOID Ramp);
|
||||
|
||||
INT
|
||||
STDCALL
|
||||
NtGdiSetICMMode(HDC hDC,
|
||||
INT EnableICM);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiSetICMProfile(HDC hDC,
|
||||
LPWSTR Filename);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiUpdateICMRegKey(DWORD Reserved,
|
||||
LPWSTR CMID,
|
||||
LPWSTR Filename,
|
||||
UINT Command);
|
||||
|
||||
#endif
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#include <win32k/dc.h>
|
||||
#include <win32k/coord.h>
|
||||
#include <win32k/bitmaps.h>
|
||||
#include <win32k/debug.h>
|
||||
//#include <win32k/debug.h>
|
||||
#include <win32k/fillshap.h>
|
||||
#include <win32k/font.h>
|
||||
#include <win32k/icm.h>
|
@@ -1,7 +1,7 @@
|
||||
#ifndef __WIN32K_NTUSER_H
|
||||
#define __WIN32K_NTUSER_H
|
||||
|
||||
#define WM_SYSTIMER 280
|
||||
//#define WM_SYSTIMER 280
|
||||
|
||||
ULONG STDCALL
|
||||
NtUserGetSystemMetrics(ULONG Index);
|
||||
@@ -301,7 +301,7 @@ NtUserCreateCaret(
|
||||
int nWidth,
|
||||
int nHeight);
|
||||
|
||||
HANDLE
|
||||
HCURSOR
|
||||
STDCALL
|
||||
NtUserCreateCursorIconHandle(
|
||||
PICONINFO IconInfo,
|
||||
@@ -395,7 +395,7 @@ NtUserDestroyAcceleratorTable(
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserDestroyCursorIcon(
|
||||
HANDLE Handle,
|
||||
HCURSOR Handle,
|
||||
DWORD Unknown);
|
||||
|
||||
BOOLEAN STDCALL
|
||||
@@ -718,13 +718,13 @@ NtUserGetGUIThreadInfo(
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetCursorIconInfo(
|
||||
HANDLE Handle,
|
||||
HCURSOR Handle,
|
||||
PICONINFO IconInfo);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetCursorIconSize(
|
||||
HANDLE Handle,
|
||||
HCURSOR Handle,
|
||||
BOOL *fIcon,
|
||||
SIZE *Size);
|
||||
|
||||
@@ -1339,7 +1339,7 @@ NtUserSetCursor(
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetCursorIconContents(
|
||||
HANDLE Handle,
|
||||
HCURSOR Handle,
|
||||
PICONINFO IconInfo);
|
||||
|
||||
BOOL
|
@@ -1,604 +0,0 @@
|
||||
// irc_test.cpp
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif//_MSC_VER
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "File.h"
|
||||
#include "ssprintf.h"
|
||||
#include "trim.h"
|
||||
|
||||
#include "IRCClient.h"
|
||||
#include "config.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
//vector<string> tech, module, dev, stru, period, status, type, func, irql, curse, cursecop;
|
||||
|
||||
class List
|
||||
{
|
||||
public:
|
||||
string name;
|
||||
bool macro;
|
||||
std::vector<std::string> list;
|
||||
string tag;
|
||||
int last;
|
||||
List() { last = -1; }
|
||||
List ( const char* _name, bool _macro ) : name(_name), macro(_macro)
|
||||
{
|
||||
tag = ssprintf("%%%s%%",_name);
|
||||
last = -1;
|
||||
}
|
||||
};
|
||||
|
||||
vector<List> lists;
|
||||
vector<string> ops;
|
||||
|
||||
void ImportList ( const char* listname, bool macro )
|
||||
{
|
||||
lists.push_back ( List ( listname, macro ) );
|
||||
List& list = lists.back();
|
||||
File f ( ssprintf("%s.txt",listname).c_str(), "r" );
|
||||
string line;
|
||||
while ( f.next_line ( line, true ) )
|
||||
list.list.push_back ( line );
|
||||
}
|
||||
|
||||
const char* ListRand ( List& list )
|
||||
{
|
||||
vector<string>& l = list.list;
|
||||
if ( !l.size() )
|
||||
{
|
||||
static string nothing;
|
||||
nothing = ssprintf ( "<list '%s' empty>", list.name.c_str() );
|
||||
return nothing.c_str();
|
||||
}
|
||||
else if ( l.size() == 1 )
|
||||
return l[0].c_str();
|
||||
int sel = list.last;
|
||||
while ( sel == list.last )
|
||||
sel = rand()%l.size();
|
||||
list.last = sel;
|
||||
return l[sel].c_str();
|
||||
}
|
||||
|
||||
const char* ListRand ( int i )
|
||||
{
|
||||
return ListRand ( lists[i] );
|
||||
}
|
||||
|
||||
int GetListIndex ( const char* listname )
|
||||
{
|
||||
for ( int i = 0; i < lists.size(); i++ )
|
||||
{
|
||||
if ( !stricmp ( lists[i].name.c_str(), listname ) )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
List& GetList ( const char* listname )
|
||||
{
|
||||
return lists[GetListIndex(listname)];
|
||||
}
|
||||
|
||||
const char* ListRand ( const char* list )
|
||||
{
|
||||
int i = GetListIndex ( list );
|
||||
if ( i < 0 )
|
||||
return NULL;
|
||||
return ListRand(i);
|
||||
}
|
||||
|
||||
string TaggedReply ( const char* listname )
|
||||
{
|
||||
string t = ListRand(listname);
|
||||
string out;
|
||||
const char* p = t.c_str();
|
||||
while ( *p )
|
||||
{
|
||||
if ( *p == '%' )
|
||||
{
|
||||
bool found = false;
|
||||
for ( int i = 0; i < lists.size() && !found; i++ )
|
||||
{
|
||||
if ( lists[i].macro && !strnicmp ( p, lists[i].tag.c_str(), lists[i].tag.size() ) )
|
||||
{
|
||||
out += ListRand(i);
|
||||
p += lists[i].tag.size();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if ( !found )
|
||||
out += *p++;
|
||||
}
|
||||
const char* p2 = strchr ( p, '%' );
|
||||
if ( !p2 )
|
||||
p2 = p + strlen(p);
|
||||
if ( p2 > p )
|
||||
{
|
||||
out += string ( p, p2-p );
|
||||
p = p2;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string gobble ( string& s, const char* delim )
|
||||
{
|
||||
const char* p = s.c_str();
|
||||
p += strspn ( p, delim );
|
||||
const char* p2 = strpbrk ( p, delim );
|
||||
if ( !p2 ) p2 = p + strlen(p);
|
||||
string out ( p, p2-p );
|
||||
p2 += strspn ( p2, delim );
|
||||
s = string ( p2 );
|
||||
return out;
|
||||
}
|
||||
|
||||
bool isop ( const string& who )
|
||||
{
|
||||
for ( int i = 0; i < ops.size(); i++ )
|
||||
{
|
||||
if ( ops[i] == who )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// do custom stuff with the IRCClient from your subclass via the provided callbacks...
|
||||
class MyIRCClient : public IRCClient
|
||||
{
|
||||
File flog;
|
||||
clock_t brake_silence;
|
||||
|
||||
// wait another 30 mins to brake the silence
|
||||
#define NOIDLE brake_silence = clock () + 30 * CLK_TCK * 60
|
||||
|
||||
void CheckIdle ( void )
|
||||
{
|
||||
while (true) // _inRun
|
||||
{
|
||||
while (clock() < brake_silence)
|
||||
Sleep(10000);
|
||||
|
||||
string out = TaggedReply("idle");
|
||||
|
||||
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
|
||||
Action ( CHANNEL, &out[4] );
|
||||
else
|
||||
PrivMsg ( CHANNEL, out );
|
||||
|
||||
NOIDLE;
|
||||
}
|
||||
}
|
||||
|
||||
static void THREADAPI CallMe ( MyIRCClient* irc )
|
||||
{
|
||||
irc->CheckIdle();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
MyIRCClient()
|
||||
{
|
||||
NOIDLE;
|
||||
ThreadPool::Instance().Launch ( (ThreadPoolFunc*)MyIRCClient::CallMe, this );
|
||||
flog.open ( "arch.log", "r+" );
|
||||
}
|
||||
// see IRCClient.h for documentation on these callbacks...
|
||||
bool OnConnected()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool OnJoin ( const string& user, const string& channel )
|
||||
{
|
||||
//printf ( "user '%s' joined channel '%s'\n", user.c_str(), channel.c_str() );
|
||||
return true;
|
||||
}
|
||||
bool OnPart ( const std::string& user, const std::string& channel )
|
||||
{
|
||||
for ( int i = 0; i < ops.size(); i++ )
|
||||
{
|
||||
if ( ops[i] == user )
|
||||
{
|
||||
printf ( "remove '%s' to ops list\n", user.c_str() );
|
||||
ops.erase ( &ops[i] );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool OnNick ( const std::string& oldNick, const std::string& newNick )
|
||||
{
|
||||
for ( int i = 0; i < ops.size(); i++ )
|
||||
{
|
||||
if ( ops[i] == oldNick )
|
||||
{
|
||||
printf ( "op '%s' changed nick to '%s'\n", oldNick.c_str(), newNick.c_str() );
|
||||
ops[i] = newNick;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool OnEndChannelUsers ( const string& channel )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool OnPrivMsg ( const string& from, const string& text )
|
||||
{
|
||||
//flog.flush();
|
||||
printf ( "<%s> %s\n", from.c_str(), text.c_str() );
|
||||
flog.printf ( "<%s> %s\n", from.c_str(), text.c_str() );
|
||||
|
||||
if ( !isop(from) )
|
||||
return PrivMsg ( from, "hey, your tongue doesn't belong there!" );
|
||||
|
||||
else if ( strnicmp ( text.c_str(), "!say ", 5 ) )
|
||||
return PrivMsg ( from, "Talk to me on normal Chanel" );
|
||||
|
||||
string say = trim(&text[5]);
|
||||
|
||||
if ( !strnicmp ( say.c_str(), "/me ", 4 ) )
|
||||
return Action ( CHANNEL, trim(&say[4]) );
|
||||
else
|
||||
return PrivMsg ( CHANNEL, trim(say) );
|
||||
}
|
||||
bool OnChannelMsg ( const string& channel, const string& from, const string& text )
|
||||
{
|
||||
fflush ( flog );
|
||||
printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() );
|
||||
flog.printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() );
|
||||
NOIDLE; // add 30 mins till idle
|
||||
|
||||
bool found_name = false;
|
||||
string text2 ( text );
|
||||
strlwr ( &text2[0] );
|
||||
|
||||
if ( !strnicmp ( text.c_str(), BOTNAME, strlen(BOTNAME) ) )
|
||||
found_name = true;
|
||||
|
||||
string s ( text );
|
||||
|
||||
if ( found_name )
|
||||
gobble ( s, " \t" ); // remove bot name
|
||||
|
||||
// command
|
||||
if ( s[0] == '!' )
|
||||
{
|
||||
bool from_op = isop(from);
|
||||
string cmd = gobble ( s, " \t" );
|
||||
|
||||
// from all
|
||||
if ( false && cmd == "!svn" && from == "TechBot" ) // || cmd == "!help" && !TechBotOnline
|
||||
{
|
||||
PrivMsg ( channel, "For my help try !what." );
|
||||
}
|
||||
|
||||
// from normel user
|
||||
else if ( !from_op )
|
||||
{
|
||||
if ( cmd == "!grovel" )
|
||||
{
|
||||
string out = ssprintf(TaggedReply("nogrovel").c_str(),from.c_str());
|
||||
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
|
||||
return Action ( channel, &out[4] );
|
||||
else
|
||||
return PrivMsg ( channel, out );
|
||||
}
|
||||
|
||||
else if ( cmd == "!what" )
|
||||
{
|
||||
return PrivMsg ( channel, ssprintf("For you, %s, I only support the \"!grovel\" command.", from.c_str()).c_str() );
|
||||
}
|
||||
|
||||
else if ( cmd == "!grovel" || cmd == "!kiss" || cmd == "!hug"
|
||||
|| cmd == "!give" || cmd == "!what" || cmd == "!add" || cmd == "!remove" )
|
||||
{
|
||||
PrivMsg ( channel, ssprintf("%s: I only take commands from ops",from.c_str()) );
|
||||
}
|
||||
}
|
||||
|
||||
// from op
|
||||
else if ( cmd == "!grovel" )
|
||||
{
|
||||
string out = ssprintf(TaggedReply("grovel").c_str(),from.c_str());
|
||||
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
|
||||
return Action ( channel, &out[4] );
|
||||
else
|
||||
return PrivMsg ( channel, out );
|
||||
}
|
||||
else if ( cmd == "!kiss" )
|
||||
{
|
||||
if ( s.size() )
|
||||
return Action ( channel, ssprintf("kisses %s",s.c_str()) );
|
||||
else
|
||||
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
|
||||
}
|
||||
else if ( cmd == "!hug" )
|
||||
{
|
||||
if ( s.size() )
|
||||
return Action ( channel, ssprintf("hugs %s",s.c_str()) );
|
||||
else
|
||||
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
|
||||
}
|
||||
else if ( cmd == "!give" )
|
||||
{
|
||||
string who = gobble(s," \t");
|
||||
if ( who.size() && s.size() )
|
||||
return Action ( channel, ssprintf("gives %s a %s",who.c_str(),s.c_str()) );
|
||||
else
|
||||
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
|
||||
}
|
||||
else if ( cmd == "!what" )
|
||||
{
|
||||
PrivMsg ( channel, "For ops I support the following commands:" );
|
||||
PrivMsg ( channel, "!grovel" );
|
||||
PrivMsg ( channel, "!kiss" );
|
||||
PrivMsg ( channel, "!hug" );
|
||||
PrivMsg ( channel, "!give" );
|
||||
PrivMsg ( channel, "!say (the input is a private message)" );
|
||||
PrivMsg ( channel, "!add" );
|
||||
PrivMsg ( channel, "!remove" );
|
||||
PrivMsg ( channel, " - for more info see wiki" );
|
||||
}
|
||||
else if ( cmd == "!add" )
|
||||
{
|
||||
string listname = gobble ( s, " \t" );
|
||||
int i = GetListIndex ( listname.c_str() );
|
||||
if ( i == -1 )
|
||||
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
|
||||
List& list = lists[i];
|
||||
if ( s[0] == '\"' || s[0] == '\'' )
|
||||
{
|
||||
char delim = s[0];
|
||||
const char* p = &s[1];
|
||||
const char* p2 = strchr ( p, delim );
|
||||
if ( !p2 )
|
||||
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
|
||||
s = string ( p, p2-p );
|
||||
}
|
||||
for ( i = 0; i < list.list.size(); i++ )
|
||||
{
|
||||
if ( list.list[i] == s )
|
||||
return PrivMsg ( channel, ssprintf("%s: entry already exists in list '%s'",from.c_str(),listname.c_str()) );
|
||||
}
|
||||
if ( !stricmp ( listname.c_str(), "curse" ) )
|
||||
strlwr ( &s[0] );
|
||||
list.list.push_back ( s );
|
||||
{
|
||||
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
|
||||
for ( i = 0; i < list.list.size(); i++ )
|
||||
f.printf ( "%s\n", list.list[i].c_str() );
|
||||
}
|
||||
return PrivMsg ( channel, ssprintf("%s: entry added to list '%s'",from.c_str(),listname.c_str()) );
|
||||
}
|
||||
else if ( cmd == "!remove" )
|
||||
{
|
||||
string listname = gobble ( s, " \t" );
|
||||
int i = GetListIndex ( listname.c_str() );
|
||||
if ( i == -1 )
|
||||
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
|
||||
List& list = lists[i];
|
||||
if ( s[0] == '\"' || s[0] == '\'' )
|
||||
{
|
||||
char delim = s[0];
|
||||
const char* p = &s[1];
|
||||
const char* p2 = strchr ( p, delim );
|
||||
if ( !p2 )
|
||||
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
|
||||
s = string ( p, p2-p );
|
||||
}
|
||||
for ( i = 0; i < list.list.size(); i++ )
|
||||
{
|
||||
if ( list.list[i] == s )
|
||||
{
|
||||
list.list.erase ( &list.list[i] );
|
||||
{
|
||||
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
|
||||
for ( i = 0; i < list.list.size(); i++ )
|
||||
f.printf ( "%s\n", list.list[i].c_str() );
|
||||
}
|
||||
return PrivMsg ( channel, ssprintf("%s: entry removed from list '%s'",from.c_str(),listname.c_str()) );
|
||||
}
|
||||
}
|
||||
return PrivMsg ( channel, ssprintf("%s: entry doesn't exist in list '%s'",from.c_str(),listname.c_str()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (found_name)
|
||||
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
|
||||
}
|
||||
|
||||
} // if (command)
|
||||
|
||||
bool found_curse = false;
|
||||
static vector<string>& curse = GetList("curse").list;
|
||||
text2 = " " + text2 + " ";
|
||||
|
||||
for ( int i = 0; i < curse.size() && !found_curse; i++ )
|
||||
{
|
||||
if ( strstr ( text2.c_str(), curse[i].c_str() ) )
|
||||
found_curse = true;
|
||||
}
|
||||
if ( found_curse )
|
||||
{
|
||||
static List& cursecop = GetList("cursecop");
|
||||
return PrivMsg ( channel, ssprintf("%s: %s", from.c_str(), ListRand(cursecop)) );
|
||||
}
|
||||
|
||||
string botname (BOTNAME);
|
||||
strlwr ( &botname[0] );
|
||||
//botname = " " + botname + " ";
|
||||
|
||||
if ( strstr(text2.c_str(), botname.c_str()) || strstr(text2.c_str(), " arch ") || found_name )
|
||||
{
|
||||
string out = ssprintf("%s: %s", from.c_str(), TaggedReply("tech").c_str());
|
||||
flog.printf ( "TECH-REPLY: %s\n", out.c_str() );
|
||||
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
|
||||
return Action ( channel, &out[4] );
|
||||
else
|
||||
return PrivMsg ( channel, out );
|
||||
}
|
||||
return true;
|
||||
|
||||
} // On Chanel Message
|
||||
|
||||
bool OnChannelMode ( const string& channel, const string& mode )
|
||||
{
|
||||
//printf ( "OnChannelMode(%s,%s)\n", channel.c_str(), mode.c_str() );
|
||||
return true;
|
||||
}
|
||||
bool OnUserModeInChannel ( const string& src, const string& channel, const string& mode, const string& target )
|
||||
{
|
||||
printf ( "OnUserModeInChannel(%s,%s,%s,%s)\n", src.c_str(), channel.c_str(), mode.c_str(), target.c_str() );
|
||||
const char* p = mode.c_str();
|
||||
if ( !p )
|
||||
return true;
|
||||
while ( *p )
|
||||
{
|
||||
switch ( *p++ )
|
||||
{
|
||||
case '+':
|
||||
while ( *p != 0 && *p != ' ' )
|
||||
{
|
||||
if ( *p == 'o' )
|
||||
{
|
||||
printf ( "adding '%s' to ops list\n", target.c_str() );
|
||||
ops.push_back ( target );
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
while ( *p != 0 && *p != ' ' )
|
||||
{
|
||||
if ( *p == 'o' )
|
||||
{
|
||||
for ( int i = 0; i < ops.size(); i++ )
|
||||
{
|
||||
if ( ops[i] == target )
|
||||
{
|
||||
printf ( "remove '%s' to ops list\n", target.c_str() );
|
||||
ops.erase ( &ops[i] );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool OnMode ( const string& user, const string& mode )
|
||||
{
|
||||
//printf ( "OnMode(%s,%s)\n", user.c_str(), mode.c_str() );
|
||||
return true;
|
||||
}
|
||||
bool OnChannelUsers ( const string& channel, const vector<string>& users )
|
||||
{
|
||||
//printf ( "[%s has %i users]: ", channel.c_str(), users.size() );
|
||||
for ( int i = 0; i < users.size(); i++ )
|
||||
{
|
||||
if ( users[i][0] == '@' )
|
||||
ops.push_back ( &users[i][1] );
|
||||
/*if ( i )
|
||||
printf ( ", " );
|
||||
printf ( "%s", users[i].c_str() );*/
|
||||
}
|
||||
//printf ( "\n" );
|
||||
return true;
|
||||
}
|
||||
bool OnKick ( void )
|
||||
{
|
||||
Join(CHANNEL);
|
||||
return true;
|
||||
}
|
||||
bool OnBanned ( const std::string& channel )
|
||||
{
|
||||
Sleep(10000);
|
||||
return Join(CHANNEL);
|
||||
}
|
||||
};
|
||||
|
||||
int main ( int argc, char** argv )
|
||||
{
|
||||
srand ( time(NULL) );
|
||||
|
||||
ImportList ( "dev", true );
|
||||
ImportList ( "func", true );
|
||||
ImportList ( "dev", true );
|
||||
ImportList ( "func", true );
|
||||
ImportList ( "irql", true );
|
||||
ImportList ( "module", true );
|
||||
ImportList ( "period", true );
|
||||
ImportList ( "status", true );
|
||||
ImportList ( "stru", true );
|
||||
ImportList ( "type", true );
|
||||
|
||||
ImportList ( "tech", false );
|
||||
ImportList ( "curse", false );
|
||||
ImportList ( "cursecop", false );
|
||||
ImportList ( "grovel", false );
|
||||
ImportList ( "nogrovel", false );
|
||||
ImportList ( "idle", false );
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf ( "initializing IRCClient debugging\n" );
|
||||
IRCClient::SetDebug ( true );
|
||||
#endif//_DEBUG
|
||||
|
||||
while (true)
|
||||
{
|
||||
printf ( "calling suStartup()\n" );
|
||||
suStartup();
|
||||
printf ( "creating IRCClient object\n" );
|
||||
MyIRCClient irc;
|
||||
printf ( "connecting to freenode\n" );
|
||||
|
||||
if ( !irc.Connect ( SERVER ) ) // irc.freenode.net
|
||||
{
|
||||
printf ( "couldn't connect to server\n" );
|
||||
Sleep(10000);
|
||||
continue;
|
||||
}
|
||||
printf ( "sending user command\n" );
|
||||
if ( !irc.User ( BOTNAME, "reactos.com", SERVER, "ArchBlackmann" ) )
|
||||
{
|
||||
printf ( "USER command failed, retying ...\n" );
|
||||
Sleep(10000);
|
||||
continue;
|
||||
}
|
||||
printf ( "sending nick\n" );
|
||||
if ( !irc.Nick ( BOTNAME ) )
|
||||
{
|
||||
printf ( "NICK command failed, retying ...\n" );
|
||||
Sleep(10000);
|
||||
continue;
|
||||
}
|
||||
printf ( "setting mode\n" );
|
||||
if ( !irc.Mode ( MODE ) )
|
||||
{
|
||||
printf ( "MODE command failed, retying ...\n" );
|
||||
Sleep(10000);
|
||||
continue;
|
||||
}
|
||||
printf ( "joining channel\n" );
|
||||
if ( !irc.Join ( CHANNEL ) )
|
||||
{
|
||||
printf ( "JOIN command failed, retying ...\n" );
|
||||
Sleep(10000);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ( "entering irc client processor\n" );
|
||||
irc.Run ( false ); // do the processing in this thread...
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,216 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="ArchBlackmann" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=ArchBlackmann - 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 "ArchBlackmann.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 "ArchBlackmann.mak" CFG="ArchBlackmann - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ArchBlackmann - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "ArchBlackmann - 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)" == "ArchBlackmann - 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 /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 /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "ArchBlackmann - 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 "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /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 /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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "ArchBlackmann - Win32 Release"
|
||||
# Name "ArchBlackmann - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ArchBlackmann.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\auto_ptr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\auto_vector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\base64.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\base64.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\chomp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\chomp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\config.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cram_md5.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cram_md5.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\File.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\File.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IRCClient.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IRCClient.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MD5.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MD5.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\panic.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\panic.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\QueueT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Reli.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ReliMT.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ReliMT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SockUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SockUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitJoin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitJoin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ssprintf.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ssprintf.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ThreadPool.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ThreadPool.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\trim.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\trim.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\verify.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ArchBlackmann"=.\ArchBlackmann.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
@@ -1,265 +0,0 @@
|
||||
// File.cpp
|
||||
// (C) 2002-2004 Royce Mitchell III
|
||||
// Dually licensed under BSD & LGPL
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif//_MSC_VER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "File.h"
|
||||
|
||||
#ifndef nelem
|
||||
#define nelem(x) ( sizeof(x) / sizeof(x[0]) )
|
||||
#endif//nelem
|
||||
|
||||
using File::filesize_t;
|
||||
using File::fileoff_t;
|
||||
|
||||
|
||||
fileoff_t File::seek ( fileoff_t offset )
|
||||
{
|
||||
#ifdef WIN32
|
||||
if ( _f->_flag & _IOWRT ) // is there pending output?
|
||||
fflush ( _f );
|
||||
|
||||
// reset "buffered input" variables
|
||||
_f->_cnt = 0;
|
||||
_f->_ptr = _f->_base;
|
||||
|
||||
// make sure we're going forward
|
||||
if ( _f->_flag & _IORW )
|
||||
_f->_flag &= ~(_IOREAD|_IOWRT);
|
||||
|
||||
return _lseeki64 ( _fileno(_f), offset, SEEK_SET );
|
||||
#else//UNIX
|
||||
return lseek64 ( fileno(_f), offset, SEEK_SET );
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string File::getline ( bool strip_crlf /*= false*/ )
|
||||
{
|
||||
std::string s = "";
|
||||
char buf[256];
|
||||
for ( ;; )
|
||||
{
|
||||
*buf = 0;
|
||||
fgets ( buf, nelem(buf)-1, _f );
|
||||
if ( !*buf )
|
||||
break;
|
||||
s += buf;
|
||||
if ( strchr ( "\r\n", buf[strlen(buf)-1] ) )
|
||||
break;
|
||||
}
|
||||
if ( strip_crlf && s.size() )
|
||||
{
|
||||
char* p = strpbrk ( &s[0], "\r\n" );
|
||||
if ( p )
|
||||
{
|
||||
*p = '\0';
|
||||
s.resize ( p-&s[0] );
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
std::wstring File::wgetline ( bool strip_crlf /*= false*/ )
|
||||
{
|
||||
std::wstring s = L"";
|
||||
wchar_t buf[256];
|
||||
for ( ;; )
|
||||
{
|
||||
*buf = 0;
|
||||
fgetws ( buf, nelem(buf)-1, _f );
|
||||
if ( !*buf )
|
||||
break;
|
||||
s += buf;
|
||||
if ( wcschr ( L"\r\n", buf[wcslen(buf)-1] ) )
|
||||
break;
|
||||
}
|
||||
if ( strip_crlf && s.size() )
|
||||
{
|
||||
wchar_t* p = wcspbrk ( &s[0], L"\r\n" );
|
||||
if ( p )
|
||||
{
|
||||
*p = L'\0';
|
||||
s.resize ( (p-&s[0])/sizeof(wchar_t) );
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// this function searches for the next end-of-line and puts all data it
|
||||
// finds until then in the 'line' parameter.
|
||||
//
|
||||
// call continuously until the function returns false ( no more data )
|
||||
bool File::next_line ( std::string& line, bool strip_crlf )
|
||||
{
|
||||
line = getline(strip_crlf);
|
||||
// indicate that we're done *if*:
|
||||
// 1) there's no more data, *and*
|
||||
// 2) we're at the end of the file
|
||||
return line.size()>0 || !eof();
|
||||
}
|
||||
|
||||
bool File::next_line ( std::wstring& line, bool strip_crlf )
|
||||
{
|
||||
line = wgetline ( strip_crlf );
|
||||
return line.size()>0 || !eof();
|
||||
}
|
||||
|
||||
/*
|
||||
example usage:
|
||||
|
||||
bool mycallback ( const std::string& line, int line_number, long lparam )
|
||||
{
|
||||
std::cout << line << std::endl;
|
||||
return true; // continue enumeration
|
||||
}
|
||||
|
||||
File f ( "file.txt", "rb" ); // open file for binary read-only ( i.e. "rb" )
|
||||
f.enum_lines ( mycallback, 0, true );
|
||||
*/
|
||||
|
||||
/*bool File::enum_lines ( bool (*callback)(const std::string& line, int line_number, long lparam), long lparam, bool strip_crlf )
|
||||
{
|
||||
int line_number = 0;
|
||||
for ( ;; )
|
||||
{
|
||||
std::string s = getline(strip_crlf);
|
||||
line_number++;
|
||||
if ( !s.size() )
|
||||
{
|
||||
if ( eof() )
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if ( !(*callback) ( s, line_number, lparam ) )
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
filesize_t File::length() const
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _filelengthi64 ( _fileno(_f) );
|
||||
#elif defined(UNIX)
|
||||
struct stat64 file_stat;
|
||||
verify(fstat64(fileno(_f), &file_stat) == 0);
|
||||
return file_stat.st_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
void File::close()
|
||||
{
|
||||
if ( _f )
|
||||
{
|
||||
fclose(_f);
|
||||
_f = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void File::printf ( const char* fmt, ... )
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
|
||||
va_start(arg, fmt);
|
||||
assert(_f);
|
||||
done = vfprintf ( _f, fmt, arg );
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
/*static*/ bool File::LoadIntoString ( std::string& s, const std::string& filename )
|
||||
{
|
||||
File in ( filename, "rb" );
|
||||
if ( !in.isopened() )
|
||||
return false;
|
||||
filesize_t flen = in.length();
|
||||
size_t len = size_t(flen);
|
||||
if ( len != flen )
|
||||
return false; // file too big...
|
||||
s.resize ( len + 1 );
|
||||
if ( !in.read ( &s[0], len ) )
|
||||
return false;
|
||||
s[len] = '\0';
|
||||
s.resize ( len );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool File::LoadIntoString ( std::string& s, const std::wstring& filename )
|
||||
{
|
||||
File in ( filename, L"rb" );
|
||||
if ( !in.isopened() )
|
||||
return false;
|
||||
filesize_t flen = in.length();
|
||||
size_t len = size_t(flen);
|
||||
if ( len != flen )
|
||||
return false; // file too big...
|
||||
s.resize ( len + 1 );
|
||||
if ( !in.read ( &s[0], len ) )
|
||||
return false;
|
||||
s[len] = '\0';
|
||||
s.resize ( len );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool File::SaveFromString ( const std::string& filename, const std::string& s, bool binary )
|
||||
{
|
||||
File out ( filename, binary ? "wb" : "w" );
|
||||
if ( !out.isopened() )
|
||||
return false;
|
||||
out.write ( s.c_str(), s.size() );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool File::SaveFromString ( const std::wstring& filename, const std::string& s, bool binary )
|
||||
{
|
||||
File out ( filename, binary ? L"wb" : L"w" );
|
||||
if ( !out.isopened() )
|
||||
return false;
|
||||
out.write ( s.c_str(), s.size() );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool File::SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary )
|
||||
{
|
||||
File out ( filename, binary ? "wb" : "w" );
|
||||
if ( !out.isopened() )
|
||||
return false;
|
||||
out.write ( buf, buflen );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool File::SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary )
|
||||
{
|
||||
File out ( filename, binary ? L"wb" : L"w" );
|
||||
if ( !out.isopened() )
|
||||
return false;
|
||||
out.write ( buf, buflen );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ std::string File::TempFileName ( const std::string& prefix )
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::string s ( _tempnam ( ".", prefix.c_str() ) );
|
||||
return s;
|
||||
#else
|
||||
// FIXME
|
||||
return string("");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*static*/ std::wstring File::TempFileName ( const std::wstring& prefix )
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring s ( _wtempnam ( L".", prefix.c_str() ) );
|
||||
return s;
|
||||
#else
|
||||
// FIXME
|
||||
return std::wstring(L"");
|
||||
#endif
|
||||
}
|
@@ -1,173 +0,0 @@
|
||||
// File.h
|
||||
// (C) 2002-2004 Royce Mitchell III
|
||||
// Dually licensed under BSD & LGPL
|
||||
|
||||
#ifndef FILE_H
|
||||
#define FILE_H
|
||||
|
||||
#ifdef WIN32
|
||||
# include <stdio.h> // fgetc
|
||||
# include <io.h>
|
||||
#elif defined(UNIX)
|
||||
# include <sys/stat.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 fileoff_t;
|
||||
typedef unsigned __int64 filesize_t;
|
||||
#else//_MSC_VER
|
||||
typedef __off64_t fileoff_t;
|
||||
typedef __size64_t filesize_t;
|
||||
#endif//_MSC_VER
|
||||
|
||||
File() : _f(0)
|
||||
{
|
||||
}
|
||||
|
||||
File ( const std::string& filename, const char* mode ) : _f(0)
|
||||
{
|
||||
open ( filename, mode );
|
||||
}
|
||||
|
||||
File ( const std::wstring& filename, const wchar_t* mode ) : _f(0)
|
||||
{
|
||||
open ( filename, mode );
|
||||
}
|
||||
|
||||
File ( const char* filename, const char* mode ) : _f(0)
|
||||
{
|
||||
open ( filename, mode );
|
||||
}
|
||||
|
||||
File ( const wchar_t* filename, const wchar_t* mode ) : _f(0)
|
||||
{
|
||||
open ( filename, mode );
|
||||
}
|
||||
|
||||
~File()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool open ( const std::string& filename, const char* mode )
|
||||
{
|
||||
assert ( !_f );
|
||||
return ( _f = fopen ( filename.c_str(), mode ) ) != 0;
|
||||
}
|
||||
|
||||
bool open ( const std::wstring& filename, const wchar_t* mode )
|
||||
{
|
||||
assert ( !_f );
|
||||
return ( _f = _wfopen ( filename.c_str(), mode ) ) != 0;
|
||||
}
|
||||
|
||||
bool open ( const char* filename, const char* mode )
|
||||
{
|
||||
assert ( !_f );
|
||||
return ( _f = fopen ( filename, mode ) ) != 0;
|
||||
}
|
||||
|
||||
bool open ( const wchar_t* filename, const wchar_t* mode )
|
||||
{
|
||||
assert ( !_f );
|
||||
return ( _f = _wfopen ( filename, mode ) ) != 0;
|
||||
}
|
||||
|
||||
fileoff_t seek ( fileoff_t offset );
|
||||
|
||||
int get()
|
||||
{
|
||||
return fgetc ( _f );
|
||||
}
|
||||
|
||||
bool put ( int c )
|
||||
{
|
||||
return fputc ( c, _f ) != EOF;
|
||||
}
|
||||
|
||||
std::string getline ( bool strip_crlf = false );
|
||||
std::wstring wgetline ( bool strip_crlf = false );
|
||||
|
||||
// this function searches for the next end-of-line and puts all data it
|
||||
// finds until then in the 'line' parameter.
|
||||
//
|
||||
// call continuously until the function returns false ( no more data )
|
||||
bool next_line ( std::string& line, bool strip_crlf );
|
||||
bool next_line ( std::wstring& line, bool strip_crlf );
|
||||
|
||||
bool read ( void* data, unsigned len )
|
||||
{
|
||||
return len == fread ( data, 1, len, _f );
|
||||
}
|
||||
|
||||
bool write ( const void* data, unsigned len )
|
||||
{
|
||||
return len == fwrite ( data, 1, len, _f );
|
||||
}
|
||||
|
||||
bool write ( const std::string& data )
|
||||
{
|
||||
return data.length() == fwrite ( data.c_str(), 1, data.length(), _f );
|
||||
}
|
||||
|
||||
bool write ( const std::wstring& data )
|
||||
{
|
||||
return data.length() == fwrite ( data.c_str(), sizeof(data[0]), data.length(), _f );
|
||||
}
|
||||
|
||||
filesize_t length() const;
|
||||
|
||||
void close();
|
||||
|
||||
bool isopened() const
|
||||
{
|
||||
return _f != 0;
|
||||
}
|
||||
|
||||
bool is_open() const
|
||||
{
|
||||
return _f != 0;
|
||||
}
|
||||
|
||||
bool eof() const
|
||||
{
|
||||
return feof(_f) ? true : false;
|
||||
}
|
||||
|
||||
FILE* operator * ()
|
||||
{
|
||||
return _f;
|
||||
}
|
||||
|
||||
operator FILE*()
|
||||
{
|
||||
return _f;
|
||||
}
|
||||
|
||||
void printf ( const char* fmt, ... );
|
||||
void printf ( const wchar_t* fmt, ... );
|
||||
|
||||
static bool LoadIntoString ( std::string& s, const std::string& filename );
|
||||
static bool LoadIntoString ( std::string& s, const std::wstring& filename );
|
||||
static bool SaveFromString ( const std::string& filename, const std::string& s, bool binary );
|
||||
static bool SaveFromString ( const std::wstring& filename, const std::string& s, bool binary );
|
||||
static bool SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary );
|
||||
static bool SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary );
|
||||
|
||||
static std::string TempFileName ( const std::string& prefix );
|
||||
static std::wstring TempFileName ( const std::wstring& prefix );
|
||||
|
||||
private:
|
||||
File(const File&) {}
|
||||
const File& operator = ( const File& ) { return *this; }
|
||||
|
||||
FILE * _f;
|
||||
};
|
||||
|
||||
#endif//FILE_H
|
@@ -1,418 +0,0 @@
|
||||
// IRCClient.cpp
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif//_MSC_VER
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "IRCClient.h"
|
||||
#include "md5.h"
|
||||
#include "cram_md5.h"
|
||||
#include "trim.h"
|
||||
#include "chomp.h"
|
||||
#include "SplitJoin.h"
|
||||
#include "base64.h"
|
||||
#include "config.h"
|
||||
|
||||
using std::string;
|
||||
using std::stringstream;
|
||||
using std::vector;
|
||||
|
||||
bool IRCClient::_debug = true;
|
||||
|
||||
// see rfc1459 for IRC-Protocoll Reference
|
||||
|
||||
IRCClient::IRCClient()
|
||||
: _timeout(10*60*1000), _inRun(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool IRCClient::Connect ( const string& server, short port )
|
||||
{
|
||||
string buf;
|
||||
Close();
|
||||
Attach ( suTcpSocket() );
|
||||
if ( !suConnect ( *this, server.c_str(), port ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::User ( const string& user, const string& mode,
|
||||
const string& network, const string& realname )
|
||||
{
|
||||
string buf;
|
||||
buf = "USER " + user + " \"" + mode + "\" \"" + network + "\" :" + realname + "\n";
|
||||
return Send ( buf );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Nick ( const string& nick )
|
||||
{
|
||||
_nick = nick;
|
||||
Send ( "NICK " + _nick + "\n" );
|
||||
PrivMsg ("NickServ", "IDENTIFY " + (string)PASS);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Mode ( const string& mode )
|
||||
{
|
||||
return Send ( "MODE " + _nick + " " + mode + "\n" );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Names ( const string& channel )
|
||||
{
|
||||
return Send ( "NAMES " + channel + "\n" );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Mode ( const string& channel, const string& mode, const string& target )
|
||||
{
|
||||
return Send ( "MODE " + channel + " " + mode + " " + target + "\n" );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Join ( const string& channel )
|
||||
{
|
||||
return Send("JOIN " + channel + "\n");
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::PrivMsg ( const string& to, const string& text )
|
||||
{
|
||||
return Send ( "PRIVMSG " + to + " :" + text + '\n' );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Action ( const string& to, const string& text )
|
||||
{
|
||||
return Send ( "PRIVMSG " + to + " :" + (char)1 + "ACTION " + text + (char)1 + '\n' );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Part ( const string& channel, const string& text )
|
||||
{
|
||||
return Send ( "PART " + channel + " :" + text + "\n" );
|
||||
}
|
||||
|
||||
bool
|
||||
IRCClient::Quit ( const string& text )
|
||||
{
|
||||
return Send( "QUIT :" + text + "\n");
|
||||
}
|
||||
|
||||
bool IRCClient::_Recv ( string& buf )
|
||||
{
|
||||
bool b = (recvUntil ( buf, '\n', _timeout ) > 0);
|
||||
if ( b && _debug )
|
||||
{
|
||||
printf ( ">> %s", buf.c_str() );
|
||||
if ( buf[buf.length()-1] != '\n' )
|
||||
printf ( "\n" );
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
bool IRCClient::Send ( const string& buf )
|
||||
{
|
||||
if ( _debug )
|
||||
{
|
||||
printf ( "<< %s", buf.c_str() );
|
||||
if ( buf[buf.length()-1] != '\n' )
|
||||
printf ( "\n" );
|
||||
}
|
||||
return ( buf.length() == (size_t)send ( *this, buf.c_str(), buf.length(), 0 ) );
|
||||
}
|
||||
|
||||
bool IRCClient::OnPing( const string& text )
|
||||
{
|
||||
return Send( "PONG " + text + "\n" );
|
||||
}
|
||||
|
||||
|
||||
int THREADAPI IRCClient::Callback ( IRCClient* irc )
|
||||
{
|
||||
return irc->Run ( false );
|
||||
}
|
||||
|
||||
int IRCClient::Run ( bool launch_thread )
|
||||
{
|
||||
if ( (SOCKET)*this == INVALID_SOCKET )
|
||||
return 0;
|
||||
if ( _inRun ) return 1;
|
||||
if ( launch_thread )
|
||||
{
|
||||
ThreadPool::Instance().Launch ( (ThreadPoolFunc*)IRCClient::Callback, this );
|
||||
return 1;
|
||||
}
|
||||
_inRun = true;
|
||||
if ( _debug ) printf ( "IRCClient::Run() - waiting for responses\n" );
|
||||
string buf;
|
||||
while ( _Recv(buf) )
|
||||
{
|
||||
if ( !strnicmp ( buf.c_str(), "NOTICE ", 7 ) )
|
||||
{
|
||||
//printf ( "recv'd NOTICE msg...\n" );
|
||||
// TODO...
|
||||
//OnAuth (
|
||||
}
|
||||
else if ( !strnicmp ( buf.c_str(), "PING ", 5 ) )
|
||||
{
|
||||
const char* p = &buf[5]; // point to first char after "PING "
|
||||
while ( *p == ':' ) // then read past the colons
|
||||
p++;
|
||||
const char* p2 = strpbrk ( p, "\r\n" ); // find the end of line
|
||||
string text ( p, p2-p ); // and set the text
|
||||
OnPing( text );
|
||||
}
|
||||
else if ( buf[0] == ':' )
|
||||
{
|
||||
const char* p = &buf[1]; // skip first colon...
|
||||
const char* p2 = strpbrk ( p, " !" );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 0: ", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
string src ( p, p2-p );
|
||||
if ( !src.length() )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 0.5: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
p = p2 + 1;
|
||||
if ( *p2 == '!' )
|
||||
{
|
||||
p2 = strchr ( p, ' ' );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 1: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
//string srchost ( p, p2-p );
|
||||
p = p2 + 1;
|
||||
}
|
||||
p2 = strchr ( p, ' ' );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 2: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
string cmd ( p, p2-p );
|
||||
p = p2 + 1;
|
||||
p2 = strpbrk ( p, " :" );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 3: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
string tgt ( p, p2-p );
|
||||
p = p2 + 1;
|
||||
p += strspn ( p, " " );
|
||||
if ( *p == '=' )
|
||||
{
|
||||
p++;
|
||||
p += strspn ( p, " " );
|
||||
}
|
||||
if ( *p == ':' )
|
||||
p++;
|
||||
p2 = strpbrk ( p, "\r\n" );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 4: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
string text ( p, p2-p );
|
||||
strlwr ( &cmd[0] );
|
||||
if ( cmd == "privmsg" )
|
||||
{
|
||||
if ( !tgt.length() )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 5 (PRIVMSG w/o target): %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
if ( *p == 1 )
|
||||
{
|
||||
p++;
|
||||
p2 = strchr ( p, ' ' );
|
||||
if ( !p2 ) p2 = p + strlen(p);
|
||||
cmd = string ( p, p2-p );
|
||||
strlwr ( &cmd[0] );
|
||||
p = p2 + 1;
|
||||
p2 = strchr ( p, 1 );
|
||||
if ( !p2 )
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 6 (no terminating \x01 for initial \x01 found: %s", buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
text = string ( p, p2-p );
|
||||
if ( cmd == "action" )
|
||||
{
|
||||
if ( tgt[0] == '#' )
|
||||
OnChannelAction ( tgt, src, text );
|
||||
else
|
||||
OnPrivAction ( src, text );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ( "!!!:OnRecv failure 7 (unrecognized \x01 command '%s': %s", cmd.c_str(), buf.c_str() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( tgt[0] == '#' )
|
||||
OnChannelMsg ( tgt, src, text );
|
||||
else
|
||||
OnPrivMsg ( src, text );
|
||||
}
|
||||
}
|
||||
else if ( cmd == "mode" )
|
||||
{
|
||||
// two diff. kinds of mode notifications...
|
||||
//printf ( "[MODE] src='%s' cmd='%s' tgt='%s' text='%s'", src.c_str(), cmd.c_str(), tgt.c_str(), text.c_str() );
|
||||
//OnMode (
|
||||
// self mode change:
|
||||
// [MODE] src=Nick cmd=mode tgt=Nick text=+i
|
||||
// channel mode change:
|
||||
// [MODE] src=Nick cmd=mode tgt=#Channel text=+o Nick
|
||||
if ( tgt[0] == '#' )
|
||||
{
|
||||
p = text.c_str();
|
||||
p2 = strchr ( p, ' ' );
|
||||
if ( p2 && *p2 )
|
||||
{
|
||||
string mode ( p, p2-p );
|
||||
p = p2 + 1;
|
||||
p += strspn ( p, " " );
|
||||
OnUserModeInChannel ( src, tgt, mode, trim(p) );
|
||||
}
|
||||
else
|
||||
OnChannelMode ( tgt, text );
|
||||
}
|
||||
else
|
||||
OnMode ( tgt, text );
|
||||
}
|
||||
else if ( cmd == "join" )
|
||||
{
|
||||
mychannel = text;
|
||||
OnJoin ( src, text );
|
||||
}
|
||||
else if ( cmd == "part" )
|
||||
{
|
||||
OnPart ( src, text );
|
||||
}
|
||||
else if ( cmd == "nick" )
|
||||
{
|
||||
OnNick ( src, text );
|
||||
}
|
||||
else if ( cmd == "kick" )
|
||||
{
|
||||
OnKick ();
|
||||
}
|
||||
else if ( isdigit(cmd[0]) )
|
||||
{
|
||||
int i = atoi(cmd.c_str());
|
||||
switch ( i )
|
||||
{
|
||||
|
||||
case 1: // "Welcome!" - i.e. it's okay to issue commands now...
|
||||
OnConnected();
|
||||
break;
|
||||
|
||||
case 353: // user list for channel....
|
||||
{
|
||||
p = text.c_str();
|
||||
p2 = strpbrk ( p, " :" );
|
||||
if ( !p2 ) continue;
|
||||
string channel ( p, p2-p );
|
||||
p = strchr ( p2, ':' );
|
||||
if ( !p ) continue;
|
||||
p++;
|
||||
vector<string> users;
|
||||
while ( *p )
|
||||
{
|
||||
p2 = strchr ( p, ' ' );
|
||||
if ( !p2 )
|
||||
p2 = p + strlen(p);
|
||||
users.push_back ( string ( p, p2-p ) );
|
||||
p = p2+1;
|
||||
p += strspn ( p, " " );
|
||||
}
|
||||
OnChannelUsers ( channel, users );
|
||||
}
|
||||
break;
|
||||
|
||||
case 366: // END of user list for channel
|
||||
{
|
||||
p = text.c_str();
|
||||
p2 = strpbrk ( p, " :" );
|
||||
if ( !p2 ) continue;
|
||||
string channel ( p, p2-p );
|
||||
OnEndChannelUsers ( channel );
|
||||
}
|
||||
break;
|
||||
|
||||
case 474: // You are banned
|
||||
{
|
||||
p = text.c_str();
|
||||
p2 = strpbrk ( p, " :" );
|
||||
if ( !p2 ) continue;
|
||||
string channel ( p, p2-p );
|
||||
OnBanned ( channel );
|
||||
}
|
||||
break;
|
||||
|
||||
case 433: // Nick in Use
|
||||
{
|
||||
string nick = _nick;
|
||||
Nick (nick + "_");
|
||||
|
||||
PrivMsg ("NickServ", "GHOST " + nick + " " + PASS);
|
||||
|
||||
// HACK HACK HACK
|
||||
Mode ( "+i" );
|
||||
Join ( CHANNEL ); // this is because IRC client does not review if his commands were sucessfull
|
||||
|
||||
Sleep ( 1000 );
|
||||
Nick ( nick );
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: //MOTD
|
||||
case 376: //MOTD
|
||||
case 372:
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( _debug ) printf ( "unknown command %i: %s", i, buf.c_str() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strstr ( buf.c_str(), "ACTION" ) )
|
||||
{
|
||||
printf ( "ACTION: " );
|
||||
for ( int i = 0; i < buf.size(); i++ )
|
||||
printf ( "%c(%xh)", buf[i], (unsigned)(unsigned char)buf[i] );
|
||||
}
|
||||
else if ( _debug ) printf ( "unrecognized ':' response: %s", buf.c_str() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( _debug ) printf ( "unrecognized irc msg: %s", buf.c_str() );
|
||||
}
|
||||
//OnRecv ( buf );
|
||||
}
|
||||
if ( _debug ) printf ( "IRCClient::Run() - exiting\n" );
|
||||
_inRun = false;
|
||||
return 0;
|
||||
}
|
@@ -1,148 +0,0 @@
|
||||
// IRCClient.h
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef IRCCLIENT_H
|
||||
#define IRCCLIENT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "SockUtils.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
class IRCClient : public suBufferedRecvSocket
|
||||
{
|
||||
|
||||
public:
|
||||
IRCClient();
|
||||
|
||||
std::string mychannel;
|
||||
static bool GetDebug() { return _debug; }
|
||||
static bool SetDebug ( bool debug ) { bool old = _debug; _debug = debug; return old; }
|
||||
|
||||
// connect to server ( record greeting for apop if it exists )
|
||||
bool Connect ( const std::string& server, short port = 6667 );
|
||||
|
||||
bool Running() { return _inRun; }
|
||||
|
||||
////////////////////////// IRC Client Protocol commands ///////////////////////
|
||||
|
||||
// first thing you must call... mode can be ""
|
||||
// network can be same as name of server used in Connect() above
|
||||
bool User ( const std::string& user, const std::string& mode,
|
||||
const std::string& network, const std::string& realname );
|
||||
|
||||
// change nick...
|
||||
bool Nick ( const std::string& nick );
|
||||
|
||||
// change mode for self...
|
||||
bool Mode ( const std::string& mode );
|
||||
|
||||
// set someone's mode in channel ( like oping someone )
|
||||
bool Mode ( const std::string& channel, const std::string& mode, const std::string& target );
|
||||
|
||||
// request a list of names of clients in a channel
|
||||
bool Names ( const std::string& channel );
|
||||
|
||||
// join a channel...
|
||||
bool Join ( const std::string& channel );
|
||||
|
||||
// send message to someone or some channel
|
||||
bool PrivMsg ( const std::string& to, const std::string& text );
|
||||
|
||||
// send /me to someone or some channel
|
||||
bool Action ( const std::string& to, const std::string& text );
|
||||
|
||||
// leave a channel
|
||||
bool Part ( const std::string& channel, const std::string& text );
|
||||
|
||||
// log off
|
||||
bool Quit ( const std::string& text );
|
||||
|
||||
////////////////////// callback functions ////////////////////////////
|
||||
|
||||
// OnConnected: you just successfully logged into irc server
|
||||
virtual bool OnConnected() = 0;
|
||||
|
||||
virtual bool OnNick ( const std::string& oldNick, const std::string& newNick ) { return true; }
|
||||
|
||||
// OnJoin: someone just successfully joined a channel you are in ( also sent when you successfully join a channel )
|
||||
virtual bool OnJoin ( const std::string& user, const std::string& channel ) { return true; }
|
||||
|
||||
// OnPart: someone just left a channel you are in
|
||||
virtual bool OnPart ( const std::string& user, const std::string& channel ) { return true; }
|
||||
|
||||
// OnPrivMsg: you just received a private message from a user
|
||||
virtual bool OnPrivMsg ( const std::string& from, const std::string& text ) { return true; }
|
||||
|
||||
virtual bool OnPrivAction ( const std::string& from, const std::string& text ) { return true; }
|
||||
|
||||
// OnChannelMsg: you just received a chat line in a channel
|
||||
virtual bool OnChannelMsg ( const std::string& channel, const std::string& from,
|
||||
const std::string& text ) { return true; }
|
||||
|
||||
// OnChannelAction: you just received a "/me" line in a channel
|
||||
virtual bool OnChannelAction ( const std::string& channel, const std::string& from,
|
||||
const std::string& text ) { return true; }
|
||||
|
||||
// OnChannelMode: notification of a change of a channel's mode
|
||||
virtual bool OnChannelMode ( const std::string& channel, const std::string& mode )
|
||||
{ return true; }
|
||||
|
||||
// OnUserModeInChannel: notification of a mode change of a user with respect to a channel.
|
||||
// f.ex.: this will be called when someone is oped in a channel.
|
||||
virtual bool OnUserModeInChannel ( const std::string& src, const std::string& channel,
|
||||
const std::string& mode, const std::string& target ) { return true; }
|
||||
|
||||
// OnMode: you will receive this when you change your own mode, at least...
|
||||
virtual bool OnMode ( const std::string& user, const std::string& mode ) { return true; }
|
||||
|
||||
// notification of what users are in a channel ( you may get multiple of these... )
|
||||
virtual bool OnChannelUsers ( const std::string& channel, const std::vector<std::string>& users )
|
||||
{ return true; }
|
||||
|
||||
// OnKick: if the client has been kicked
|
||||
virtual bool OnKick ( void ) { return true; }
|
||||
|
||||
// OnKick: if the client has been kicked
|
||||
virtual bool OnBanned ( const std::string& channel ) { return true; }
|
||||
|
||||
// notification that you have received the entire list of users for a channel
|
||||
virtual bool OnEndChannelUsers ( const std::string& channel ) { return true; }
|
||||
|
||||
// OnPing - default implementation replies to PING with a valid PONG. required on some systems to
|
||||
// log in. Most systems require a response in order to stay connected, used to verify a client hasn't
|
||||
// dropped.
|
||||
virtual bool OnPing ( const std::string& text );
|
||||
|
||||
////////////////////// other functions ////////////////////////////
|
||||
|
||||
// this is for sending data to irc server. it's public in case you need to send some
|
||||
// command not supported by this base class...
|
||||
bool Send ( const std::string& buf );
|
||||
|
||||
// if launch_thread is true, this function will spawn a thread that will process
|
||||
// incoming packets until the socket dies.
|
||||
// otherwise ( launch_thread is false ) this function will do that processing
|
||||
// in *this* thread, and not return until the socket dies.
|
||||
int Run ( bool launch_thread );
|
||||
|
||||
////////////////////// private stuff ////////////////////////////
|
||||
private:
|
||||
bool _Recv ( std::string& buf );
|
||||
|
||||
static int THREADAPI Callback ( IRCClient* irc );
|
||||
|
||||
static bool _debug;
|
||||
std::string _nick;
|
||||
int _timeout;
|
||||
std::string _apop_challenge;
|
||||
|
||||
volatile bool _inRun;
|
||||
|
||||
// disable copy semantics
|
||||
IRCClient ( const IRCClient& );
|
||||
IRCClient& operator = ( const IRCClient& );
|
||||
};
|
||||
|
||||
#endif//IRCCLIENT_H
|
@@ -1,418 +0,0 @@
|
||||
// MD5.CPP - RSA Data Security, Inc., MD5 message-digest algorithm
|
||||
|
||||
/*
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
//#include <assert.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#include "MD5.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
// Constants for MD5Transform routine.
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
|
||||
static void MD5Transform ( UINT4 [4], const uchar [64] );
|
||||
static void Encode ( unsigned char *, UINT4 *, unsigned int );
|
||||
static void Decode ( UINT4 *, const uchar *, unsigned int );
|
||||
|
||||
static unsigned char PADDING[64] =
|
||||
{
|
||||
0x80, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
// F, G, H and I are basic MD5 functions.
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
// ROTATE_LEFT rotates x left n bits.
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
// Rotation is separate from addition to prevent recomputation.
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
// MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||
void MD5Init (
|
||||
MD5_CTX *context ) // context
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
// Load magic initialization constants.
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xefcdab89;
|
||||
context->state[2] = 0x98badcfe;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
|
||||
// MD5 block update operation. Continues an MD5 message-digest
|
||||
// operation, processing another message block, and updating the
|
||||
// context.
|
||||
void MD5Update (
|
||||
MD5_CTX *context, // context
|
||||
const char *input_, // input block
|
||||
unsigned int inputLen ) // length of input block
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
const uchar* input = (const uchar*)input_;
|
||||
|
||||
// Compute number of bytes mod 64
|
||||
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
// Update number of bits
|
||||
if ((context->count[0] += ((UINT4)inputLen << 3))
|
||||
< ((UINT4)inputLen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += ((UINT4)inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
// Transform as many times as possible.
|
||||
if (inputLen >= partLen)
|
||||
{
|
||||
memcpy
|
||||
((POINTER)&context->buffer[index], (POINTER)input, partLen);
|
||||
MD5Transform (context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
MD5Transform (context->state, &input[i]);
|
||||
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
|
||||
// Buffer remaining input
|
||||
memcpy
|
||||
((POINTER)&context->buffer[index], (POINTER)&input[i],
|
||||
inputLen-i);
|
||||
}
|
||||
|
||||
// MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
// the message digest and zeroizing the context.
|
||||
void MD5Final (
|
||||
unsigned char digest[16], // message digest
|
||||
MD5_CTX *context ) // context
|
||||
{
|
||||
uchar bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
// Save number of bits
|
||||
Encode (bits, context->count, 8);
|
||||
|
||||
// Pad out to 56 mod 64.
|
||||
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
MD5Update (context, (const char*)PADDING, padLen);
|
||||
|
||||
// Append length (before padding)
|
||||
MD5Update (context, (const char*)bits, 8);
|
||||
|
||||
// Store state in digest
|
||||
Encode (digest, context->state, 16);
|
||||
|
||||
// Zeroize sensitive information.
|
||||
memset ((POINTER)context, 0, sizeof (*context));
|
||||
}
|
||||
|
||||
// MD5 basic transformation. Transforms state based on block.
|
||||
static void MD5Transform (
|
||||
UINT4 state[4],
|
||||
const uchar block[64] )
|
||||
{
|
||||
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode (x, block, 64);
|
||||
|
||||
// Round 1
|
||||
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); // 1
|
||||
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); // 2
|
||||
FF (c, d, a, b, x[ 2], S13, 0x242070db); // 3
|
||||
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); // 4
|
||||
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); // 5
|
||||
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); // 6
|
||||
FF (c, d, a, b, x[ 6], S13, 0xa8304613); // 7
|
||||
FF (b, c, d, a, x[ 7], S14, 0xfd469501); // 8
|
||||
FF (a, b, c, d, x[ 8], S11, 0x698098d8); // 9
|
||||
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); // 10
|
||||
FF (c, d, a, b, x[10], S13, 0xffff5bb1); // 11
|
||||
FF (b, c, d, a, x[11], S14, 0x895cd7be); // 12
|
||||
FF (a, b, c, d, x[12], S11, 0x6b901122); // 13
|
||||
FF (d, a, b, c, x[13], S12, 0xfd987193); // 14
|
||||
FF (c, d, a, b, x[14], S13, 0xa679438e); // 15
|
||||
FF (b, c, d, a, x[15], S14, 0x49b40821); // 16
|
||||
|
||||
// Round 2
|
||||
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); // 17
|
||||
GG (d, a, b, c, x[ 6], S22, 0xc040b340); // 18
|
||||
GG (c, d, a, b, x[11], S23, 0x265e5a51); // 19
|
||||
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); // 20
|
||||
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); // 21
|
||||
GG (d, a, b, c, x[10], S22, 0x2441453); // 22
|
||||
GG (c, d, a, b, x[15], S23, 0xd8a1e681); // 23
|
||||
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); // 24
|
||||
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); // 25
|
||||
GG (d, a, b, c, x[14], S22, 0xc33707d6); // 26
|
||||
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); // 27
|
||||
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); // 28
|
||||
GG (a, b, c, d, x[13], S21, 0xa9e3e905); // 29
|
||||
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); // 30
|
||||
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); // 31
|
||||
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); // 32
|
||||
|
||||
// Round 3
|
||||
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); // 33
|
||||
HH (d, a, b, c, x[ 8], S32, 0x8771f681); // 34
|
||||
HH (c, d, a, b, x[11], S33, 0x6d9d6122); // 35
|
||||
HH (b, c, d, a, x[14], S34, 0xfde5380c); // 36
|
||||
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); // 37
|
||||
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); // 38
|
||||
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); // 39
|
||||
HH (b, c, d, a, x[10], S34, 0xbebfbc70); // 40
|
||||
HH (a, b, c, d, x[13], S31, 0x289b7ec6); // 41
|
||||
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); // 42
|
||||
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); // 43
|
||||
HH (b, c, d, a, x[ 6], S34, 0x4881d05); // 44
|
||||
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); // 45
|
||||
HH (d, a, b, c, x[12], S32, 0xe6db99e5); // 46
|
||||
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); // 47
|
||||
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); // 48
|
||||
|
||||
// Round 4
|
||||
II (a, b, c, d, x[ 0], S41, 0xf4292244); // 49
|
||||
II (d, a, b, c, x[ 7], S42, 0x432aff97); // 50
|
||||
II (c, d, a, b, x[14], S43, 0xab9423a7); // 51
|
||||
II (b, c, d, a, x[ 5], S44, 0xfc93a039); // 52
|
||||
II (a, b, c, d, x[12], S41, 0x655b59c3); // 53
|
||||
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); // 54
|
||||
II (c, d, a, b, x[10], S43, 0xffeff47d); // 55
|
||||
II (b, c, d, a, x[ 1], S44, 0x85845dd1); // 56
|
||||
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); // 57
|
||||
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); // 58
|
||||
II (c, d, a, b, x[ 6], S43, 0xa3014314); // 59
|
||||
II (b, c, d, a, x[13], S44, 0x4e0811a1); // 60
|
||||
II (a, b, c, d, x[ 4], S41, 0xf7537e82); // 61
|
||||
II (d, a, b, c, x[11], S42, 0xbd3af235); // 62
|
||||
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); // 63
|
||||
II (b, c, d, a, x[ 9], S44, 0xeb86d391); // 64
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
|
||||
// Zeroize sensitive information.
|
||||
memset ((POINTER)x, 0, sizeof (x));
|
||||
}
|
||||
|
||||
// Encodes input (UINT4) into output (unsigned char). Assumes len is
|
||||
// a multiple of 4.
|
||||
static void Encode (
|
||||
unsigned char *output,
|
||||
UINT4 *input,
|
||||
unsigned int len )
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j] = (unsigned char)(input[i] & 0xff);
|
||||
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
// Decodes input (unsigned char) into output (UINT4). Assumes len is
|
||||
// a multiple of 4.
|
||||
static void Decode (
|
||||
UINT4 *output,
|
||||
const uchar *input,
|
||||
unsigned int len )
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
|
||||
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
|
||||
}
|
||||
|
||||
void digest2ascii ( char *ascii, const unsigned char *digest )
|
||||
{
|
||||
int i;
|
||||
static char* table = "0123456789abcdef";
|
||||
for ( i = 0; i < 16; i++ )
|
||||
{
|
||||
*ascii++ = table[(*digest)>>4];
|
||||
*ascii++ = table[(*digest++)%16];
|
||||
}
|
||||
*ascii++ = 0;
|
||||
}
|
||||
|
||||
void ascii2digest ( unsigned char *digest, const char *ascii )
|
||||
{
|
||||
int i;
|
||||
#define CONV(c) (unsigned char)( (toupper(c)>='A') ? (toupper(c)+10-'A') : ((c)-'0') )
|
||||
#define MAKECHAR(a,b) ((CONV(a)%16)<<4)|(CONV(b)%16)
|
||||
for ( i = 0; i < 16; i++ )
|
||||
{
|
||||
*digest++ = MAKECHAR(ascii[0],ascii[1]);
|
||||
ascii += 2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
MD5::MD5()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
void MD5::Init()
|
||||
{
|
||||
MD5Init(&_ctx);
|
||||
}
|
||||
|
||||
void MD5::Update ( const string& s )
|
||||
{
|
||||
MD5Update ( &_ctx, s.c_str(), s.size() );
|
||||
}
|
||||
|
||||
string MD5::Final ( char* digest )
|
||||
{
|
||||
vector<uchar> v;
|
||||
v.resize(16);
|
||||
MD5Final ( &v[0], &_ctx );
|
||||
if ( digest )
|
||||
memmove ( digest, &v[0], 16 );
|
||||
string s;
|
||||
static char* tohex = "0123456789abcdef";
|
||||
for ( int i = 0; i < 16; i++ )
|
||||
{
|
||||
uchar c = v[i];
|
||||
s += tohex[ (c>>4) & 0xF ];
|
||||
s += tohex[ c & 0xF ];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
string MD5Hex ( const string& s )
|
||||
{
|
||||
MD5 md5;
|
||||
md5.Update ( s );
|
||||
return md5.Final();
|
||||
}
|
||||
|
||||
string MD5Bin ( const string& s )
|
||||
{
|
||||
MD5 md5;
|
||||
md5.Update ( s );
|
||||
char digest[16];
|
||||
md5.Final ( digest );
|
||||
return string ( digest, 16 );
|
||||
}
|
||||
|
||||
string HMAC_MD5 ( const string& key, const string& text, char* out_bin )
|
||||
{
|
||||
MD5 md5;
|
||||
char k_ipad[65]; // inner padding - key XORd with ipad
|
||||
char k_opad[65]; // outer padding - key XORd with opad
|
||||
string tmp;
|
||||
char digest[16];
|
||||
int i;
|
||||
// if key is longer than 64 bytes reset it to key=MD5(key)
|
||||
if ( key.length() > 64 )
|
||||
{
|
||||
md5.Init();
|
||||
md5.Update ( key );
|
||||
md5.Final ( digest );
|
||||
tmp = string ( digest, 16 );
|
||||
}
|
||||
else
|
||||
tmp = key;
|
||||
|
||||
// start out by storing key in pads
|
||||
memset ( k_ipad, 0, sizeof(k_ipad) );
|
||||
memset ( k_opad, 0, sizeof(k_opad) );
|
||||
memcpy ( k_ipad, tmp.c_str(), tmp.length() );
|
||||
memcpy ( k_opad, tmp.c_str(), tmp.length() );
|
||||
|
||||
// XOR key with ipad and opad values
|
||||
for ( i=0; i<64; i++ )
|
||||
{
|
||||
k_ipad[i] ^= 0x36;
|
||||
k_opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
// "inner" MD5
|
||||
md5.Init();
|
||||
md5.Update(k_ipad);
|
||||
md5.Update(text);
|
||||
md5.Final ( digest );
|
||||
|
||||
// "outer" MD5
|
||||
md5.Init();
|
||||
md5.Update(k_opad);
|
||||
md5.Update(string(digest,16));
|
||||
return md5.Final(out_bin);
|
||||
}
|
||||
#endif//__cplusplus
|
@@ -1,95 +0,0 @@
|
||||
// MD5.H - header file for MD5.CPP
|
||||
|
||||
/*
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
#ifndef __MD5_H
|
||||
#define __MD5_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif//__cplusplus
|
||||
|
||||
#ifndef uchar
|
||||
#define uchar unsigned char
|
||||
#endif//uchar
|
||||
|
||||
#ifndef ushort
|
||||
#define ushort unsigned short
|
||||
#endif//ushort
|
||||
|
||||
#ifndef ulong
|
||||
#define ulong unsigned long
|
||||
#endif//ulong
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
|
||||
typedef uchar *POINTER; // POINTER defines a generic pointer type
|
||||
typedef ushort UINT2; // UINT2 defines a two byte word
|
||||
typedef ulong UINT4; // UINT4 defines a four byte word
|
||||
|
||||
// MD5 context.
|
||||
typedef struct
|
||||
{
|
||||
UINT4 state[4]; // state (ABCD)
|
||||
UINT4 count[2]; // number of bits, modulo 2^64 (lsb first)
|
||||
unsigned char buffer[64]; // input buffer
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5Init ( MD5_CTX * );
|
||||
void MD5Update ( MD5_CTX *, const char *, unsigned int );
|
||||
void MD5Final ( uchar [16], MD5_CTX * );
|
||||
|
||||
void digest2ascii ( char *ascii, const uchar *digest );
|
||||
void ascii2digest ( uchar *digest, const char *ascii );
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
} // extern "C"
|
||||
|
||||
class MD5
|
||||
{
|
||||
public:
|
||||
MD5();
|
||||
void Init();
|
||||
void Update ( const std::string& s );
|
||||
std::string Final ( char* digest = 0 );
|
||||
|
||||
private:
|
||||
MD5_CTX _ctx;
|
||||
};
|
||||
|
||||
std::string MD5Hex ( const std::string& s );
|
||||
|
||||
std::string MD5Bin ( const std::string& s );
|
||||
|
||||
std::string HMAC_MD5 (
|
||||
const std::string& key,
|
||||
const std::string& text,
|
||||
char* out_bin = NULL );
|
||||
|
||||
#endif//__cplusplus
|
||||
|
||||
#endif//__MD5_H
|
@@ -1,315 +0,0 @@
|
||||
/*
|
||||
** Author: Samuel R. Blackburn
|
||||
** Internet: wfc@pobox.com
|
||||
**
|
||||
** You can use it any way you like as long as you don't try to sell it.
|
||||
**
|
||||
** Any attempt to sell WFC in source code form must have the permission
|
||||
** of the original author. You can produce commercial executables with
|
||||
** WFC but you can't sell WFC.
|
||||
**
|
||||
** Copyright, 2000, Samuel R. Blackburn
|
||||
**
|
||||
** NOTE: I modified the info block below so it hopefully wouldn't conflict
|
||||
** with the original file. Royce Mitchell III
|
||||
*/
|
||||
|
||||
#ifndef QUEUET_CLASS_HEADER
|
||||
#define QUEUET_CLASS_HEADER
|
||||
|
||||
#include "ReliMT.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <sys/types.h> // off_t
|
||||
#define HEAPCREATE(size) m_Heap = ::HeapCreate ( HEAP_NO_SERIALIZE, size, 0 )
|
||||
#define HEAPALLOC(size) ::HeapAlloc ( m_Heap, HEAP_NO_SERIALIZE, size )
|
||||
#define HEAPREALLOC(p,size) ::HeapReAlloc( m_Heap, HEAP_NO_SERIALIZE, p, size )
|
||||
#define HEAPFREE(p) ::HeapFree ( m_Heap, HEAP_NO_SERIALIZE, p )
|
||||
#define HEAPDESTROY() ::HeapDestroy ( m_Heap ); m_Heap = 0;
|
||||
#else
|
||||
#define HEAPCREATE(size)
|
||||
#define HEAPALLOC(size) malloc(size)
|
||||
#define HEAPREALLOC(p,size) realloc(p,size);
|
||||
#define HEAPFREE(p) free(p)
|
||||
#define HEAPDESTROY()
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class CQueueT : public Uncopyable
|
||||
{
|
||||
protected:
|
||||
|
||||
// What we want to protect
|
||||
|
||||
Mutex m_AddMutex;
|
||||
Mutex m_GetMutex;
|
||||
|
||||
T* m_Items;
|
||||
|
||||
off_t m_AddIndex;
|
||||
off_t m_GetIndex;
|
||||
size_t m_Size;
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE m_Heap;
|
||||
#endif//WIN32
|
||||
inline void m_GrowBy ( size_t number_of_new_items );
|
||||
|
||||
public:
|
||||
|
||||
inline CQueueT ( size_t initial_size = 1024 );
|
||||
inline ~CQueueT();
|
||||
|
||||
inline bool Add( const T& new_item );
|
||||
inline void Empty() { m_AddIndex = 0; m_GetIndex = 0; };
|
||||
inline bool Get( T& item );
|
||||
inline size_t GetLength() const;
|
||||
inline size_t GetMaximumLength() const { return( m_Size ); };
|
||||
inline bool AddArray ( const T* new_items, int item_count );
|
||||
inline int GetArray ( T* items, const int maxget, const T& tEnd );
|
||||
inline bool Contains ( const T& t );
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline CQueueT<T>::CQueueT ( size_t initial_size )
|
||||
{
|
||||
m_AddIndex = 0;
|
||||
m_GetIndex = 0;
|
||||
m_Items = NULL;
|
||||
|
||||
if ( initial_size == 0 )
|
||||
initial_size = 1;
|
||||
|
||||
/*
|
||||
** 1999-11-05
|
||||
** We create our own heap because all of the pointers used are allocated
|
||||
** and freed be us. We don't have to worry about a non-serialized thread
|
||||
** accessing something we allocated. Because of this, we can perform our
|
||||
** memory allocations in a heap dedicated to queueing. This means when we
|
||||
** have to allocate more memory, we don't have to wait for all other threads
|
||||
** to pause while we allocate from the shared heap (like the C Runtime heap)
|
||||
*/
|
||||
|
||||
HEAPCREATE( ( ( ( 2 * initial_size * sizeof(T) ) < 65536 ) ? 65536 : (2 * initial_size * sizeof(T) ) ) );
|
||||
|
||||
m_Items = (T*)HEAPALLOC ( initial_size * sizeof(T) );
|
||||
|
||||
m_Size = ( m_Items == NULL ) ? 0 : initial_size;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline CQueueT<T>::~CQueueT()
|
||||
{
|
||||
m_AddIndex = 0;
|
||||
m_GetIndex = 0;
|
||||
m_Size = 0;
|
||||
|
||||
if ( m_Items != NULL )
|
||||
{
|
||||
HEAPFREE(m_Items);
|
||||
m_Items = NULL;
|
||||
}
|
||||
|
||||
HEAPDESTROY();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool CQueueT<T>::Add ( const T& item )
|
||||
{
|
||||
// Block other threads from entering Add();
|
||||
Mutex::Lock addlock ( m_AddMutex );
|
||||
|
||||
// Add the item
|
||||
|
||||
m_Items[ m_AddIndex ] = item;
|
||||
|
||||
// 1999-12-08
|
||||
// Many many thanks go to Lou Franco (lfranco@spheresoft.com)
|
||||
// for finding an bug here. It rare but recreatable situations,
|
||||
// m_AddIndex could be in an invalid state.
|
||||
|
||||
// Make sure m_AddIndex is never invalid
|
||||
|
||||
off_t new_add_index = ( ( m_AddIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_AddIndex + 1;
|
||||
|
||||
if ( new_add_index == m_GetIndex )
|
||||
{
|
||||
// The queue is full. We need to grow.
|
||||
// Stop anyone from getting from the queue
|
||||
Mutex::Lock getlock ( m_GetMutex );
|
||||
|
||||
m_AddIndex = new_add_index;
|
||||
|
||||
// One last double-check.
|
||||
|
||||
if ( m_AddIndex == m_GetIndex )
|
||||
{
|
||||
m_GrowBy ( m_Size );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AddIndex = new_add_index;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool CQueueT<T>::Get( T& item )
|
||||
{
|
||||
// Prevent other threads from entering Get()
|
||||
Mutex::Lock getlock ( m_GetMutex );
|
||||
|
||||
if ( m_GetIndex == m_AddIndex )
|
||||
{
|
||||
// Let's check to see if our queue has grown too big
|
||||
// If it has, then shrink it
|
||||
|
||||
if ( m_Size > 1024 )
|
||||
{
|
||||
// Yup, we're too big for our britches
|
||||
Mutex::TryLock addlock ( m_AddMutex );
|
||||
if ( addlock )
|
||||
{
|
||||
// Now, no one can add to the queue
|
||||
|
||||
if ( m_GetIndex == m_AddIndex ) // is queue empty?
|
||||
{
|
||||
// See if we can just shrink it...
|
||||
T* return_value = (T*)HEAPREALLOC(m_Items,1024 * sizeof(T));
|
||||
|
||||
if ( return_value != NULL )
|
||||
{
|
||||
m_Items = (T*) return_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Looks like we'll have to do it the hard way
|
||||
HEAPFREE ( m_Items );
|
||||
m_Items = (T*) HEAPALLOC ( 1024 * sizeof(T) );
|
||||
}
|
||||
|
||||
m_Size = ( m_Items == NULL ) ? 0 : 1024;
|
||||
m_AddIndex = 0;
|
||||
m_GetIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_GetIndex != m_AddIndex, this means that someone added
|
||||
// to the queue between the time we checked m_Size for being
|
||||
// too big and the time we entered the add critical section.
|
||||
// If this happened then we are too busy to shrink
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
item = m_Items[ m_GetIndex ];
|
||||
|
||||
// Make sure m_GetIndex is never invalid
|
||||
|
||||
m_GetIndex = ( ( m_GetIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_GetIndex + 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int CQueueT<T>::GetArray ( T* items, const int maxget, const T& tEnd )
|
||||
{
|
||||
// TODO - oooh baby does this need to be optimized
|
||||
// Prevent other threads from entering Get()
|
||||
Mutex::Lock getlock ( m_GetMutex ); //::EnterCriticalSection( &m_GetCriticalSection );
|
||||
|
||||
int iResult = 0;
|
||||
for ( int i = 0; i < maxget; i++ )
|
||||
{
|
||||
if ( !Get(items[i]) )
|
||||
break;
|
||||
iResult++;
|
||||
if ( items[i] == tEnd )
|
||||
break;
|
||||
}
|
||||
// Let other threads call Get() now
|
||||
//::LeaveCriticalSection( &m_GetCriticalSection );
|
||||
return iResult;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline size_t CQueueT<T>::GetLength() const
|
||||
{
|
||||
// This is a very expensive process!
|
||||
// No one can call Add() or Get() while we're computing this
|
||||
|
||||
size_t number_of_items_in_the_queue = 0;
|
||||
|
||||
Mutex::Lock addlock ( m_AddMutex );
|
||||
Mutex::Lock getlock ( m_GetMutex );
|
||||
|
||||
number_of_items_in_the_queue = ( m_AddIndex >= m_GetIndex ) ?
|
||||
( m_AddIndex - m_GetIndex ) :
|
||||
( ( m_AddIndex + m_Size ) - m_GetIndex );
|
||||
|
||||
return number_of_items_in_the_queue;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CQueueT<T>::m_GrowBy ( size_t number_of_new_items )
|
||||
{
|
||||
// Prevent other threads from calling Get().
|
||||
// We don't need to enter the AddCriticalSection because
|
||||
// m_GrowBy() is only called from Add();
|
||||
|
||||
T* new_array = NULL;
|
||||
T* pointer_to_free = NULL;
|
||||
|
||||
size_t new_size = m_Size + number_of_new_items;
|
||||
|
||||
{ // Prevent other threads from getting
|
||||
Mutex::Lock getlock ( m_GetMutex );
|
||||
|
||||
// 2000-05-16
|
||||
// Thanks go to Royce Mitchell III (royce3@aim-controls.com) for finding
|
||||
// a HUGE bug here. I was using HeapReAlloc as a short cut but my logic
|
||||
// was flawed. In certain circumstances, queue items were being dropped.
|
||||
|
||||
new_array = (T*)HEAPALLOC ( new_size * sizeof(T) );
|
||||
|
||||
// Now copy all of the old items from the old queue to the new one.
|
||||
|
||||
// Get the entries from the get-index to the end of the array
|
||||
memcpy ( new_array, &m_Items[m_GetIndex], ( m_Size - m_GetIndex ) * sizeof(T) );
|
||||
|
||||
// Get the entries from the beginning of the array to the add-index
|
||||
memcpy ( &new_array[m_Size-m_GetIndex], m_Items, m_AddIndex * sizeof(T) );
|
||||
|
||||
m_AddIndex = (off_t)m_Size;
|
||||
m_GetIndex = 0;
|
||||
m_Size = new_size;
|
||||
pointer_to_free = m_Items;
|
||||
m_Items = new_array;
|
||||
} // Mutex::Lock
|
||||
HEAPFREE ( pointer_to_free );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool CQueueT<T>::Contains ( const T& t )
|
||||
{
|
||||
Mutex::Lock addlock ( m_AddMutex );
|
||||
Mutex::Lock getlock ( m_GetMutex );
|
||||
|
||||
for ( int i = m_GetIndex; i != m_AddIndex; i++ )
|
||||
{
|
||||
if ( i == m_Size )
|
||||
i = 0;
|
||||
if ( m_Items[i] == t )
|
||||
return true;
|
||||
}
|
||||
return m_Items[m_AddIndex] == t;
|
||||
}
|
||||
|
||||
typedef CQueueT<char> CCharQueue;
|
||||
|
||||
#endif // QUEUE_CLASS_HEADER
|
@@ -1,143 +0,0 @@
|
||||
// Reli.h
|
||||
// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com
|
||||
// The rest is (C) 2002-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#ifndef __RELI_H
|
||||
#define __RELI_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Assert
|
||||
|
||||
#undef Assert
|
||||
#ifdef NDEBUG
|
||||
#define Assert(exp) ((void)0)
|
||||
#else
|
||||
void _wassert (char* szExpr, char* szFile, int line);
|
||||
#define Assert(exp) (void)( (exp) || (_wassert(#exp, __FILE__, __LINE__), 0) )
|
||||
#endif /* NDEBUG */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Swap
|
||||
|
||||
template <class T>
|
||||
void Swap(T a,T b)
|
||||
{
|
||||
T t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Uncopyable - base class disabling copy ctors
|
||||
class Uncopyable
|
||||
{
|
||||
public:
|
||||
Uncopyable(){} // need a default ctor
|
||||
private:
|
||||
Uncopyable ( const Uncopyable& );
|
||||
const Uncopyable& operator = ( const Uncopyable& );
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SPtr - Smart Pointer's must be passed by reference or const reference
|
||||
|
||||
template <class T>
|
||||
class SPtr : public Uncopyable
|
||||
{
|
||||
public:
|
||||
virtual ~SPtr () { Destroy(); }
|
||||
T * operator->() { return _p; }
|
||||
T const * operator->() const { return _p; }
|
||||
operator T&() { Assert(_p); return *_p; }
|
||||
operator const T&() const { Assert(_p); return *_p; }
|
||||
void Acquire ( SPtr<T>& t ) { Destroy(); Swap(_p,t._p); }
|
||||
void Destroy() { if ( _p ) { delete _p; _p = 0; } }
|
||||
protected:
|
||||
SPtr (): _p (0) {}
|
||||
explicit SPtr (T* p): _p (p) {}
|
||||
T * _p;
|
||||
private:
|
||||
operator T* () { return _p; }
|
||||
};
|
||||
|
||||
#define DECLARE_SPTR(cls,init,init2) \
|
||||
class S##cls : public SPtr<cls> \
|
||||
{ \
|
||||
public: \
|
||||
S##cls ( cls* p ) : SPtr<cls>(p) {} \
|
||||
explicit S##cls init : SPtr<cls> (new cls init2) {} \
|
||||
};
|
||||
/* Example Usage of DECLARE_SPTR:
|
||||
class MyClass
|
||||
{
|
||||
public: // can be protected
|
||||
MyClass ( int i )
|
||||
{
|
||||
...
|
||||
}
|
||||
...
|
||||
}; DECLARE_SPTR(MyClass,(int i),(i))
|
||||
SMyClass ptr(i);
|
||||
*/
|
||||
#define DECLARE_SPTRV(cls) typedef SPtr<cls> S##cls;
|
||||
/* Example Usage of DECLARE_SPTRV:
|
||||
class MyAbstractClass
|
||||
{
|
||||
public: // can be protected
|
||||
MyAbstractClass ( int i )
|
||||
{
|
||||
...
|
||||
}
|
||||
void MyPureVirtFunc() = 0;
|
||||
...
|
||||
}; DECLARE_SPTRV(MyAbstractClass)
|
||||
SMyAbstractClass ptr ( new MySubClass(i) );
|
||||
*/
|
||||
|
||||
#define DECLARE_PTR(cls,init,init2) \
|
||||
class Ptr : public SPtr<cls> \
|
||||
{ \
|
||||
Ptr(cls* p) : SPtr<cls> ( p ) \
|
||||
{ \
|
||||
} \
|
||||
Ptr init : SPtr<cls> ( new cls init2 ) {} \
|
||||
};
|
||||
/* Example Usage of DECLARE_PTR:
|
||||
class MyClass
|
||||
{
|
||||
DECLARE_PTR(MyClass,(int i),(i))
|
||||
public: // can be protected
|
||||
MyClass ( int i )
|
||||
{
|
||||
...
|
||||
}
|
||||
void MyPureVirtFunc() = 0;
|
||||
...
|
||||
};
|
||||
MyClass::Ptr ptr ( i );
|
||||
*/
|
||||
|
||||
#define DECLARE_PTRV(cls) \
|
||||
class Ptr : public SPtr<cls> \
|
||||
{ \
|
||||
Ptr(cls* p) : SPtr<cls> ( p ) \
|
||||
{ \
|
||||
} \
|
||||
};
|
||||
/* Example Usage of DECLARE_PTRV:
|
||||
class MyAbstractClass
|
||||
{
|
||||
DECLARE_PTRV(MyAbstractClass)
|
||||
public: // can be protected
|
||||
MyAbstractClass ( int i )
|
||||
{
|
||||
...
|
||||
}
|
||||
void MyPureVirtFunc() = 0;
|
||||
...
|
||||
};
|
||||
MyAbstractClass::Ptr ptr ( new MySubClass(i) );
|
||||
*/
|
||||
|
||||
#endif//__RELI_H
|
@@ -1,331 +0,0 @@
|
||||
// ReliMT.cpp
|
||||
// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com
|
||||
// The rest is (C) 2002-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# define snprintf _snprintf
|
||||
#elif defined(UNIX)
|
||||
# include <errno.h>
|
||||
# include <sys/sem.h>
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif//WIN32|UNIX
|
||||
#include "verify.h"
|
||||
#include "ReliMT.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Assert
|
||||
|
||||
void _wassert ( char* szExpr, char* szFile, int line )
|
||||
{
|
||||
fprintf ( stderr, "Assertion Failure: \"%s\" in file %s, line %d", szExpr, szFile, line );
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Thread
|
||||
|
||||
Thread::Thread ( long (THREADAPI * pFun) (void* arg), void* pArg )
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( _handle = CreateThread (
|
||||
0, // Security attributes
|
||||
0, // Stack size
|
||||
(DWORD (WINAPI*)(void*))pFun,
|
||||
pArg,
|
||||
0, // don't create suspended.
|
||||
&_tid ));
|
||||
#elif defined(UNIX)
|
||||
// set up the thread attribute: right now, we do nothing with it.
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
|
||||
// this will make the threads created by this process really concurrent
|
||||
verify ( !pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) );
|
||||
|
||||
// create the new OS thread object
|
||||
verify ( !pthread_create ( &_threadId, &attr, (void* (*) (void*))pFun, pArg ) );
|
||||
|
||||
verify ( !pthread_attr_destroy(&attr) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif//WIN32|UNIX
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( CloseHandle ( _handle ) );
|
||||
#elif defined(UNIX)
|
||||
verify ( !pthread_cancel ( _threadId ) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif//WIN32|UNIX
|
||||
}
|
||||
|
||||
/*void Thread::Resume()
|
||||
{
|
||||
#ifdef WIN32
|
||||
ResumeThread (_handle);
|
||||
#elif defined(UNIX)
|
||||
# error how to resume thread in unix?
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif//WIN32|UNIX
|
||||
}*/
|
||||
|
||||
void Thread::WaitForDeath()
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD dw = WaitForSingleObject ( _handle, 2000 );
|
||||
ASSERT ( dw != WAIT_FAILED );
|
||||
#elif defined(UNIX)
|
||||
verify ( !pthread_join ( _threadId, (void**)NULL ) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif//WIN32|UNIX
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ActiveObject
|
||||
|
||||
// The constructor of the derived class
|
||||
// should call
|
||||
// _thread.Resume();
|
||||
// at the end of construction
|
||||
|
||||
ActiveObject::ActiveObject() : _isDying (0), _thread (0)
|
||||
{
|
||||
}
|
||||
|
||||
ActiveObject::~ActiveObject()
|
||||
{
|
||||
ASSERT ( !_thread ); // call Kill() from subclass's dtor
|
||||
// Kill() - // You can't call a virtual function from a dtor, EVEN INDIRECTLY
|
||||
// so, you must call Kill() in the subclass's dtor
|
||||
}
|
||||
|
||||
// FlushThread must reset all the events on which the thread might be waiting.
|
||||
void ActiveObject::Kill()
|
||||
{
|
||||
if ( _thread )
|
||||
{
|
||||
_isDying++;
|
||||
FlushThread();
|
||||
// Let's make sure it's gone
|
||||
_thread->WaitForDeath();
|
||||
delete _thread;
|
||||
_thread = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveObject::Start()
|
||||
{
|
||||
ASSERT ( !_thread );
|
||||
_thread = new Thread ( ThreadEntry, this );
|
||||
}
|
||||
|
||||
long THREADAPI ActiveObject::ThreadEntry ( void* pArg )
|
||||
{
|
||||
ActiveObject * pActive = (ActiveObject*)pArg;
|
||||
pActive->InitThread();
|
||||
pActive->Run();
|
||||
pActive->Kill();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Mutex
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( _h = CreateMutex ( NULL, FALSE, NULL ) );
|
||||
#elif defined(UNIX)
|
||||
pthread_mutexattr_t attrib;
|
||||
verify ( !pthread_mutexattr_init( &attrib ) );
|
||||
// allow recursive locks
|
||||
verify ( !pthread_mutexattr_settype( &attrib, PTHREAD_MUTEX_RECURSIVE ) );
|
||||
verify ( !pthread_mutex_init ( &_mutex, &attrib ) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( CloseHandle ( _h ) );
|
||||
#elif defined(UNIX)
|
||||
verify ( !pthread_mutex_destroy(&_mutex) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mutex::Acquire()
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD dw = WaitForSingleObject ( _h, INFINITE );
|
||||
ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED );
|
||||
#elif defined(UNIX)
|
||||
verify ( !pthread_mutex_lock(&_mutex) );
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Mutex::TryAcquire()
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD dw = WaitForSingleObject ( _h, 1 );
|
||||
ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_TIMEOUT || dw == WAIT_ABANDONED );
|
||||
return (dw != WAIT_TIMEOUT);
|
||||
#elif defined(UNIX)
|
||||
int err = pthread_mutex_trylock(&_mutex);
|
||||
ASSERT ( err == EBUSY || err == 0 );
|
||||
return (err == 0);
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mutex::Release()
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( ReleaseMutex ( _h ) );
|
||||
#elif defined(UNIX)
|
||||
verify ( !pthread_mutex_unlock(&_mutex) );
|
||||
// we could allow EPERM return value too, but we are forcing user into RIIA
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
Mutex::Lock::Lock ( Mutex& m ) : _m(m)
|
||||
{
|
||||
_m.Acquire();
|
||||
}
|
||||
|
||||
Mutex::Lock::~Lock()
|
||||
{
|
||||
_m.Release();
|
||||
}
|
||||
|
||||
Mutex::TryLock::TryLock ( Mutex& m ) : _m(m)
|
||||
{
|
||||
_bLocked = _m.TryAcquire();
|
||||
}
|
||||
|
||||
Mutex::TryLock::~TryLock()
|
||||
{
|
||||
if ( _bLocked )
|
||||
_m.Release();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Event
|
||||
|
||||
Event::Event()
|
||||
{
|
||||
#ifdef WIN32
|
||||
// start in non-signaled state (red light)
|
||||
// auto reset after every Wait
|
||||
verify ( _handle = CreateEvent ( 0, FALSE, FALSE, 0 ) );
|
||||
#elif defined(UNIX)
|
||||
//verify ( !pthread_cond_init ( &_cond, NULL /* default attributes */) );
|
||||
sem_init();
|
||||
//verify(sem_init());
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
Event::~Event()
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( CloseHandle ( _handle ) );
|
||||
#elif defined(UNIX)
|
||||
//verify ( !pthread_cond_destroy ( &_cond ) );
|
||||
sem_destroy();
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
void Event::Release() // put into signaled state
|
||||
{
|
||||
#ifdef WIN32
|
||||
verify ( SetEvent ( _handle ) );
|
||||
#elif defined(UNIX)
|
||||
//verify ( !pthread_cond_signal ( &_cond ) );
|
||||
verify(!sem_V());
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
void Event::Wait()
|
||||
{
|
||||
#ifdef WIN32
|
||||
// Wait until event is in signaled (green) state
|
||||
DWORD dw = WaitForSingleObject ( _handle, INFINITE );
|
||||
ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED );
|
||||
#elif defined(UNIX)
|
||||
// According to docs: The pthread_cond_wait() and pthread_cond_timedwait()
|
||||
// functions are used to block on a condition variable. They are called
|
||||
// with mutex locked by the calling thread or undefined behaviour will
|
||||
// result.
|
||||
//Mutex::Lock lock ( _mutex );
|
||||
//verify ( !pthread_cond_wait ( &_cond, _mutex ) );
|
||||
verify(!sem_P());
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef UNIX
|
||||
void Event::sem_init()
|
||||
{
|
||||
sem_id = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT);
|
||||
ASSERT(sem_id != -1);
|
||||
}
|
||||
|
||||
int Event::sem_P()
|
||||
{
|
||||
struct sembuf sb;
|
||||
sb.sem_num = 0;
|
||||
sb.sem_op = -1;
|
||||
sb.sem_flg = 0;
|
||||
return semop(sem_id, &sb, 1);
|
||||
}
|
||||
|
||||
int Event::sem_V()
|
||||
{
|
||||
struct sembuf sb;
|
||||
sb.sem_num = 0;
|
||||
sb.sem_op = 1;
|
||||
sb.sem_flg = 0;
|
||||
return semop(sem_id, &sb, 1);
|
||||
}
|
||||
|
||||
void Event::sem_destroy()
|
||||
{
|
||||
#ifdef MACOSX
|
||||
semun mactmp;
|
||||
mactmp.val = 0;
|
||||
semctl(sem_id, 0, IPC_RMID, mactmp);
|
||||
#else
|
||||
semctl(sem_id, 0, IPC_RMID, 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,229 +0,0 @@
|
||||
// ReliMT.h
|
||||
// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com
|
||||
// The rest is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
|
||||
#ifndef __RELIMT_H
|
||||
#define __RELIMT_H
|
||||
|
||||
#include "Reli.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef _WINDOWS_
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# define THREADAPI WINAPI
|
||||
#elif defined(UNIX)
|
||||
# include <pthread.h>
|
||||
# include <stdlib.h>
|
||||
# include "string.h"
|
||||
# include <sys/types.h> //Semaphore
|
||||
# include <sys/ipc.h> //Semaphore
|
||||
# include <sys/sem.h> //Semaphore
|
||||
# define THREADAPI
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Thread
|
||||
|
||||
class Thread : public Uncopyable
|
||||
{
|
||||
public:
|
||||
Thread ( long (THREADAPI * pFun) (void* arg), void* pArg );
|
||||
~Thread();
|
||||
//void Resume();
|
||||
void WaitForDeath();
|
||||
|
||||
// platform-specific stuff:
|
||||
private:
|
||||
#ifdef WIN32
|
||||
HANDLE _handle;
|
||||
DWORD _tid; // thread id
|
||||
#elif defined(UNIX)
|
||||
pthread_t _threadId; // id of the thread
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
//DECLARE_PTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg));
|
||||
}; //DECLARE_SPTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ActiveObject
|
||||
|
||||
class ActiveObject : public Uncopyable
|
||||
{
|
||||
public:
|
||||
ActiveObject();
|
||||
virtual ~ActiveObject();
|
||||
void Kill();
|
||||
void Start();
|
||||
|
||||
protected:
|
||||
virtual void InitThread() = 0;
|
||||
virtual void Run() = 0;
|
||||
virtual void FlushThread() = 0;
|
||||
|
||||
int _isDying;
|
||||
|
||||
static long THREADAPI ThreadEntry ( void *pArg );
|
||||
Thread *_thread;
|
||||
|
||||
//DECLARE_PTRV(ActiveObject);
|
||||
}; //DECLARE_SPTRV(ActiveObject);
|
||||
|
||||
// Last thing in the constructor of a class derived from
|
||||
// ActiveObject you must call
|
||||
// Start();
|
||||
// Inside the loop the Run method you must keep checking _isDying
|
||||
// if (_isDying)
|
||||
// return;
|
||||
// FlushThread must reset all the events on which the thread might be waiting.
|
||||
// Example:
|
||||
#if 0
|
||||
// MyAsyncOutputter - class that outputs strings to a file asynchronously
|
||||
class MyAsyncOutputter : public ActiveObject
|
||||
{
|
||||
public:
|
||||
MyAsyncOutputter ( const string& filename ) : _filename(filename), _currentBuf(0)
|
||||
{
|
||||
Start(); // start thread
|
||||
}
|
||||
void InitThread()
|
||||
{
|
||||
_f.open ( _filename, "wb" );
|
||||
}
|
||||
void Output ( const string& s )
|
||||
{
|
||||
{
|
||||
// acquire lock long enough to add the string to the active buffer
|
||||
Mutex::Lock lock ( _mutex );
|
||||
_buf[_currentBuf].push_back ( s );
|
||||
}
|
||||
_event.Release(); // don't need the lock fire the event
|
||||
}
|
||||
void Run()
|
||||
{
|
||||
while ( !_isDying )
|
||||
{
|
||||
// wait for signal from Output() or FlushThread()
|
||||
_event.Wait();
|
||||
{
|
||||
// acquire lock long enough to switch active buffers
|
||||
Mutex::Lock lock ( _mutex );
|
||||
_currentBuf = 1-_currentBuf;
|
||||
ASSERT ( !_buf[_currentBuf].size() );
|
||||
}
|
||||
// get a reference to the old buffer
|
||||
vector<string>& buf = _buf[1-_currentBuf];
|
||||
// write each string out to file and then empty the buffer
|
||||
for ( int i = 0; i < buf.size(); i++ )
|
||||
_f.write ( buf[i].c_str(), buf[i].size() );
|
||||
buf.resize(0);
|
||||
}
|
||||
}
|
||||
void FlushThread()
|
||||
{
|
||||
// _isDying is already set: signal thread so it can see that too
|
||||
_event.Release();
|
||||
}
|
||||
private:
|
||||
string _filename;
|
||||
File _f;
|
||||
int _currentBuf;
|
||||
vector<string> _buf[2];
|
||||
Event _event;
|
||||
Mutex _mutex;
|
||||
};
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Mutex
|
||||
|
||||
class Mutex : public Uncopyable
|
||||
{
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
private:
|
||||
void Acquire();
|
||||
bool TryAcquire();
|
||||
void Release();
|
||||
public:
|
||||
// sub-class used to lock the Mutex
|
||||
class Lock : public Uncopyable
|
||||
{
|
||||
public:
|
||||
Lock ( Mutex& m );
|
||||
~Lock();
|
||||
|
||||
private:
|
||||
// private data
|
||||
Mutex& _m;
|
||||
};
|
||||
friend class Mutex::Lock;
|
||||
|
||||
|
||||
// sub-class used to attempt to lock the mutex. Use operator bool()
|
||||
// to test if the lock was successful
|
||||
class TryLock : public Uncopyable
|
||||
{
|
||||
public:
|
||||
TryLock ( Mutex& m );
|
||||
~TryLock();
|
||||
operator bool () { return _bLocked; }
|
||||
|
||||
private:
|
||||
// private data
|
||||
bool _bLocked;
|
||||
Mutex& _m;
|
||||
};
|
||||
friend class Mutex::TryLock;
|
||||
|
||||
private:
|
||||
// platform-specific stuff:
|
||||
#ifdef WIN32
|
||||
HANDLE _h;
|
||||
#elif defined(UNIX)
|
||||
pthread_mutex_t _mutex;
|
||||
public: operator pthread_mutex_t* () { return &_mutex; }
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Event
|
||||
|
||||
class Event : public Uncopyable
|
||||
{
|
||||
public:
|
||||
Event();
|
||||
~Event();
|
||||
void Release(); // put into signaled state
|
||||
void Wait();
|
||||
|
||||
private:
|
||||
#ifdef WIN32
|
||||
HANDLE _handle;
|
||||
#elif defined(UNIX)
|
||||
//Sem util functions
|
||||
void sem_init();
|
||||
int sem_P();
|
||||
int sem_V();
|
||||
void sem_destroy();
|
||||
|
||||
int sem_id;
|
||||
//pthread_cond_t _cond;
|
||||
//Mutex _mutex;
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
//DECLARE_PTR(Event,(),());
|
||||
}; //DECLARE_SPTR(Event,(),());
|
||||
|
||||
#endif//__RELIWIN32_H
|
@@ -1,504 +0,0 @@
|
||||
// SockUtils.cpp - Some basic socket utility functions.
|
||||
// (C) 2002-2004 Royce Mitchell III
|
||||
// This file is under the BSD & LGPL licenses
|
||||
|
||||
#include <stdio.h>
|
||||
#include "SockUtils.h"
|
||||
#ifdef WIN32
|
||||
# ifndef SD_SEND // defined in winsock2.h, but not winsock.h
|
||||
# define SD_SEND 1
|
||||
# endif
|
||||
# define snprintf _snprintf
|
||||
# ifdef _MSC_VER
|
||||
# pragma comment ( lib, "ws2_32.lib" )
|
||||
# endif//_MSC_VER
|
||||
#elif defined(UNIX)
|
||||
# include <errno.h>
|
||||
# include "string.h" // memset
|
||||
# include <netdb.h> // hostent
|
||||
# include <arpa/inet.h> //inet_addr
|
||||
# include <sys/time.h>
|
||||
# define SD_SEND SHUT_WR //bah thou shalt name thy defines the same
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
//// Constants /////////////////////////////////////////////////////////
|
||||
const int kBufferSize = 1024;
|
||||
// creates broadcast address
|
||||
SockAddrIn::SockAddrIn()
|
||||
{
|
||||
memset ( this, 0, sizeof(sockaddr_in) );
|
||||
sin_family = AF_INET;
|
||||
}
|
||||
SockAddrIn::SockAddrIn ( const char* szAddr, u_short iPort )
|
||||
{
|
||||
memset ( this, 0, sizeof(sockaddr_in) );
|
||||
sin_family = AF_INET;
|
||||
sin_addr.s_addr = suLookupAddress(szAddr);
|
||||
sin_port = htons(iPort);
|
||||
}
|
||||
SockAddrIn::SockAddrIn ( in_addr_t iAddr, u_short iPort )
|
||||
{
|
||||
memset ( this, 0, sizeof(sockaddr_in) );
|
||||
sin_family = AF_INET;
|
||||
sin_addr.s_addr = iAddr;
|
||||
sin_port = htons(iPort);
|
||||
}
|
||||
bool suStartup()
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData;
|
||||
if ( WSAStartup ( MAKEWORD(2,0), &wsaData ) )
|
||||
return false;
|
||||
if ( wsaData.wVersion != MAKEWORD(2,0) )
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#elif defined(UNIX)
|
||||
// nothing special required here
|
||||
return true;
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
//// suTcpSocket ////////////////////////////////////////////////
|
||||
// Creates a TCP socket.
|
||||
SOCKET suTcpSocket()
|
||||
{
|
||||
SOCKET so = socket ( AF_INET, SOCK_STREAM, 0 );
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
return so;
|
||||
}
|
||||
//// suUdpSocket ////////////////////////////////////////////////
|
||||
// Creates a UDP socket. Compensates for new "functionality" introduced
|
||||
// in Win2K with regards to select() calls
|
||||
// MS Transport Provider IOCTL to control
|
||||
// reporting PORT_UNREACHABLE messages
|
||||
// on UDP sockets via recv/WSARecv/etc.
|
||||
// Path TRUE in input buffer to enable (default if supported),
|
||||
// FALSE to disable.
|
||||
#ifndef SIO_UDP_CONNRESET
|
||||
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
|
||||
#endif//SIO_UDP_CONNRESET
|
||||
SOCKET suUdpSocket()
|
||||
{
|
||||
SOCKET so = socket ( AF_INET, SOCK_DGRAM, 0 );
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
// for Windows 2000, disable new behavior...
|
||||
// see: http://www-pc.uni-regensburg.de/systemsw/W2KPRO/UPDATE/POSTSP1/Q263823.htm
|
||||
// this code is innocuous on other win32 platforms
|
||||
DWORD dwBytesReturned = 0;
|
||||
BOOL bNewBehavior = FALSE;
|
||||
// disable new Win2K behavior using
|
||||
// IOCTL: SIO_UDP_CONNRESET
|
||||
// we don't care about return value :)
|
||||
WSAIoctl(so, SIO_UDP_CONNRESET,
|
||||
&bNewBehavior, sizeof(bNewBehavior),
|
||||
NULL, 0, &dwBytesReturned,
|
||||
NULL, NULL);
|
||||
#endif
|
||||
return so;
|
||||
}
|
||||
//// suShutdownConnection ////////////////////////////////////////////////
|
||||
// Gracefully shuts the connection sd down. Returns true if it was able
|
||||
// to shut it down nicely, false if we had to "slam" it shut.
|
||||
// (either way, the socket does get closed)
|
||||
bool suShutdownConnection(SOCKET sd)
|
||||
{
|
||||
if ( sd == INVALID_SOCKET )
|
||||
return true;
|
||||
// Disallow any further data sends. This will tell the other side
|
||||
// that we want to go away now. If we skip this step, we don't
|
||||
// shut the connection down nicely.
|
||||
if (shutdown(sd, SD_SEND) == SOCKET_ERROR)
|
||||
{
|
||||
closesocket(sd);
|
||||
return false;
|
||||
}
|
||||
// Receive any extra data still sitting on the socket. After all
|
||||
// data is received, this call will block until the remote host
|
||||
// acknowledges the TCP control packet sent by the shutdown above.
|
||||
// Then we'll get a 0 back from recv, signalling that the remote
|
||||
// host has closed its side of the connection.
|
||||
char acReadBuffer[kBufferSize];
|
||||
for ( ;; )
|
||||
{
|
||||
int nNewBytes = recv(sd, acReadBuffer, kBufferSize, 0);
|
||||
if (nNewBytes == SOCKET_ERROR)
|
||||
{
|
||||
closesocket(sd);
|
||||
return false;
|
||||
}
|
||||
else if (nNewBytes != 0)
|
||||
{
|
||||
// FYI, received (nNewBytes) unexpected bytes during shutdown.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Okay, we're done!
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Close the socket.
|
||||
if (closesocket(sd) == SOCKET_ERROR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//// suLookupAddress ////////////////////////////////////////////////
|
||||
// Basically converts a name address to an ip address
|
||||
in_addr_t suLookupAddress ( const char* pcHost )
|
||||
{
|
||||
in_addr_t nRemoteAddr = inet_addr(pcHost);
|
||||
if ( nRemoteAddr == INADDR_NONE )
|
||||
{
|
||||
// pcHost isn't a dotted IP, so resolve it through DNS
|
||||
hostent* pHE = gethostbyname(pcHost);
|
||||
if ( pHE == 0 )
|
||||
{
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
return INADDR_NONE;
|
||||
}
|
||||
nRemoteAddr = *((in_addr_t*)pHE->h_addr_list[0]);
|
||||
}
|
||||
return nRemoteAddr;
|
||||
}
|
||||
bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort )
|
||||
{
|
||||
SockAddrIn sinRemote ( iAddress, iPort );
|
||||
if ( SOCKET_ERROR == connect(so,sinRemote,sizeof(sinRemote)) )
|
||||
{
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool suConnect ( SOCKET so, const char* szAddress, u_short iPort )
|
||||
{
|
||||
return suConnect ( so, suLookupAddress(szAddress), iPort );
|
||||
}
|
||||
//// suEstablishConnection ////////////////////////////////////////////////
|
||||
// creates a socket of the specified type, connects to the ip address/port
|
||||
// requested, and returns the SOCKET created
|
||||
SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type )
|
||||
{
|
||||
// Create a socket
|
||||
if ( type != SOCK_STREAM && type != SOCK_DGRAM )
|
||||
return INVALID_SOCKET;
|
||||
SOCKET so = socket(AF_INET, type, 0);
|
||||
if ( so == INVALID_SOCKET )
|
||||
return so;
|
||||
if ( !suConnect(so, iAddress, iPort) )
|
||||
{
|
||||
closesocket(so);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
return so;
|
||||
}
|
||||
//// suEstablishConnection ////////////////////////////////////////////////
|
||||
// creates a socket of the specified type, connects to the address/port
|
||||
// requested, and returns the SOCKET created
|
||||
SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type )
|
||||
{
|
||||
return suEstablishConnection ( suLookupAddress ( szAddress ), iPort, type );
|
||||
}
|
||||
//// suBroadcast ////////////////////////////////////////////////
|
||||
// takes a previously created broadcast-enabled UDP socket, and broadcasts
|
||||
// a message on the local network
|
||||
bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len /* = -1 */ )
|
||||
{
|
||||
if ( len == -1 )
|
||||
len = (int)strlen(buf);
|
||||
#if 1
|
||||
SockAddrIn to ( INADDR_BROADCAST, port );
|
||||
#else // some strange MS OS's don't broadcast to localhost...
|
||||
SockAddrIn to ( "127.0.0.1", port );
|
||||
if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) )
|
||||
return false;
|
||||
to.sin_addr.s_addr = INADDR_BROADCAST;
|
||||
#endif
|
||||
if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
//// suRecv ////////////////////////////////////////////////
|
||||
// retrieves data sent to our TCP socket. If no data, waits for
|
||||
// a period of timeout ms.
|
||||
// returns bytes received
|
||||
// -1 == SOCKET_ERROR
|
||||
// -2 == timed out waiting for data
|
||||
int suRecv ( SOCKET so, char* buf, int buflen, int timeout )
|
||||
{
|
||||
struct timeval to;
|
||||
fd_set rread;
|
||||
int res;
|
||||
FD_ZERO(&rread); // clear the fd_set
|
||||
FD_SET(so,&rread); // indicate which socket(s) we want to check
|
||||
memset((char *)&to,0,sizeof(to)); // clear the timeval struct
|
||||
to.tv_sec = timeout; // timeout select after (timeout) seconds
|
||||
// select returns > 0 if there is an event on the socket
|
||||
res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to );
|
||||
if (res < 0)
|
||||
return -1; // socket error
|
||||
// there was an event on the socket
|
||||
if ( (res>0) && (FD_ISSET(so,&rread)) )
|
||||
return recv ( so, buf, buflen, 0 );
|
||||
return -2;
|
||||
}
|
||||
//// suRecvFrom ////////////////////////////////////////////////
|
||||
// retrieves data sent to our UDP socket. If no data, waits for
|
||||
// a period of timeout ms.
|
||||
// returns bytes received
|
||||
// returns bytes received
|
||||
// -1 == SOCKET_ERROR
|
||||
// -2 == timed out waiting for data
|
||||
int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen )
|
||||
{
|
||||
struct timeval to;
|
||||
fd_set rread;
|
||||
int res;
|
||||
FD_ZERO(&rread); // clear the fd_set
|
||||
FD_SET(so,&rread); // indicate which socket(s) we want to check
|
||||
memset((char *)&to,0,sizeof(to)); // clear the timeval struct
|
||||
to.tv_sec = timeout; // timeout select after (timeout) seconds
|
||||
// select returns > 0 if there is an event on the socket
|
||||
res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to );
|
||||
if (res < 0)
|
||||
return -1; // socket error
|
||||
// there was an event on the socket
|
||||
if ( (res>0) && (FD_ISSET(so,&rread)) )
|
||||
return recvfrom ( so, buf, buflen, 0, (sockaddr*)from, fromlen );
|
||||
return -2; // timeout
|
||||
}
|
||||
//// suBind ////////////////////////////////////////////////
|
||||
// binds a UDP socket to an interface & port to receive
|
||||
// data on that port
|
||||
bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ )
|
||||
{
|
||||
SockAddrIn sinInterface ( iInterfaceAddress, iListenPort );
|
||||
if ( bReuseAddr )
|
||||
{
|
||||
int optval = -1; // true
|
||||
if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_REUSEADDR, (const char*)&optval, sizeof(optval) ) )
|
||||
{
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( SOCKET_ERROR == bind(so, sinInterface, sizeof(sinInterface)) )
|
||||
{
|
||||
int err = SUERRNO;
|
||||
if ( err != EADDRINUSE )
|
||||
return false;
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
if ( WSANOTINITIALISED == WSAGetLastError() )
|
||||
MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION );
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//// suBind ////////////////////////////////////////////////
|
||||
// binds a UDP socket to an interface & port to receive
|
||||
// data on that port
|
||||
bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ )
|
||||
{
|
||||
in_addr_t iInterfaceAddr = inet_addr(szInterfaceAddress);
|
||||
if ( iInterfaceAddr == INADDR_NONE )
|
||||
return false;
|
||||
return suBind ( so, iInterfaceAddr, iListenPort, bReuseAddr );
|
||||
}
|
||||
//// suEnableBroadcast ////////////////////////////////////////////////
|
||||
// in order to send broadcast messages on a UDP socket, this function
|
||||
// must be called first
|
||||
bool suEnableBroadcast ( SOCKET so, bool bEnable /* = true */ )
|
||||
{
|
||||
int optval = bEnable ? -1 : 0;
|
||||
if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_BROADCAST, (const char*)&optval, sizeof(optval) ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
//// suErrDesc ////////////////////////////////////////////////
|
||||
// returns text description of error code
|
||||
const char* suErrDesc ( int err )
|
||||
{
|
||||
static char errbuf[256];
|
||||
#ifdef WIN32
|
||||
switch ( err )
|
||||
{
|
||||
#define X(E) case E: return #E;
|
||||
X(WSAEINTR) X(WSAEBADF)
|
||||
X(WSAEACCES) X(WSAEFAULT)
|
||||
X(WSAEINVAL) X(WSAEMFILE)
|
||||
X(WSAEWOULDBLOCK) X(WSAEINPROGRESS)
|
||||
X(WSAEALREADY) X(WSAENOTSOCK)
|
||||
X(WSAEDESTADDRREQ) X(WSAEMSGSIZE)
|
||||
X(WSAEPROTOTYPE) X(WSAENOPROTOOPT)
|
||||
X(WSAEPROTONOSUPPORT) X(WSAESOCKTNOSUPPORT)
|
||||
X(WSAEOPNOTSUPP) X(WSAEPFNOSUPPORT)
|
||||
X(WSAEAFNOSUPPORT) X(WSAEADDRINUSE)
|
||||
X(WSAEADDRNOTAVAIL) X(WSAENETDOWN)
|
||||
X(WSAENETUNREACH) X(WSAENETRESET)
|
||||
X(WSAECONNABORTED) X(WSAECONNRESET)
|
||||
X(WSAENOBUFS) X(WSAEISCONN)
|
||||
X(WSAENOTCONN) X(WSAESHUTDOWN)
|
||||
X(WSAETOOMANYREFS) X(WSAETIMEDOUT)
|
||||
X(WSAECONNREFUSED) X(WSAELOOP)
|
||||
X(WSAENAMETOOLONG) X(WSAEHOSTDOWN)
|
||||
X(WSAEHOSTUNREACH) X(WSAENOTEMPTY)
|
||||
X(WSAEPROCLIM) X(WSAEUSERS)
|
||||
X(WSAEDQUOT) X(WSAESTALE)
|
||||
X(WSAEREMOTE) X(WSASYSNOTREADY)
|
||||
X(WSAVERNOTSUPPORTED) X(WSANOTINITIALISED)
|
||||
X(WSAEDISCON) X(WSAENOMORE)
|
||||
X(WSAECANCELLED) X(WSAEINVALIDPROCTABLE)
|
||||
X(WSAEINVALIDPROVIDER) X(WSAEPROVIDERFAILEDINIT)
|
||||
X(WSASYSCALLFAILURE) X(WSASERVICE_NOT_FOUND)
|
||||
X(WSATYPE_NOT_FOUND) X(WSA_E_NO_MORE)
|
||||
X(WSA_E_CANCELLED) X(WSAEREFUSED)
|
||||
#undef X
|
||||
}
|
||||
snprintf ( errbuf, sizeof(errbuf), "Unknown socket error (%lu)", err );
|
||||
errbuf[sizeof(errbuf)-1] = '\0';
|
||||
return errbuf;
|
||||
#elif defined(UNIX)
|
||||
perror(errbuf);
|
||||
return errbuf;
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
}
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
in_addr_t suLookupAddress ( const wchar_t* pcHost )
|
||||
{
|
||||
int len = wcslen(pcHost);
|
||||
char* p = new char[len+1];
|
||||
wcstombs ( p, pcHost, len );
|
||||
p[len] = 0;
|
||||
in_addr_t rc = suLookupAddress ( p );
|
||||
delete[] p;
|
||||
return rc;
|
||||
}
|
||||
bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len /* = -1 */ )
|
||||
{
|
||||
char* p = new char[len+1];
|
||||
wcstombs ( p, buf, len );
|
||||
p[len] = 0;
|
||||
bool rc = suBroadcast ( so, port, p, len );
|
||||
delete[] p;
|
||||
return rc;
|
||||
}
|
||||
int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout )
|
||||
{
|
||||
char* p = new char[buflen+1];
|
||||
int rc = suRecv ( so, p, buflen, timeout );
|
||||
p[buflen] = 0;
|
||||
mbstowcs ( buf, p, buflen );
|
||||
delete[] p;
|
||||
return rc;
|
||||
}
|
||||
int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen )
|
||||
{
|
||||
char* p = new char[buflen+1];
|
||||
int rc = suRecvFrom ( so, p, buflen, timeout, from, fromlen );
|
||||
p[buflen] = 0;
|
||||
mbs2wcs ( buf, p, buflen );
|
||||
delete[] p;
|
||||
return rc;
|
||||
}
|
||||
bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ )
|
||||
{
|
||||
int len = wcslen(szInterfaceAddress);
|
||||
char* p = new char[len+1];
|
||||
wcstombs ( p, szInterfaceAddress, len );
|
||||
p[len] = 0;
|
||||
bool rc = suBind ( so, p, iListenPort, bReuseAddr );
|
||||
delete[] p;
|
||||
return rc;
|
||||
}
|
||||
#endif//UNICODE
|
||||
|
||||
suBufferedRecvSocket::suBufferedRecvSocket ( SOCKET so )
|
||||
: suSocket ( so ), _off(0), _len(0)
|
||||
{
|
||||
}
|
||||
|
||||
int suBufferedRecvSocket::recvUntil ( std::string& buf, char until, int timeout )
|
||||
{
|
||||
if ( !_len )
|
||||
_off = 0;
|
||||
else if ( _off > (sizeof(_buf)>>1) )
|
||||
{
|
||||
memmove ( _buf, &_buf[_off], _len );
|
||||
_off = 0;
|
||||
}
|
||||
char* poff = &_buf[_off];
|
||||
for ( ;; )
|
||||
{
|
||||
char* p = (char*)memchr ( poff, until, _len );
|
||||
if ( p /*&& p < &poff[_len]*/ )
|
||||
{
|
||||
int ret_len = p-poff+1;
|
||||
buf.resize ( ret_len );
|
||||
memmove ( &buf[0], poff, ret_len );
|
||||
_off += ret_len;
|
||||
_len -= ret_len;
|
||||
return ret_len;
|
||||
}
|
||||
int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, timeout );
|
||||
if ( rc < 0 )
|
||||
{
|
||||
if ( _len )
|
||||
{
|
||||
rc = _len;
|
||||
buf.resize ( rc );
|
||||
memmove ( &buf[0], &_buf[_off], rc );
|
||||
_len = 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
_len += rc;
|
||||
}
|
||||
}
|
||||
|
||||
void suBufferedRecvSocket::recvPending()
|
||||
{
|
||||
if ( !_len )
|
||||
_off = 0;
|
||||
else if ( _off > (sizeof(_buf)>>1) )
|
||||
{
|
||||
memmove ( _buf, &_buf[_off], _len );
|
||||
_off = 0;
|
||||
}
|
||||
char* poff = &_buf[_off];
|
||||
while ( sizeof(_buf)-_len-_off )
|
||||
{
|
||||
int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, 1 );
|
||||
if ( rc <= 0 )
|
||||
break;
|
||||
_len += rc;
|
||||
}
|
||||
}
|
||||
|
||||
bool suBufferedRecvSocket::recvInStr ( char c )
|
||||
{
|
||||
return NULL != memchr ( &_buf[_off], c, _len );
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
// SockUtils.h - Declarations for the Winsock utility functions module.
|
||||
// (C) 2002-2004 Royce Mitchell III
|
||||
// This file is under the BSD & LGPL licenses
|
||||
|
||||
#ifndef __SOCKUTILS_H
|
||||
#define __SOCKUTILS_H
|
||||
|
||||
#include <string>
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define in_addr_t u_long
|
||||
# define SUERRNO WSAGetLastError()
|
||||
# define EADDRINUSE WSAEADDRINUSE
|
||||
# define ENOTSOCK WSAENOTSOCK
|
||||
# define socklen_t int
|
||||
#elif defined(UNIX)
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
# define closesocket(so) close(so)
|
||||
# define SOCKET int
|
||||
# define INVALID_SOCKET -1
|
||||
# define SOCKET_ERROR -1
|
||||
# define SUERRNO errno
|
||||
# ifdef MACOSX
|
||||
# define socklen_t int //Stupid mac
|
||||
# endif
|
||||
#else
|
||||
# error unrecognized target
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
extern bool suStartup();
|
||||
extern SOCKET suTcpSocket();
|
||||
extern SOCKET suUdpSocket();
|
||||
extern bool suShutdownConnection(SOCKET sd);
|
||||
extern in_addr_t suLookupAddress ( const char* pcHost );
|
||||
extern bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort );
|
||||
extern bool suConnect ( SOCKET so, const char* szAddress, u_short iPort );
|
||||
extern SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type );
|
||||
extern SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type );
|
||||
extern bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len = -1 );
|
||||
extern int suRecv ( SOCKET so, char* buf, int buflen, int timeout );
|
||||
extern int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen );
|
||||
extern bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr = false );
|
||||
extern bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false );
|
||||
extern bool suEnableBroadcast ( SOCKET so, bool bEnable = true );
|
||||
extern const char* suErrDesc ( int err );
|
||||
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
extern in_addr_t suLookupAddress ( const wchar_t* pcHost );
|
||||
extern bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len = -1 );
|
||||
extern int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout );
|
||||
extern int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen );
|
||||
extern bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false );
|
||||
#endif//UNICODE
|
||||
|
||||
class suSocket
|
||||
{
|
||||
SOCKET _so;
|
||||
public:
|
||||
suSocket ( SOCKET so = INVALID_SOCKET ) : _so(so)
|
||||
{
|
||||
}
|
||||
const suSocket& operator = ( SOCKET so )
|
||||
{
|
||||
assert ( _so == INVALID_SOCKET ); // must Detach() or Close() existing socket first
|
||||
_so = so;
|
||||
return *this;
|
||||
}
|
||||
virtual ~suSocket()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
void Close()
|
||||
{
|
||||
if ( _so != INVALID_SOCKET )
|
||||
{
|
||||
//suShutdownConnection ( _so ); // TODO - only valid on TCP sockets
|
||||
closesocket ( _so );
|
||||
_so = INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
operator SOCKET() const
|
||||
{
|
||||
return _so;
|
||||
}
|
||||
SOCKET Attach ( SOCKET so )
|
||||
{
|
||||
SOCKET old = Detach();
|
||||
_so = so;
|
||||
return old;
|
||||
}
|
||||
SOCKET Detach()
|
||||
{
|
||||
SOCKET so = _so;
|
||||
_so = INVALID_SOCKET;
|
||||
return so;
|
||||
}
|
||||
|
||||
private:
|
||||
// disable copy semantics
|
||||
suSocket ( const suSocket& );
|
||||
const suSocket& operator = ( const suSocket& );
|
||||
};
|
||||
|
||||
class suBufferedRecvSocket : public suSocket
|
||||
{
|
||||
char _buf[2048];
|
||||
int _off;
|
||||
int _len;
|
||||
public:
|
||||
suBufferedRecvSocket ( SOCKET so = INVALID_SOCKET );
|
||||
int recvUntil ( std::string& buf, char until, int timeout );
|
||||
void recvPending();
|
||||
bool recvInStr ( char c );
|
||||
};
|
||||
|
||||
class SockAddrIn : public sockaddr_in
|
||||
{
|
||||
public:
|
||||
SockAddrIn(); // creates broadcast address
|
||||
SockAddrIn ( const char* szAddr, u_short iPort );
|
||||
SockAddrIn ( in_addr_t iAddr, u_short iPort );
|
||||
operator sockaddr* () { return (sockaddr*)this; }
|
||||
operator sockaddr_in* () { return (sockaddr_in*)this; }
|
||||
};
|
||||
|
||||
#endif//__SOCKUTILS_H
|
@@ -1,96 +0,0 @@
|
||||
// SplitJoin.cpp
|
||||
//
|
||||
// This code is copyright 2003-2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 ) // MSVC6 can't handle too-long template names
|
||||
#endif//_MSC_VER
|
||||
|
||||
//#include <sstream>
|
||||
|
||||
#include "SplitJoin.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
//using std::stringstream;
|
||||
|
||||
static const char* quotes = "\"\'";
|
||||
|
||||
bool Split ( vector<string>& vec, const char* csv, char sep, bool merge )
|
||||
{
|
||||
string scsv ( csv );
|
||||
char* col = &scsv[0];
|
||||
vec.resize ( 0 );
|
||||
for ( ;; )
|
||||
{
|
||||
char* p = col;
|
||||
while ( isspace(*p) && *p != sep )
|
||||
p++;
|
||||
char quote = 0;
|
||||
if ( strchr ( quotes, *p ) )
|
||||
quote = *p++;
|
||||
while ( *p && (*p != sep || quote) )
|
||||
{
|
||||
if ( *p++ == quote )
|
||||
break;
|
||||
}
|
||||
|
||||
while ( isspace(*p) && *p != sep )
|
||||
p++;
|
||||
|
||||
if ( *p && *p != sep )
|
||||
return false;
|
||||
|
||||
string scol ( col, p-col );
|
||||
|
||||
//quote = scol[0];
|
||||
if ( quote )
|
||||
{
|
||||
if ( scol[scol.size()-1] == quote )
|
||||
scol = string ( &scol[1], scol.size()-2 );
|
||||
}
|
||||
|
||||
if ( scol.length() || !merge )
|
||||
vec.push_back ( scol );
|
||||
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
col = p + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Join ( string& csv, vector<string>& vec, char sep )
|
||||
{
|
||||
csv.resize(0);
|
||||
for ( int i = 0; i < vec.size(); i++ )
|
||||
{
|
||||
if ( i )
|
||||
csv += sep;
|
||||
string& s = vec[i];
|
||||
if ( strchr ( s.c_str(), sep ) )
|
||||
{
|
||||
if ( strchr ( s.c_str(), '\"' ) )
|
||||
{
|
||||
if ( strchr ( s.c_str(), '\'' ) )
|
||||
return false; // the sep, " and ' are all in the string, can't build valid output
|
||||
csv += '\'';
|
||||
csv += s;
|
||||
csv += '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
csv += '\"';
|
||||
csv += s;
|
||||
csv += '\"';
|
||||
}
|
||||
}
|
||||
else
|
||||
csv += s;
|
||||
}
|
||||
return true;
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
// SplitJoin.h
|
||||
//
|
||||
// This code is copyright 2003-2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef SPLITJOIN_H
|
||||
#define SPLITJOIN_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
bool Split (
|
||||
std::vector<std::string>& vec,
|
||||
const char* csv,
|
||||
char sep=',',
|
||||
bool merge=false );
|
||||
|
||||
bool Join (
|
||||
std::string& csv,
|
||||
std::vector<std::string>& vec,
|
||||
char sep=',' );
|
||||
|
||||
inline bool Split (
|
||||
std::vector<std::string>& vec,
|
||||
const std::string& csv,
|
||||
char sep=',',
|
||||
bool merge=false )
|
||||
{
|
||||
return Split ( vec, csv.c_str(), sep, merge );
|
||||
}
|
||||
|
||||
#endif//SPLIT_H
|
@@ -1,240 +0,0 @@
|
||||
// ThreadPool.cpp
|
||||
// This file is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#include <vector>
|
||||
using std::vector;
|
||||
#include "ThreadPool.h"
|
||||
#include "QueueT.h"
|
||||
#include "auto_vector.h"
|
||||
#include "verify.h"
|
||||
#include "ReliMT.h"
|
||||
|
||||
class PoolableThread : public ActiveObject
|
||||
{
|
||||
public:
|
||||
PoolableThread ( ThreadPoolImpl& );
|
||||
~PoolableThread()
|
||||
{
|
||||
Kill();
|
||||
}
|
||||
void InitThread();
|
||||
void Run();
|
||||
void FlushThread();
|
||||
|
||||
ThreadPoolImpl& _pool;
|
||||
};
|
||||
|
||||
class ThreadPoolLaunchData
|
||||
{
|
||||
public:
|
||||
ThreadPoolFunc* pFun;
|
||||
void* pArg;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class AtomicCounter : public Uncopyable
|
||||
{
|
||||
Mutex _m;
|
||||
T _t;
|
||||
public:
|
||||
AtomicCounter ( T init = 0 ) : _t(init)
|
||||
{
|
||||
}
|
||||
AtomicCounter ( const AtomicCounter<T>& t )
|
||||
{
|
||||
//Mutex::Lock l ( _m ); // don't need to lock since this is a ctor
|
||||
Mutex::Lock l2 ( t._m );
|
||||
_t = t._t;
|
||||
}
|
||||
const AtomicCounter<T>& operator = ( const AtomicCounter<T>& t )
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
Mutex::Lock l2 ( t._m );
|
||||
_t = t._t;
|
||||
return *this;
|
||||
}
|
||||
T operator ++ ()
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
T t = _t++;
|
||||
return t;
|
||||
}
|
||||
const AtomicCounter<T>& operator ++ ( int )
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
++_t;
|
||||
return *this;
|
||||
}
|
||||
T operator -- ()
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
T t = _t--;
|
||||
return t;
|
||||
}
|
||||
const AtomicCounter<T>& operator -- ( int )
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
--_t;
|
||||
return *this;
|
||||
}
|
||||
const AtomicCounter<T>& operator += ( T t )
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
return _t += t;
|
||||
return *this;
|
||||
}
|
||||
const AtomicCounter<T>& operator -= ( T t )
|
||||
{
|
||||
Mutex::Lock l ( _m );
|
||||
return _t -= t;
|
||||
return *this;
|
||||
}
|
||||
operator const T& () const
|
||||
{
|
||||
//Mutex::Lock l ( _m );
|
||||
return _t;
|
||||
}
|
||||
T operator !() const
|
||||
{
|
||||
//Mutex::Lock l ( _m );
|
||||
return !_t;
|
||||
}
|
||||
};
|
||||
|
||||
class ThreadPoolImpl : public Uncopyable
|
||||
{
|
||||
public:
|
||||
ThreadPoolImpl() : _isDying(false), _idleThreads(0)
|
||||
{
|
||||
}
|
||||
|
||||
~ThreadPoolImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
_isDying = true;
|
||||
while ( _idleThreads )
|
||||
{
|
||||
_threadWaitEvent.Release();
|
||||
_threadStartEvent.Wait(); // let thread actually get a grip
|
||||
}
|
||||
}
|
||||
|
||||
void Launch ( ThreadPoolFunc* pFun, void* pArg )
|
||||
{
|
||||
// this mutex is necessary to make sure we never have a conflict
|
||||
// between checking !_idleThreads and the call to _threadStartEvent.Wait()
|
||||
// basically if 2 threads call Launch() simultaneously, and there is only
|
||||
// 1 idle thread, it's possible that a new thread won't be created to
|
||||
// satisfy the 2nd request until an existing thread finishes.
|
||||
Mutex::Lock launchlock ( _launchMutex );
|
||||
|
||||
ASSERT ( pFun );
|
||||
ThreadPoolLaunchData* data;
|
||||
{
|
||||
Mutex::Lock lock ( _vectorMutex );
|
||||
if ( !_spareData.size() )
|
||||
_spareData.push_back ( new ThreadPoolLaunchData() );
|
||||
data = _spareData.pop_back().release();
|
||||
if ( !_idleThreads )
|
||||
_threads.push_back ( new PoolableThread(*this) );
|
||||
}
|
||||
|
||||
data->pFun = pFun;
|
||||
data->pArg = pArg;
|
||||
verify ( _pendingData.Add ( data ) );
|
||||
_threadWaitEvent.Release(); // tell a thread to do it's thing...
|
||||
_threadStartEvent.Wait(); // wait on a thread to pick up the request
|
||||
}
|
||||
|
||||
// functions for threads to call...
|
||||
ThreadPoolLaunchData* GetPendingData()
|
||||
{
|
||||
ThreadPoolLaunchData* data = NULL;
|
||||
++_idleThreads;
|
||||
_threadWaitEvent.Wait(); // waits until there's a request
|
||||
--_idleThreads;
|
||||
_threadStartEvent.Release(); // tell requester we got it
|
||||
if ( _isDying )
|
||||
return NULL;
|
||||
_pendingData.Get ( data );
|
||||
ASSERT ( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
void RecycleData ( ThreadPoolLaunchData* data )
|
||||
{
|
||||
Mutex::Lock lock ( _vectorMutex );
|
||||
_spareData.push_back ( data );
|
||||
}
|
||||
|
||||
bool _isDying;
|
||||
Mutex _vectorMutex, _launchMutex;
|
||||
auto_vector<PoolableThread> _threads;
|
||||
auto_vector<ThreadPoolLaunchData> _spareData;
|
||||
CQueueT<ThreadPoolLaunchData*> _pendingData;
|
||||
Event _threadWaitEvent, _threadStartEvent;
|
||||
AtomicCounter<int> _idleThreads;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ThreadPool
|
||||
|
||||
/*static*/ ThreadPool& ThreadPool::Instance()
|
||||
{
|
||||
static ThreadPool tp;
|
||||
return tp;
|
||||
}
|
||||
|
||||
ThreadPool::ThreadPool() : _pimpl ( new ThreadPoolImpl )
|
||||
{
|
||||
};
|
||||
|
||||
ThreadPool::~ThreadPool()
|
||||
{
|
||||
_pimpl->Shutdown();
|
||||
delete _pimpl;
|
||||
_pimpl = 0;
|
||||
}
|
||||
|
||||
void ThreadPool::Launch ( ThreadPoolFunc* pFun, void* pArg )
|
||||
{
|
||||
_pimpl->Launch ( pFun, pArg );
|
||||
}
|
||||
|
||||
int ThreadPool::IdleThreads()
|
||||
{
|
||||
return _pimpl->_idleThreads;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PoolableThread
|
||||
|
||||
PoolableThread::PoolableThread ( ThreadPoolImpl& pool ) : _pool(pool)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
|
||||
void PoolableThread::InitThread()
|
||||
{
|
||||
}
|
||||
|
||||
void PoolableThread::Run()
|
||||
{
|
||||
ThreadPoolLaunchData* data;
|
||||
while ( !_isDying )
|
||||
{
|
||||
data = _pool.GetPendingData(); // enter wait state if none...
|
||||
if ( !data ) // NULL data means kill thread
|
||||
break;
|
||||
(*data->pFun) ( data->pArg ); // call the function
|
||||
_pool.RecycleData ( data );
|
||||
}
|
||||
}
|
||||
|
||||
void PoolableThread::FlushThread()
|
||||
{
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
// ThreadPool.h
|
||||
// This file is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#ifndef THREADPOOL_H
|
||||
#define THREADPOOL_H
|
||||
|
||||
#include "ReliMT.h"
|
||||
|
||||
typedef void THREADAPI ThreadPoolFunc ( void* );
|
||||
|
||||
class ThreadPoolImpl;
|
||||
|
||||
class ThreadPool : public Uncopyable
|
||||
{
|
||||
public:
|
||||
static ThreadPool& Instance();
|
||||
~ThreadPool();
|
||||
|
||||
void Launch ( ThreadPoolFunc* pFun, void* pArg );
|
||||
int IdleThreads();
|
||||
|
||||
private:
|
||||
ThreadPool();
|
||||
ThreadPoolImpl *_pimpl;
|
||||
};
|
||||
|
||||
#endif// THREADPOOL_H
|
@@ -1,87 +0,0 @@
|
||||
// auto_ptr.h
|
||||
// This file is (C) 2002-2003 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#ifndef AUTO_PTR_H
|
||||
#define AUTO_PTR_H
|
||||
|
||||
template<class T>
|
||||
class auto_ptr
|
||||
{
|
||||
public:
|
||||
typedef T element_type;
|
||||
|
||||
explicit auto_ptr(T *p = 0) : _p(p)
|
||||
{
|
||||
}
|
||||
|
||||
auto_ptr(auto_ptr<T>& rhs) : _p(rhs.release())
|
||||
{
|
||||
}
|
||||
|
||||
auto_ptr<T>& operator=(auto_ptr<T>& rhs)
|
||||
{
|
||||
if ( &rhs != this )
|
||||
{
|
||||
dispose();
|
||||
_p = rhs.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto_ptr<T>& set ( auto_ptr<T>& rhs )
|
||||
{
|
||||
if ( &rhs != this )
|
||||
{
|
||||
dispose();
|
||||
_p = rhs.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~auto_ptr()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
void dispose()
|
||||
{
|
||||
if ( _p )
|
||||
{
|
||||
delete _p;
|
||||
_p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
T& operator[] ( int i )
|
||||
{
|
||||
return _p[i];
|
||||
}
|
||||
|
||||
T& operator*() const
|
||||
{
|
||||
return *_p;
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
return _p;
|
||||
}
|
||||
|
||||
T* get() const
|
||||
{
|
||||
return _p;
|
||||
}
|
||||
|
||||
T* release()
|
||||
{
|
||||
T* p = _p;
|
||||
_p = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
private:
|
||||
T* _p;
|
||||
};
|
||||
|
||||
#endif//AUTO_PTR_H
|
@@ -1,141 +0,0 @@
|
||||
// auto_vector.h
|
||||
// This file is (C) 2002-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#ifndef AUTO_VECTOR_H
|
||||
#define AUTO_VECTOR_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "verify.h"
|
||||
#include "auto_ptr.h"
|
||||
|
||||
template<class T>
|
||||
class auto_vector
|
||||
{
|
||||
public:
|
||||
explicit auto_vector ( size_t capacity = 0 )
|
||||
: _arr(0), _capacity(0), _end(0)
|
||||
{
|
||||
if ( capacity != 0 )
|
||||
_arr = new auto_ptr<T>[capacity];
|
||||
_capacity = capacity;
|
||||
}
|
||||
|
||||
~auto_vector()
|
||||
{
|
||||
delete []_arr;
|
||||
}
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
return _end;
|
||||
}
|
||||
|
||||
const auto_ptr<T>& operator [] ( size_t i ) const
|
||||
{
|
||||
ASSERT ( i < _end );
|
||||
return _arr[i];
|
||||
}
|
||||
|
||||
auto_ptr<T>& operator [] ( size_t i )
|
||||
{
|
||||
ASSERT ( i < _end );
|
||||
return _arr[i];
|
||||
}
|
||||
|
||||
void assign ( size_t i, auto_ptr<T>& p )
|
||||
{
|
||||
ASSERT ( i < _end );
|
||||
_arr[i] = p;
|
||||
}
|
||||
|
||||
void assign_direct ( size_t i, T * p )
|
||||
{
|
||||
ASSERT ( i < _end );
|
||||
reserve ( i + 1 );
|
||||
_arr[i].reset ( ptr );
|
||||
}
|
||||
|
||||
void push_back ( auto_ptr<T>& p )
|
||||
{
|
||||
reserve ( _end + 1 );
|
||||
_arr[_end++] = p;
|
||||
}
|
||||
|
||||
auto_ptr<T>& back()
|
||||
{
|
||||
ASSERT ( _end != 0 );
|
||||
return _arr[_end-1];
|
||||
}
|
||||
|
||||
void push_back ( T * p )
|
||||
{
|
||||
reserve ( _end + 1 );
|
||||
auto_ptr<T> tmp(p);
|
||||
_arr[_end++] = tmp;
|
||||
//GCC is pedantic, this is an error.
|
||||
//_arr[_end++] = auto_ptr<T>(p);
|
||||
}
|
||||
|
||||
auto_ptr<T> pop_back()
|
||||
{
|
||||
ASSERT ( _end != 0 );
|
||||
if ( !_end )
|
||||
{
|
||||
auto_ptr<T> tmp((T*)0);
|
||||
return tmp;
|
||||
//GCC, this is an error.
|
||||
//return auto_ptr<T>(NULL);
|
||||
}
|
||||
return _arr[--_end];
|
||||
}
|
||||
|
||||
void resize ( size_t newSize )
|
||||
{
|
||||
ASSERT ( newSize >= 0 );
|
||||
reserve ( newSize ); // make sure we have at least this much room
|
||||
_end = newSize;
|
||||
}
|
||||
|
||||
void reserve ( size_t reqCapacity )
|
||||
{
|
||||
if ( reqCapacity <= _capacity )
|
||||
return;
|
||||
size_t newCapacity = 2 * _capacity;
|
||||
if ( reqCapacity > newCapacity )
|
||||
newCapacity = reqCapacity;
|
||||
// allocate new array
|
||||
auto_ptr<T> * arrNew = new auto_ptr<T> [newCapacity];
|
||||
// transfer all entries
|
||||
for ( size_t i = 0; i < _capacity; ++i )
|
||||
arrNew[i] = _arr[i];
|
||||
_capacity = newCapacity;
|
||||
// free old memory
|
||||
delete[] _arr;
|
||||
// substitute new array for old array
|
||||
_arr = arrNew;
|
||||
}
|
||||
|
||||
void remove ( size_t off )
|
||||
{
|
||||
size_t last = _end-1;
|
||||
if ( off == last )
|
||||
resize ( last );
|
||||
else if ( off < last )
|
||||
{
|
||||
auto_ptr<T> tmp ( pop_back().release() );
|
||||
_arr[off] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//typedef const_auto_iterator<T> const_iterator;
|
||||
//const_iterator begin () const { return _arr; }
|
||||
//const_iterator end () const { return _arr + _end; }
|
||||
|
||||
private:
|
||||
auto_ptr<T> *_arr;
|
||||
size_t _capacity;
|
||||
size_t _end;
|
||||
};
|
||||
|
||||
#endif//AUTO_VECTOR_H
|
@@ -1,58 +0,0 @@
|
||||
// base64.cpp
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
static const char* alfabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
string base64_encode ( const string& sInput )
|
||||
{
|
||||
unsigned char x=0, topbit=0;
|
||||
int v=0;
|
||||
string sOutput;
|
||||
do
|
||||
{
|
||||
if ( topbit < 6 )
|
||||
{
|
||||
x++;
|
||||
v <<= 8;
|
||||
if ( x <= sInput.length() ) v += sInput[x-1];
|
||||
topbit += 8;
|
||||
}
|
||||
topbit -= 6;
|
||||
if ( x > sInput.length() && !v )
|
||||
break;
|
||||
sOutput += alfabet[(v >> topbit) & 63];
|
||||
v &= (1 << topbit) - 1;
|
||||
} while ( x < sInput.length() || v );
|
||||
int eq = (8 - (sOutput.length() % 4)) % 4;
|
||||
while ( eq-- )
|
||||
sOutput += '=';
|
||||
return sOutput;
|
||||
}
|
||||
|
||||
string base64_decode ( const string& sInput )
|
||||
{
|
||||
unsigned char x=0, topbit=0;
|
||||
int v=0, inlen = sInput.length();
|
||||
string sOutput;
|
||||
while ( inlen && sInput[inlen-1] == '=' )
|
||||
inlen--;
|
||||
do
|
||||
{
|
||||
while ( topbit < 8 )
|
||||
{
|
||||
x++;
|
||||
v <<= 6;
|
||||
if ( x <= inlen ) v += (strchr(alfabet, sInput[x-1]) - alfabet);
|
||||
topbit += 6;
|
||||
}
|
||||
topbit -= 8;
|
||||
if ( x > inlen && !v )
|
||||
break;
|
||||
sOutput += (char)((v >> topbit) & 255);
|
||||
v &= ((1 << topbit) - 1);
|
||||
} while ( x <= inlen || v );
|
||||
return sOutput;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
// base64.h
|
||||
|
||||
#ifndef BASE64_H
|
||||
#define BASE64_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode ( const std::string& s );
|
||||
|
||||
std::string base64_decode ( const std::string& s );
|
||||
|
||||
#endif//BASE64_H
|
@@ -1,15 +0,0 @@
|
||||
// chomp.cpp
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#include "chomp.h"
|
||||
|
||||
std::string chomp ( const std::string& s )
|
||||
{
|
||||
const char* p = &s[0];
|
||||
const char* p2 = &s[0] + s.size();
|
||||
while ( p2 > p && strchr("\r\n", p2[-1]) )
|
||||
p2--;
|
||||
return std::string ( p, p2-p );
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
// chomp.h
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef CHOMP_H
|
||||
#define CHOMP_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string chomp ( const std::string& s );
|
||||
|
||||
#endif//TRIM_H
|
||||
|
@@ -1,7 +0,0 @@
|
||||
|
||||
|
||||
#define SERVER "irc.freenode.net"
|
||||
#define BOTNAME "ArchBlackmann"
|
||||
#define CHANNEL "#ReactOS"
|
||||
#define MODE "+i"
|
||||
#define PASS "ilovebunnies"
|
@@ -1,23 +0,0 @@
|
||||
// cram_md5.cpp
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#include "md5.h"
|
||||
#include "cram_md5.h"
|
||||
#include "base64.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
string cram_md5 ( const string& username, const string& password, const string& greeting )
|
||||
{
|
||||
string challenge = base64_decode ( greeting );
|
||||
|
||||
string hmac = HMAC_MD5 ( password, challenge );
|
||||
//printf ( "(cram_md5): hmac = %s\n", hmac.c_str() );
|
||||
string raw_response = username;
|
||||
raw_response += " ";
|
||||
raw_response += hmac;
|
||||
//printf ( "(cram_md5): raw_response = %s\n", raw_response.c_str() );
|
||||
|
||||
return base64_encode ( raw_response );
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
// cram_md5.h
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef CRAM_MD5_H
|
||||
#define CRAM_MD5_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string cram_md5 (
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& greeting );
|
||||
|
||||
#endif//CRAM_MD5_H
|
@@ -1,27 +0,0 @@
|
||||
shit
|
||||
fuck
|
||||
pussy
|
||||
ass
|
||||
ass-
|
||||
-ass
|
||||
dumbass
|
||||
jackass
|
||||
fatass
|
||||
asshole
|
||||
smartass
|
||||
cunt
|
||||
fucker
|
||||
bitch
|
||||
dick
|
||||
penile
|
||||
stfu
|
||||
omfg
|
||||
lmao
|
||||
ass.
|
||||
-ass.
|
||||
semprini
|
||||
goat.cx
|
||||
ekush
|
||||
akshor
|
||||
poop
|
||||
guten morgen
|
@@ -1,10 +0,0 @@
|
||||
You should have your mouth washed out with soap!
|
||||
This is a clean channel... please watch your language
|
||||
Please try to keep it clean
|
||||
Hey, there's children present ( I'm not even a year old yet! )
|
||||
Could you find a less-offensive way to express yourself, please?
|
||||
Such language :(
|
||||
Those aren't nice words to use
|
||||
Oh, my poor innocent ears :(
|
||||
Help! My mind is being corrupted!
|
||||
filthy mouths are not appreciated here
|
@@ -1,15 +0,0 @@
|
||||
Royce3
|
||||
kjk_hyperion
|
||||
tamlin
|
||||
GvG
|
||||
filip2307
|
||||
hardon
|
||||
w3seek
|
||||
arty
|
||||
sedwards
|
||||
Exception
|
||||
blight_
|
||||
jimtabor
|
||||
mtempel
|
||||
Gge
|
||||
Alex_Ionescu
|
@@ -1,580 +0,0 @@
|
||||
CcCanIWrite
|
||||
CcCopyRead
|
||||
CcCopyWrite
|
||||
CcDeferWrite
|
||||
CcFastCopyRead
|
||||
CcFastCopyWrite
|
||||
CcFlushCache
|
||||
CcGetDirtyPages
|
||||
CcGetFileObjectFromBcb
|
||||
CcGetFileObjectFromSectionPtrs
|
||||
CcGetFlushedValidData
|
||||
CcGetLsnForFileObject
|
||||
CcInitializeCacheMap
|
||||
CcIsThereDirtyData
|
||||
CcMapData
|
||||
CcMdlRead
|
||||
CcMdlReadComplete
|
||||
CcMdlWriteAbort
|
||||
CcMdlWriteComplete
|
||||
CcPinMappedData
|
||||
CcPinRead
|
||||
CcPrepareMdlWrite
|
||||
CcPreparePinWrite
|
||||
CcPurgeCacheSection
|
||||
CcRemapBcb
|
||||
CcRepinBcb
|
||||
CcScheduleReadAhead
|
||||
CcSetAdditionalCacheAttributes
|
||||
CcSetBcbOwnerPointer
|
||||
CcSetDirtyPageThreshold
|
||||
CcSetDirtyPinnedData
|
||||
CcSetFileSizes
|
||||
CcSetLogHandleForFile
|
||||
CcSetReadAheadGranularity
|
||||
CcUninitializeCacheMap
|
||||
CcUnpinData
|
||||
CcUnpinDataForThread
|
||||
CcUnpinRepinnedBcb
|
||||
CcWaitForCurrentLazyWriterActivity
|
||||
CcZeroData
|
||||
DbgLoadImageSymbols
|
||||
DbgQueryDebugFilterState
|
||||
DbgSetDebugFilterState
|
||||
EVENT_TYPE
|
||||
ExAcquireResourceExclusive
|
||||
ExAcquireResourceExclusiveLite
|
||||
ExAcquireResourceSharedLite
|
||||
ExAcquireSharedStarveExclusive
|
||||
ExAcquireSharedWaitForExclusive
|
||||
ExAllocateFromZone
|
||||
ExAllocatePool
|
||||
ExAllocatePoolWithQuota
|
||||
ExAllocatePoolWithQuotaTag
|
||||
ExAllocatePoolWithTag
|
||||
ExConvertExclusiveToSharedLite
|
||||
ExCreateCallback
|
||||
ExDeleteNPagedLookasideList
|
||||
ExDeletePagedLookasideList
|
||||
ExDeleteResource
|
||||
ExDeleteResourceLite
|
||||
ExDisableResourceBoostLite
|
||||
ExEnumHandleTable
|
||||
ExExtendZone
|
||||
ExFreePool
|
||||
ExGetCurrentProcessorCounts
|
||||
ExGetCurrentProcessorCpuUsage
|
||||
ExGetExclusiveWaiterCount
|
||||
ExGetPreviousMode
|
||||
ExGetSharedWaiterCount
|
||||
ExInitializeNPagedLookasideList
|
||||
ExInitializePagedLookasideList
|
||||
ExInitializeResource
|
||||
ExInitializeResourceLite
|
||||
ExInitializeZone
|
||||
ExInterlockedAddLargeInteger
|
||||
ExInterlockedAddUlong
|
||||
ExInterlockedDecrementLong
|
||||
ExInterlockedExchangeUlong
|
||||
ExInterlockedExtendZone
|
||||
ExInterlockedIncrementLong
|
||||
ExInterlockedInsertHeadList
|
||||
ExInterlockedInsertTailList
|
||||
ExInterlockedPopEntryList
|
||||
ExInterlockedPushEntryList
|
||||
ExInterlockedRemoveHeadList
|
||||
ExIsProcessorFeaturePresent
|
||||
ExIsResourceAcquiredExclusiveLite
|
||||
ExIsResourceAcquiredSharedLite
|
||||
ExLocalTimeToSystemTime
|
||||
ExNotifyCallback
|
||||
ExPostSystemEvent
|
||||
ExQueryPoolBlockSize
|
||||
ExQueueWorkItem
|
||||
ExRaiseAccessViolation
|
||||
ExRaiseDatatypeMisalignment
|
||||
ExRaiseException
|
||||
ExRaiseHardError
|
||||
ExRaiseStatus
|
||||
ExRegisterCallback
|
||||
ExReinitializeResourceLite
|
||||
ExReleaseResource
|
||||
ExReleaseResourceForThread
|
||||
ExReleaseResourceForThreadLite
|
||||
ExRosDumpPagedPoolByTag
|
||||
ExRosQueryPoolTag
|
||||
ExSetResourceOwnerPointer
|
||||
ExSetTimerResolution
|
||||
ExSystemExceptionFilter
|
||||
ExSystemTimeToLocalTime
|
||||
ExTryToAcquireResourceExclusiveLite
|
||||
ExUnregisterCallback
|
||||
ExUuidCreate
|
||||
ExVerifySuite
|
||||
FsRtlAcquireFileExclusive
|
||||
FsRtlAddMcbEntry
|
||||
FsRtlAddToTunnelCache
|
||||
FsRtlAllocateFileLock
|
||||
FsRtlAllocatePool
|
||||
FsRtlAllocatePoolWithQuota
|
||||
FsRtlAllocatePoolWithQuotaTag
|
||||
FsRtlAllocatePoolWithTag
|
||||
FsRtlAllocateResource
|
||||
FsRtlAreNamesEqual
|
||||
FsRtlBalanceReads
|
||||
FsRtlCheckLockForReadAccess
|
||||
FsRtlCheckLockForWriteAccess
|
||||
FsRtlCopyRead
|
||||
FsRtlCopyWrite
|
||||
FsRtlFastCheckLockForRead
|
||||
FsRtlFastCheckLockForWrite
|
||||
FsRtlFastUnlockAll
|
||||
FsRtlFastUnlockAllByKey
|
||||
FsRtlFastUnlockSingle
|
||||
FsRtlFindInTunnelCache
|
||||
FsRtlFreeFileLock
|
||||
FsRtlGetFileSize
|
||||
FsRtlGetNextFileLock
|
||||
FsRtlGetNextMcbEntry
|
||||
FsRtlIncrementCcFastReadNoWait
|
||||
FsRtlIncrementCcFastReadNotPossible
|
||||
FsRtlIncrementCcFastReadResourceMiss
|
||||
FsRtlIncrementCcFastReadWait
|
||||
FsRtlInitializeFileLock
|
||||
FsRtlInitializeMcb
|
||||
FsRtlInitializeTunnelCache
|
||||
FsRtlInsertPerFileObjectContext
|
||||
FsRtlInsertPerStreamContext
|
||||
FsRtlIsDbcsInExpression
|
||||
FsRtlIsFatDbcsLegal
|
||||
FsRtlIsHpfsDbcsLegal
|
||||
FsRtlIsNameInExpression
|
||||
FsRtlLookupLastLargeMcbEntryAndIndex
|
||||
FsRtlLookupLastMcbEntry
|
||||
FsRtlLookupMcbEntry
|
||||
FsRtlLookupPerFileObjectContext
|
||||
FsRtlLookupPerStreamContextInternal
|
||||
FsRtlMdlRead
|
||||
FsRtlMdlReadComplete
|
||||
FsRtlMdlReadCompleteDev
|
||||
FsRtlMdlReadDev
|
||||
FsRtlMdlWriteComplete
|
||||
FsRtlMdlWriteCompleteDev
|
||||
FsRtlNotifyChangeDirectory
|
||||
FsRtlNotifyCleanup
|
||||
FsRtlNotifyFilterChangeDirectory
|
||||
FsRtlNotifyFilterReportChange
|
||||
FsRtlNotifyFullChangeDirectory
|
||||
FsRtlNotifyFullReportChange
|
||||
FsRtlNotifyReportChange
|
||||
FsRtlNotifyUninitializeSync
|
||||
FsRtlNumberOfRunsInMcb
|
||||
FsRtlPostPagingFileStackOverflow
|
||||
FsRtlPostStackOverflow
|
||||
FsRtlPrepareMdlWrite
|
||||
FsRtlPrepareMdlWriteDev
|
||||
FsRtlPrivateLock
|
||||
FsRtlProcessFileLock
|
||||
FsRtlRegisterFileSystemFilterCallbacks
|
||||
FsRtlReleaseFile
|
||||
FsRtlRemoveMcbEntry
|
||||
FsRtlRemovePerFileObjectContext
|
||||
FsRtlRemovePerStreamContext
|
||||
FsRtlResetLargeMcb
|
||||
FsRtlSyncVolumes
|
||||
FsRtlTeardownPerStreamContexts
|
||||
FsRtlTruncateMcb
|
||||
FsRtlUninitializeFileLock
|
||||
FsRtlUninitializeMcb
|
||||
HalAdjustResourceList
|
||||
HalAllocateCommonBuffer
|
||||
HalAssignSlotResources
|
||||
HalCalibratePerformanceCounter
|
||||
HalFlushCommonBuffer
|
||||
HalFreeCommonBuffer
|
||||
HalGetAdapter
|
||||
HalGetBusData
|
||||
HalGetBusDataByOffset
|
||||
HalGetDmaAlignmentRequirement
|
||||
HalMakeBeep
|
||||
HalQueryDisplayParameters
|
||||
HalQueryRealTimeClock
|
||||
HalReadDmaCounter
|
||||
HalRequestIpi
|
||||
HalSetBusData
|
||||
HalSetBusDataByOffset
|
||||
HalSetDisplayParameters
|
||||
HalSetRealTimeClock
|
||||
HalStartNextProcessor
|
||||
IoAcquireCancelSpinLock
|
||||
IoAcquireRemoveLockEx
|
||||
IoAcquireVpbSpinLock
|
||||
IoAllocateAdapterChannel
|
||||
IoAllocateController
|
||||
IoAllocateDriverObjectExtension
|
||||
IoAllocateErrorLogEntry
|
||||
IoAllocateIrp
|
||||
IoAllocateMdl
|
||||
IoAllocateWorkItem
|
||||
IoAssignResources
|
||||
IoAttachDevice
|
||||
IoAttachDeviceByPointer
|
||||
IoAttachDeviceToDeviceStack
|
||||
IoAttachDeviceToDeviceStackSafe
|
||||
IoBuildAsynchronousFsdRequest
|
||||
IoBuildDeviceIoControlRequest
|
||||
IoBuildPartialMdl
|
||||
IoBuildSynchronousFsdRequest
|
||||
IoCallDriver
|
||||
IoCancelFileOpen
|
||||
IoCancelIrp
|
||||
IoCheckQuerySetFileInformation
|
||||
IoCheckQuerySetVolumeInformation
|
||||
IoCheckQuotaBufferValidity
|
||||
IoCheckShareAccess
|
||||
IoCompleteRequest
|
||||
IoConnectInterrupt
|
||||
IoCreateController
|
||||
IoCreateDevice
|
||||
IoCreateDisk
|
||||
IoCreateDriver
|
||||
IoCreateFile
|
||||
IoCreateFileSpecifyDeviceObjectHint
|
||||
IoCreateNotificationEvent
|
||||
IoCreateStreamFileObject
|
||||
IoCreateStreamFileObjectEx
|
||||
IoCreateStreamFileObjectLite
|
||||
IoCreateSymbolicLink
|
||||
IoCreateSynchronizationEvent
|
||||
IoCreateUnprotectedSymbolicLink
|
||||
IoDeleteController
|
||||
IoDeleteDevice
|
||||
IoDeleteDriver
|
||||
IoDeleteSymbolicLink
|
||||
IoDetachDevice
|
||||
IoDisconnectInterrupt
|
||||
IoEnqueueIrp
|
||||
IoEnumerateDeviceObjectList
|
||||
IoFlushAdapterBuffers
|
||||
IoForwardIrpSynchronously
|
||||
IoFreeAdapterChannel
|
||||
IoFreeController
|
||||
IoFreeErrorLogEntry
|
||||
IoFreeIrp
|
||||
IoFreeMapRegisters
|
||||
IoFreeMdl
|
||||
IoFreeWorkItem
|
||||
IoGetAttachedDevice
|
||||
IoGetAttachedDeviceReference
|
||||
IoGetBaseFileSystemDeviceObject
|
||||
IoGetBootDiskInformation
|
||||
IoGetConfigurationInformation
|
||||
IoGetCurrentProcess
|
||||
IoGetDeviceAttachmentBaseRef
|
||||
IoGetDeviceInterfaceAlias
|
||||
IoGetDeviceInterfaces
|
||||
IoGetDeviceObjectPointer
|
||||
IoGetDeviceProperty
|
||||
IoGetDeviceToVerify
|
||||
IoGetDiskDeviceObject
|
||||
IoGetDriverObjectExtension
|
||||
IoGetFileObjectGenericMapping
|
||||
IoGetInitialStack
|
||||
IoGetLowerDeviceObject
|
||||
IoGetRelatedDeviceObject
|
||||
IoGetRequestorProcess
|
||||
IoGetRequestorProcessId
|
||||
IoGetRequestorSessionId
|
||||
IoGetStackLimits
|
||||
IoGetTopLevelIrp
|
||||
IoInitializeIrp
|
||||
IoInitializeRemoveLockEx
|
||||
IoInitializeTimer
|
||||
IoInvalidateDeviceRelations
|
||||
IoInvalidateDeviceState
|
||||
IoIsFileOriginRemote
|
||||
IoIsOperationSynchronous
|
||||
IoIsSystemThread
|
||||
IoIsValidNameGraftingBuffer
|
||||
IoMakeAssociatedIrp
|
||||
IoMapTransfer
|
||||
IoOpenDeviceInstanceKey
|
||||
IoOpenDeviceInterfaceRegistryKey
|
||||
IoOpenDeviceRegistryKey
|
||||
IoPageRead
|
||||
IoPnPDeliverServicePowerNotification
|
||||
IoQueryDeviceDescription
|
||||
IoQueryDeviceEnumInfo
|
||||
IoQueryFileDosDeviceName
|
||||
IoQueryFileInformation
|
||||
IoQueryVolumeInformation
|
||||
IoQueueThreadIrp
|
||||
IoQueueWorkItem
|
||||
IoRaiseHardError
|
||||
IoRaiseInformationalHardError
|
||||
IoReadDiskSignature
|
||||
IoReadPartitionTableEx
|
||||
IoRegisterBootDriverReinitialization
|
||||
IoRegisterDeviceInterface
|
||||
IoRegisterDriverReinitialization
|
||||
IoRegisterFileSystem
|
||||
IoRegisterFsRegistrationChange
|
||||
IoRegisterLastChanceShutdownNotification
|
||||
IoRegisterPlugPlayNotification
|
||||
IoRegisterShutdownNotification
|
||||
IoReleaseCancelSpinLock
|
||||
IoReleaseRemoveLockAndWaitEx
|
||||
IoReleaseRemoveLockEx
|
||||
IoReleaseVpbSpinLock
|
||||
IoRemoveShareAccess
|
||||
IoReportDetectedDevice
|
||||
IoReportHalResourceUsage
|
||||
IoReportResourceForDetection
|
||||
IoReportResourceUsage
|
||||
IoReportTargetDeviceChange
|
||||
IoReportTargetDeviceChangeAsynchronous
|
||||
IoRequestDeviceEject
|
||||
IoReuseIrp
|
||||
IoSetCompletionRoutineEx
|
||||
IoSetDeviceInterfaceState
|
||||
IoSetDeviceToVerify
|
||||
IoSetFileOrigin
|
||||
IoSetHardErrorOrVerifyDevice
|
||||
IoSetInformation
|
||||
IoSetIoCompletion
|
||||
IoSetPartitionInformationEx
|
||||
IoSetShareAccess
|
||||
IoSetStartIoAttributes
|
||||
IoSetSystemPartition
|
||||
IoSetThreadHardErrorMode
|
||||
IoSetTopLevelIrp
|
||||
IoStartNextPacket
|
||||
IoStartNextPacketByKey
|
||||
IoStartPacket
|
||||
IoStartTimer
|
||||
IoStopTimer
|
||||
IoSynchronousInvalidateDeviceRelations
|
||||
IoSynchronousPageWrite
|
||||
IoUnregisterFileSystem
|
||||
IoUnregisterFsRegistrationChange
|
||||
IoUnregisterPlugPlayNotification
|
||||
IoUnregisterShutdownNotification
|
||||
IoUpdateShareAccess
|
||||
IoValidateDeviceIoControlAccess
|
||||
IoVerifyPartitionTable
|
||||
IoVerifyVolume
|
||||
IoVolumeDeviceToDosName
|
||||
IoWMIAllocateInstanceIds
|
||||
IoWMIDeviceObjectToInstanceName
|
||||
IoWMIExecuteMethod
|
||||
IoWMIHandleToInstanceName
|
||||
IoWMIOpenBlock
|
||||
IoWMIQueryAllData
|
||||
IoWMIQueryAllDataMultiple
|
||||
IoWMIQuerySingleInstance
|
||||
IoWMIQuerySingleInstanceMultiple
|
||||
IoWMIRegistrationControl
|
||||
IoWMISetNotificationCallback
|
||||
IoWMISetSingleInstance
|
||||
IoWMISetSingleItem
|
||||
IoWMISuggestInstanceName
|
||||
IoWMIWriteEvent
|
||||
IoWriteErrorLogEntry
|
||||
IoWritePartitionTableEx
|
||||
KPRIORITY
|
||||
KdPortGetByte
|
||||
KdPortPollByte
|
||||
KdPortPutByte
|
||||
Ke386QueryIoAccessMap
|
||||
Ke386SetIoAccessMap
|
||||
KeAcquireInterruptSpinLock
|
||||
KeAreApcsDisabled
|
||||
KeCapturePersistentThreadState
|
||||
KeDeregisterBugCheckReasonCallback
|
||||
KeFindConfigurationEntry
|
||||
KeFindConfigurationNextEntry
|
||||
KeFlushEntireTb
|
||||
KeFlushQueuedDpcs
|
||||
KeGetRecommendedSharedDataAlignment
|
||||
KeIsExecutingDpc
|
||||
KeQueryActiveProcessors
|
||||
KeQueryPerformanceCounter
|
||||
KeQueryPriorityThread
|
||||
KeQueryRuntimeThread
|
||||
KeQuerySystemTime
|
||||
KeQueryTickCount
|
||||
KeQueryTimeIncrement
|
||||
KeRaiseIrql
|
||||
KeRaiseIrqlToDpcLevel
|
||||
KeRaiseUserException
|
||||
KeReadStateEvent
|
||||
KeRegisterBugCheckCallback
|
||||
KeRegisterBugCheckReasonCallback
|
||||
KeReleaseInterruptSpinLock
|
||||
KeReleaseMutant
|
||||
KeReleaseMutex
|
||||
KeReleaseSemaphore
|
||||
KeReleaseSpinLock
|
||||
KeReleaseSpinLockFromDpcLevel
|
||||
KeReleaseSpinLockFromDpcLevel
|
||||
KeRemoveByKeyDeviceQueue
|
||||
KeRemoveByKeyDeviceQueueIfBusy
|
||||
KeRemoveDeviceQueue
|
||||
KeRemoveEntryDeviceQueue
|
||||
KeRemoveSystemServiceTable
|
||||
KeRestoreFloatingPointState
|
||||
KeRevertToUserAffinityThread
|
||||
KeRosDumpStackFrames
|
||||
KeRosGetStackFrames
|
||||
KeRosPrintAddress
|
||||
KeSaveFloatingPointState
|
||||
KeSetDmaIoCoherency
|
||||
KeSetEvent
|
||||
KeSetEventBoostPriority
|
||||
KeSetIdealProcessorThread
|
||||
KeSetKernelStackSwapEnable
|
||||
KeSetProfileIrql
|
||||
KeSetSystemAffinityThread
|
||||
KeSetTimeIncrement
|
||||
KeTerminateThread
|
||||
KeUserModeCallback
|
||||
KeWaitForMutexObject
|
||||
KeWaitForSingleObject
|
||||
KiCoprocessorError
|
||||
KiUnexpectedInterrupt
|
||||
LONG
|
||||
LdrFindResourceDirectory_U
|
||||
MmAddPhysicalMemory
|
||||
MmAddVerifierThunks
|
||||
MmAdjustWorkingSetSize
|
||||
MmAdvanceMdl
|
||||
MmAllocateContiguousMemory
|
||||
MmAllocateContiguousMemorySpecifyCache
|
||||
MmAllocateMappingAddress
|
||||
MmAllocateNonCachedMemory
|
||||
MmBuildMdlForNonPagedPool
|
||||
MmCanFileBeTruncated
|
||||
MmCreateMdl
|
||||
MmCreateSection
|
||||
MmDbgTranslatePhysicalAddress
|
||||
MmDisableModifiedWriteOfSection
|
||||
MmFlushImageSection
|
||||
MmForceSectionClosed
|
||||
MmFreeContiguousMemory
|
||||
MmFreeMappingAddress
|
||||
MmFreeNonCachedMemory
|
||||
MmGetPhysicalAddress
|
||||
MmGetPhysicalMemoryRanges
|
||||
MmGetSystemRoutineAddress
|
||||
MmGetVirtualForPhysical
|
||||
MmGrowKernelStack
|
||||
MmIsAddressValid
|
||||
MmIsDriverVerifying
|
||||
MmIsNonPagedSystemAddressValid
|
||||
MmIsRecursiveIoFault
|
||||
MmIsThisAnNtAsSystem
|
||||
MmIsVerifierEnabled
|
||||
MmLockPagableDataSection
|
||||
MmLockPagableImageSection
|
||||
MmLockPagableSectionByHandle
|
||||
MmMapIoSpace
|
||||
MmMapLockedPages
|
||||
MmMapLockedPagesWithReservedMapping
|
||||
MmMapMemoryDumpMdl
|
||||
MmMapUserAddressesToPage
|
||||
MmMapVideoDisplay
|
||||
MmMapViewInSessionSpace
|
||||
MmMapViewInSystemSpace
|
||||
MmMapViewOfSection
|
||||
MmMarkPhysicalMemoryAsBad
|
||||
MmMarkPhysicalMemoryAsGood
|
||||
MmPageEntireDriver
|
||||
MmPrefetchPages
|
||||
MmProbeAndLockPages
|
||||
MmProbeAndLockProcessPages
|
||||
MmProbeAndLockSelectedPages
|
||||
MmProtectMdlSystemAddress
|
||||
MmQuerySystemSize
|
||||
MmRemovePhysicalMemory
|
||||
MmResetDriverPaging
|
||||
MmSecureVirtualMemory
|
||||
MmSetAddressRangeModified
|
||||
MmSetBankedSection
|
||||
MmSizeOfMdl
|
||||
MmTrimAllSystemPagableMemory
|
||||
MmUnlockPagableImageSection
|
||||
MmUnlockPages
|
||||
MmUnmapIoSpace
|
||||
MmUnmapLockedPages
|
||||
MmUnmapReservedMapping
|
||||
MmUnmapVideoDisplay
|
||||
MmUnmapViewInSessionSpace
|
||||
MmUnmapViewInSystemSpace
|
||||
MmUnmapViewOfSection
|
||||
MmUnsecureVirtualMemory
|
||||
OUT
|
||||
ObCreateObject
|
||||
PEJOB
|
||||
PEPROCESS
|
||||
PKBUGCHECK_CALLBACK_RECORD
|
||||
PKDEVICE_QUEUE_ENTRY
|
||||
PKIRQL
|
||||
PULONG
|
||||
PVOID
|
||||
PW32_THREAD_CALLBACK
|
||||
PoCallDriver
|
||||
PoRegisterDeviceForIdleDetection
|
||||
PoRegisterSystemState
|
||||
PoRequestPowerIrp
|
||||
PoSetDeviceBusy
|
||||
PoSetPowerState
|
||||
PoSetSystemState
|
||||
PoStartNextPowerIrp
|
||||
PoUnregisterSystemState
|
||||
ProbeForRead
|
||||
ProbeForWrite
|
||||
PsAssignImpersonationToken
|
||||
PsCreateSystemProcess
|
||||
PsCreateSystemThread
|
||||
PsGetCurrentProcessId
|
||||
PsGetCurrentThreadId
|
||||
PsImpersonateClient
|
||||
PsReferenceImpersonationToken
|
||||
PsReferencePrimaryToken
|
||||
PsRevertThreadToSelf
|
||||
PsRevertToSelf
|
||||
PsTerminateSystemThread
|
||||
READ_PORT_BUFFER_UCHAR
|
||||
READ_PORT_BUFFER_ULONG
|
||||
READ_PORT_BUFFER_USHORT
|
||||
READ_PORT_UCHAR
|
||||
READ_PORT_ULONG
|
||||
READ_PORT_USHORT
|
||||
SeAssignSecurityEx
|
||||
SeAuditHardLinkCreation
|
||||
SeAuditingFileEvents
|
||||
SeAuditingFileEventsWithContext
|
||||
SeAuditingFileOrGlobalEvents
|
||||
SeAuditingHardLinkEvents
|
||||
SeAuditingHardLinkEventsWithContext
|
||||
SeCaptureSecurityDescriptor
|
||||
SeCaptureSubjectContext
|
||||
SeCloseObjectAuditAlarm
|
||||
SeCreateAccessState
|
||||
SeCreateClientSecurityFromSubjectContext
|
||||
SeFilterToken
|
||||
SeImpersonateClientEx
|
||||
SePrivilegeObjectAuditAlarm
|
||||
SeQueryInformationToken
|
||||
SeQuerySessionIdToken
|
||||
SeReleaseSecurityDescriptor
|
||||
SeSetSecurityDescriptorInfoEx
|
||||
SeTokenIsAdmin
|
||||
SeTokenIsRestricted
|
||||
SeTokenIsWriteRestricted
|
||||
WRITE_PORT_BUFFER_UCHAR
|
||||
WRITE_PORT_BUFFER_ULONG
|
||||
WRITE_PORT_BUFFER_USHORT
|
||||
WRITE_PORT_UCHAR
|
||||
WRITE_PORT_ULONG
|
||||
WRITE_PORT_USHORT
|
@@ -1,10 +0,0 @@
|
||||
/me bows humbly and begs %s's forgiveness
|
||||
%s is soo cool... I hope to be like him some day
|
||||
/me hides in a corner and hopes %s doesn't beat him with the whipping noodle again
|
||||
/me prostrates at %s's feet and begs his majesty's forgiveness
|
||||
%s: please don't hurt me!
|
||||
I'm not worthy... I'm not worthy...
|
||||
/me sings %s's praises to the world!
|
||||
/me thinks %s is smarter than %dev%
|
||||
%s: oh please may I defrag your sock drawer?
|
||||
/me gives %s a cookie, hoping it will make up for breaking %func% the other day...
|
@@ -1 +0,0 @@
|
||||
/me is bored
|
@@ -1,9 +0,0 @@
|
||||
PASSIVE_LEVEL
|
||||
APC_LEVEL
|
||||
DISPATCH_LEVEL
|
||||
PROFILE_LEVEL
|
||||
CLOCK1_LEVEL
|
||||
IPI_LEVEL
|
||||
POWER_LEVEL
|
||||
HIGH_LEVEL
|
||||
SYNCH_LEVEL
|
@@ -1,13 +0,0 @@
|
||||
the kernel
|
||||
ntoskrnl
|
||||
win32k
|
||||
msafd
|
||||
ws2_32
|
||||
user32
|
||||
shell32
|
||||
the cache manager
|
||||
tdi
|
||||
the scheduler
|
||||
the thread queue
|
||||
the message queue
|
||||
atapi
|
@@ -1,5 +0,0 @@
|
||||
/me slaps %s with a large trout
|
||||
recycle(%s)
|
||||
Did I hear something? Musta been a %s-fly... Where's that fly-swatter?
|
||||
%s: go away son, you bother me....
|
||||
/me beats %s with the whipping noodle
|
@@ -1,34 +0,0 @@
|
||||
// panic.cpp
|
||||
// This file is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef WIN32
|
||||
#include <conio.h>
|
||||
#include <windows.h>
|
||||
#endif//WIN32
|
||||
#include "panic.h"
|
||||
|
||||
void panic ( const char* format, ... )
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
|
||||
va_start(arg, format);
|
||||
#if defined(WIN32) && !defined(_CONSOLE)
|
||||
char buf[4096];
|
||||
_vsnprintf ( buf, sizeof(buf)-1, format, arg );
|
||||
MessageBox ( NULL, buf, "Panic!", MB_OK|MB_ICONEXCLAMATION );
|
||||
#else
|
||||
done = vprintf(format, arg);
|
||||
printf ( "\n" );
|
||||
#endif
|
||||
va_end(arg);
|
||||
#if defined(WIN32) && defined(_CONSOLE)
|
||||
printf ( "Press any key to exit\n" );
|
||||
(void)getch();
|
||||
#endif//WIN32 && _CONSOLE
|
||||
exit ( -1 );
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
// panic.h
|
||||
// This file is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef PANIC_H
|
||||
#define PANIC_H
|
||||
|
||||
void panic ( const char* format, ... );
|
||||
|
||||
#define suAssert(expr) if ( !(expr) ) panic ( "%s(%lu): SOCKET ERROR %s\nExpression: %s\n", __FILE__, __LINE__, suErrDesc(SUERRNO), #expr )
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
# define suVerify(expr) suAssert(expr)
|
||||
#else
|
||||
# define suVerify(expr) expr
|
||||
#endif
|
||||
|
||||
#endif//PANIC_H
|
@@ -1,11 +0,0 @@
|
||||
minute
|
||||
hour
|
||||
day
|
||||
week
|
||||
fortnight
|
||||
month
|
||||
year
|
||||
decade
|
||||
century
|
||||
millenium
|
||||
eon
|
@@ -1,44 +0,0 @@
|
||||
This doc can be also found on the wiki.
|
||||
|
||||
ArchBlackman is a IRC-Chat bot of the #reactos irc channel. He has been coded by Royce3 and DrFred (mbosma) currently runs him.
|
||||
|
||||
|
||||
If some one use a swear word he'll tell him not to do so and you can also ask him something technical about reactos. :)
|
||||
|
||||
Besides this he also knows some commands. The systax for giving him commands "ArchBlackmann: !grovel". (don't forget to address him)
|
||||
|
||||
- !grovel - This is the only command that non ops can do (No Parameter)
|
||||
- !kiss <person>
|
||||
- !hug <person>
|
||||
- !give <someone> <something>
|
||||
- !say <something> - You can tell him to say something on the channel via PrivateMessage
|
||||
|
||||
|
||||
ArchBlackmann know what he should say from some text files. They can be found on the svn-dir. But can also edit them online if you are op using:
|
||||
|
||||
- !add <list> <item>
|
||||
- !remove <list> <item>
|
||||
|
||||
List that are used directly to create responses are:
|
||||
|
||||
- tech - here are the sentces ArchBlackmann sais when he finds his name
|
||||
- curse - this are the curses he looks for
|
||||
- cursecop - this the responces to them
|
||||
- grovel - this is said when a op does the grovel command
|
||||
- nogrovel - this when someone else does it
|
||||
|
||||
The remaining lists are not used directly, but by the other lists.
|
||||
|
||||
They are:
|
||||
|
||||
- dev
|
||||
- func
|
||||
- irql
|
||||
- module
|
||||
- period
|
||||
- status
|
||||
- stru
|
||||
- type
|
||||
|
||||
And they are used like this:
|
||||
/me thinks %s is smarter than %dev%
|
@@ -1,998 +0,0 @@
|
||||
// ssprintf.cpp
|
||||
|
||||
#include <malloc.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <assert.h>
|
||||
#include "ssprintf.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define alloca _alloca
|
||||
#endif//_MSC_VER
|
||||
|
||||
typedef __int64 LONGLONG;
|
||||
typedef unsigned __int64 ULONGLONG;
|
||||
|
||||
typedef struct {
|
||||
unsigned int mantissa:23;
|
||||
unsigned int exponent:8;
|
||||
unsigned int sign:1;
|
||||
} ieee_float_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int mantissal:32;
|
||||
unsigned int mantissah:20;
|
||||
unsigned int exponent:11;
|
||||
unsigned int sign:1;
|
||||
} ieee_double_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int mantissal:32;
|
||||
unsigned int mantissah:32;
|
||||
unsigned int exponent:15;
|
||||
unsigned int sign:1;
|
||||
unsigned int empty:16;
|
||||
} ieee_long_double_t;
|
||||
|
||||
std::string ssprintf ( const char* fmt, ... )
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, fmt);
|
||||
std::string f = ssvprintf ( fmt, arg );
|
||||
va_end(arg);
|
||||
return f;
|
||||
}
|
||||
|
||||
#define ZEROPAD 1 /* pad with zero */
|
||||
#define SIGN 2 /* unsigned/signed long */
|
||||
#define PLUS 4 /* show plus */
|
||||
#define SPACE 8 /* space if plus */
|
||||
#define LEFT 16 /* left justified */
|
||||
#define SPECIAL 32 /* 0x */
|
||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
#define ZEROTRUNC 128 /* truncate zero 's */
|
||||
|
||||
|
||||
static int skip_atoi(const char **s)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while (isdigit(**s))
|
||||
i = i*10 + *((*s)++) - '0';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static int do_div(LONGLONG *n,int base)
|
||||
{
|
||||
int __res = ((ULONGLONG) *n) % (unsigned) base;
|
||||
*n = ((ULONGLONG) *n) / (unsigned) base;
|
||||
return __res;
|
||||
}
|
||||
|
||||
|
||||
static bool number(std::string& f, LONGLONG num, int base, int size, int precision ,int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
int i;
|
||||
|
||||
if (type & LARGE)
|
||||
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++]='0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(&num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
while(size-->0)
|
||||
f += ' ';
|
||||
if (sign)
|
||||
f += sign;
|
||||
if (type & SPECIAL)
|
||||
{
|
||||
if (base==8)
|
||||
f += '0';
|
||||
else if (base==16)
|
||||
{
|
||||
f += '0';
|
||||
f += digits[33];
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT))
|
||||
{
|
||||
while (size-- > 0)
|
||||
f += c;
|
||||
}
|
||||
while (i < precision--)
|
||||
{
|
||||
f += '0';
|
||||
}
|
||||
while (i-- > 0)
|
||||
{
|
||||
f += tmp[i];
|
||||
}
|
||||
while (size-- > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool numberf(std::string& f, double __n, char exp_sign, int size, int precision, int type)
|
||||
{
|
||||
double exponent = 0.0;
|
||||
double e;
|
||||
long ie;
|
||||
|
||||
//int x;
|
||||
char *buf, *tmp;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
//int k = 0;
|
||||
|
||||
double frac, intr;
|
||||
double p;
|
||||
char sign;
|
||||
char c;
|
||||
char ro = 0;
|
||||
int result;
|
||||
|
||||
union
|
||||
{
|
||||
double* __n;
|
||||
ieee_double_t* n;
|
||||
} n;
|
||||
|
||||
n.__n = &__n;
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) {
|
||||
ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
|
||||
exponent = ie/3.321928;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' ) {
|
||||
type |= ZEROTRUNC;
|
||||
if ( exponent < -4 || fabs(exponent) >= precision )
|
||||
exp_sign -= 2; // g -> e and G -> E
|
||||
}
|
||||
|
||||
if ( exp_sign == 'e' || exp_sign == 'E' ) {
|
||||
frac = modf(exponent,&e);
|
||||
if ( frac > 0.5 )
|
||||
e++;
|
||||
else if ( frac < -0.5 )
|
||||
e--;
|
||||
|
||||
result = numberf(f,__n/pow(10.0L,e),'f',size-4, precision, type);
|
||||
if (result < 0)
|
||||
return false;
|
||||
f += exp_sign;
|
||||
size--;
|
||||
ie = (long)e;
|
||||
type = LEFT | PLUS;
|
||||
if ( ie < 0 )
|
||||
type |= SIGN;
|
||||
|
||||
result = number(f,ie, 10,2, 2,type );
|
||||
if (result < 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'f' ) {
|
||||
buf = (char*)alloca(4096);
|
||||
if (type & LEFT) {
|
||||
type &= ~ZEROPAD;
|
||||
}
|
||||
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (__n < 0) {
|
||||
sign = '-';
|
||||
__n = fabs(__n);
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
frac = modf(__n,&intr);
|
||||
|
||||
// # flags forces a . and prevents trucation of trailing zero's
|
||||
|
||||
if ( precision > 0 ) {
|
||||
//frac = modfl(__n,&intr);
|
||||
i = precision-1;
|
||||
while ( i >= 0 ) {
|
||||
frac*=10.0L;
|
||||
frac = modf(frac, &p);
|
||||
buf[i] = (int)p + '0';
|
||||
i--;
|
||||
}
|
||||
i = precision;
|
||||
size -= precision;
|
||||
|
||||
ro = 0;
|
||||
if ( frac > 0.5 ) {
|
||||
ro = 1;
|
||||
}
|
||||
|
||||
if ( precision >= 1 || type & SPECIAL) {
|
||||
buf[i++] = '.';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if ( intr == 0.0 ) {
|
||||
buf[i++] = '0';
|
||||
size--;
|
||||
}
|
||||
else {
|
||||
while ( intr > 0.0 ) {
|
||||
p = intr;
|
||||
intr/=10.0L;
|
||||
modf(intr, &intr);
|
||||
|
||||
p -= 10.0*intr;
|
||||
|
||||
buf[i++] = (int)p + '0';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while ( j < i && ro == 1) {
|
||||
if ( buf[j] >= '0' && buf[j] <= '8' ) {
|
||||
buf[j]++;
|
||||
ro = 0;
|
||||
}
|
||||
else if ( buf[j] == '9' ) {
|
||||
buf[j] = '0';
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if ( ro == 1 )
|
||||
buf[i++] = '1';
|
||||
|
||||
buf[i] = 0;
|
||||
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
{
|
||||
while(size-->0)
|
||||
f += ' ';
|
||||
}
|
||||
if (sign)
|
||||
{
|
||||
f += sign;
|
||||
}
|
||||
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
while(size-->0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
}
|
||||
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
{
|
||||
f += c;
|
||||
}
|
||||
|
||||
tmp = buf;
|
||||
if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) )
|
||||
{
|
||||
j = 0;
|
||||
while ( j < i && ( *tmp == '0' || *tmp == '.' ))
|
||||
{
|
||||
tmp++;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
// else
|
||||
// while (i < precision--)
|
||||
// putc('0', f);
|
||||
while (i-- > 0)
|
||||
{
|
||||
f += tmp[i];
|
||||
}
|
||||
while (size-- > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool numberfl(std::string& f, long double __n, char exp_sign, int size, int precision, int type)
|
||||
{
|
||||
long double exponent = 0.0;
|
||||
long double e;
|
||||
long ie;
|
||||
|
||||
//int x;
|
||||
char *buf, *tmp;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
//int k = 0;
|
||||
|
||||
long double frac, intr;
|
||||
long double p;
|
||||
char sign;
|
||||
char c;
|
||||
char ro = 0;
|
||||
|
||||
int result;
|
||||
|
||||
union
|
||||
{
|
||||
long double* __n;
|
||||
ieee_long_double_t* n;
|
||||
} n;
|
||||
|
||||
n.__n = &__n;
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) {
|
||||
ie = ((unsigned int)n.n->exponent - (unsigned int)0x3fff);
|
||||
exponent = ie/3.321928;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' ) {
|
||||
type |= ZEROTRUNC;
|
||||
if ( exponent < -4 || fabs(exponent) >= precision )
|
||||
exp_sign -= 2; // g -> e and G -> E
|
||||
}
|
||||
|
||||
if ( exp_sign == 'e' || exp_sign == 'E' ) {
|
||||
frac = modfl(exponent,&e);
|
||||
if ( frac > 0.5 )
|
||||
e++;
|
||||
else if ( frac < -0.5 )
|
||||
e--;
|
||||
|
||||
result = numberf(f,__n/powl(10.0L,e),'f',size-4, precision, type);
|
||||
if (result < 0)
|
||||
return false;
|
||||
f += exp_sign;
|
||||
size--;
|
||||
ie = (long)e;
|
||||
type = LEFT | PLUS;
|
||||
if ( ie < 0 )
|
||||
type |= SIGN;
|
||||
|
||||
result = number(f,ie, 10,2, 2,type );
|
||||
if (result < 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'f' )
|
||||
{
|
||||
|
||||
buf = (char*)alloca(4096);
|
||||
if (type & LEFT)
|
||||
{
|
||||
type &= ~ZEROPAD;
|
||||
}
|
||||
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN)
|
||||
{
|
||||
if (__n < 0)
|
||||
{
|
||||
sign = '-';
|
||||
__n = fabs(__n);
|
||||
size--;
|
||||
} else if (type & PLUS)
|
||||
{
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE)
|
||||
{
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
frac = modfl(__n,&intr);
|
||||
|
||||
// # flags forces a . and prevents trucation of trailing zero's
|
||||
if ( precision > 0 )
|
||||
{
|
||||
//frac = modfl(__n,&intr);
|
||||
|
||||
i = precision-1;
|
||||
while ( i >= 0 )
|
||||
{
|
||||
frac*=10.0L;
|
||||
frac = modfl((long double)frac, &p);
|
||||
buf[i] = (int)p + '0';
|
||||
i--;
|
||||
}
|
||||
i = precision;
|
||||
size -= precision;
|
||||
|
||||
ro = 0;
|
||||
if ( frac > 0.5 )
|
||||
{
|
||||
ro = 1;
|
||||
}
|
||||
|
||||
if ( precision >= 1 || type & SPECIAL)
|
||||
{
|
||||
buf[i++] = '.';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if ( intr == 0.0 )
|
||||
{
|
||||
buf[i++] = '0';
|
||||
size--;
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( intr > 0.0 )
|
||||
{
|
||||
p=intr;
|
||||
intr/=10.0L;
|
||||
modfl(intr, &intr);
|
||||
|
||||
p -= 10.0L*intr;
|
||||
|
||||
buf[i++] = (int)p + '0';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while ( j < i && ro == 1) {
|
||||
if ( buf[j] >= '0' && buf[j] <= '8' )
|
||||
{
|
||||
buf[j]++;
|
||||
ro = 0;
|
||||
}
|
||||
else if ( buf[j] == '9' )
|
||||
{
|
||||
buf[j] = '0';
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if ( ro == 1 )
|
||||
buf[i++] = '1';
|
||||
|
||||
buf[i] = 0;
|
||||
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
{
|
||||
while(size-->0)
|
||||
f += ' ';
|
||||
}
|
||||
if (sign)
|
||||
{
|
||||
f += sign;
|
||||
}
|
||||
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
{
|
||||
while(size-->0)
|
||||
f += ' ';
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
}
|
||||
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
{
|
||||
f += c;
|
||||
}
|
||||
tmp = buf;
|
||||
if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) )
|
||||
{
|
||||
j = 0;
|
||||
while ( j < i && ( *tmp == '0' || *tmp == '.' ))
|
||||
{
|
||||
tmp++;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
// else
|
||||
// while (i < precision--)
|
||||
// putc( '0', f);
|
||||
while (i-- > 0)
|
||||
{
|
||||
f += tmp[i];
|
||||
}
|
||||
while (size-- > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int string(std::string& f, const char* s, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i, done = 0;
|
||||
if (s == NULL)
|
||||
{
|
||||
s = "<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && s[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
f += ' ';
|
||||
done++;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
f += *s++;
|
||||
done++;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
f += ' ';
|
||||
done++;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
static int stringw(std::string& f, const wchar_t* sw, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i, done = 0;
|
||||
if (sw == NULL)
|
||||
{
|
||||
sw = L"<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && sw[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
f += ' ';
|
||||
done++;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
#define MY_MB_CUR_MAX 1
|
||||
char mb[MY_MB_CUR_MAX];
|
||||
int mbcount, j;
|
||||
mbcount = wctomb(mb, *sw++);
|
||||
if (mbcount <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < mbcount; j++)
|
||||
{
|
||||
f += mb[j];
|
||||
done++;
|
||||
}
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
f += ' ';
|
||||
done++;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#define _isnanl _isnan
|
||||
#define _finitel _finite
|
||||
|
||||
std::string ssvprintf ( const char *fmt, va_list args )
|
||||
{
|
||||
ULONGLONG num;
|
||||
int base;
|
||||
long double _ldouble;
|
||||
double _double;
|
||||
const char *s;
|
||||
const unsigned short* sw;
|
||||
int result;
|
||||
std::string f;
|
||||
|
||||
int flags; /* flags to number() */
|
||||
|
||||
int field_width; /* width of output field */
|
||||
int precision; /* min. # of digits for integers; max
|
||||
number of chars for from string */
|
||||
int qualifier = 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
|
||||
|
||||
for (; *fmt ; ++fmt)
|
||||
{
|
||||
if (*fmt != '%')
|
||||
{
|
||||
f += *fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* process flags */
|
||||
flags = 0;
|
||||
repeat:
|
||||
++fmt; /* this also skips first '%' */
|
||||
switch (*fmt) {
|
||||
case '-': flags |= LEFT; goto repeat;
|
||||
case '+': flags |= PLUS; goto repeat;
|
||||
case ' ': flags |= SPACE; goto repeat;
|
||||
case '#': flags |= SPECIAL; goto repeat;
|
||||
case '0': flags |= ZEROPAD; goto repeat;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
if (isdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the precision */
|
||||
precision = -1;
|
||||
if (*fmt == '.') {
|
||||
++fmt;
|
||||
if (isdigit(*fmt))
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
/* get the conversion qualifier */
|
||||
qualifier = 0;
|
||||
// %Z can be just stand alone or as size_t qualifier
|
||||
if ( *fmt == 'Z' ) {
|
||||
qualifier = *fmt;
|
||||
switch ( *(fmt+1)) {
|
||||
case 'o':
|
||||
case 'b':
|
||||
case 'X':
|
||||
case 'x':
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'u':
|
||||
++fmt;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
} else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
|
||||
qualifier = *fmt;
|
||||
fmt += 3;
|
||||
}
|
||||
|
||||
// go fine with ll instead of L
|
||||
if ( *fmt == 'l' ) {
|
||||
++fmt;
|
||||
qualifier = 'L';
|
||||
}
|
||||
|
||||
/* default base */
|
||||
base = 10;
|
||||
|
||||
switch (*fmt) {
|
||||
case 'c':
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
if (qualifier == 'l' || qualifier == 'w')
|
||||
{
|
||||
f += (char)(unsigned char)(wchar_t) va_arg(args,int);
|
||||
}
|
||||
else
|
||||
{
|
||||
f += (char)(unsigned char) va_arg(args,int);
|
||||
}
|
||||
while (--field_width > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'C':
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
if (qualifier == 'h')
|
||||
{
|
||||
f += (char)(unsigned char) va_arg(args,int);
|
||||
}
|
||||
else
|
||||
{
|
||||
f += (char)(unsigned char)(wchar_t) va_arg(args,int);
|
||||
}
|
||||
while (--field_width > 0)
|
||||
{
|
||||
f += ' ';
|
||||
}
|
||||
continue;
|
||||
|
||||
case 's':
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
result = stringw(f, sw, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
result = string(f, s, -1, field_width, precision, flags);
|
||||
}
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'S':
|
||||
if (qualifier == 'h') {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
result = string(f, s, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
result = stringw(f, sw, -1, field_width, precision, flags);
|
||||
}
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
continue;
|
||||
|
||||
/*case 'Z':
|
||||
if (qualifier == 'w') {
|
||||
// print counted unicode string
|
||||
PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
sw = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
sw = pus->Buffer;
|
||||
len = pus->Length / sizeof(WCHAR);
|
||||
}
|
||||
result = stringw(f, sw, len, field_width, precision, flags);
|
||||
} else {
|
||||
// print counted ascii string
|
||||
PANSI_STRING pas = va_arg(args, PANSI_STRING);
|
||||
if ((pas == NULL) || (pas->Buffer == NULL)) {
|
||||
s = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
s = pas->Buffer;
|
||||
len = pas->Length;
|
||||
}
|
||||
result = string(f, s, -1, field_width, precision, flags);
|
||||
}
|
||||
if (result < 0)
|
||||
return -1;
|
||||
continue;*/
|
||||
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (qualifier == 'l' || qualifier == 'L' ) {
|
||||
_ldouble = va_arg(args, long double);
|
||||
|
||||
if ( _isnanl(_ldouble) )
|
||||
{
|
||||
f += "Nan";
|
||||
}
|
||||
else if ( !_finitel(_ldouble) )
|
||||
{
|
||||
if ( _ldouble < 0 )
|
||||
f += "-Inf";
|
||||
else
|
||||
f += "+Inf";
|
||||
} else {
|
||||
if ( precision == -1 )
|
||||
precision = 6;
|
||||
result = numberfl(f,_ldouble,*fmt,field_width,precision,flags);
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_double = (double)va_arg(args, double);
|
||||
|
||||
if ( _isnan(_double) )
|
||||
{
|
||||
f += "Nan";
|
||||
}
|
||||
else if ( !_finite(_double) )
|
||||
{
|
||||
if ( _double < 0 )
|
||||
f += "-Inf";
|
||||
else
|
||||
f += "+Inf";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( precision == -1 )
|
||||
precision = 6;
|
||||
result = numberf(f,_double,*fmt,field_width,precision,flags);
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if (field_width == -1) {
|
||||
field_width = 2*sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
result = number(f,
|
||||
(unsigned long) va_arg(args, void *), 16,
|
||||
field_width, precision, flags);
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'n':
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = 0;
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
*ip = 0;
|
||||
}
|
||||
continue;
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
base = 2;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
flags |= LARGE;
|
||||
case 'x':
|
||||
base = 16;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
flags |= SIGN;
|
||||
case 'u':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (*fmt != '%')
|
||||
{
|
||||
f += '%';
|
||||
}
|
||||
if (*fmt)
|
||||
{
|
||||
f += *fmt;
|
||||
}
|
||||
else
|
||||
--fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qualifier == 'I')
|
||||
num = va_arg(args, ULONGLONG);
|
||||
else if (qualifier == 'l') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, long);
|
||||
else
|
||||
num = va_arg(args, unsigned long);
|
||||
}
|
||||
else if (qualifier == 'h') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
else if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
result = number(f, num, base, field_width, precision, flags);
|
||||
if (result < 0)
|
||||
{
|
||||
assert(!"TODO FIXME handle error better");
|
||||
return f;
|
||||
}
|
||||
}
|
||||
//putc('\0',f);
|
||||
return f;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
// ssprintf.h
|
||||
|
||||
#ifndef SSPRINTF_H
|
||||
#define SSPRINTF_H
|
||||
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
|
||||
std::string ssprintf ( const char* fmt, ... );
|
||||
std::string ssvprintf ( const char* fmt, va_list args );
|
||||
|
||||
#endif//SSPRINTF_H
|
@@ -1,654 +0,0 @@
|
||||
RPC_NT_ALREADY_LISTENING
|
||||
RPC_NT_ALREADY_REGISTERED
|
||||
RPC_NT_CALL_FAILED
|
||||
RPC_NT_CALL_FAILED_DNE
|
||||
RPC_NT_CANT_CREATE_ENDPOINT
|
||||
RPC_NT_INVALID_BINDING
|
||||
RPC_NT_INVALID_ENDPOINT_FORMAT
|
||||
RPC_NT_INVALID_NETWORK_OPTIONS
|
||||
RPC_NT_INVALID_NET_ADDR
|
||||
RPC_NT_INVALID_RPC_PROTSEQ
|
||||
RPC_NT_INVALID_STRING_BINDING
|
||||
RPC_NT_INVALID_STRING_UUID
|
||||
RPC_NT_INVALID_TIMEOUT
|
||||
RPC_NT_NOT_LISTENING
|
||||
RPC_NT_NO_BINDINGS
|
||||
RPC_NT_NO_CALL_ACTIVE
|
||||
RPC_NT_NO_ENDPOINT_FOUND
|
||||
RPC_NT_NO_PROTSEQS
|
||||
RPC_NT_NO_PROTSEQS_REGISTERED
|
||||
RPC_NT_OBJECT_NOT_FOUND
|
||||
RPC_NT_OUT_OF_RESOURCES
|
||||
RPC_NT_PROTOCOL_ERROR
|
||||
RPC_NT_PROTSEQ_NOT_SUPPORTED
|
||||
RPC_NT_SERVER_TOO_BUSY
|
||||
RPC_NT_SERVER_UNAVAILABLE
|
||||
RPC_NT_SS_IN_NULL_CONTEXT
|
||||
RPC_NT_TYPE_ALREADY_REGISTERED
|
||||
RPC_NT_UNKNOWN_IF
|
||||
RPC_NT_UNKNOWN_MGR_TYPE
|
||||
RPC_NT_WRONG_KIND_OF_BINDING
|
||||
STATUS_ABANDONED
|
||||
STATUS_ABANDONED_WAIT_0
|
||||
STATUS_ABANDONED_WAIT_63
|
||||
STATUS_ABIOS_INVALID_COMMAND
|
||||
STATUS_ABIOS_INVALID_LID
|
||||
STATUS_ABIOS_INVALID_SELECTOR
|
||||
STATUS_ABIOS_LID_ALREADY_OWNED
|
||||
STATUS_ABIOS_LID_NOT_EXIST
|
||||
STATUS_ABIOS_NOT_LID_OWNER
|
||||
STATUS_ABIOS_NOT_PRESENT
|
||||
STATUS_ABIOS_SELECTOR_NOT_AVAILABLE
|
||||
STATUS_ACCESS_DENIED
|
||||
STATUS_ACCESS_VIOLATION
|
||||
STATUS_ACCOUNT_DISABLED
|
||||
STATUS_ACCOUNT_EXPIRED
|
||||
STATUS_ACCOUNT_LOCKED_OUT
|
||||
STATUS_ACCOUNT_RESTRICTION
|
||||
STATUS_ADAPTER_HARDWARE_ERROR
|
||||
STATUS_ADDRESS_ALREADY_ASSOCIATED
|
||||
STATUS_ADDRESS_ALREADY_EXISTS
|
||||
STATUS_ADDRESS_CLOSED
|
||||
STATUS_ADDRESS_NOT_ASSOCIATED
|
||||
STATUS_AGENTS_EXHAUSTED
|
||||
STATUS_ALERTED
|
||||
STATUS_ALIAS_EXISTS
|
||||
STATUS_ALLOCATE_BUCKET
|
||||
STATUS_ALLOTTED_SPACE_EXCEEDED
|
||||
STATUS_ALREADY_COMMITTED
|
||||
STATUS_ALREADY_DISCONNECTED
|
||||
STATUS_ALREADY_WIN32
|
||||
STATUS_APP_INIT_FAILURE
|
||||
STATUS_ARBITRATION_UNHANDLED
|
||||
STATUS_ARRAY_BOUNDS_EXCEEDED
|
||||
STATUS_AUDIT_FAILED
|
||||
STATUS_BACKUP_CONTROLLER
|
||||
STATUS_BAD_COMPRESSION_BUFFER
|
||||
STATUS_BAD_CURRENT_DIRECTORY
|
||||
STATUS_BAD_DESCRIPTOR_FORMAT
|
||||
STATUS_BAD_DEVICE_TYPE
|
||||
STATUS_BAD_DLL_ENTRYPOINT
|
||||
STATUS_BAD_FUNCTION_TABLE
|
||||
STATUS_BAD_IMPERSONATION_LEVEL
|
||||
STATUS_BAD_INHERITANCE_ACL
|
||||
STATUS_BAD_INITIAL_PC
|
||||
STATUS_BAD_INITIAL_STACK
|
||||
STATUS_BAD_LOGON_SESSION_STATE
|
||||
STATUS_BAD_MASTER_BOOT_RECORD
|
||||
STATUS_BAD_NETWORK_NAME
|
||||
STATUS_BAD_NETWORK_PATH
|
||||
STATUS_BAD_REMOTE_ADAPTER
|
||||
STATUS_BAD_SERVICE_ENTRYPOINT
|
||||
STATUS_BAD_STACK
|
||||
STATUS_BAD_TOKEN_TYPE
|
||||
STATUS_BAD_VALIDATION_CLASS
|
||||
STATUS_BAD_WORKING_SET_LIMIT
|
||||
STATUS_BEGINNING_OF_MEDIA
|
||||
STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT
|
||||
STATUS_BREAKPOINT
|
||||
STATUS_BUFFER_OVERFLOW
|
||||
STATUS_BUFFER_TOO_SMALL
|
||||
STATUS_BUS_RESET
|
||||
STATUS_CANCELLED
|
||||
STATUS_CANNOT_DELETE
|
||||
STATUS_CANNOT_IMPERSONATE
|
||||
STATUS_CANNOT_LOAD_REGISTRY_FILE
|
||||
STATUS_CANT_ACCESS_DOMAIN_INFO
|
||||
STATUS_CANT_DISABLE_MANDATORY
|
||||
STATUS_CANT_OPEN_ANONYMOUS
|
||||
STATUS_CANT_TERMINATE_SELF
|
||||
STATUS_CANT_WAIT
|
||||
STATUS_CARDBUS_NOT_SUPPORTED
|
||||
STATUS_CHECKING_FILE_SYSTEM
|
||||
STATUS_CHILD_MUST_BE_VOLATILE
|
||||
STATUS_CLIENT_SERVER_PARAMETERS_INVALID
|
||||
STATUS_COMMITMENT_LIMIT
|
||||
STATUS_CONFLICTING_ADDRESSES
|
||||
STATUS_CONNECTION_ABORTED
|
||||
STATUS_CONNECTION_ACTIVE
|
||||
STATUS_CONNECTION_COUNT_LIMIT
|
||||
STATUS_CONNECTION_DISCONNECTED
|
||||
STATUS_CONNECTION_INVALID
|
||||
STATUS_CONNECTION_IN_USE
|
||||
STATUS_CONNECTION_REFUSED
|
||||
STATUS_CONNECTION_RESET
|
||||
STATUS_CONTROL_C_EXIT
|
||||
STATUS_CONVERT_TO_LARGE
|
||||
STATUS_COULD_NOT_INTERPRET
|
||||
STATUS_CRC_ERROR
|
||||
STATUS_CTL_FILE_NOT_SUPPORTED
|
||||
STATUS_DATATYPE_MISALIGNMENT
|
||||
STATUS_DATA_ERROR
|
||||
STATUS_DATA_LATE_ERROR
|
||||
STATUS_DATA_NOT_ACCEPTED
|
||||
STATUS_DATA_OVERRUN
|
||||
STATUS_DEBUG_ATTACH_FAILED
|
||||
STATUS_DELETE_PENDING
|
||||
STATUS_DEVICE_ALREADY_ATTACHED
|
||||
STATUS_DEVICE_BUSY
|
||||
STATUS_DEVICE_CONFIGURATION_ERROR
|
||||
STATUS_DEVICE_DATA_ERROR
|
||||
STATUS_DEVICE_DOES_NOT_EXIST
|
||||
STATUS_DEVICE_NOT_CONNECTED
|
||||
STATUS_DEVICE_NOT_PARTITIONED
|
||||
STATUS_DEVICE_NOT_READY
|
||||
STATUS_DEVICE_OFF_LINE
|
||||
STATUS_DEVICE_PAPER_EMPTY
|
||||
STATUS_DEVICE_POWERED_OFF
|
||||
STATUS_DEVICE_POWER_FAILURE
|
||||
STATUS_DEVICE_PROTOCOL_ERROR
|
||||
STATUS_DFS_EXIT_PATH_FOUND
|
||||
STATUS_DFS_UNAVAILABLE
|
||||
STATUS_DIRECTORY_NOT_EMPTY
|
||||
STATUS_DISK_CORRUPT_ERROR
|
||||
STATUS_DISK_FULL
|
||||
STATUS_DISK_OPERATION_FAILED
|
||||
STATUS_DISK_RECALIBRATE_FAILED
|
||||
STATUS_DISK_RESET_FAILED
|
||||
STATUS_DLL_INIT_FAILED
|
||||
STATUS_DLL_INIT_FAILED_LOGOFF
|
||||
STATUS_DLL_NOT_FOUND
|
||||
STATUS_DOMAIN_CONTROLLER_NOT_FOUND
|
||||
STATUS_DOMAIN_CTRLR_CONFIG_ERROR
|
||||
STATUS_DOMAIN_EXISTS
|
||||
STATUS_DOMAIN_LIMIT_EXCEEDED
|
||||
STATUS_DOMAIN_TRUST_INCONSISTENT
|
||||
STATUS_DRIVER_CANCEL_TIMEOUT
|
||||
STATUS_DRIVER_ENTRYPOINT_NOT_FOUND
|
||||
STATUS_DRIVER_INTERNAL_ERROR
|
||||
STATUS_DRIVER_ORDINAL_NOT_FOUND
|
||||
STATUS_DRIVER_UNABLE_TO_LOAD
|
||||
STATUS_DUPLICATE_NAME
|
||||
STATUS_DUPLICATE_OBJECTID
|
||||
STATUS_EAS_NOT_SUPPORTED
|
||||
STATUS_EA_CORRUPT_ERROR
|
||||
STATUS_EA_LIST_INCONSISTENT
|
||||
STATUS_EA_TOO_LARGE
|
||||
STATUS_END_OF_FILE
|
||||
STATUS_END_OF_MEDIA
|
||||
STATUS_ENTRYPOINT_NOT_FOUND
|
||||
STATUS_EOM_OVERFLOW
|
||||
STATUS_EVALUATION_EXPIRATION
|
||||
STATUS_EVENTLOG_CANT_START
|
||||
STATUS_EVENTLOG_FILE_CHANGED
|
||||
STATUS_EVENTLOG_FILE_CORRUPT
|
||||
STATUS_EVENT_DONE
|
||||
STATUS_EVENT_PENDING
|
||||
STATUS_EXTRANEOUS_INFORMATION
|
||||
STATUS_FAIL_CHECK
|
||||
STATUS_FATAL_APP_EXIT
|
||||
STATUS_FILEMARK_DETECTED
|
||||
STATUS_FILES_OPEN
|
||||
STATUS_FILE_CLOSED
|
||||
STATUS_FILE_CORRUPT_ERROR
|
||||
STATUS_FILE_DELETED
|
||||
STATUS_FILE_FORCED_CLOSED
|
||||
STATUS_FILE_INVALID
|
||||
STATUS_FILE_IS_A_DIRECTORY
|
||||
STATUS_FILE_IS_OFFLINE
|
||||
STATUS_FILE_LOCK_CONFLICT
|
||||
STATUS_FILE_RENAMED
|
||||
STATUS_FLOAT_DENORMAL_OPERAND
|
||||
STATUS_FLOAT_DIVIDE_BY_ZERO
|
||||
STATUS_FLOAT_INEXACT_RESULT
|
||||
STATUS_FLOAT_INVALID_OPERATION
|
||||
STATUS_FLOAT_OVERFLOW
|
||||
STATUS_FLOAT_STACK_CHECK
|
||||
STATUS_FLOAT_UNDERFLOW
|
||||
STATUS_FLOPPY_BAD_REGISTERS
|
||||
STATUS_FLOPPY_ID_MARK_NOT_FOUND
|
||||
STATUS_FLOPPY_UNKNOWN_ERROR
|
||||
STATUS_FLOPPY_VOLUME
|
||||
STATUS_FLOPPY_WRONG_CYLINDER
|
||||
STATUS_FOUND_OUT_OF_SCOPE
|
||||
STATUS_FREE_VM_NOT_AT_BASE
|
||||
STATUS_FS_DRIVER_REQUIRED
|
||||
STATUS_FT_MISSING_MEMBER
|
||||
STATUS_FT_ORPHANING
|
||||
STATUS_FT_READ_RECOVERING_FROM_BACKUP
|
||||
STATUS_FT_WRITE_RECOVERY
|
||||
STATUS_FULLSCREEN_MODE
|
||||
STATUS_GENERIC_NOT_MAPPED
|
||||
STATUS_GRACEFUL_DISCONNECT
|
||||
STATUS_GROUP_EXISTS
|
||||
STATUS_GUARD_PAGE_VIOLATION
|
||||
STATUS_GUIDS_EXHAUSTED
|
||||
STATUS_GUID_SUBSTITUTION_MADE
|
||||
STATUS_HANDLES_CLOSED
|
||||
STATUS_HANDLE_NOT_CLOSABLE
|
||||
STATUS_HOST_UNREACHABLE
|
||||
STATUS_ILLEGAL_CHARACTER
|
||||
STATUS_ILLEGAL_DLL_RELOCATION
|
||||
STATUS_ILLEGAL_FLOAT_CONTEXT
|
||||
STATUS_ILLEGAL_FUNCTION
|
||||
STATUS_ILLEGAL_INSTRUCTION
|
||||
STATUS_ILL_FORMED_PASSWORD
|
||||
STATUS_ILL_FORMED_SERVICE_ENTRY
|
||||
STATUS_IMAGE_ALREADY_LOADED
|
||||
STATUS_IMAGE_CHECKSUM_MISMATCH
|
||||
STATUS_IMAGE_MACHINE_TYPE_MISMATCH
|
||||
STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE
|
||||
STATUS_IMAGE_MP_UP_MISMATCH
|
||||
STATUS_IMAGE_NOT_AT_BASE
|
||||
STATUS_INCOMPATIBLE_FILE_MAP
|
||||
STATUS_INFO_LENGTH_MISMATCH
|
||||
STATUS_INSTANCE_NOT_AVAILABLE
|
||||
STATUS_INSTRUCTION_MISALIGNMENT
|
||||
STATUS_INSUFFICIENT_LOGON_INFO
|
||||
STATUS_INSUFFICIENT_RESOURCES
|
||||
STATUS_INSUFF_SERVER_RESOURCES
|
||||
STATUS_INTEGER_DIVIDE_BY_ZERO
|
||||
STATUS_INTEGER_OVERFLOW
|
||||
STATUS_INTERNAL_DB_CORRUPTION
|
||||
STATUS_INTERNAL_DB_ERROR
|
||||
STATUS_INTERNAL_ERROR
|
||||
STATUS_INVALID_ACCOUNT_NAME
|
||||
STATUS_INVALID_ACL
|
||||
STATUS_INVALID_ADDRESS
|
||||
STATUS_INVALID_ADDRESS_COMPONENT
|
||||
STATUS_INVALID_ADDRESS_WILDCARD
|
||||
STATUS_INVALID_BLOCK_LENGTH
|
||||
STATUS_INVALID_BUFFER_SIZE
|
||||
STATUS_INVALID_CID
|
||||
STATUS_INVALID_COMPUTER_NAME
|
||||
STATUS_INVALID_CONNECTION
|
||||
STATUS_INVALID_DEVICE_REQUEST
|
||||
STATUS_INVALID_DEVICE_STATE
|
||||
STATUS_INVALID_DISPOSITION
|
||||
STATUS_INVALID_DOMAIN_ROLE
|
||||
STATUS_INVALID_DOMAIN_STATE
|
||||
STATUS_INVALID_EA_FLAG
|
||||
STATUS_INVALID_EA_NAME
|
||||
STATUS_INVALID_FILE_FOR_SECTION
|
||||
STATUS_INVALID_GROUP_ATTRIBUTES
|
||||
STATUS_INVALID_HANDLE
|
||||
STATUS_INVALID_HW_PROFILE
|
||||
STATUS_INVALID_ID_AUTHORITY
|
||||
STATUS_INVALID_IMAGE_FORMAT
|
||||
STATUS_INVALID_IMAGE_LE_FORMAT
|
||||
STATUS_INVALID_IMAGE_NE_FORMAT
|
||||
STATUS_INVALID_IMAGE_NOT_MZ
|
||||
STATUS_INVALID_IMAGE_PROTECT
|
||||
STATUS_INVALID_IMAGE_WIN_16
|
||||
STATUS_INVALID_INFO_CLASS
|
||||
STATUS_INVALID_LDT_DESCRIPTOR
|
||||
STATUS_INVALID_LDT_OFFSET
|
||||
STATUS_INVALID_LDT_SIZE
|
||||
STATUS_INVALID_LEVEL
|
||||
STATUS_INVALID_LOCK_SEQUENCE
|
||||
STATUS_INVALID_LOGON_HOURS
|
||||
STATUS_INVALID_LOGON_TYPE
|
||||
STATUS_INVALID_MEMBER
|
||||
STATUS_INVALID_NETWORK_RESPONSE
|
||||
STATUS_INVALID_OPLOCK_PROTOCOL
|
||||
STATUS_INVALID_OWNER
|
||||
STATUS_INVALID_PAGE_PROTECTION
|
||||
STATUS_INVALID_PARAMETER
|
||||
STATUS_INVALID_PARAMETER_1
|
||||
STATUS_INVALID_PARAMETER_10
|
||||
STATUS_INVALID_PARAMETER_11
|
||||
STATUS_INVALID_PARAMETER_12
|
||||
STATUS_INVALID_PARAMETER_2
|
||||
STATUS_INVALID_PARAMETER_3
|
||||
STATUS_INVALID_PARAMETER_4
|
||||
STATUS_INVALID_PARAMETER_5
|
||||
STATUS_INVALID_PARAMETER_6
|
||||
STATUS_INVALID_PARAMETER_7
|
||||
STATUS_INVALID_PARAMETER_8
|
||||
STATUS_INVALID_PARAMETER_9
|
||||
STATUS_INVALID_PARAMETER_MIX
|
||||
STATUS_INVALID_PIPE_STATE
|
||||
STATUS_INVALID_PLUGPLAY_DEVICE_PATH
|
||||
STATUS_INVALID_PORT_ATTRIBUTES
|
||||
STATUS_INVALID_PORT_HANDLE
|
||||
STATUS_INVALID_PRIMARY_GROUP
|
||||
STATUS_INVALID_QUOTA_LOWER
|
||||
STATUS_INVALID_READ_MODE
|
||||
STATUS_INVALID_SECURITY_DESCR
|
||||
STATUS_INVALID_SERVER_STATE
|
||||
STATUS_INVALID_SID
|
||||
STATUS_INVALID_SUB_AUTHORITY
|
||||
STATUS_INVALID_SYSTEM_SERVICE
|
||||
STATUS_INVALID_UNWIND_TARGET
|
||||
STATUS_INVALID_USER_BUFFER
|
||||
STATUS_INVALID_VARIANT
|
||||
STATUS_INVALID_VIEW_SIZE
|
||||
STATUS_INVALID_VLM_OPERATION
|
||||
STATUS_INVALID_VOLUME_LABEL
|
||||
STATUS_INVALID_WORKSTATION
|
||||
STATUS_IN_PAGE_ERROR
|
||||
STATUS_IO_DEVICE_ERROR
|
||||
STATUS_IO_PRIVILEGE_FAILED
|
||||
STATUS_IO_REPARSE_DATA_INVALID
|
||||
STATUS_IO_REPARSE_TAG_INVALID
|
||||
STATUS_IO_REPARSE_TAG_MISMATCH
|
||||
STATUS_IO_REPARSE_TAG_NOT_HANDLED
|
||||
STATUS_IO_TIMEOUT
|
||||
STATUS_IP_ADDRESS_CONFLICT1
|
||||
STATUS_IP_ADDRESS_CONFLICT2
|
||||
STATUS_KERNEL_APC
|
||||
STATUS_KEY_DELETED
|
||||
STATUS_KEY_HAS_CHILDREN
|
||||
STATUS_LAST_ADMIN
|
||||
STATUS_LICENSE_QUOTA_EXCEEDED
|
||||
STATUS_LICENSE_VIOLATION
|
||||
STATUS_LINK_FAILED
|
||||
STATUS_LINK_TIMEOUT
|
||||
STATUS_LM_CROSS_ENCRYPTION_REQUIRED
|
||||
STATUS_LOCAL_DISCONNECT
|
||||
STATUS_LOCAL_USER_SESSION_KEY
|
||||
STATUS_LOCK_NOT_GRANTED
|
||||
STATUS_LOGIN_TIME_RESTRICTION
|
||||
STATUS_LOGIN_WKSTA_RESTRICTION
|
||||
STATUS_LOGON_FAILURE
|
||||
STATUS_LOGON_NOT_GRANTED
|
||||
STATUS_LOGON_SERVER_CONFLICT
|
||||
STATUS_LOGON_SESSION_COLLISION
|
||||
STATUS_LOGON_SESSION_EXISTS
|
||||
STATUS_LOGON_TYPE_NOT_GRANTED
|
||||
STATUS_LOG_FILE_FULL
|
||||
STATUS_LOG_HARD_ERROR
|
||||
STATUS_LONGJUMP
|
||||
STATUS_LOST_WRITEBEHIND_DATA
|
||||
STATUS_LPC_REPLY_LOST
|
||||
STATUS_LUIDS_EXHAUSTED
|
||||
STATUS_MAPPED_ALIGNMENT
|
||||
STATUS_MAPPED_FILE_SIZE_ZERO
|
||||
STATUS_MARSHALL_OVERFLOW
|
||||
STATUS_MEDIA_CHANGED
|
||||
STATUS_MEDIA_CHECK
|
||||
STATUS_MEDIA_WRITE_PROTECTED
|
||||
STATUS_MEMBERS_PRIMARY_GROUP
|
||||
STATUS_MEMBER_IN_ALIAS
|
||||
STATUS_MEMBER_IN_GROUP
|
||||
STATUS_MEMBER_NOT_IN_ALIAS
|
||||
STATUS_MEMBER_NOT_IN_GROUP
|
||||
STATUS_MEMORY_NOT_ALLOCATED
|
||||
STATUS_MESSAGE_NOT_FOUND
|
||||
STATUS_MISSING_SYSTEMFILE
|
||||
STATUS_MORE_ENTRIES
|
||||
STATUS_MORE_PROCESSING_REQUIRED
|
||||
STATUS_MUTANT_LIMIT_EXCEEDED
|
||||
STATUS_MUTANT_NOT_OWNED
|
||||
STATUS_NAME_TOO_LONG
|
||||
STATUS_NETLOGON_NOT_STARTED
|
||||
STATUS_NETWORK_ACCESS_DENIED
|
||||
STATUS_NETWORK_BUSY
|
||||
STATUS_NETWORK_CREDENTIAL_CONFLICT
|
||||
STATUS_NETWORK_NAME_DELETED
|
||||
STATUS_NETWORK_UNREACHABLE
|
||||
STATUS_NET_WRITE_FAULT
|
||||
STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT
|
||||
STATUS_NOLOGON_SERVER_TRUST_ACCOUNT
|
||||
STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT
|
||||
STATUS_NONCONTINUABLE_EXCEPTION
|
||||
STATUS_NONEXISTENT_EA_ENTRY
|
||||
STATUS_NONEXISTENT_SECTOR
|
||||
STATUS_NONE_MAPPED
|
||||
STATUS_NOTIFY_CLEANUP
|
||||
STATUS_NOTIFY_ENUM_DIR
|
||||
STATUS_NOT_ALL_ASSIGNED
|
||||
STATUS_NOT_A_DIRECTORY
|
||||
STATUS_NOT_A_REPARSE_POINT
|
||||
STATUS_NOT_CLIENT_SESSION
|
||||
STATUS_NOT_COMMITTED
|
||||
STATUS_NOT_FOUND
|
||||
STATUS_NOT_IMPLEMENTED
|
||||
STATUS_NOT_LOCKED
|
||||
STATUS_NOT_LOGON_PROCESS
|
||||
STATUS_NOT_MAPPED_DATA
|
||||
STATUS_NOT_MAPPED_VIEW
|
||||
STATUS_NOT_REGISTRY_FILE
|
||||
STATUS_NOT_SAME_DEVICE
|
||||
STATUS_NOT_SERVER_SESSION
|
||||
STATUS_NOT_SUPPORTED
|
||||
STATUS_NOT_TINY_STREAM
|
||||
STATUS_NO_BROWSER_SERVERS_FOUND
|
||||
STATUS_NO_CALLBACK_ACTIVE
|
||||
STATUS_NO_DATA_DETECTED
|
||||
STATUS_NO_EAS_ON_FILE
|
||||
STATUS_NO_EVENT_PAIR
|
||||
STATUS_NO_GUID_TRANSLATION
|
||||
STATUS_NO_IMPERSONATION_TOKEN
|
||||
STATUS_NO_INHERITANCE
|
||||
STATUS_NO_LDT
|
||||
STATUS_NO_LOGON_SERVERS
|
||||
STATUS_NO_LOG_SPACE
|
||||
STATUS_NO_MATCH
|
||||
STATUS_NO_MEDIA
|
||||
STATUS_NO_MEDIA_IN_DEVICE
|
||||
STATUS_NO_MEMORY
|
||||
STATUS_NO_MORE_EAS
|
||||
STATUS_NO_MORE_ENTRIES
|
||||
STATUS_NO_MORE_FILES
|
||||
STATUS_NO_MORE_MATCHES
|
||||
STATUS_NO_PAGEFILE
|
||||
STATUS_NO_QUOTAS_NO_ACCOUNT
|
||||
STATUS_NO_SECURITY_ON_OBJECT
|
||||
STATUS_NO_SPOOL_SPACE
|
||||
STATUS_NO_SUCH_ALIAS
|
||||
STATUS_NO_SUCH_DEVICE
|
||||
STATUS_NO_SUCH_DOMAIN
|
||||
STATUS_NO_SUCH_FILE
|
||||
STATUS_NO_SUCH_GROUP
|
||||
STATUS_NO_SUCH_LOGON_SESSION
|
||||
STATUS_NO_SUCH_MEMBER
|
||||
STATUS_NO_SUCH_PACKAGE
|
||||
STATUS_NO_SUCH_PRIVILEGE
|
||||
STATUS_NO_SUCH_USER
|
||||
STATUS_NO_TOKEN
|
||||
STATUS_NO_TRUST_LSA_SECRET
|
||||
STATUS_NO_TRUST_SAM_ACCOUNT
|
||||
STATUS_NO_USER_SESSION_KEY
|
||||
STATUS_NO_YIELD_PERFORMED
|
||||
STATUS_NT_CROSS_ENCRYPTION_REQUIRED
|
||||
STATUS_NULL_LM_PASSWORD
|
||||
STATUS_OBJECTID_EXISTS
|
||||
STATUS_OBJECT_EXISTS
|
||||
STATUS_OBJECT_NAME_COLLISION
|
||||
STATUS_OBJECT_NAME_EXISTS
|
||||
STATUS_OBJECT_NAME_INVALID
|
||||
STATUS_OBJECT_NAME_NOT_FOUND
|
||||
STATUS_OBJECT_PATH_INVALID
|
||||
STATUS_OBJECT_PATH_NOT_FOUND
|
||||
STATUS_OBJECT_PATH_SYNTAX_BAD
|
||||
STATUS_OBJECT_TYPE_MISMATCH
|
||||
STATUS_OPEN_FAILED
|
||||
STATUS_OPLOCK_BREAK_IN_PROCESS
|
||||
STATUS_OPLOCK_NOT_GRANTED
|
||||
STATUS_ORDINAL_NOT_FOUND
|
||||
STATUS_PAGEFILE_CREATE_FAILED
|
||||
STATUS_PAGEFILE_QUOTA
|
||||
STATUS_PAGEFILE_QUOTA_EXCEEDED
|
||||
STATUS_PARITY_ERROR
|
||||
STATUS_PARTIAL_COPY
|
||||
STATUS_PARTITION_FAILURE
|
||||
STATUS_PASSWORD_EXPIRED
|
||||
STATUS_PASSWORD_MUST_CHANGE
|
||||
STATUS_PASSWORD_RESTRICTION
|
||||
STATUS_PATH_NOT_COVERED
|
||||
STATUS_PENDING
|
||||
STATUS_PIPE_BROKEN
|
||||
STATUS_PIPE_BUSY
|
||||
STATUS_PIPE_CLOSING
|
||||
STATUS_PIPE_CONNECTED
|
||||
STATUS_PIPE_DISCONNECTED
|
||||
STATUS_PIPE_EMPTY
|
||||
STATUS_PIPE_LISTENING
|
||||
STATUS_PIPE_NOT_AVAILABLE
|
||||
STATUS_PLUGPLAY_NO_DEVICE
|
||||
STATUS_PORT_ALREADY_SET
|
||||
STATUS_PORT_CONNECTION_REFUSED
|
||||
STATUS_PORT_DISCONNECTED
|
||||
STATUS_PORT_MESSAGE_TOO_LONG
|
||||
STATUS_PORT_UNREACHABLE
|
||||
STATUS_POSSIBLE_DEADLOCK
|
||||
STATUS_PREDEFINED_HANDLE
|
||||
STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED
|
||||
STATUS_PRINT_CANCELLED
|
||||
STATUS_PRINT_QUEUE_FULL
|
||||
STATUS_PRIVILEGED_INSTRUCTION
|
||||
STATUS_PRIVILEGE_NOT_HELD
|
||||
STATUS_PROCEDURE_NOT_FOUND
|
||||
STATUS_PROCESS_IN_JOB
|
||||
STATUS_PROCESS_IS_TERMINATING
|
||||
STATUS_PROCESS_NOT_IN_JOB
|
||||
STATUS_PROFILING_AT_LIMIT
|
||||
STATUS_PROFILING_NOT_STARTED
|
||||
STATUS_PROFILING_NOT_STOPPED
|
||||
STATUS_PROPSET_NOT_FOUND
|
||||
STATUS_PROTOCOL_UNREACHABLE
|
||||
STATUS_PWD_HISTORY_CONFLICT
|
||||
STATUS_PWD_TOO_RECENT
|
||||
STATUS_PWD_TOO_SHORT
|
||||
STATUS_QUOTA_EXCEEDED
|
||||
STATUS_QUOTA_LIST_INCONSISTENT
|
||||
STATUS_RANGE_LIST_CONFLICT
|
||||
STATUS_RANGE_NOT_FOUND
|
||||
STATUS_RANGE_NOT_LOCKED
|
||||
STATUS_RECEIVE_EXPEDITED
|
||||
STATUS_RECEIVE_PARTIAL
|
||||
STATUS_RECEIVE_PARTIAL_EXPEDITED
|
||||
STATUS_RECOVERY_FAILURE
|
||||
STATUS_REDIRECTOR_HAS_OPEN_HANDLES
|
||||
STATUS_REDIRECTOR_NOT_STARTED
|
||||
STATUS_REDIRECTOR_PAUSED
|
||||
STATUS_REDIRECTOR_STARTED
|
||||
STATUS_REGISTRY_CORRUPT
|
||||
STATUS_REGISTRY_IO_FAILED
|
||||
STATUS_REGISTRY_QUOTA_LIMIT
|
||||
STATUS_REGISTRY_RECOVERED
|
||||
STATUS_REMOTE_DISCONNECT
|
||||
STATUS_REMOTE_NOT_LISTENING
|
||||
STATUS_REMOTE_RESOURCES
|
||||
STATUS_REMOTE_SESSION_LIMIT
|
||||
STATUS_REPARSE
|
||||
STATUS_REPLY_MESSAGE_MISMATCH
|
||||
STATUS_REQUEST_ABORTED
|
||||
STATUS_REQUEST_NOT_ACCEPTED
|
||||
STATUS_RESOURCE_DATA_NOT_FOUND
|
||||
STATUS_RESOURCE_LANG_NOT_FOUND
|
||||
STATUS_RESOURCE_NAME_NOT_FOUND
|
||||
STATUS_RESOURCE_NOT_OWNED
|
||||
STATUS_RESOURCE_TYPE_NOT_FOUND
|
||||
STATUS_RETRY
|
||||
STATUS_REVISION_MISMATCH
|
||||
STATUS_RXACT_COMMITTED
|
||||
STATUS_RXACT_COMMIT_FAILURE
|
||||
STATUS_RXACT_COMMIT_NECESSARY
|
||||
STATUS_RXACT_INVALID_STATE
|
||||
STATUS_RXACT_STATE_CREATED
|
||||
STATUS_SAM_INIT_FAILURE
|
||||
STATUS_SECRET_TOO_LONG
|
||||
STATUS_SECTION_NOT_EXTENDED
|
||||
STATUS_SECTION_NOT_IMAGE
|
||||
STATUS_SECTION_PROTECTION
|
||||
STATUS_SECTION_TOO_BIG
|
||||
STATUS_SEGMENT_NOTIFICATION
|
||||
STATUS_SEMAPHORE_LIMIT_EXCEEDED
|
||||
STATUS_SERIAL_COUNTER_TIMEOUT
|
||||
STATUS_SERIAL_MORE_WRITES
|
||||
STATUS_SERIAL_NO_DEVICE_INITED
|
||||
STATUS_SERVER_DISABLED
|
||||
STATUS_SERVER_HAS_OPEN_HANDLES
|
||||
STATUS_SERVER_NOT_DISABLED
|
||||
STATUS_SERVICE_NOTIFICATION
|
||||
STATUS_SETMARK_DETECTED
|
||||
STATUS_SHARED_IRQ_BUSY
|
||||
STATUS_SHARING_PAUSED
|
||||
STATUS_SHARING_VIOLATION
|
||||
STATUS_SINGLE_STEP
|
||||
STATUS_SOME_NOT_MAPPED
|
||||
STATUS_SPECIAL_ACCOUNT
|
||||
STATUS_SPECIAL_GROUP
|
||||
STATUS_SPECIAL_USER
|
||||
STATUS_STACK_OVERFLOW
|
||||
STATUS_STACK_OVERFLOW_READ
|
||||
STATUS_SUCCESS
|
||||
STATUS_SUSPEND_COUNT_EXCEEDED
|
||||
STATUS_SYNCHRONIZATION_REQUIRED
|
||||
STATUS_SYSTEM_PROCESS_TERMINATED
|
||||
STATUS_THREAD_IS_TERMINATING
|
||||
STATUS_THREAD_NOT_IN_PROCESS
|
||||
STATUS_THREAD_WAS_SUSPENDED
|
||||
STATUS_TIMEOUT
|
||||
STATUS_TIMER_NOT_CANCELED
|
||||
STATUS_TIMER_RESOLUTION_NOT_SET
|
||||
STATUS_TIMER_RESUME_IGNORED
|
||||
STATUS_TIME_DIFFERENCE_AT_DC
|
||||
STATUS_TOKEN_ALREADY_IN_USE
|
||||
STATUS_TOO_LATE
|
||||
STATUS_TOO_MANY_ADDRESSES
|
||||
STATUS_TOO_MANY_COMMANDS
|
||||
STATUS_TOO_MANY_CONTEXT_IDS
|
||||
STATUS_TOO_MANY_GUIDS_REQUESTED
|
||||
STATUS_TOO_MANY_LINKS
|
||||
STATUS_TOO_MANY_LUIDS_REQUESTED
|
||||
STATUS_TOO_MANY_NAMES
|
||||
STATUS_TOO_MANY_NODES
|
||||
STATUS_TOO_MANY_OPENED_FILES
|
||||
STATUS_TOO_MANY_PAGING_FILES
|
||||
STATUS_TOO_MANY_SECRETS
|
||||
STATUS_TOO_MANY_SESSIONS
|
||||
STATUS_TOO_MANY_SIDS
|
||||
STATUS_TOO_MANY_THREADS
|
||||
STATUS_TRANSACTION_ABORTED
|
||||
STATUS_TRANSACTION_INVALID_ID
|
||||
STATUS_TRANSACTION_INVALID_TYPE
|
||||
STATUS_TRANSACTION_NO_MATCH
|
||||
STATUS_TRANSACTION_NO_RELEASE
|
||||
STATUS_TRANSACTION_RESPONDED
|
||||
STATUS_TRANSACTION_TIMED_OUT
|
||||
STATUS_TRUSTED_DOMAIN_FAILURE
|
||||
STATUS_TRUSTED_RELATIONSHIP_FAILURE
|
||||
STATUS_TRUST_FAILURE
|
||||
STATUS_UNABLE_TO_DECOMMIT_VM
|
||||
STATUS_UNABLE_TO_DELETE_SECTION
|
||||
STATUS_UNABLE_TO_FREE_VM
|
||||
STATUS_UNABLE_TO_LOCK_MEDIA
|
||||
STATUS_UNABLE_TO_UNLOAD_MEDIA
|
||||
STATUS_UNDEFINED_CHARACTER
|
||||
STATUS_UNEXPECTED_IO_ERROR
|
||||
STATUS_UNEXPECTED_MM_CREATE_ERR
|
||||
STATUS_UNEXPECTED_MM_EXTEND_ERR
|
||||
STATUS_UNEXPECTED_MM_MAP_ERROR
|
||||
STATUS_UNEXPECTED_NETWORK_ERROR
|
||||
STATUS_UNHANDLED_EXCEPTION
|
||||
STATUS_UNKNOWN_REVISION
|
||||
STATUS_UNMAPPABLE_CHARACTER
|
||||
STATUS_UNRECOGNIZED_MEDIA
|
||||
STATUS_UNRECOGNIZED_VOLUME
|
||||
STATUS_UNSUCCESSFUL
|
||||
STATUS_UNSUPPORTED_COMPRESSION
|
||||
STATUS_UNWIND
|
||||
STATUS_USER_APC
|
||||
STATUS_USER_EXISTS
|
||||
STATUS_USER_MAPPED_FILE
|
||||
STATUS_USER_SESSION_DELETED
|
||||
STATUS_VALIDATE_CONTINUE
|
||||
STATUS_VARIABLE_NOT_FOUND
|
||||
STATUS_VDM_HARD_ERROR
|
||||
STATUS_VERIFY_REQUIRED
|
||||
STATUS_VIRTUAL_CIRCUIT_CLOSED
|
||||
STATUS_VOLUME_DISMOUNTED
|
||||
STATUS_VOLUME_MOUNTED
|
||||
STATUS_WAIT_0
|
||||
STATUS_WAIT_63
|
||||
STATUS_WAKE_SYSTEM_DEBUGGER
|
||||
STATUS_WAS_LOCKED
|
||||
STATUS_WAS_UNLOCKED
|
||||
STATUS_WORKING_SET_LIMIT_RANGE
|
||||
STATUS_WORKING_SET_QUOTA
|
||||
STATUS_WRONG_PASSWORD
|
||||
STATUS_WRONG_PASSWORD_CORE
|
||||
STATUS_WRONG_VOLUME
|
||||
STATUS_WX86_BREAKPOINT
|
||||
STATUS_WX86_CONTINUE
|
||||
STATUS_WX86_CREATEWX86TIB
|
||||
STATUS_WX86_EXCEPTION_CHAIN
|
||||
STATUS_WX86_EXCEPTION_CONTINUE
|
||||
STATUS_WX86_EXCEPTION_LASTCHANCE
|
||||
STATUS_WX86_FLOAT_STACK_CHECK
|
||||
STATUS_WX86_INTERNAL_ERROR
|
||||
STATUS_WX86_SINGLE_STEP
|
||||
STATUS_WX86_UNSIMULATE
|
@@ -1,7 +0,0 @@
|
||||
FAST_MUTEX
|
||||
KPCR
|
||||
PEB
|
||||
TEB
|
||||
SPINLOCK
|
||||
APC
|
||||
DPC
|
@@ -1,73 +0,0 @@
|
||||
What do you think I am, your personal tech support?
|
||||
You *know* a %stru% is non-re-entrant, right?
|
||||
The answer to that is so simple, I'm not going to waste my time telling you.
|
||||
Well, of course... if you're not below DISPATCH_LEVEL, ros is gonna explode on ya when you try to do that ( duh! ).
|
||||
I don't think that functionality has been implemented, yet.
|
||||
What do you mean it crashed? It can't crash there!
|
||||
Wow. That's a new one.
|
||||
Ask %dev%, I bet he knows.. he knows everything...
|
||||
When's the last time you rebuilt?
|
||||
Have you tried a make clean?
|
||||
Is it plugged in?
|
||||
Well it works on *my* system :P
|
||||
Well don't do that, and you won't have that problem.
|
||||
Didn't we already fix that?
|
||||
Well... I don't know.. I just have that code disabled in my tree.
|
||||
Try surrounding it with parenthesis.
|
||||
Don't you know going around dereferncing null pointers all day can be hazardous to your health?
|
||||
Well, duh!
|
||||
There's a bit in cr3 for problems like that.
|
||||
Just add a field to the %stru% to keep track of it!
|
||||
Don't worry about it... the garbage collector in %module% will clean it up for you.
|
||||
Did I do that?
|
||||
Didn't %dev% fix that already?
|
||||
Yes, I think I've seen that bug before... no... that was another program.
|
||||
I could tell you, but then I'd have to unlink() you.
|
||||
Well if you'd get some sleep, maybe you'd figure it out... not all of us can keep the hours %dev% can...
|
||||
You did what? Uh oh... that can't be good.
|
||||
Well... I could tell you, but the answer's pretty complicated. Why don't you wait to read about it in the book I'm writing.
|
||||
Yeah, that's happened to me, before, too. All you have to do is wrap it in an SEH block and forget about it.
|
||||
Just put a NULL dereference in there and commit it. It helps get bugs fixed fast! (Not that I would know)
|
||||
ASSERT is your friend!
|
||||
I dunno.. but I bet %dev% could find it for you.
|
||||
I hereby declare that code is perfect. Your problem must be elsewhere.
|
||||
I wrote that code... it must be perfect.
|
||||
$#@!$ One of these days I'm gonna throw %module% out the window!!! Sorry, what were you saying?
|
||||
maybe I broke it in my last commit. Maybe I did it on purpose...
|
||||
Have you tried debugging it? I got a can of Raid...
|
||||
Just delete it, it can't be that important ( You should see all the useless cruft I got rid of in %module% )
|
||||
Try queueing a work item...
|
||||
My %stru% fell in love with some %stru% in %module%, and %module% has been hell since...
|
||||
Maybe the PEB is getting corrupted. Try allocating a new PEB and overwriting the old one. That's what I did last time I had a bug like that.
|
||||
Hmm.. that seems to have been introduced by my last commit... I bet CVS mixed up the bits during the commit.
|
||||
It can't possibly be my fault, so I don't care.
|
||||
I'm not experiencing that problem, perhaps it's all in your mind.
|
||||
Well... like a good friend of mine said... "Don't Panic!"
|
||||
It just shows you how far ReactOS has come along! A %period% ago a bug like that wouldn't have even been possible!
|
||||
Just surround the code with an #if 0/#endif block, it solves all my problems!
|
||||
You know.. if %dev% would just finish %module% for us, we wouldn't be having this problem.
|
||||
I say we move on to the next function, since we can't seem to figure this one out.
|
||||
Well, sure, that would have been my first guess, too.... TEN YEARS AGO :p
|
||||
yup, that sounds like a problem.
|
||||
If I wanted to talk about VB, I'd go bug Alex...
|
||||
ask %dev%
|
||||
Thank you for that amazingly keen insight, Commander Obvious.
|
||||
Sorry, can't help you right now, trying to track down this bug %dev% caused in %module%
|
||||
I dont know about that, but I just fixed a problem in %module% for %dev%
|
||||
How should I know? I'm still trying to figure out this main() thing... ooh! wanna see what I did in %module%?
|
||||
lol!
|
||||
*wink*
|
||||
;)
|
||||
42
|
||||
It's gonna take me over %period% to fix all %dev%'s bugs in %module% :(
|
||||
How could %func% return %status%!? It bet %dev% broke it! I didn't touch it... honest! no.. really! (me hides)
|
||||
It's fine if you get %status% there ... just ignore the destruction, and call %func% instead.
|
||||
%dev% said %status% isn't really an error in this context because we expect %module% to be toast by now
|
||||
heh, I'm still trying to figure out why %func% is returning %status% when I call it from %module%...
|
||||
%dev% said it's okay to ignore that as long as you're below %irql%
|
||||
erm, what do you mean?
|
||||
damn, I do that all the time
|
||||
if you want a reply that sounds right, I'd say that %func% support for that is vital to the future of %module%
|
||||
Sounds like you're having a problem with %func%. I hate that thing... don't talk to me about it.
|
||||
Just return %status% and forget about it. Someone else will fix it, later.
|
||||
Blah blah blah... sheesh... can't you figure out *anything*?
|
@@ -1,17 +0,0 @@
|
||||
// trim.cpp
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#include "trim.h"
|
||||
|
||||
std::string trim ( const std::string& s )
|
||||
{
|
||||
const char* p = &s[0];
|
||||
const char* p2 = p + s.size();
|
||||
while ( *p == ' ' )
|
||||
p++;
|
||||
while ( p2 > p && p2[-1] == ' ' )
|
||||
p2--;
|
||||
return std::string ( p, p2-p );
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
// trim.h
|
||||
// This file is (C) 2004 Royce Mitchell III
|
||||
// and released under the BSD & LGPL licenses
|
||||
|
||||
#ifndef TRIM_H
|
||||
#define TRIM_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string trim ( const std::string& s );
|
||||
|
||||
#endif//TRIM_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
// verify.h
|
||||
// This code is (C) 2003-2004 Royce Mitchell III
|
||||
// and released under the LGPL & BSD licenses
|
||||
|
||||
#ifndef VERIFY_H
|
||||
#define VERIFY_H
|
||||
|
||||
//#include <assert.h>
|
||||
|
||||
#ifdef ASSERT
|
||||
#undef ASSERT
|
||||
#endif//ASSERT
|
||||
|
||||
#include "panic.h"
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
inline void AssertHandler ( bool b, const char* str )
|
||||
{
|
||||
if ( !b )
|
||||
panic ( str );
|
||||
}
|
||||
# define ASSERT(x) AssertHandler((x) ? true : false, #x )
|
||||
#else
|
||||
# define ASSERT(x)
|
||||
#endif
|
||||
|
||||
#ifdef verify
|
||||
#undef verify
|
||||
#endif//verify
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
# define verify(x) ASSERT(x)
|
||||
#else
|
||||
# define verify(x) x
|
||||
#endif
|
||||
|
||||
#endif//VERIFY_H
|
@@ -1,32 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all values by your own or you can build default build and revision
|
||||
// numbers with the '*' character (the default):
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes specify the key for the sign of your assembly. See the
|
||||
// .NET Framework documentation for more information about signing.
|
||||
// This is not required, if you don't want signing let these attributes like they're.
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
@@ -1,274 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
|
||||
namespace HtmlHelp.ChmDecoding
|
||||
{
|
||||
/// <summary>
|
||||
/// The class <c>BinaryReaderHelp</c> implements static helper methods for extracting binary data
|
||||
/// from a binary reader object.
|
||||
/// </summary>
|
||||
internal class BinaryReaderHelp
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal helper method to extract null-terminated strings from a binary reader
|
||||
/// </summary>
|
||||
/// <param name="binReader">reference to the binary reader</param>
|
||||
/// <param name="offset">offset in the stream</param>
|
||||
/// <param name="noOffset">true if the offset value should be used</param>
|
||||
/// <param name="encoder">encoder used for text encoding</param>
|
||||
/// <returns>An extracted string value</returns>
|
||||
internal static string ExtractString(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder)
|
||||
{
|
||||
string strReturn = "";
|
||||
|
||||
if(encoder == null)
|
||||
encoder = Encoding.ASCII;
|
||||
|
||||
ArrayList nameBytes = new ArrayList();
|
||||
byte curByte;
|
||||
|
||||
if(!noOffset)
|
||||
binReader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
if(binReader.BaseStream.Position >= binReader.BaseStream.Length)
|
||||
return "";
|
||||
|
||||
curByte = binReader.ReadByte();
|
||||
while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) )
|
||||
{
|
||||
nameBytes.Add( curByte );
|
||||
curByte = binReader.ReadByte();
|
||||
}
|
||||
|
||||
byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte")));
|
||||
strReturn = encoder.GetString(name,0,name.Length);
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper method to extract a string with a specific length from the binary reader
|
||||
/// </summary>
|
||||
/// <param name="binReader">reference to the binary reader</param>
|
||||
/// <param name="length">length of the string (number of bytes)</param>
|
||||
/// <param name="offset">offset in the stream</param>
|
||||
/// <param name="noOffset">true if the offset value should be used</param>
|
||||
/// <param name="encoder">encoder used for text encoding</param>
|
||||
/// <returns>An extracted string value</returns>
|
||||
internal static string ExtractString(ref BinaryReader binReader, int length, int offset, bool noOffset, Encoding encoder)
|
||||
{
|
||||
string strReturn = "";
|
||||
|
||||
if(length == 0)
|
||||
return "";
|
||||
|
||||
if(encoder == null)
|
||||
encoder = Encoding.ASCII;
|
||||
|
||||
ArrayList nameBytes = new ArrayList();
|
||||
byte curByte;
|
||||
|
||||
if(!noOffset)
|
||||
binReader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
if(binReader.BaseStream.Position >= binReader.BaseStream.Length)
|
||||
return "";
|
||||
|
||||
curByte = binReader.ReadByte();
|
||||
while( (curByte != (byte)0) && (nameBytes.Count < length) && (binReader.BaseStream.Position < binReader.BaseStream.Length) )
|
||||
{
|
||||
nameBytes.Add( curByte );
|
||||
|
||||
if(nameBytes.Count < length)
|
||||
curByte = binReader.ReadByte();
|
||||
}
|
||||
|
||||
byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte")));
|
||||
strReturn = encoder.GetString(name,0,name.Length);
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper method to extract a string with a specific length from the binary reader
|
||||
/// </summary>
|
||||
/// <param name="binReader">reference to the binary reader</param>
|
||||
/// <param name="bFoundTerminator">reference to a bool vairable which will receive true if the
|
||||
/// string terminator \0 was found. false indicates that the end of the stream was reached.</param>
|
||||
/// <param name="offset">offset in the stream</param>
|
||||
/// <param name="noOffset">true if the offset value should be used</param>
|
||||
/// <param name="encoder">encoder used for text encoding</param>
|
||||
/// <returns>An extracted string value</returns>
|
||||
internal static string ExtractString(ref BinaryReader binReader, ref bool bFoundTerminator, int offset, bool noOffset, Encoding encoder)
|
||||
{
|
||||
string strReturn = "";
|
||||
|
||||
ArrayList nameBytes = new ArrayList();
|
||||
byte curByte;
|
||||
|
||||
if(encoder == null)
|
||||
encoder = Encoding.ASCII;
|
||||
|
||||
if(!noOffset)
|
||||
binReader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
if(binReader.BaseStream.Position >= binReader.BaseStream.Length)
|
||||
return "";
|
||||
|
||||
curByte = binReader.ReadByte();
|
||||
while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) )
|
||||
{
|
||||
nameBytes.Add( curByte );
|
||||
curByte = binReader.ReadByte();
|
||||
|
||||
if( curByte == (byte)0 )
|
||||
{
|
||||
bFoundTerminator = true;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte")));
|
||||
strReturn = encoder.GetString(name,0,name.Length);
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper method to extract a null-terminated UTF-16/UCS-2 strings from a binary reader
|
||||
/// </summary>
|
||||
/// <param name="binReader">reference to the binary reader</param>
|
||||
/// <param name="offset">offset in the stream</param>
|
||||
/// <param name="noOffset">true if the offset value should be used</param>
|
||||
/// <param name="encoder">encoder used for text encoding</param>
|
||||
/// <returns>An extracted string value</returns>
|
||||
internal static string ExtractUTF16String(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder)
|
||||
{
|
||||
string strReturn = "";
|
||||
|
||||
ArrayList nameBytes = new ArrayList();
|
||||
byte curByte;
|
||||
int lastByte=-1;
|
||||
|
||||
if(!noOffset)
|
||||
binReader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
if(binReader.BaseStream.Position >= binReader.BaseStream.Length)
|
||||
return "";
|
||||
|
||||
if(encoder == null)
|
||||
encoder = Encoding.Unicode;
|
||||
|
||||
curByte = binReader.ReadByte();
|
||||
int nCnt = 0;
|
||||
while( ((curByte != (byte)0) || (lastByte != 0) ) && (binReader.BaseStream.Position < binReader.BaseStream.Length) )
|
||||
{
|
||||
nameBytes.Add( curByte );
|
||||
|
||||
if(nCnt%2 == 0)
|
||||
lastByte = (int)curByte;
|
||||
|
||||
curByte = binReader.ReadByte();
|
||||
|
||||
nCnt++;
|
||||
}
|
||||
|
||||
byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte")));
|
||||
strReturn = Encoding.Unicode.GetString(name,0,name.Length);
|
||||
|
||||
// apply text encoding
|
||||
name = Encoding.Default.GetBytes(strReturn);
|
||||
strReturn = encoder.GetString(name,0,name.Length);
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper for reading ENCINT encoded integer values
|
||||
/// </summary>
|
||||
/// <param name="binReader">reference to the reader</param>
|
||||
/// <returns>a long value</returns>
|
||||
internal static long ReadENCINT(ref BinaryReader binReader)
|
||||
{
|
||||
long nRet = 0;
|
||||
byte buffer = 0;
|
||||
int shift = 0;
|
||||
|
||||
if(binReader.BaseStream.Position >= binReader.BaseStream.Length)
|
||||
return nRet;
|
||||
|
||||
do
|
||||
{
|
||||
buffer = binReader.ReadByte();
|
||||
nRet |= ((long)((buffer & (byte)0x7F))) << shift;
|
||||
shift += 7;
|
||||
|
||||
}while ( (buffer & (byte)0x80) != 0);
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an s/r encoded value from the byte array and decodes it into an integer
|
||||
/// </summary>
|
||||
/// <param name="wclBits">a byte array containing all bits (contains only 0 or 1 elements)</param>
|
||||
/// <param name="s">scale param for encoding</param>
|
||||
/// <param name="r">root param for encoding</param>
|
||||
/// <param name="nBitIndex">current index in the wclBits array</param>
|
||||
/// <returns>Returns an decoded integer value.</returns>
|
||||
internal static int ReadSRItem(byte[] wclBits, int s, int r, ref int nBitIndex)
|
||||
{
|
||||
int nRet = 0;
|
||||
int q = r;
|
||||
|
||||
int nPref1Cnt = 0;
|
||||
|
||||
while( wclBits[nBitIndex++] == 1)
|
||||
{
|
||||
nPref1Cnt++;
|
||||
}
|
||||
|
||||
if(nPref1Cnt == 0)
|
||||
{
|
||||
int nMask = 0;
|
||||
|
||||
for(int nbits=0; nbits<q;nbits++)
|
||||
{
|
||||
nMask |= ( 0x01 & (int)wclBits[nBitIndex]) << (q-nbits-1);
|
||||
nBitIndex++;
|
||||
}
|
||||
|
||||
nRet = nMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
q += (nPref1Cnt-1);
|
||||
|
||||
int nMask = 0;
|
||||
int nRMaxValue = 0;
|
||||
|
||||
for(int nbits=0; nbits<q;nbits++)
|
||||
{
|
||||
nMask |= ( 0x01 & (int)wclBits[nBitIndex]) << (q-nbits-1);
|
||||
nBitIndex++;
|
||||
}
|
||||
|
||||
for(int nsv=0; nsv<r; nsv++)
|
||||
{
|
||||
nRMaxValue = nRMaxValue << 1;
|
||||
nRMaxValue |= 0x1;
|
||||
}
|
||||
|
||||
nRMaxValue++; // startvalue of s/r encoding with 1 prefixing '1'
|
||||
|
||||
nRMaxValue *= (int) Math.Pow((double)2, (double)(nPref1Cnt-1));
|
||||
|
||||
nRet = nRMaxValue + nMask;
|
||||
}
|
||||
|
||||
return nRet;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,325 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace HtmlHelp.ChmDecoding
|
||||
{
|
||||
/// <summary>
|
||||
/// The class <c>CHMBtree</c> implements methods/properties to decode the binary help index.
|
||||
/// This class automatically creates an index arraylist for the current CHMFile instance.
|
||||
/// It does not store the index internally !
|
||||
/// </summary>
|
||||
/// <remarks>The binary index can be found in the storage file $WWKeywordLinks/BTree</remarks>
|
||||
internal sealed class CHMBtree : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant specifying the size of the string blocks
|
||||
/// </summary>
|
||||
private const int BLOCK_SIZE = 2048;
|
||||
/// <summary>
|
||||
/// Internal flag specifying if the object is going to be disposed
|
||||
/// </summary>
|
||||
private bool disposed = false;
|
||||
/// <summary>
|
||||
/// Internal member storing the binary file data
|
||||
/// </summary>
|
||||
private byte[] _binaryFileData = null;
|
||||
/// <summary>
|
||||
/// Internal member storing flags
|
||||
/// </summary>
|
||||
private int _flags = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the data format
|
||||
/// </summary>
|
||||
private byte[] _dataFormat = new byte[16];
|
||||
/// <summary>
|
||||
/// Internal member storing the index of the last listing block
|
||||
/// </summary>
|
||||
private int _indexOfLastListingBlock = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the index of the root block
|
||||
/// </summary>
|
||||
private int _indexOfRootBlock = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the number of blocks
|
||||
/// </summary>
|
||||
private int _numberOfBlocks = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the tree depth.
|
||||
/// (1 if no index blocks, 2 one level of index blocks, ...)
|
||||
/// </summary>
|
||||
private int _treeDepth = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the number of keywords in the file
|
||||
/// </summary>
|
||||
private int _numberOfKeywords = 0;
|
||||
/// <summary>
|
||||
/// Internal member storing the codepage
|
||||
/// </summary>
|
||||
private int _codePage = 0;
|
||||
/// <summary>
|
||||
/// true if the index is from a CHI or CHM file, else CHW
|
||||
/// </summary>
|
||||
private bool _isCHI_CHM = true;
|
||||
/// <summary>
|
||||
/// Internal member storing the associated chmfile object
|
||||
/// </summary>
|
||||
private CHMFile _associatedFile = null;
|
||||
/// <summary>
|
||||
/// Internal flag specifying if we have to read listing or index blocks
|
||||
/// </summary>
|
||||
private bool _readListingBlocks = true;
|
||||
/// <summary>
|
||||
/// Internal member storing an indexlist of the current file.
|
||||
/// </summary>
|
||||
private ArrayList _indexList = new ArrayList();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of the class
|
||||
/// </summary>
|
||||
/// <param name="binaryFileData">binary file data of the $WWKeywordLinks/BTree file</param>
|
||||
/// <param name="associatedFile">associated chm file</param>
|
||||
public CHMBtree(byte[] binaryFileData, CHMFile associatedFile)
|
||||
{
|
||||
if( associatedFile == null)
|
||||
{
|
||||
throw new ArgumentException("CHMBtree.ctor() - Associated CHMFile must not be null !", "associatedFile");
|
||||
}
|
||||
|
||||
_binaryFileData = binaryFileData;
|
||||
_associatedFile = associatedFile;
|
||||
DecodeData();
|
||||
|
||||
// clear internal binary data after extraction
|
||||
_binaryFileData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the binary file data and fills the internal properties
|
||||
/// </summary>
|
||||
/// <returns>true if succeeded</returns>
|
||||
private bool DecodeData()
|
||||
{
|
||||
bool bRet = true;
|
||||
|
||||
MemoryStream memStream = new MemoryStream(_binaryFileData);
|
||||
BinaryReader binReader = new BinaryReader(memStream);
|
||||
|
||||
int nCurOffset = 0;
|
||||
int nTemp = 0;
|
||||
|
||||
// decode header
|
||||
binReader.ReadChars(2); // 2chars signature (not important)
|
||||
|
||||
_flags = (int)binReader.ReadInt16(); // WORD flags
|
||||
|
||||
binReader.ReadInt16(); // size of blocks (always 2048)
|
||||
|
||||
_dataFormat = binReader.ReadBytes(16);
|
||||
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
|
||||
_indexOfLastListingBlock = binReader.ReadInt32();
|
||||
_indexOfRootBlock = binReader.ReadInt32();
|
||||
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
|
||||
_numberOfBlocks = binReader.ReadInt32();
|
||||
_treeDepth = binReader.ReadInt16();
|
||||
_numberOfKeywords = binReader.ReadInt32();
|
||||
_codePage = binReader.ReadInt32();
|
||||
|
||||
binReader.ReadInt32(); // lcid DWORD
|
||||
|
||||
nTemp = binReader.ReadInt32();
|
||||
_isCHI_CHM = (nTemp==1);
|
||||
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
binReader.ReadInt32(); // unknown DWORD
|
||||
|
||||
// end of header decode
|
||||
|
||||
while( (memStream.Position < memStream.Length) && (bRet) )
|
||||
{
|
||||
nCurOffset = (int)memStream.Position;
|
||||
byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE);
|
||||
bRet &= DecodeBlock(dataBlock, ref nCurOffset, _treeDepth-1);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a block of url-string data
|
||||
/// </summary>
|
||||
/// <param name="dataBlock">block of data</param>
|
||||
/// <param name="nOffset">current file offset</param>
|
||||
/// <param name="indexBlocks">number of index blocks</param>
|
||||
/// <returns>true if succeeded</returns>
|
||||
private bool DecodeBlock( byte[] dataBlock, ref int nOffset, int indexBlocks )
|
||||
{
|
||||
bool bRet = true;
|
||||
int nblockOffset = nOffset;
|
||||
|
||||
MemoryStream memStream = new MemoryStream(dataBlock);
|
||||
BinaryReader binReader = new BinaryReader(memStream);
|
||||
|
||||
int freeSpace = binReader.ReadInt16(); // length of freespace
|
||||
int nrOfEntries = binReader.ReadInt16(); // number of entries
|
||||
|
||||
bool bListingEndReached = false;
|
||||
|
||||
//while( (memStream.Position < (memStream.Length-freeSpace)) && (bRet) )
|
||||
//{
|
||||
int nIndexOfPrevBlock = -1;
|
||||
int nIndexOfNextBlock = -1;
|
||||
int nIndexOfChildBlock = 0;
|
||||
|
||||
if(_readListingBlocks)
|
||||
{
|
||||
nIndexOfPrevBlock = binReader.ReadInt32(); // -1 if this is the header
|
||||
nIndexOfNextBlock = binReader.ReadInt32(); // -1 if this is the last block
|
||||
}
|
||||
else
|
||||
{
|
||||
nIndexOfChildBlock = binReader.ReadInt32();
|
||||
}
|
||||
|
||||
for(int nE = 0; nE < nrOfEntries; nE++)
|
||||
{
|
||||
if(_readListingBlocks)
|
||||
{
|
||||
bListingEndReached = (nIndexOfNextBlock==-1);
|
||||
|
||||
string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding);
|
||||
|
||||
bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0);
|
||||
|
||||
int indent = binReader.ReadInt16(); // indent of entry
|
||||
int nCharIndex = binReader.ReadInt32();
|
||||
|
||||
binReader.ReadInt32();
|
||||
|
||||
int numberOfPairs = binReader.ReadInt32();
|
||||
|
||||
int[] nTopics = new int[numberOfPairs];
|
||||
string[] seeAlso = new string[numberOfPairs];
|
||||
|
||||
for(int i=0; i < numberOfPairs; i++)
|
||||
{
|
||||
if(isSeeAlsoKeyword)
|
||||
{
|
||||
seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTopics[i] = binReader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
binReader.ReadInt32(); // unknown
|
||||
|
||||
int nIndexOfThisEntry = binReader.ReadInt32();
|
||||
|
||||
IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics);
|
||||
_indexList.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding);
|
||||
|
||||
bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0);
|
||||
|
||||
int indent = binReader.ReadInt16(); // indent of entry
|
||||
int nCharIndex = binReader.ReadInt32();
|
||||
|
||||
binReader.ReadInt32();
|
||||
|
||||
int numberOfPairs = binReader.ReadInt32();
|
||||
|
||||
int[] nTopics = new int[numberOfPairs];
|
||||
string[] seeAlso = new string[numberOfPairs];
|
||||
|
||||
for(int i=0; i < numberOfPairs; i++)
|
||||
{
|
||||
if(isSeeAlsoKeyword)
|
||||
{
|
||||
seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTopics[i] = binReader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
int nIndexChild = binReader.ReadInt32();
|
||||
int nIndexOfThisEntry=-1;
|
||||
|
||||
IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics);
|
||||
_indexList.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
binReader.ReadBytes(freeSpace);
|
||||
|
||||
|
||||
if( bListingEndReached )
|
||||
_readListingBlocks = false;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal generated index list
|
||||
/// </summary>
|
||||
internal ArrayList IndexList
|
||||
{
|
||||
get { return _indexList; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement IDisposable.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
// This object will be cleaned up by the Dispose method.
|
||||
// Therefore, you should call GC.SupressFinalize to
|
||||
// take this object off the finalization queue
|
||||
// and prevent finalization code for this object
|
||||
// from executing a second time.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose(bool disposing) executes in two distinct scenarios.
|
||||
/// If disposing equals true, the method has been called directly
|
||||
/// or indirectly by a user's code. Managed and unmanaged resources
|
||||
/// can be disposed.
|
||||
/// If disposing equals false, the method has been called by the
|
||||
/// runtime from inside the finalizer and you should not reference
|
||||
/// other objects. Only unmanaged resources can be disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">disposing flag</param>
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if(!this.disposed)
|
||||
{
|
||||
// If disposing equals true, dispose all managed
|
||||
// and unmanaged resources.
|
||||
if(disposing)
|
||||
{
|
||||
// Dispose managed resources.
|
||||
_binaryFileData = null;
|
||||
}
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user