ReactOS 0.4.16-dev-1484-g212a1a5
reader.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
#include "editor.h"
#include "rtf.h"
Include dependency graph for reader.c:

Go to the source code of this file.

Classes

struct  RTFKey
 
struct  tagRTFHashTableEntry
 

Typedefs

typedef struct RTFKey RTFKey
 
typedef struct tagRTFHashTableEntry RTFHashTableEntry
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (richedit)
 
static int _RTFGetChar (RTF_Info *)
 
static void _RTFGetToken (RTF_Info *)
 
static void _RTFGetToken2 (RTF_Info *)
 
static int GetChar (RTF_Info *)
 
static void ReadFontTbl (RTF_Info *)
 
static void ReadColorTbl (RTF_Info *)
 
static void ReadStyleSheet (RTF_Info *)
 
static void ReadInfoGroup (RTF_Info *)
 
static void ReadPictGroup (RTF_Info *)
 
static void ReadObjGroup (RTF_Info *)
 
static void Lookup (RTF_Info *, char *)
 
static int Hash (const char *)
 
static void CharAttr (RTF_Info *info)
 
static void CharSet (RTF_Info *info)
 
static void DocAttr (RTF_Info *info)
 
static void RTFFlushCPOutputBuffer (RTF_Info *info)
 
static void RTFPutCodePageChar (RTF_Info *info, int c)
 
void RTFSetEditStream (RTF_Info *info, ME_InStream *stream)
 
static void RTFDestroyAttrs (RTF_Info *info)
 
void RTFDestroy (RTF_Info *info)
 
static void RTFSetClassCallback (RTF_Info *info, int class, RTFFuncPtr callback)
 
static RTFFuncPtr RTFGetClassCallback (const RTF_Info *info, int class)
 
void RTFInit (RTF_Info *info)
 
void RTFSetDestinationCallback (RTF_Info *info, int dest, RTFFuncPtr callback)
 
static RTFFuncPtr RTFGetDestinationCallback (const RTF_Info *info, int dest)
 
void RTFRead (RTF_Info *info)
 
void RTFRouteToken (RTF_Info *info)
 
void RTFSkipGroup (RTF_Info *info)
 
void RTFReadGroup (RTF_Info *info)
 
void RTFSetReadHook (RTF_Info *info, RTFFuncPtr f)
 
static RTFFuncPtr RTFGetReadHook (const RTF_Info *info)
 
int RTFGetToken (RTF_Info *info)
 
static void RTFUngetToken (RTF_Info *info)
 
int RTFCharSetToCodePage (RTF_Info *info, int charset)
 
RTFFontRTFGetFont (const RTF_Info *info, int num)
 
RTFColorRTFGetColor (const RTF_Info *info, int num)
 
void LookupInit (void)
 
void LookupCleanup (void)
 
int RTFCheckCM (const RTF_Info *info, int class, int major)
 
int RTFCheckCMM (const RTF_Info *info, int class, int major, int minor)
 
int RTFCheckMM (const RTF_Info *info, int major, int minor)
 
int RTFCharToHex (char c)
 
static void TextClass (RTF_Info *info)
 
static void ControlClass (RTF_Info *info)
 
static void DefFont (RTF_Info *info)
 
static void Destination (RTF_Info *info)
 
static void SpecialChar (RTF_Info *info)
 
static void RTFPutUnicodeChar (RTF_Info *info, int c)
 
void WriterInit (RTF_Info *info)
 
int BeginFile (RTF_Info *info)
 
static void RTFFlushUnicodeOutputBuffer (RTF_Info *info)
 
static void RTFPutUnicodeString (RTF_Info *info, const WCHAR *string, int length)
 
void RTFFlushOutputBuffer (RTF_Info *info)
 

Variables

static RTFKey rtfKey []
 
static RTFHashTableEntry rtfHashTable [ARRAY_SIZE(rtfKey) *2]
 

Typedef Documentation

◆ RTFHashTableEntry

◆ RTFKey

typedef struct RTFKey RTFKey

Definition at line 1242 of file reader.c.

Function Documentation

◆ _RTFGetChar()

int _RTFGetChar ( RTF_Info info)
static

Definition at line 78 of file reader.c.

79{
80 int ch;
81 ME_InStream *stream = info->stream;
82
83 if (stream->dwSize <= stream->dwUsed)
84 {
86 /* if error, it's EOF */
87 if (stream->editstream->dwError)
88 return EOF;
89 /* if no bytes read, it's EOF */
90 if (stream->dwSize == 0)
91 return EOF;
92 }
93 ch = (unsigned char)stream->buffer[stream->dwUsed++];
94 if (!ch)
95 return ' ';
96 return ch;
97}
void ME_StreamInFill(ME_InStream *stream)
Definition: editor.c:1562
unsigned char
Definition: typeof.h:29
#define EOF
Definition: stdio.h:24
if(dx< 0)
Definition: linetemp.h:194
Definition: parse.h:23

Referenced by GetChar().

◆ _RTFGetToken()

static void _RTFGetToken ( RTF_Info info)
static

Definition at line 437 of file reader.c.

438{
439 if (info->rtfFormat == SF_TEXT)
440 {
441 info->rtfMajor = GetChar (info);
442 info->rtfMinor = 0;
443 info->rtfParam = rtfNoParam;
444 info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
445 if (info->rtfMajor == EOF)
446 info->rtfClass = rtfEOF;
447 else
448 info->rtfClass = rtfText;
449 return;
450 }
451
452 /* first check for pushed token from RTFUngetToken() */
453
454 if (info->pushedClass >= 0)
455 {
456 info->rtfClass = info->pushedClass;
457 info->rtfMajor = info->pushedMajor;
458 info->rtfMinor = info->pushedMinor;
459 info->rtfParam = info->pushedParam;
460 lstrcpyA (info->rtfTextBuf, info->pushedTextBuf);
461 info->rtfTextLen = lstrlenA(info->rtfTextBuf);
462 info->pushedClass = -1;
463 return;
464 }
465
466 /*
467 * Beyond this point, no token is ever seen twice, which is
468 * important, e.g., for making sure no "}" pops the font stack twice.
469 */
470
472}
static void _RTFGetToken2(RTF_Info *)
Definition: reader.c:537
static int GetChar(RTF_Info *)
Definition: reader.c:708
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define SF_TEXT
Definition: richedit.h:720
#define rtfEOF
Definition: rtf.h:82
#define rtfNoParam
Definition: rtf.h:62
#define rtfText
Definition: rtf.h:80

Referenced by RTFGetToken().

◆ _RTFGetToken2()

static void _RTFGetToken2 ( RTF_Info info)
static

Definition at line 537 of file reader.c.

538{
539 int sign;
540 int c;
541
542 /* initialize token vars */
543
544 info->rtfClass = rtfUnknown;
545 info->rtfParam = rtfNoParam;
546 info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
547
548 /* get first character, which may be a pushback from previous token */
549
550 if (info->pushedChar != EOF)
551 {
552 c = info->pushedChar;
553 info->rtfTextBuf[info->rtfTextLen++] = c;
554 info->rtfTextBuf[info->rtfTextLen] = '\0';
555 info->pushedChar = EOF;
556 }
557 else if ((c = GetChar (info)) == EOF)
558 {
559 info->rtfClass = rtfEOF;
560 return;
561 }
562
563 if (c == '{')
564 {
565 info->rtfClass = rtfGroup;
566 info->rtfMajor = rtfBeginGroup;
567 return;
568 }
569 if (c == '}')
570 {
571 info->rtfClass = rtfGroup;
572 info->rtfMajor = rtfEndGroup;
573 return;
574 }
575 if (c != '\\')
576 {
577 /*
578 * Two possibilities here:
579 * 1) ASCII 9, effectively like \tab control symbol
580 * 2) literal text char
581 */
582 if (c == '\t') /* ASCII 9 */
583 {
584 info->rtfClass = rtfControl;
585 info->rtfMajor = rtfSpecialChar;
586 info->rtfMinor = rtfTab;
587 }
588 else
589 {
590 info->rtfClass = rtfText;
591 info->rtfMajor = c;
592 }
593 return;
594 }
595 if ((c = GetChar (info)) == EOF)
596 {
597 /* early eof, whoops (class is rtfUnknown) */
598 return;
599 }
600 if (!isalpha (c))
601 {
602 /*
603 * Three possibilities here:
604 * 1) hex encoded text char, e.g., \'d5, \'d3
605 * 2) special escaped text char, e.g., \{, \}
606 * 3) control symbol, e.g., \_, \-, \|, <10>
607 */
608 if (c == '\'') /* hex char */
609 {
610 int c2;
611
612 if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF
613 && isxdigit(c) && isxdigit(c2))
614 {
615 info->rtfClass = rtfText;
616 info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2);
617 return;
618 }
619 /* early eof, whoops */
620 info->rtfClass = rtfEOF;
621 info->stream->editstream->dwError = -14;
622 return;
623 }
624
625 /* escaped char */
626 /*if (index (":{}\\", c) != NULL)*/ /* escaped char */
627 if (c == ':' || c == '{' || c == '}' || c == '\\')
628 {
629 info->rtfClass = rtfText;
630 info->rtfMajor = c;
631 return;
632 }
633
634 /* control symbol */
635 Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
636 return;
637 }
638 /* control word */
639 while (isalpha (c))
640 {
641 if ((c = GetChar (info)) == EOF)
642 break;
643 }
644
645 /*
646 * At this point, the control word is all collected, so the
647 * major/minor numbers are determined before the parameter
648 * (if any) is scanned. There will be one too many characters
649 * in the buffer, though, so fix up before and restore after
650 * looking up.
651 */
652
653 if (c != EOF)
654 info->rtfTextBuf[info->rtfTextLen-1] = '\0';
655 Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
656 if (c != EOF)
657 info->rtfTextBuf[info->rtfTextLen-1] = c;
658
659 /*
660 * Should be looking at first digit of parameter if there
661 * is one, unless it's negative. In that case, next char
662 * is '-', so need to gobble next char, and remember sign.
663 */
664
665 sign = 1;
666 if (c == '-')
667 {
668 sign = -1;
669 c = GetChar (info);
670 }
671 if (c != EOF && isdigit (c))
672 {
673 info->rtfParam = 0;
674 while (isdigit (c)) /* gobble parameter */
675 {
676 info->rtfParam = info->rtfParam * 10 + c - '0';
677 if ((c = GetChar (info)) == EOF)
678 break;
679 }
680 info->rtfParam *= sign;
681 }
682 /*
683 * If control symbol delimiter was a blank, gobble it.
684 * Otherwise the character is first char of next token, so
685 * push it back for next call. In either case, delete the
686 * delimiter from the token buffer.
687 */
688 if (c != EOF)
689 {
690 if (c != ' ')
691 info->pushedChar = c;
692 info->rtfTextBuf[--info->rtfTextLen] = '\0';
693 }
694}
#define isalpha(c)
Definition: acclib.h:74
#define isdigit(c)
Definition: acclib.h:68
#define isxdigit(c)
Definition: acclib.h:70
static void Lookup(RTF_Info *, char *)
Definition: reader.c:2208
int RTFCharToHex(char c)
Definition: reader.c:2277
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define sign(x)
Definition: mapdesc.cc:613
#define rtfBeginGroup
Definition: rtf.h:89
#define rtfEndGroup
Definition: rtf.h:90
#define rtfSpecialChar
Definition: rtf.h:206
#define rtfTab
Definition: rtf.h:246
#define rtfControl
Definition: rtf.h:81
#define rtfGroup
Definition: rtf.h:79
#define rtfUnknown
Definition: rtf.h:78

Referenced by _RTFGetToken().

◆ BeginFile()

int BeginFile ( RTF_Info info)

Definition at line 2315 of file reader.c.

2316{
2317 /* install class callbacks */
2318
2321
2322 return (1);
2323}
static const WCHAR ControlClass[]
Definition: cfgmgr.c:38
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:174
static void TextClass(RTF_Info *info)
Definition: reader.c:2330

Referenced by ME_StreamIn().

◆ CharAttr()

static void CharAttr ( RTF_Info info)
static

Definition at line 2372 of file reader.c.

2373{
2374 RTFFont *font;
2375
2376 switch (info->rtfMinor)
2377 {
2378 case rtfFontNum:
2379 font = RTFGetFont(info, info->rtfParam);
2380 if (font)
2381 {
2382 if (info->ansiCodePage != CP_UTF8 && info->codePage != font->rtfFCodePage)
2383 {
2385 info->codePage = font->rtfFCodePage;
2386 }
2387 TRACE("font %d codepage %d\n", info->rtfParam, info->codePage);
2388 }
2389 else
2390 ERR( "unknown font %d\n", info->rtfParam);
2391 break;
2392 case rtfUnicodeLength:
2393 info->unicodeLength = info->rtfParam;
2394 break;
2395 }
2396}
#define ERR(fmt,...)
Definition: precomp.h:57
RTFFont * RTFGetFont(const RTF_Info *info, int num)
Definition: reader.c:1205
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2606
Definition: mk_font.cpp:20
#define rtfUnicodeLength
Definition: rtf.h:599
#define rtfFontNum
Definition: rtf.h:573
#define CP_UTF8
Definition: nls.h:20
#define TRACE(s)
Definition: solgame.cpp:4
Definition: rtf.h:960

Referenced by ControlClass().

◆ CharSet()

static void CharSet ( RTF_Info info)
static

Definition at line 2400 of file reader.c.

2401{
2402 if (info->ansiCodePage == CP_UTF8)
2403 return;
2404
2405 switch (info->rtfMinor)
2406 {
2407 case rtfAnsiCharSet:
2408 info->ansiCodePage = 1252; /* Latin-1 */
2409 break;
2410 case rtfMacCharSet:
2411 info->ansiCodePage = 10000; /* MacRoman */
2412 break;
2413 case rtfPcCharSet:
2414 info->ansiCodePage = 437;
2415 break;
2416 case rtfPcaCharSet:
2417 info->ansiCodePage = 850;
2418 break;
2419 }
2420}
#define rtfPcCharSet
Definition: rtf.h:103
#define rtfMacCharSet
Definition: rtf.h:102
#define rtfAnsiCharSet
Definition: rtf.h:101
#define rtfPcaCharSet
Definition: rtf.h:104

Referenced by AddDlg_OnInitDialog(), ControlClass(), EditDlg_OnInitDialog(), GetFontSig(), IntGetCharSet(), is_charset_font_installed(), is_fixed_charset_font_installed(), main(), NameFromCharSet(), and T1_OnImeControl().

◆ ControlClass()

static void ControlClass ( RTF_Info info)
static

Definition at line 2337 of file reader.c.

2338{
2339 switch (info->rtfMajor)
2340 {
2341 case rtfCharAttr:
2342 CharAttr(info);
2344 break;
2345 case rtfParAttr:
2347 break;
2348 case rtfTblAttr:
2350 break;
2351 case rtfCharSet:
2352 CharSet(info);
2353 break;
2354 case rtfDefFont:
2355 DefFont(info);
2356 break;
2357 case rtfDestination:
2358 Destination (info);
2359 break;
2360 case rtfDocAttr:
2361 DocAttr(info);
2362 break;
2363 case rtfSpecialChar:
2364 SpecialChar (info);
2366 break;
2367 }
2368}
void ME_RTFTblAttrHook(RTF_Info *info)
Definition: editor.c:869
void ME_RTFCharAttrHook(RTF_Info *info)
Definition: editor.c:425
void ME_RTFSpecialCharHook(RTF_Info *info)
Definition: editor.c:943
void ME_RTFParAttrHook(RTF_Info *info)
Definition: editor.c:556
static void CharAttr(RTF_Info *info)
Definition: reader.c:2372
static void SpecialChar(RTF_Info *info)
Definition: reader.c:2461
static void CharSet(RTF_Info *info)
Definition: reader.c:2400
static void DocAttr(RTF_Info *info)
Definition: reader.c:2445
static void DefFont(RTF_Info *info)
Definition: reader.c:2437
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3043
#define rtfTblAttr
Definition: rtf.h:414
#define rtfCharAttr
Definition: rtf.h:562
#define rtfDefFont
Definition: rtf.h:98
#define rtfParAttr
Definition: rtf.h:455
#define rtfCharSet
Definition: rtf.h:100
#define rtfDocAttr
Definition: rtf.h:276
#define rtfDestination
Definition: rtf.h:109

◆ DefFont()

static void DefFont ( RTF_Info info)
static

Definition at line 2437 of file reader.c.

2438{
2439 TRACE("%d\n", info->rtfParam);
2440 info->defFont = info->rtfParam;
2441}

Referenced by ControlClass().

◆ Destination()

static void Destination ( RTF_Info info)
static

Definition at line 2429 of file reader.c.

2430{
2431 if (!RTFGetDestinationCallback(info, info->rtfMinor))
2432 RTFSkipGroup (info);
2433}
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:271
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:337

◆ DocAttr()

static void DocAttr ( RTF_Info info)
static

Definition at line 2445 of file reader.c.

2446{
2447 TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
2448
2449 switch (info->rtfMinor)
2450 {
2451 case rtfAnsiCodePage:
2452 info->codePage = info->ansiCodePage = info->rtfParam;
2453 break;
2454 case rtfUTF8RTF:
2455 info->codePage = info->ansiCodePage = CP_UTF8;
2456 break;
2457 }
2458}
#define rtfAnsiCodePage
Definition: rtf.h:355
#define rtfUTF8RTF
Definition: rtf.h:356

Referenced by ControlClass().

◆ GetChar()

static int GetChar ( RTF_Info info)
static

Definition at line 708 of file reader.c.

709{
710 int c;
711 BOOL oldBumpLine;
712
713 if ((c = _RTFGetChar(info)) != EOF)
714 {
715 info->rtfTextBuf[info->rtfTextLen++] = c;
716 info->rtfTextBuf[info->rtfTextLen] = '\0';
717 }
718 if (info->prevChar == EOF)
719 info->bumpLine = TRUE;
720 oldBumpLine = info->bumpLine; /* TRUE if prev char was line ending */
721 info->bumpLine = FALSE;
722 if (c == '\r')
723 info->bumpLine = TRUE;
724 else if (c == '\n')
725 {
726 info->bumpLine = TRUE;
727 if (info->prevChar == '\r') /* oops, previous \r wasn't */
728 oldBumpLine = FALSE; /* really a line ending */
729 }
730 ++info->rtfLinePos;
731 if (oldBumpLine) /* were we supposed to increment the */
732 { /* line count on this char? */
733 ++info->rtfLineNum;
734 info->rtfLinePos = 1;
735 }
736 info->prevChar = c;
737 return (c);
738}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static int _RTFGetChar(RTF_Info *)
Definition: reader.c:78
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by _RTFGetToken(), and _RTFGetToken2().

◆ Hash()

◆ Lookup()

static void Lookup ( RTF_Info info,
char s 
)
static

Definition at line 2208 of file reader.c.

2209{
2210 RTFKey *rp;
2211 int hash;
2213 int i;
2214
2215 ++s; /* skip over the leading \ character */
2216 hash = Hash (s);
2218 for (i = 0; i < entry->count; i++)
2219 {
2220 rp = entry->value[i];
2221 if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2222 {
2223 info->rtfClass = rtfControl;
2224 info->rtfMajor = rp->rtfKMajor;
2225 info->rtfMinor = rp->rtfKMinor;
2226 return;
2227 }
2228 }
2229 info->rtfClass = rtfUnknown;
2230}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAY_SIZE(A)
Definition: main.h:20
static RTFHashTableEntry rtfHashTable[ARRAY_SIZE(rtfKey) *2]
Definition: reader.c:2167
static int Hash(const char *)
Definition: reader.c:2237
static RTFKey rtfKey[]
Definition: reader.c:1257
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
int rtfKMajor
Definition: reader.c:1246
const char * rtfKStr
Definition: reader.c:1248
int rtfKMinor
Definition: reader.c:1247
int rtfKHash
Definition: reader.c:1249
Definition: _hash_fun.h:40

Referenced by _RTFGetToken2(), ApphelpCacheLookupEntry(), ApphelpCacheUpdateEntry(), BasepShimCacheRemoveEntry(), BasepShimCacheSearch(), GetProtoPatternMatch(), and RtlLookupElementGenericTableAvl().

◆ LookupCleanup()

void LookupCleanup ( void  )

Definition at line 2190 of file reader.c.

2191{
2192 unsigned int i;
2193
2194 for (i = 0; i < ARRAY_SIZE(rtfKey) * 2; i++)
2195 {
2198 rtfHashTable[i].count = 0;
2199 }
2200}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
RTFKey ** value
Definition: reader.c:2164
Definition: pdh_main.c:96

Referenced by DllMain().

◆ LookupInit()

void LookupInit ( void  )

Definition at line 2174 of file reader.c.

2175{
2176 RTFKey *rp;
2177
2178 memset(rtfHashTable, 0, sizeof rtfHashTable);
2179 for (rp = rtfKey; rp->rtfKStr != NULL; rp++)
2180 {
2181 int index;
2182
2183 rp->rtfKHash = Hash (rp->rtfKStr);
2184 index = rp->rtfKHash % (ARRAY_SIZE(rtfKey) * 2);
2187 }
2188}
#define index(s, c)
Definition: various.h:29
#define realloc
Definition: debug_ros.c:6
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
#define memset(x, y, z)
Definition: compat.h:39

Referenced by DllMain().

◆ ReadColorTbl()

static void ReadColorTbl ( RTF_Info info)
static

Definition at line 948 of file reader.c.

949{
950 RTFColor *cp;
951 int cnum = 0;
952 int group_level = 1;
953
954 for (;;)
955 {
957 if (info->rtfClass == rtfEOF)
958 break;
960 {
961 group_level--;
962 if (!group_level)
963 break;
964 continue;
965 }
967 {
968 group_level++;
969 continue;
970 }
971
972 cp = malloc (sizeof(*cp));
973 if (cp == NULL) {
974 ERR ("cannot allocate color entry\n");
975 break;
976 }
977 cp->rtfCNum = cnum++;
978 cp->rtfNextColor = info->colorList;
979 info->colorList = cp;
981 cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
982 else {
983 cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = 0;
984 do {
985 switch (info->rtfMinor)
986 {
987 case rtfRed: cp->rtfCRed = info->rtfParam & 0xFF; break;
988 case rtfGreen: cp->rtfCGreen = info->rtfParam & 0xFF; break;
989 case rtfBlue: cp->rtfCBlue = info->rtfParam & 0xFF; break;
990 }
993 }
994 if (info->rtfClass == rtfEOF)
995 break;
996 if (!RTFCheckCM (info, rtfText, ';'))
997 ERR ("malformed entry\n");
998 }
999 RTFRouteToken (info); /* feed "}" back to router */
1000}
#define malloc
Definition: debug_ros.c:4
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2256
int RTFGetToken(RTF_Info *info)
Definition: reader.c:389
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:304
POINT cp
Definition: magnifier.c:59
#define rtfColorName
Definition: rtf.h:201
#define rtfGreen
Definition: rtf.h:203
#define rtfBlue
Definition: rtf.h:204
#define rtfRed
Definition: rtf.h:202
Definition: rtf.h:979

Referenced by RTFInit().

◆ ReadFontTbl()

static void ReadFontTbl ( RTF_Info info)
static

Definition at line 769 of file reader.c.

770{
771 RTFFont *fp = NULL;
772 char buf[rtfBufSiz], *bp;
773 int old = -1;
774
775 for (;;)
776 {
778 if (info->rtfClass == rtfEOF)
779 break;
781 break;
782 if (old < 0) /* first entry - determine tbl type */
783 {
785 old = 1; /* no brace */
787 old = 0; /* brace */
788 else /* can't tell! */
789 ERR ("cannot determine format\n");
790 }
791 if (old == 0) /* need to find "{" here */
792 {
794 ERR ("missing \"{\"\n");
795 RTFGetToken (info); /* yes, skip to next token */
796 if (info->rtfClass == rtfEOF)
797 break;
798 }
799 fp = malloc (sizeof(*fp));
800 if (fp == NULL) {
801 ERR ("cannot allocate font entry\n");
802 break;
803 }
804
805 fp->rtfNextFont = info->fontList;
806 info->fontList = fp;
807
808 fp->rtfFName = NULL;
809 fp->rtfFAltName = NULL;
810 fp->rtfFNum = -1;
812 fp->rtfFCharSet = DEFAULT_CHARSET; /* 1 */
814 fp->rtfFType = 0;
815 fp->rtfFCodePage = CP_ACP;
816
817 while (info->rtfClass != rtfEOF
818 && !RTFCheckCM (info, rtfText, ';')
820 {
821 if (info->rtfClass == rtfControl)
822 {
823 switch (info->rtfMajor)
824 {
825 default:
826 /* ignore token but announce it */
827 WARN ("unknown token \"%s\"\n",
828 info->rtfTextBuf);
829 break;
830 case rtfFontFamily:
831 fp->rtfFFamily = info->rtfMinor;
832 break;
833 case rtfCharAttr:
834 switch (info->rtfMinor)
835 {
836 default:
837 break; /* ignore unknown? */
838 case rtfFontNum:
839 fp->rtfFNum = info->rtfParam;
840 break;
841 }
842 break;
843 case rtfFontAttr:
844 switch (info->rtfMinor)
845 {
846 default:
847 break; /* ignore unknown? */
848 case rtfFontCharSet:
849 fp->rtfFCharSet = info->rtfParam;
850 if (!fp->rtfFCodePage)
851 fp->rtfFCodePage = RTFCharSetToCodePage(info, info->rtfParam);
852 break;
853 case rtfFontPitch:
854 fp->rtfFPitch = info->rtfParam;
855 break;
856 case rtfFontCodePage:
857 fp->rtfFCodePage = info->rtfParam;
858 break;
859 case rtfFTypeNil:
860 case rtfFTypeTrueType:
861 fp->rtfFType = info->rtfParam;
862 break;
863 }
864 break;
865 }
866 }
867 else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) /* dest */
868 {
869 RTFSkipGroup (info); /* ignore for now */
870 }
871 else if (info->rtfClass == rtfText) /* font name */
872 {
873 bp = buf;
874 while (info->rtfClass == rtfText
875 && !RTFCheckCM (info, rtfText, ';'))
876 {
877 *bp++ = info->rtfMajor;
879 }
880
881 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
883 {
885 }
886 *bp = '\0';
887 fp->rtfFName = strdup (buf);
888 if (fp->rtfFName == NULL)
889 ERR ("cannot allocate font name\n");
890 /* already have next token; don't read one */
891 /* at bottom of loop */
892 continue;
893 }
894 else
895 {
896 /* ignore token but announce it */
897 WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
898 }
900 if (info->rtfClass == rtfEOF)
901 break;
902 }
903 if (info->rtfClass == rtfEOF)
904 break;
905 if (old == 0) /* need to see "}" here */
906 {
909 ERR ("missing \"}\"\n");
910 if (info->rtfClass == rtfEOF)
911 break;
912 }
913
914 /* Apply the real properties of the default font */
915 if (fp->rtfFNum == info->defFont)
916 {
917 if (info->ansiCodePage != CP_UTF8)
918 info->codePage = fp->rtfFCodePage;
919 TRACE("default font codepage %d\n", info->codePage);
920 }
921 }
922 if (!fp || (fp->rtfFNum == -1))
923 ERR("missing font number\n");
924/*
925 * Could check other pieces of structure here, too, I suppose.
926 */
927 RTFRouteToken (info); /* feed "}" back to router */
928
929 /* Set default font */
930 info->rtfClass = rtfControl;
931 info->rtfMajor = rtfCharAttr;
932 info->rtfMinor = rtfFontNum;
933 info->rtfParam = info->defFont;
934 lstrcpyA(info->rtfTextBuf, "f");
936}
#define WARN(fmt,...)
Definition: precomp.h:61
#define CP_ACP
Definition: compat.h:109
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:476
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:414
int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
Definition: reader.c:2262
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfFontFamily
Definition: rtf.h:191
#define rtfFontAttr
Definition: rtf.h:734
#define rtfFTypeTrueType
Definition: rtf.h:739
#define rtfBufSiz
Definition: rtf.h:30
#define rtfFontCodePage
Definition: rtf.h:737
#define rtfFTypeNil
Definition: rtf.h:738
#define rtfFontCharSet
Definition: rtf.h:735
#define rtfFontPitch
Definition: rtf.h:736
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
int rtfFNum
Definition: rtf.h:963
int rtfFType
Definition: rtf.h:967
int rtfFPitch
Definition: rtf.h:966
int rtfFFamily
Definition: rtf.h:964
RTFFont * rtfNextFont
Definition: rtf.h:969
char * rtfFName
Definition: rtf.h:961
int rtfFCodePage
Definition: rtf.h:968
int rtfFCharSet
Definition: rtf.h:965
char * rtfFAltName
Definition: rtf.h:962
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define FF_DONTCARE
Definition: wingdi.h:448
#define DEFAULT_CHARSET
Definition: wingdi.h:384

Referenced by RTFInit().

◆ ReadInfoGroup()

static void ReadInfoGroup ( RTF_Info info)
static

Definition at line 1177 of file reader.c.

1178{
1180 RTFRouteToken (info); /* feed "}" back to router */
1181}

Referenced by RTFInit().

◆ ReadObjGroup()

static void ReadObjGroup ( RTF_Info info)
static

Definition at line 1191 of file reader.c.

1192{
1194 RTFRouteToken (info); /* feed "}" back to router */
1195}

Referenced by RTFInit().

◆ ReadPictGroup()

static void ReadPictGroup ( RTF_Info info)
static

Definition at line 1184 of file reader.c.

1185{
1187 RTFRouteToken (info); /* feed "}" back to router */
1188}

Referenced by RTFInit().

◆ ReadStyleSheet()

static void ReadStyleSheet ( RTF_Info info)
static

Definition at line 1008 of file reader.c.

1009{
1010 RTFStyle *sp;
1011 RTFStyleElt *sep, *sepLast;
1012 char buf[rtfBufSiz], *bp;
1013 int real_style;
1014
1015 for (;;)
1016 {
1017 RTFGetToken (info);
1018 if (info->rtfClass == rtfEOF)
1019 break;
1021 break;
1022 sp = malloc (sizeof(*sp));
1023 if (sp == NULL) {
1024 ERR ("cannot allocate stylesheet entry\n");
1025 break;
1026 }
1027 sp->rtfSName = NULL;
1028 sp->rtfSNum = -1;
1029 sp->rtfSType = rtfParStyle;
1030 sp->rtfSAdditive = 0;
1031 sp->rtfSBasedOn = rtfNoStyleNum;
1032 sp->rtfSNextPar = -1;
1033 sp->rtfSSEList = sepLast = NULL;
1034 sp->rtfNextStyle = info->styleList;
1035 sp->rtfExpanding = 0;
1036 info->styleList = sp;
1038 ERR ("missing \"{\"\n");
1039 real_style = TRUE;
1040 for (;;)
1041 {
1042 RTFGetToken (info);
1043 if (info->rtfClass == rtfEOF
1044 || RTFCheckCM (info, rtfText, ';'))
1045 break;
1046 if (info->rtfClass == rtfControl)
1047 {
1050 ERR("skipping optional destination\n");
1052 info->rtfClass = rtfGroup;
1053 info->rtfMajor = rtfEndGroup;
1054 real_style = FALSE;
1055 break; /* ignore "\*" */
1056 }
1058 {
1059 sp->rtfSNum = info->rtfParam;
1060 sp->rtfSType = rtfParStyle;
1061 continue;
1062 }
1064 {
1065 sp->rtfSNum = info->rtfParam;
1066 sp->rtfSType = rtfCharStyle;
1067 continue;
1068 }
1070 {
1071 sp->rtfSNum = info->rtfParam;
1072 sp->rtfSType = rtfSectStyle;
1073 continue;
1074 }
1076 {
1077 sp->rtfSBasedOn = info->rtfParam;
1078 continue;
1079 }
1081 {
1082 sp->rtfSAdditive = 1;
1083 continue;
1084 }
1086 {
1087 sp->rtfSNextPar = info->rtfParam;
1088 continue;
1089 }
1090 sep = malloc (sizeof(*sep));
1091 if (sep == NULL)
1092 {
1093 ERR ("cannot allocate style element\n");
1094 break;
1095 }
1096 sep->rtfSEClass = info->rtfClass;
1097 sep->rtfSEMajor = info->rtfMajor;
1098 sep->rtfSEMinor = info->rtfMinor;
1099 sep->rtfSEParam = info->rtfParam;
1100 sep->rtfSEText = strdup (info->rtfTextBuf);
1101 if (sep->rtfSEText == NULL)
1102 ERR ("cannot allocate style element text\n");
1103 if (sepLast == NULL)
1104 sp->rtfSSEList = sep; /* first element */
1105 else /* add to end */
1106 sepLast->rtfNextSE = sep;
1107 sep->rtfNextSE = NULL;
1108 sepLast = sep;
1109 }
1111 {
1112 /*
1113 * This passes over "{\*\keycode ... }, among
1114 * other things. A temporary (perhaps) hack.
1115 */
1116 ERR("skipping begin\n");
1118 continue;
1119 }
1120 else if (info->rtfClass == rtfText) /* style name */
1121 {
1122 bp = buf;
1123 while (info->rtfClass == rtfText)
1124 {
1125 if (info->rtfMajor == ';')
1126 {
1127 /* put back for "for" loop */
1129 break;
1130 }
1131 *bp++ = info->rtfMajor;
1132 RTFGetToken (info);
1133 }
1134 *bp = '\0';
1135 sp->rtfSName = strdup (buf);
1136 if (sp->rtfSName == NULL)
1137 ERR ("cannot allocate style name\n");
1138 }
1139 else /* unrecognized */
1140 {
1141 /* ignore token but announce it */
1142 WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
1143 }
1144 }
1145 if (real_style) {
1146 RTFGetToken (info);
1148 ERR ("missing \"}\"\n");
1149 /*
1150 * Check over the style structure. A name is a must.
1151 * If no style number was specified, check whether it's the
1152 * Normal style (in which case it's given style number
1153 * rtfNormalStyleNum). Note that some "normal" style names
1154 * just begin with "Normal" and can have other stuff following,
1155 * e.g., "Normal,Times 10 point". Ugh.
1156 *
1157 * Some German RTF writers use "Standard" instead of "Normal".
1158 */
1159 if (sp->rtfSName == NULL)
1160 ERR ("missing style name\n");
1161 if (sp->rtfSNum < 0)
1162 {
1163 if (strncmp (buf, "Normal", 6) != 0
1164 && strncmp (buf, "Standard", 8) != 0)
1165 ERR ("missing style number\n");
1166 sp->rtfSNum = rtfNormalStyleNum;
1167 }
1168 if (sp->rtfSNextPar == -1) /* if \snext not given, */
1169 sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1170 }
1171 /* otherwise we're just dealing with fake end group from skipped group */
1172 }
1173 RTFRouteToken (info); /* feed "}" back to router */
1174}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int RTFCheckMM(const RTF_Info *info, int major, int minor)
Definition: reader.c:2268
static const WCHAR sp[]
Definition: suminfo.c:287
#define rtfStyleAttr
Definition: rtf.h:271
#define rtfSectAttr
Definition: rtf.h:358
#define rtfAdditive
Definition: rtf.h:272
#define rtfNext
Definition: rtf.h:274
#define rtfNormalStyleNum
Definition: rtf.h:71
#define rtfBasedOn
Definition: rtf.h:273
#define rtfSectStyle
Definition: rtf.h:944
#define rtfNoStyleNum
Definition: rtf.h:70
#define rtfSectStyleNum
Definition: rtf.h:363
#define rtfParStyle
Definition: rtf.h:942
#define rtfCharStyle
Definition: rtf.h:943
#define rtfOptDest
Definition: rtf.h:260
#define rtfStyleNum
Definition: rtf.h:457
#define rtfCharStyleNum
Definition: rtf.h:595
int rtfSEMinor
Definition: rtf.h:1006
char * rtfSEText
Definition: rtf.h:1008
int rtfSEParam
Definition: rtf.h:1007
RTFStyleElt * rtfNextSE
Definition: rtf.h:1009
int rtfSEClass
Definition: rtf.h:1004
int rtfSEMajor
Definition: rtf.h:1005
Definition: rtf.h:989

Referenced by RTFInit().

◆ RTFCharSetToCodePage()

int RTFCharSetToCodePage ( RTF_Info info,
int  charset 
)

Definition at line 476 of file reader.c.

477{
478 switch (charset)
479 {
480 case ANSI_CHARSET:
481 return 1252;
482 case DEFAULT_CHARSET:
483 return CP_ACP;
484 case SYMBOL_CHARSET:
485 return CP_SYMBOL;
486 case MAC_CHARSET:
487 return CP_MACCP;
488 case SHIFTJIS_CHARSET:
489 return 932;
490 case HANGEUL_CHARSET:
491 return 949;
492 case JOHAB_CHARSET:
493 return 1361;
494 case GB2312_CHARSET:
495 return 936;
497 return 950;
498 case GREEK_CHARSET:
499 return 1253;
500 case TURKISH_CHARSET:
501 return 1254;
503 return 1258;
504 case HEBREW_CHARSET:
505 return 1255;
506 case ARABIC_CHARSET:
507 return 1256;
508 case BALTIC_CHARSET:
509 return 1257;
510 case RUSSIAN_CHARSET:
511 return 1251;
512 case THAI_CHARSET:
513 return 874;
515 return 1250;
516 case OEM_CHARSET:
517 return CP_OEMCP;
518 default:
519 {
520 CHARSETINFO csi;
521 DWORD n = charset;
522
523 /* FIXME: TranslateCharsetInfo does not work as good as it
524 * should, so let's use it only when all else fails */
526 ERR("unknown charset %d\n", charset);
527 else
528 return csi.ciACP;
529 }
530 }
531 return 0;
532}
CFF_Charset charset
Definition: cffcmap.c:138
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble n
Definition: glext.h:7729
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define ARABIC_CHARSET
Definition: wingdi.h:394
#define HANGEUL_CHARSET
Definition: wingdi.h:387
#define THAI_CHARSET
Definition: wingdi.h:397
#define GREEK_CHARSET
Definition: wingdi.h:391
#define JOHAB_CHARSET
Definition: wingdi.h:401
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define ANSI_CHARSET
Definition: wingdi.h:383
#define TCI_SRCCHARSET
Definition: wingdi.h:961
#define OEM_CHARSET
Definition: wingdi.h:400
#define VIETNAMESE_CHARSET
Definition: wingdi.h:402
#define MAC_CHARSET
Definition: wingdi.h:403
#define HEBREW_CHARSET
Definition: wingdi.h:393
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define SYMBOL_CHARSET
Definition: wingdi.h:385
#define EASTEUROPE_CHARSET
Definition: wingdi.h:399
#define GB2312_CHARSET
Definition: wingdi.h:389
#define BALTIC_CHARSET
Definition: wingdi.h:395
#define TURKISH_CHARSET
Definition: wingdi.h:392
#define CP_OEMCP
Definition: winnls.h:249
#define CP_SYMBOL
Definition: winnls.h:252
#define CP_MACCP
Definition: winnls.h:250

