hre_internal.h 5.4 KB

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