hre_internal.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * hre_internal.h: Internal Interface for Recognizer.
  3. * Author: James Kempf
  4. * Created On: Thu Nov 5 10:54:18 1992
  5. * Last Modified By: James Kempf
  6. * Last Modified On: Fri Sep 23 13:51:15 1994
  7. * Update Count: 99
  8. * Copyright (c) 1994 by Sun Microsystems Computer Company
  9. * All rights reserved.
  10. *
  11. * Use and copying of this software and preparation of
  12. * derivative works based upon this software are permitted.
  13. * Any distribution of this software or derivative works
  14. * must comply with all applicable United States export control
  15. * laws.
  16. *
  17. * This software is made available as is, and Sun Microsystems
  18. * Computer Company makes no warranty about the software, its
  19. * performance, or its conformity to any specification
  20. */
  21. /*Avoids forward reference problem.*/
  22. /*
  23. * Internal view of wordset. The recognition engine uses this view to
  24. * maintain information about which recognizer object this wordset
  25. * belongs to, which file (in case it needs to be saved), and internal
  26. * data structures.
  27. */
  28. struct _wordset {
  29. char* ws_pathname; /*Path name to word set file.*/
  30. recognizer ws_recognizer; /*To whom it belongs.*/
  31. void* ws_internal; /*Internal data structures.*/
  32. };
  33. /*
  34. * Internal view of the recognizer struct. This view is only available
  35. * to OEM clients who implement a recognizer shared library. Clients
  36. * of the recognizer itself see it as an opaque data type. The struct
  37. * contains a function pointer for each function in the client API.
  38. */
  39. struct _Recognizer {
  40. uint recognizer_magic;
  41. char *recognizer_version;
  42. rec_info *recognizer_info;
  43. void *recognizer_specific;
  44. int (*recognizer_load_state)(struct _Recognizer*, char*, char*);
  45. int (*recognizer_save_state)(struct _Recognizer*, char*, char*);
  46. char* (*recognizer_error)(struct _Recognizer*);
  47. wordset (*recognizer_load_dictionary)(struct _Recognizer*, char*, char*);
  48. int (*recognizer_save_dictionary)(struct _Recognizer*, char*, char*, wordset);
  49. int (*recognizer_free_dictionary)(struct _Recognizer*, wordset);
  50. int (*recognizer_add_to_dictionary)(struct _Recognizer*, letterset*, wordset);
  51. int (*recognizer_delete_from_dictionary)(struct _Recognizer*, letterset*, wordset);
  52. int (*recognizer_set_context)(struct _Recognizer*,rc*);
  53. rc* (*recognizer_get_context)(struct _Recognizer*);
  54. int (*recognizer_clear)(struct _Recognizer*, bool);
  55. int (*recognizer_get_buffer)(struct _Recognizer*, uint*, Stroke**);
  56. int (*recognizer_set_buffer)(struct _Recognizer*, uint, Stroke*);
  57. int (*recognizer_translate)(struct _Recognizer*, uint, Stroke*, bool, int*, rec_alternative**);
  58. rec_fn* (*recognizer_get_extension_functions)(struct _Recognizer*);
  59. char** (*recognizer_get_gesture_names)(struct _Recognizer*);
  60. xgesture (*recognizer_set_gesture_action)(struct _Recognizer*, char*, xgesture, void*);
  61. uint recognizer_end_magic;
  62. };
  63. /*
  64. * recognizer_internal_initialize - Allocate and initialize the recognizer
  65. * object. The recognition shared library has the responsibility for filling
  66. * in all the function pointers for the recognition functions. This
  67. * function must be defined as a global function within the shared
  68. * library, so it can be accessed using dlsym() when the recognizer
  69. * shared library is loaded. It returns NULL if an error occured and
  70. * sets errno to indicate what.
  71. */
  72. typedef recognizer (*recognizer_internal_initialize)(rec_info* ri);
  73. /*Function header definition for recognizer internal initializer.*/
  74. #define RECOGNIZER_INITIALIZE(_a) \
  75. recognizer __recognizer_internal_initialize(rec_info* _a)
  76. /*
  77. * recognizer_internal_finalize - Deallocate and deinitialize the recognizer
  78. * object. If the recognizer has allocated any additional storage, it should
  79. * be deallocated as well. Returns 0 if successful, -1 if the argument
  80. * wasn't a recognizer or wasn't a recognizer handled by this library.
  81. */
  82. typedef int (*recognizer_internal_finalize)(recognizer r);
  83. #define RECOGNIZER_FINALIZE(_a) \
  84. int __recognizer_internal_finalize(recognizer _a)
  85. /*
  86. * The following are for creating HRE structures.
  87. */
  88. recognizer make_recognizer(rec_info* ri);
  89. void delete_recognizer(recognizer rec);
  90. RECOGNIZER_FINALIZE(_a);
  91. rec_alternative* make_rec_alternative_array(uint size);
  92. rec_correlation* make_rec_correlation(char type, uint size, void* trans, rec_confidence conf, uint ps_size);
  93. rec_fn*
  94. make_rec_fn_array(uint size);
  95. void
  96. delete_rec_fn_array(rec_fn* rf);
  97. gesture*
  98. initialize_gesture(gesture* g,
  99. char* name,
  100. uint nhs,
  101. pen_point* hspots,
  102. pen_rect bbox,
  103. xgesture cback,
  104. void* wsinfo);
  105. gesture*
  106. make_gesture_array(uint size);
  107. void
  108. delete_gesture_array(uint size,gesture* ga,bool delete_points_p);
  109. Stroke*
  110. concatenate_Strokes(int nstrokes1,
  111. Stroke* strokes1,
  112. int nstrokes2,
  113. Stroke* strokes2,
  114. int* nstrokes3,
  115. Stroke** strokes3);
  116. rec_alternative* initialize_rec_alternative(rec_alternative* ra, uint);
  117. rec_element* initialize_rec_element(rec_element*, char, uint, void*, rec_confidence);
  118. /*
  119. * Pathnames, etc.
  120. */
  121. #define REC_DEFAULT_LOCALE "C"
  122. #define RECHOME "RECHOME"
  123. #define LANG "LANG"