Referenced by ME_StreamOutRTFCharProps(), and ReadFontTbl().

◆ RTFCharToHex()

int RTFCharToHex ( char  c)

Definition at line 2277 of file reader.c.

2278{
2279 if (isupper (c))
2280 c = tolower (c);
2281 if (isdigit (c))
2282 return (c - '0'); /* '0'..'9' */
2283 return (c - 'a' + 10); /* 'a'..'f' */
2284}
#define isupper(c)
Definition: acclib.h:71
int tolower(int c)
Definition: utclib.c:902

Referenced by _RTFGetToken2(), and read_hex_data().

◆ RTFCheckCM()

int RTFCheckCM ( const RTF_Info info,
int  class,
int  major 
)

Definition at line 2256 of file reader.c.

2257{
2258 return (info->rtfClass == class && info->rtfMajor == major);
2259}
#define major(rdev)
Definition: propsheet.cpp:928

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), ReadColorTbl(), ReadFontTbl(), ReadStyleSheet(), RTFRouteToken(), and RTFUngetToken().

◆ RTFCheckCMM()

int RTFCheckCMM ( const RTF_Info info,
int  class,
int  major,
int  minor 
)

Definition at line 2262 of file reader.c.

2263{
2264 return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2265}
#define minor(rdev)
Definition: propsheet.cpp:929

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), and ReadFontTbl().

◆ RTFCheckMM()

int RTFCheckMM ( const RTF_Info info,
int  major,
int  minor 
)

Definition at line 2268 of file reader.c.

2269{
2270 return (info->rtfMajor == major && info->rtfMinor == minor);
2271}

Referenced by ME_RTFReadPictGroup(), and ReadStyleSheet().

◆ RTFDestroy()

void RTFDestroy ( RTF_Info info)

Definition at line 144 of file reader.c.

145{
146 if (info->rtfTextBuf)
147 {
148 free(info->rtfTextBuf);
149 free(info->pushedTextBuf);
150 }
152 free(info->cpOutputBuffer);
153 while (info->tableDef)
154 {
155 RTFTable *tableDef = info->tableDef;
156 info->tableDef = tableDef->parent;
157 free(tableDef);
158 }
159}
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:105
Definition: rtf.h:1026
RTFTable * parent
Definition: rtf.h:1044

Referenced by ME_StreamIn().

◆ RTFDestroyAttrs()

static void RTFDestroyAttrs ( RTF_Info info)
static

Definition at line 105 of file reader.c.

106{
107 RTFColor *cp;
108 RTFFont *fp;
109 RTFStyle *sp;
110 RTFStyleElt *eltList, *ep;
111
112 while (info->fontList)
113 {
114 fp = info->fontList->rtfNextFont;
115 free (info->fontList->rtfFName);
116 free (info->fontList);
117 info->fontList = fp;
118 }
119 while (info->colorList)
120 {
121 cp = info->colorList->rtfNextColor;
122 free (info->colorList);
123 info->colorList = cp;
124 }
125 while (info->styleList)
126 {
127 sp = info->styleList->rtfNextStyle;
128 eltList = info->styleList->rtfSSEList;
129 while (eltList)
130 {
131 ep = eltList->rtfNextSE;
132 free (eltList->rtfSEText);
133 free (eltList);
134 eltList = ep;
135 }
136 free (info->styleList->rtfSName);
137 free (info->styleList);
138 info->styleList = sp;
139 }
140}

Referenced by RTFDestroy(), and RTFInit().

◆ RTFFlushCPOutputBuffer()

static void RTFFlushCPOutputBuffer ( RTF_Info info)
static

Definition at line 2591 of file reader.c.

2592{
2593 int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
2594 WCHAR *buffer = malloc(bufferMax);
2595 int length;
2596
2597 length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
2598 info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR));
2599 info->dwCPOutputCount = 0;
2600
2602 free(buffer);
2603}
#define MultiByteToWideChar
Definition: compat.h:110
static void RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
Definition: reader.c:2573
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RTFFlushOutputBuffer(), RTFPutUnicodeChar(), and RTFPutUnicodeString().

◆ RTFFlushOutputBuffer()

void RTFFlushOutputBuffer ( RTF_Info info)

Definition at line 2606 of file reader.c.

2607{
2608 if (info->dwCPOutputCount)
2611}
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2591
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2561

Referenced by CharAttr(), ME_RTFCharAttrHook(), ME_RTFParAttrHook(), ME_RTFReadHook(), ME_RTFSpecialCharHook(), ME_StreamIn(), and SpecialChar().

◆ RTFFlushUnicodeOutputBuffer()

static void RTFFlushUnicodeOutputBuffer ( RTF_Info info)
static

Definition at line 2561 of file reader.c.

2562{
2563 if (info->dwOutputCount)
2564 {
2565 ME_InsertTextFromCursor(info->editor, 0, info->OutputBuffer,
2566 info->dwOutputCount, info->style);
2567 info->dwOutputCount = 0;
2568 }
2569}
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:584

Referenced by RTFFlushOutputBuffer(), RTFPutUnicodeChar(), and RTFPutUnicodeString().

◆ RTFGetClassCallback()

static RTFFuncPtr RTFGetClassCallback ( const RTF_Info info,
int  class 
)
static

Definition at line 181 of file reader.c.

182{
183 if (class >= 0 && class < rtfMaxClass)
184 return info->ccb[class];
185 return NULL;
186}
#define rtfMaxClass
Definition: rtf.h:83

Referenced by RTFRouteToken().

◆ RTFGetColor()

RTFColor * RTFGetColor ( const RTF_Info info,
int  num 
)

Definition at line 1220 of file reader.c.

1221{
1222 RTFColor *c;
1223
1224 if (num == -1)
1225 return (info->colorList);
1226 for (c = info->colorList; c != NULL; c = c->rtfNextColor)
1227 {
1228 if (c->rtfCNum == num)
1229 break;
1230 }
1231 return (c); /* NULL if not found */
1232}
GLuint GLuint num
Definition: glext.h:9618

Referenced by ME_RTFCharAttrHook().

◆ RTFGetDestinationCallback()

static RTFFuncPtr RTFGetDestinationCallback ( const RTF_Info info,
int  dest 
)
static

Definition at line 271 of file reader.c.

272{
273 if (dest >= 0 && dest < rtfMaxDestination)
274 return info->dcb[dest];
275 return NULL;
276}
static char * dest
Definition: rtl.c:135
#define rtfMaxDestination
Definition: rtf.h:189

Referenced by Destination(), and RTFRouteToken().

◆ RTFGetFont()

RTFFont * RTFGetFont ( const RTF_Info info,
int  num 
)

Definition at line 1205 of file reader.c.

1206{
1207 RTFFont *f;
1208
1209 if (num == -1)
1210 return (info->fontList);
1211 for (f = info->fontList; f != NULL; f = f->rtfNextFont)
1212 {
1213 if (f->rtfFNum == num)
1214 break;
1215 }
1216 return (f); /* NULL if not found */
1217}
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83

Referenced by CharAttr(), and ME_RTFCharAttrHook().

◆ RTFGetReadHook()

static RTFFuncPtr RTFGetReadHook ( const RTF_Info info)
static

Definition at line 377 of file reader.c.

378{
379 return (info->readHook);
380}

Referenced by RTFGetToken().

◆ RTFGetToken()

int RTFGetToken ( RTF_Info info)

Definition at line 389 of file reader.c.

