// // ~ • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
Timo,
Wow, I cannot believe the nice work you did !!!!
Boy I tip my hat to you !!!!
I am just speechless. Such fine work. I am surprised I was smart enough to get it to work !!!
Really super. Really impressive. Wow !!!!
Tx, sure would not have thought something like this could be done.
Yikes, I feel pretty small !
Tx, will comment some more in a day or two.
Best Regards,
Ed
/****************************************************************************
* *
* File : Export.c *
* *
* Purpose : Add-In for Pelles C - export C source as XXX file. *
* *
* History : Date Reason *
* 05-03-16 Created *
* *
****************************************************************************/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commdlg.h>
#include <addin.h>
#include <tchar.h>
#include <stdlib.h>
#include <stdio.h>
#include "Export2XXX.h"
#define NELEMS(a) (sizeof(a) / sizeof(a[0]))
#define COOKIE_COMMENT 0x0001
#define COOKIE_PREPROCESSOR 0x0002
#define COOKIE_EXT_COMMENT 0x0004
#define COOKIE_STRING 0x0008
#define COOKIE_CHAR 0x0010
enum {
COLOR_TEXT = 0,
COLOR_KEYWORD = 1,
COLOR_COMMENT = 2,
COLOR_NUMBER = 3,
COLOR_STRING = 4,
COLOR_PREPROCESSOR = 5,
COLOR_OPERATOR = 6,
};
typedef struct _PARSEPOINT *PPARSEPOINT;
typedef struct _PARSEPOINT {
int iChar; // Column position where text changes...
int iColor; // ...to this color index.
} PARSEPOINT;
// Private command ID.
#define ID_EXPORT_XXXX 1
// Locals.
static HANDLE g_hmod = NULL;
static HWND g_hwndMain = NULL;
// C keywords + M$ junk.
static PCTSTR apszKeywords[] = {
_T("_Bool"),
_T("_Complex"),
_T("_Imaginary"),
_T("_Pragma"),
_T("__asm"),
_T("__cdecl"),
_T("__declspec"),
_T("__except"),
_T("__fastcall"),
_T("__finally"),
_T("__func__"),
_T("__inline"),
_T("__int16"),
_T("__int32"),
_T("__int64"),
_T("__int8"),
_T("__leave"),
_T("__stdcall"),
_T("__try"),
_T("_asm"),
_T("_cdecl"),
_T("_fastcall"),
_T("_inline"),
_T("_stdcall"),
_T("auto"),
_T("break"),
_T("case"),
_T("char"),
_T("const"),
_T("continue"),
_T("default"),
_T("do"),
_T("double"),
_T("else"),
_T("enum"),
_T("extern"),
_T("float"),
_T("for"),
_T("goto"),
_T("if"),
_T("inline"),
_T("int"),
_T("long"),
_T("register"),
_T("restrict"),
_T("return"),
_T("short"),
_T("signed"),
_T("sizeof"),
_T("static"),
_T("struct"),
_T("switch"),
_T("typedef"),
_T("union"),
_T("unsigned"),
_T("void"),
_T("volatile"),
_T("while")
};
#define DEFINE_BLOCK(pos, colorindex) \
if (aPoints != NULL) \
{\
if (*pcPoints == 0 || aPoints[(*pcPoints)-1].iChar <= (pos)) \
{ \
aPoints[(*pcPoints)].iChar = (pos);\
aPoints[(*pcPoints)].iColor = (colorindex);\
(*pcPoints)++; \
} \
}
// Static function prototypes.
static void Export2XXX(HWND, PCTSTR);
static char * XXX_EmitColor(PCTSTR, int);
static UINT C_Parser(UINT, PCTSTR, int, PARSEPOINT [], PINT);
static int IsKeyword(PCTSTR [], int, PCTSTR, int);
static BOOL IsNumber(PCTSTR, int);
/****************************************************************************
* *
* Function: DllMain *
* *
* Purpose : DLL entry and exit procedure. *
* *
* History : Date Reason *
* 04-01-10 Created *
* *
****************************************************************************/
// // ~ • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •