[go: up one dir, main page]

Menu

[2e205f]: / tea / src / Tea.h  Maximize  Restore  History

Download this file

111 lines (83 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
/*
*
* TEA - A quick and simple text preprocessor
* Copyright (C) 2010-2016 DarkBatcher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TEA_LIB_H
#define TEA_LIB_H
#include <libDos9.h>
#define TEA_NODE_PLAIN_TEXT (0)
#define TEA_NODE_LINK (1)
#define TEA_NODE_EMPHASIS (2)
#define TEA_BLOCK_PARAGRAPH (3)
#define TEA_BLOCK_CODE (4)
#define TEA_BLOCK_HEADING (5)
#define TEA_LIST_NO_MARK (1)
#define TEA_MSG_READ_FILE (1)
#define TEA_MSG_MAKE_NODE (2)
typedef struct TEANODE {
int iNodeType;
char *lpContent;
char *lpTarget;
struct TEANODE* lpTeaNodeNext;
} TEANODE,*LPTEANODE;
typedef struct TEAPAGE {
int iBlockType;
int iBlockLevel;
int iFlag;
char* lpBlockContent;
struct TEANODE* lpTeaNode; //
struct TEAPAGE* lpTeaNext;
} TEAPAGE,*LPTEAPAGE;
/*
the modifier functions
*/
typedef void(*LP_OUTPUT_HANDLER)(TEAPAGE*,FILE*,int,char**);
typedef void(*LP_PARSE_HANDLER)(int,void*);
extern ESTR* lpEsEncoding;
TEAPAGE* Tea_PageLoad(const char* lpFilename, LP_PARSE_HANDLER pHandler);
TEAPAGE* Tea_ParseStringBlock(char* lpContent);
TEAPAGE* Tea_AllocTeaPage(void);
void Tea_FreeTeaPage(TEAPAGE* lpTeaPage);
int Tea_PurifyPage(TEAPAGE* lpTeaPage);
int Tea_SweepSpace(char* lpContent);
int Tea_SweepCodeTabs(char* lpContent);
int Tea_BreakParagraph(TEAPAGE* lpTeaPage);
TEAPAGE* Tea_RemoveVoidBlocks(TEAPAGE* lpTeaPage);
int Tea_MakeLevels(TEAPAGE* lpTeaPage);
void Tea_ParseParagraphs(TEAPAGE* lpTeaPage, LP_PARSE_HANDLER pHandler);
int Tea_PageFree(TEAPAGE* lpTeaPage);
char* Tea_SeekNextDelimiter(const char* lpBeginPos, const char** lpToken, int* iDelimPos);
char* Tea_SeekNextClosingBrace(const char* lpBeginPos);
TEANODE* Tea_AllocTeaNode(void);
void Tea_FreeTeaNode(TEANODE* lpTeaNode);
TEANODE* Tea_ParseStringNode(char* lpContent, LP_PARSE_HANDLER pHandler);
int Tea_PurifyNode(TEANODE* lpTeaNode);
int Tea_SweepSpaceNode(char* lpContent, int* iSweepBegin);
TEANODE* Tea_RemoveVoidNode(TEANODE* lpTeaNode);
/* for teanode specific word */
size_t Tea_GetWordLengthT(char* lpBegin, TEANODE* lpTeaNode);
/* for all-purpose words */
size_t Tea_GetWordLength(char* lpBegin);
void Tea_MakeMargin(size_t iLength, size_t* iLeft, FILE* pFile);
char* Tea_OutputWord(char* lpBegin, FILE* pFile, size_t* iLeft);
char* Tea_OutputLineT(char* lpBegin, FILE* pFile, TEANODE* lpTeaNode, size_t* iLeft);
char* Tea_OutputLine(char* lpBegin, FILE* pFile, size_t* iLeft);
#ifndef WIN32
char* strupr(char*);
#endif
#endif // TEA_LIB_H