Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
8.3 KiB

  1. /* ************************************************************************** */
  2. /* * Head functions of Pegasus recognizer header * */
  3. /* ************************************************************************** */
  4. #ifndef PR_PEGREC_H_INCLUDED
  5. #define PR_PEGREC_H_INCLUDED
  6. #include "Cgr_Ver.h"
  7. #include "bastypes.h"
  8. #ifndef DLLEXP
  9. #define DLLEXP _stdcall
  10. #else
  11. #define __cdecl
  12. #endif
  13. #if (defined(__PSION32__) || defined(__WINS__) || defined(__MARM__))
  14. #define _PSION_DLL
  15. #include <e32def.h>
  16. #ifdef DLLEXP
  17. #undef DLLEXP
  18. #endif
  19. #if defined(__DLL__)
  20. #define DLLEXP EXPORT_C
  21. #else
  22. #define DLLEXP IMPORT_C
  23. #endif /* __DLL__ */
  24. #ifdef __cdecl
  25. #undef __cdecl
  26. #endif
  27. #define __cdecl GLDEF_C
  28. #endif /* __PSION32__ */
  29. /* ------------------------- Defines ---------------------------------------- */
  30. // #define PEG_RECINT_UNICODE /* Will Recognizer pass text strings as UNICODE strings or char strings */
  31. #define PEG_RECINT_ID_001 0x01000002 /* Rec Interface ID */
  32. #define PEG_MAX_SPELL_NUM_ALTS 10 /* How many variants will be out by the SpellCheck func */
  33. #define PEG_RECID_MAXLEN 45 /* Max length of the RecID string */
  34. #define PEG_MAX_FILENAME 128 /* Limit for filename buffer */
  35. /* Recognizer Control Falgs */
  36. #define PEG_RECFL_NSEG 0x0001 /* Do not perform segmentation at all*/
  37. #define PEG_RECFL_NCSEG 0x0002 /* Do not allow segm not waiting for final stroke. (No results on the go) */
  38. #define PEG_RECFL_TTSEG 0x0004 /* Perform read-ahead of tentative segmented words */
  39. #define PEG_RECFL_INTL_CS 0x0010 /* Enables international charsets */
  40. #define PEG_RECFL_LANGMODEL_DISABLED 0x0020 /* Disables word dictionary */
  41. #define PEG_RECFL_SEPLET 0x0100 /* Enables separate letter mode */
  42. #define PEG_RECFL_DICTONLY 0x0200 /* Restricts dictionary words only recognition */
  43. #define PEG_RECFL_NUMONLY 0x0400 /* NUMBERS only */
  44. #define PEG_RECFL_CAPSONLY 0x0800 /* CAPITALS only */
  45. #define PEG_RECFL_COERCE 0x1000 /* Is COERCION enabled */
  46. /* Bits of recognizer capabilities */
  47. #define PEG_CPFL_CURS 0x0001 /* Cursive capable */
  48. #define PEG_CPFL_TRNBL 0x0002 /* Training capable */
  49. #define PEG_CPFL_SPVSQ 0x0004 /* Speed VS Quality control capable */
  50. #define PEG_CPFL_INTER 0x0008 /* International support capable */
  51. #define PEG_SPELL_CHECK 0x0000 /* SpellCheck flag: do spell checking */
  52. #define PEG_SPELL_LIST 0x0001 /* SpellCheck flag: list continuations */
  53. #define CGA_NUM_ANSWERS 1 /* Request to get number of recognized words */
  54. #define CGA_NUM_ALTS 2 /* Request number of alternatives for given word */
  55. #define CGA_ALT_WORD 3 /* Requestto get pointer to a given word alternative */
  56. #define CGA_ALT_WEIGHT 4 /* Request to get weight of a give word alternative */
  57. #define CGA_ALT_NSTR 5 /* Request to get number of strokes used for a given word alternative */
  58. #define CGA_ALT_STROKES 6 /* Request to get a pointer to a given word alternative stroke ids */
  59. #define LRN_WEIGHTSBUFFER_SIZE 448
  60. #define LRN_SETDEFWEIGHTS_OP 0 /* LEARN interface commands for CgrGetSetPictWghts func */
  61. #define LRN_GETCURWEIGHTS_OP 1
  62. #define LRN_SETCURWEIGHTS_OP 2
  63. /* ------------------------- Structures ------------------------------------- */
  64. typedef void * CGRCTX; /* Type of handle of recognizer context */
  65. typedef void * CGRHDICT; /* Type of handle of user dictionary handle */
  66. typedef int (__cdecl *info_func_type)(void *); /* Type of the callback returning parent status */
  67. #ifdef PEG_RECINT_UNICODE
  68. typedef unsigned short UCHR; /* Unicode character define */
  69. #else // PEG_RECINT_UNICODE
  70. typedef char UCHR; /* Regular character define */
  71. #endif // PEG_RECINT_UNICODE
  72. typedef struct { /* Control structure for initializing recognition */
  73. int flags; /* place for the PEG_RECFL_ flags */
  74. int sp_vs_q; /* Parameter of speed-quality tradeof */
  75. CGRHDICT h_main_dict; /* Handle to user dictionary loaded by ELK functions */
  76. p_VOID h_user_dict; /* user dict handle */
  77. info_func_type InfoCallBack; /* CallBack for interrupting recognizer operation */
  78. void * ICB_param; /* Parameter, which will be passed to InfoCallBack */
  79. void *pvFactoid;
  80. unsigned char *szPrefix;
  81. unsigned char *szSuffix;
  82. } CGR_control_type, * p_CGR_control_type;
  83. typedef struct {
  84. int capabilities; /* Bits (PEG_CPFL_) describing what type of recognizer it is */
  85. UCHR id_string[PEG_RECID_MAXLEN]; /* Name of the recognizer */
  86. } CGR_ID_type, * p_CGR_ID_type;
  87. typedef struct { /* Trajectory point declaration */
  88. short x;
  89. short y;
  90. }CGR_point_type, * p_CGR_point_type;
  91. typedef struct { /* Baseline definition for SymbRecognize */
  92. int size;
  93. int base;
  94. } CGR_baseline_type, * p_CGR_baseline_type;
  95. /* ------------------------- Prototypes ------------------------------------- */
  96. #ifdef __cplusplus
  97. extern "C"
  98. {
  99. #endif
  100. // --------------- Recognition API functions -----------------------------------
  101. int DLLEXP CgrGetRecID(p_CGR_ID_type p_inf);
  102. int CgrGetRecIDInternal(p_CGR_ID_type p_inf);
  103. CGRCTX DLLEXP CgrCreateContext(void);
  104. CGRCTX CgrCreateContextInternal(void);
  105. CGRCTX getContextFromGlobal(CGRCTX context);
  106. void PegRecUnloadDti(CGRCTX context);
  107. int DLLEXP CgrCloseContext(CGRCTX context);
  108. int CgrCloseContextInternal(CGRCTX context);
  109. int DLLEXP CgrOpenSession(p_CGR_control_type ctrl, CGRCTX context);
  110. int CgrOpenSessionInternal(p_CGR_control_type ctrl, CGRCTX context);
  111. int DLLEXP CgrCloseSession(CGRCTX context);
  112. int CgrCloseSessionInternal(CGRCTX context, void *pxrc, int bRecognize);
  113. int DLLEXP CgrRecognize(int npoints, p_CGR_point_type strokes, CGRCTX context);
  114. int CgrRecognizeInternal(int npoints, p_CGR_point_type strokes, CGRCTX context, int bRecognize);
  115. int DLLEXP CgrRecognizeSymbol(int npoints, p_CGR_point_type strokes, p_CGR_baseline_type baseline, CGRCTX context);
  116. int CgrRecognizeSymbolInternal(int npoints, p_CGR_point_type strokes, p_CGR_baseline_type baseline, CGRCTX context);
  117. long DLLEXP CgrGetAnswers(int what, int nw, int na, CGRCTX context);
  118. long CgrGetAnswersInternal(int what, int nw, int na, CGRCTX context);
  119. // -------------- Dictionary functions -----------------------------------------
  120. int DLLEXP CgrLoadDict(char * store, CGRHDICT *phDict);
  121. int CgrLoadDictInternal(char * store, CGRHDICT *phDict);
  122. int DLLEXP CgrSaveDict(char * store, CGRHDICT h_dict);
  123. int CgrSaveDictInternal(char * store, CGRHDICT h_dict);
  124. int DLLEXP CgrFreeDict(CGRHDICT * h_dict);
  125. int CgrFreeDictInternal(CGRHDICT * h_dict);
  126. int DLLEXP CgrGetDictStatus(int * plen, CGRHDICT h_dict);
  127. int CgrGetDictStatusInternal(int * plen, CGRHDICT h_dict);
  128. int DLLEXP CgrAddWordToDict(UCHR * word, CGRHDICT * h_dict);
  129. int CgrAddWordToDictInternal(UCHR * word, CGRHDICT * h_dict);
  130. int DLLEXP CgrCheckWordInDicts(UCHR * word, CGRHDICT h_main_dict, CGRHDICT h_user_dict);
  131. int CgrCheckWordInDictsInternal(UCHR * word, CGRHDICT h_main_dict, CGRHDICT h_user_dict);
  132. #ifndef _PSION_DLL
  133. int DLLEXP CgrSpellCheckWord(UCHR * word, UCHR * answ, int buf_len, CGRHDICT h_main_dict, CGRHDICT h_user_dict, int flags);
  134. int CgrSpellCheckWordInternal(UCHR * word, UCHR * answ, int buf_len, CGRHDICT h_main_dict, CGRHDICT h_user_dict, int flags);
  135. #endif
  136. // -------------- Letter Shape selector functions ------------------------------
  137. int DLLEXP CgrGetSetPicturesWeights(int operation, void * buf, CGRCTX context); // Private API call
  138. // -----------------------------------------------------------------------------
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif /* PR_PEGREC_H_INCLUDED */
  143. /* ************************************************************************** */
  144. /* * Head functions of Pegasus recognizer header end * */
  145. /* ************************************************************************** */