390{
392
393 /* don't try to return anything once EOF is reached */
394 if (info->rtfClass == rtfEOF) {
395 return rtfEOF;
396 }
397
398 for (;;)
399 {
402 if (p != NULL)
403 (*p) (info); /* give read hook a look at token */
404
405 /* Silently discard newlines, carriage returns, nulls. */
406 if (!(info->rtfClass == rtfText && info->rtfFormat != SF_TEXT
407 && (info->rtfMajor == '\r' || info->rtfMajor == '\n' || info->rtfMajor == '\0')))
408 break;
409 }
410 return (info->rtfClass);
411}
static void _RTFGetToken(RTF_Info *)
Definition: reader.c:437
static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
Definition: reader.c:377
GLfloat GLfloat p
Definition: glext.h:8902
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1088

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), read_hex_data(), ReadColorTbl(), ReadFontTbl(), ReadStyleSheet(), RTFRead(), RTFSkipGroup(), and SpecialChar().

◆ RTFInit()

void RTFInit ( RTF_Info info)

Definition at line 195 of file reader.c.

196{
197 int i;
198
199 if (info->rtfTextBuf == NULL) /* initialize the text buffers */
200 {
201 info->rtfTextBuf = malloc (rtfBufSiz);
202 info->pushedTextBuf = malloc (rtfBufSiz);
203 if (info->rtfTextBuf == NULL || info->pushedTextBuf == NULL) {
204 ERR ("Cannot allocate text buffers.\n");
205 return;
206 }
207 info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0';
208 }
209
210 for (i = 0; i < rtfMaxClass; i++)
212 for (i = 0; i < rtfMaxDestination; i++)
214
215 /* install built-in destination readers */
222
223
225
226 /* dump old lists if necessary */
227
229
230 info->ansiCodePage = 1252; /* Latin-1; actually unused */
231 info->unicodeLength = 1; /* \uc1 is the default */
232 info->codePage = info->ansiCodePage;
233 info->defFont = 0;
234
235 info->rtfClass = -1;
236 info->pushedClass = -1;
237 info->pushedChar = EOF;
238
239 info->rtfLineNum = 0;
240 info->rtfLinePos = 0;
241 info->prevChar = EOF;
242 info->bumpLine = FALSE;
243
244 info->dwCPOutputCount = 0;
245 if (!info->cpOutputBuffer)
246 {
247 info->dwMaxCPOutputCount = 0x1000;
248 info->cpOutputBuffer = malloc (info->dwMaxCPOutputCount);
249 }
250
251 info->tableDef = NULL;
252 info->nestingLevel = 0;
253 info->canInheritInTbl = FALSE;
254 info->borderType = 0;
255
256 memset(&info->fmt, 0, sizeof(info->fmt));
257 info->fmt.cbSize = sizeof(info->fmt);
258}
static void ReadInfoGroup(RTF_Info *)
Definition: reader.c:1177
static void ReadFontTbl(RTF_Info *)
Definition: reader.c:769
static void ReadColorTbl(RTF_Info *)
Definition: reader.c:948
static void ReadPictGroup(RTF_Info *)
Definition: reader.c:1184
static void ReadStyleSheet(RTF_Info *)
Definition: reader.c:1008
void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
Definition: reader.c:371
static void ReadObjGroup(RTF_Info *)
Definition: reader.c:1191
void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
Definition: reader.c:264
#define rtfFontTbl
Definition: rtf.h:110
#define rtfObject
Definition: rtf.h:155
#define rtfStyleSheet
Definition: rtf.h:117
#define rtfInfo
Definition: rtf.h:120
#define rtfPict
Definition: rtf.h:154
#define rtfColorTbl
Definition: rtf.h:116

Referenced by ME_StreamIn().

◆ RTFPutCodePageChar()

static void RTFPutCodePageChar ( RTF_Info info,
int  c 
)
static

Definition at line 2624 of file reader.c.

2625{
2626 /* Use dynamic buffer here because it's the best way to handle
2627 * MBCS codepages without having to worry about partial chars */
2628 if (info->dwCPOutputCount >= info->dwMaxCPOutputCount)
2629 {
2630 info->dwMaxCPOutputCount *= 2;
2631 info->cpOutputBuffer = realloc(info->cpOutputBuffer, info->dwMaxCPOutputCount);
2632 }
2633 info->cpOutputBuffer[info->dwCPOutputCount++] = c;
2634}

Referenced by TextClass().

◆ RTFPutUnicodeChar()

static void RTFPutUnicodeChar ( RTF_Info info,
int  c 
)
static

Definition at line 2614 of file reader.c.

2615{
2616 if (info->dwCPOutputCount)
2618 if (info->dwOutputCount * sizeof(WCHAR) >= ( sizeof info->OutputBuffer - 1 ) )
2620 info->OutputBuffer[info->dwOutputCount++] = c;
2621}

Referenced by SpecialChar().

◆ RTFPutUnicodeString()

static void RTFPutUnicodeString ( RTF_Info info,
const WCHAR string,
int  length 
)
static

Definition at line 2573 of file reader.c.

2574{
2575 if (info->dwCPOutputCount)
2577 while (length)
2578 {
2579 int fit = min(length, ARRAY_SIZE(info->OutputBuffer) - info->dwOutputCount);
2580
2581 memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
2582 info->dwOutputCount += fit;
2583 length -= fit;
2584 string += fit;
2585 if (ARRAY_SIZE(info->OutputBuffer) == info->dwOutputCount)
2587 }
2588}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define min(a, b)
Definition: monoChain.cc:55

Referenced by RTFFlushCPOutputBuffer().

◆ RTFRead()

void RTFRead ( RTF_Info info)

Definition at line 291 of file reader.c.

292{
293 while (RTFGetToken (info) != rtfEOF)
295}

Referenced by ME_StreamIn().

◆ RTFReadGroup()

void RTFReadGroup ( RTF_Info info)

Definition at line 362 of file reader.c.

363{
364}

Referenced by ME_StreamIn().

◆ RTFRouteToken()

void RTFRouteToken ( RTF_Info info)

Definition at line 304 of file reader.c.

305{
307
308 if (info->rtfClass < 0 || info->rtfClass >= rtfMaxClass) /* watchdog */
309 {
310 ERR( "Unknown class %d: %s (reader malfunction)\n",
311 info->rtfClass, info->rtfTextBuf);
312 }
314 {
315 /* invoke destination-specific callback if there is one */
316 p = RTFGetDestinationCallback (info, info->rtfMinor);
317 if (p != NULL)
318 {
319 (*p) (info);
320 return;
321 }
322 }
323 /* invoke class callback if there is one */
324 p = RTFGetClassCallback (info, info->rtfClass);
325 if (p != NULL)
326 (*p) (info);
327}
static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
Definition: reader.c:181

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), ReadColorTbl(), ReadFontTbl(), ReadInfoGroup(), ReadObjGroup(), ReadPictGroup(), ReadStyleSheet(), RTFRead(), and SpecialChar().

◆ RTFSetClassCallback()

static void RTFSetClassCallback ( RTF_Info info,
int  class,
RTFFuncPtr  callback 
)
static

Definition at line 174 of file reader.c.

175{
176 if (class >= 0 && class < rtfMaxClass)
177 info->ccb[class] = callback;
178}
static IPrintDialogCallback callback
Definition: printdlg.c:326

Referenced by BeginFile(), and RTFInit().

◆ RTFSetDestinationCallback()

void RTFSetDestinationCallback ( RTF_Info info,
int  dest,
RTFFuncPtr  callback 
)

Definition at line 264 of file reader.c.

265{
266 if (dest >= 0 && dest < rtfMaxDestination)
267 info->dcb[dest] = callback;
268}

Referenced by ME_StreamIn(), and RTFInit().

◆ RTFSetEditStream()

void RTFSetEditStream ( RTF_Info info,
ME_InStream stream 
)

Definition at line 99 of file reader.c.

100{
101 info->stream = stream;
102}

Referenced by ME_StreamIn().

◆ RTFSetReadHook()

void RTFSetReadHook ( RTF_Info info,
RTFFuncPtr  f 
)

Definition at line 371 of file reader.c.

372{
373 info->readHook = f;
374}

Referenced by ME_StreamIn(), and RTFInit().

◆ RTFSkipGroup()

void RTFSkipGroup ( RTF_Info info)

Definition at line 337 of file reader.c.

338{
339 int level = 1;
340
341 while (RTFGetToken (info) != rtfEOF)
342 {
343 if (info->rtfClass == rtfGroup)
344 {
345 if (info->rtfMajor == rtfBeginGroup)
346 ++level;
347 else if (info->rtfMajor == rtfEndGroup)
348 {
349 if (--level < 1)
350 break; /* end of initial group */
351 }
352 }
353 }
354}
GLint level
Definition: gl.h:1546

Referenced by Destination(), ME_RTFReadObjectGroup(), ME_RTFReadPictGroup(), ME_StreamIn(), ReadFontTbl(), ReadInfoGroup(), ReadObjGroup(), ReadPictGroup(), ReadStyleSheet(), and SpecialChar().

◆ RTFUngetToken()

static void RTFUngetToken ( RTF_Info info)
static

Definition at line 414 of file reader.c.

415{
416 if (info->pushedClass >= 0) /* there's already an ungotten token */
417 ERR ("cannot unget two tokens\n");
418 if (info->rtfClass < 0)
419 ERR ("no token to unget\n");
420 info->pushedClass = info->rtfClass;
421 info->pushedMajor = info->rtfMajor;
422 info->pushedMinor = info->rtfMinor;
423 info->pushedParam = info->rtfParam;
424 lstrcpyA (info->pushedTextBuf, info->rtfTextBuf);
425 /* The read hook decrements stackTop on rtfEndGroup, so
426 * increment the value to compensate for it being decremented
427 * twice due to the RTFUngetToken. */
429 {
430 info->stack[info->stackTop].style = info->style;
431 ME_AddRefStyle(info->style);
432 info->stackTop++;
433 }
434}
void ME_AddRefStyle(ME_Style *item)
Definition: style.c:454

Referenced by ReadFontTbl(), ReadStyleSheet(), and SpecialChar().

◆ SpecialChar()

static void SpecialChar ( RTF_Info info)
static

Definition at line 2461 of file reader.c.

2462{
2463 switch (info->rtfMinor)
2464 {
2465 case rtfOptDest:
2466 /* the next token determines destination, if it's unknown, skip the group */
2467 /* this way we filter out the garbage coming from unknown destinations */
2468 RTFGetToken(info);
2469 if (info->rtfClass != rtfDestination)
2471 else
2472 RTFRouteToken(info); /* "\*" is ignored with known destinations */
2473 break;
2474 case rtfUnicode:
2475 {
2476 int i;
2477
2478 RTFPutUnicodeChar(info, info->rtfParam);
2479
2480 /* After \u we must skip number of character tokens set by \ucN */
2481 for (i = 0; i < info->unicodeLength; i++)
2482 {
2484 if (info->rtfClass != rtfText)
2485 {
2486 ERR("The token behind \\u is not text, but (%d,%d,%d)\n",
2487 info->rtfClass, info->rtfMajor, info->rtfMinor);
2489 break;
2490 }
2491 }
2492 break;
2493 }
2494 case rtfLine:
2496 ME_InsertEndRowFromCursor(info->editor, 0);
2497 break;
2498 case rtfPage:
2499 case rtfSect:
2500 case rtfPar:
2502 editor_set_selection_para_fmt( info->editor, &info->fmt );
2503 memset(&info->fmt, 0, sizeof(info->fmt));
2504 info->fmt.cbSize = sizeof(info->fmt);
2505 RTFPutUnicodeChar (info, '\r');
2506 if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n');
2507 break;
2508 case rtfNoBrkSpace:
2509 RTFPutUnicodeChar (info, 0x00A0);
2510 break;
2511 case rtfTab:
2512 RTFPutUnicodeChar (info, '\t');
2513 break;
2514 case rtfNoBrkHyphen:
2515 RTFPutUnicodeChar (info, 0x2011);
2516 break;
2517 case rtfBullet:
2518 RTFPutUnicodeChar (info, 0x2022);
2519 break;
2520 case rtfEmDash:
2521 RTFPutUnicodeChar (info, 0x2014);
2522 break;
2523 case rtfEnDash:
2524 RTFPutUnicodeChar (info, 0x2013);
2525 break;
2526 case rtfEmSpace:
2527 RTFPutUnicodeChar (info, ' ');
2528 break;
2529 case rtfEnSpace:
2530 RTFPutUnicodeChar (info, ' ');
2531 break;
2532 case rtfLQuote:
2533 RTFPutUnicodeChar (info, 0x2018);
2534 break;
2535 case rtfRQuote:
2536 RTFPutUnicodeChar (info, 0x2019);
2537 break;
2538 case rtfLDblQuote:
2539 RTFPutUnicodeChar (info, 0x201C);
2540 break;
2541 case rtfRDblQuote:
2542 RTFPutUnicodeChar (info, 0x201D);
2543 break;
2544 case rtfLTRMark:
2545 RTFPutUnicodeChar (info, 0x200E);
2546 break;
2547 case rtfRTLMark:
2548 RTFPutUnicodeChar (info, 0x200F);
2549 break;
2550 case rtfNoWidthJoiner:
2551 RTFPutUnicodeChar (info, 0x200D);
2552 break;
2554 RTFPutUnicodeChar (info, 0x200C);
2555 break;
2556 }
2557}
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
Definition: caret.c:568
static void RTFPutUnicodeChar(RTF_Info *info, int c)
Definition: reader.c:2614
BOOL editor_set_selection_para_fmt(ME_TextEditor *editor, const PARAFORMAT2 *fmt)
Definition: para.c:873
#define rtfBullet
Definition: rtf.h:251
#define rtfPar
Definition: rtf.h:237
#define rtfRQuote
Definition: rtf.h:253
#define rtfRDblQuote
Definition: rtf.h:255
#define rtfPage
Definition: rtf.h:239
#define rtfUnicode
Definition: rtf.h:267
#define rtfNoWidthNonJoiner
Definition: rtf.h:264
#define rtfLine
Definition: rtf.h:241
#define rtfNoWidthJoiner
Definition: rtf.h:263
#define rtfEmSpace
Definition: rtf.h:249
#define rtfSect
Definition: rtf.h:238
#define rtfNoBrkHyphen
Definition: rtf.h:259
#define rtfLDblQuote
Definition: rtf.h:254
#define rtfLTRMark
Definition: rtf.h:261
#define rtfEnDash
Definition: rtf.h:248
#define rtfNoBrkSpace
Definition: rtf.h:257
#define rtfEmDash
Definition: rtf.h:247
#define rtfRTLMark
Definition: rtf.h:262
#define rtfLQuote
Definition: rtf.h:252
#define rtfEnSpace
Definition: rtf.h:250

Referenced by ControlClass().

◆ TextClass()

static void TextClass ( RTF_Info info)
static

Definition at line 2330 of file reader.c.

2331{
2332 RTFPutCodePageChar(info, info->rtfMajor);
2333}
static void RTFPutCodePageChar(RTF_Info *info, int c)
Definition: reader.c:2624

Referenced by BeginFile().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( richedit  )

◆ WriterInit()

void WriterInit ( RTF_Info info)

Definition at line 2309 of file reader.c.

2310{
2311}

Referenced by ME_StreamIn().

Variable Documentation

◆ rtfHashTable

RTFHashTableEntry rtfHashTable[ARRAY_SIZE(rtfKey) *2]
static

Definition at line 2167 of file reader.c.

Referenced by Lookup(), LookupCleanup(), and LookupInit().

◆ rtfKey

RTFKey rtfKey[]
static

Definition at line 1257 of file reader.c.

Referenced by Lookup(), LookupCleanup(), and LookupInit().