OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [demos/] [nxscribble/] [hre_api.c] - Diff between revs 27 and 174

Only display areas with differences | Details | Blame | View Log

Rev 27 Rev 174
/*
/*
 *  hre_api.c:        Implementation of HRE API
 *  hre_api.c:        Implementation of HRE API
 *  Author:           James &
 *  Author:           James &
 *  Created On:       Wed Dec  9 13:49:14 1992
 *  Created On:       Wed Dec  9 13:49:14 1992
 *  Last Modified By: James Kempf
 *  Last Modified By: James Kempf
 *  Last Modified On: Fri Sep 23 13:49:04 1994
 *  Last Modified On: Fri Sep 23 13:49:04 1994
 *  Update Count:     137
 *  Update Count:     137
 *  Copyright (c) 1994 by Sun Microsystems Computer Company
 *  Copyright (c) 1994 by Sun Microsystems Computer Company
 *  All rights reserved.
 *  All rights reserved.
 *
 *
 *  Use and copying of this software and preparation of
 *  Use and copying of this software and preparation of
 *  derivative works based upon this software are permitted.
 *  derivative works based upon this software are permitted.
 *  Any distribution of this software or derivative works
 *  Any distribution of this software or derivative works
 *  must comply with all applicable United States export control
 *  must comply with all applicable United States export control
 *  laws.
 *  laws.
 *
 *
 *  This software is made available as is, and Sun Microsystems
 *  This software is made available as is, and Sun Microsystems
 *  Computer Company makes no warranty about the software, its
 *  Computer Company makes no warranty about the software, its
 *  performance, or its conformity to any specification
 *  performance, or its conformity to any specification
 */
 */
 
 
 
 
#include <sys/types.h>
#include <sys/types.h>
#ifdef ELX
#ifdef ELX
#include <vxWorks.h>
#include <vxWorks.h>
#endif
#endif
#include <sys/stat.h>
#include <sys/stat.h>
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <locale.h>
#include <locale.h>
#include <stdlib.h>
#include <stdlib.h>
/*#include <libintl.h>*/
/*#include <libintl.h>*/
#include <hre_internal.h>   /* includes hre.h */
#include <hre_internal.h>   /* includes hre.h */
 
 
/* ari -- prototype for rii function */
/* ari -- prototype for rii function */
recognizer __recognizer_internal_initialize(rec_info* ri);
recognizer __recognizer_internal_initialize(rec_info* ri);
 
 
/*Version number of API.*/
/*Version number of API.*/
 
 
char* REC_VERSION = "2.0";
char* REC_VERSION = "2.0";
 
 
/*Domain name for internationalized text.*/
/*Domain name for internationalized text.*/
 
 
#define INTL_DOMAIN "recognition_manager"
#define INTL_DOMAIN "recognition_manager"
 
 
/* XXX -- Intl Hack -- Jay & Ari */
/* XXX -- Intl Hack -- Jay & Ari */
#define dgettext(domain, msg)   (msg)
#define dgettext(domain, msg)   (msg)
#define bindtextdomain(dirname, domain)
#define bindtextdomain(dirname, domain)
 
 
/*
/*
 * These magic numbers are used to ensure the integrity of the
 * These magic numbers are used to ensure the integrity of the
 * recognizer structure.
 * recognizer structure.
*/
*/
 
 
 
 
#define REC_MAGIC       0xfeed
#define REC_MAGIC       0xfeed
#define REC_END_MAGIC   0xbeef
#define REC_END_MAGIC   0xbeef
 
 
/*Check the recognizer for validity*/
/*Check the recognizer for validity*/
 
 
#define RI_CHECK_MAGIC(rec) \
#define RI_CHECK_MAGIC(rec) \
  ( (rec != NULL) && \
  ( (rec != NULL) && \
    (((recognizer)rec)->recognizer_magic == REC_MAGIC) && \
    (((recognizer)rec)->recognizer_magic == REC_MAGIC) && \
   (((recognizer)rec)->recognizer_end_magic == REC_END_MAGIC) &&\
   (((recognizer)rec)->recognizer_end_magic == REC_END_MAGIC) &&\
   (((recognizer)rec)->recognizer_version == REC_VERSION) )
   (((recognizer)rec)->recognizer_version == REC_VERSION) )
 
 
/*The name of the initialization & finalization functions.*/
/*The name of the initialization & finalization functions.*/
 
 
/* static char rii_name[] = "__recognizer_internal_initialize";
/* static char rii_name[] = "__recognizer_internal_initialize";
static char rif_name[] = "__recognizer_internal_finalize";  */
static char rif_name[] = "__recognizer_internal_finalize";  */
 
 
/*User home directory for recognizer info.*/
/*User home directory for recognizer info.*/
/* ari -- changed USERRECHOME from ".recognizers" */
/* ari -- changed USERRECHOME from ".recognizers" */
#define HOME "HOME"
#define HOME "HOME"
#define USERRECHOME ".classifiers"
#define USERRECHOME ".classifiers"
 
 
/*Local functions*/
/*Local functions*/
 
 
#if 0
#if 0
static char* shared_library_name(char* directory,char* locale,char* name);
static char* shared_library_name(char* directory,char* locale,char* name);
#endif
#endif
static rec_info* make_rec_info(char* directory,char* name,char** subset);
static rec_info* make_rec_info(char* directory,char* name,char** subset);
static void delete_rec_info(rec_info* ri);
static void delete_rec_info(rec_info* ri);
#if 0
#if 0
static int check_for_user_home();
static int check_for_user_home();
#endif
#endif
static void intl_initialize();
static void intl_initialize();
 
 
static void cleanup_rec_element(rec_element* re,bool delete_points_p);
static void cleanup_rec_element(rec_element* re,bool delete_points_p);
 
 
/*The last error.*/
/*The last error.*/
 
 
static char* the_last_error = NULL;
static char* the_last_error = NULL;
 
 
static char *safe_malloc (int nbytes)
static char *safe_malloc (int nbytes)
{
{
  char *res = malloc(nbytes);
  char *res = malloc(nbytes);
  if (res == NULL) {
  if (res == NULL) {
    error("malloc failure");
    error("malloc failure");
    exit(2);
    exit(2);
  }
  }
  return (res);
  return (res);
}
}
 
 
 
 
/*
/*
 * Implementation of API functions
 * Implementation of API functions
*/
*/
 
 
/*
/*
 * recognizer_load - Load the recognizer matching the rec_info struct.
 * recognizer_load - Load the recognizer matching the rec_info struct.
 * If name is not null, then load the recognizer having that name. Returns
 * If name is not null, then load the recognizer having that name. Returns
 * the recognizer object, or null if it can't load the recognizer, and
 * the recognizer object, or null if it can't load the recognizer, and
 * sets errno to indicate why.
 * sets errno to indicate why.
*/
*/
 
 
recognizer
recognizer
recognizer_load(char* directory,char* name,char** subset)
recognizer_load(char* directory,char* name,char** subset)
{
{
    recognizer rec;                     /*the recognizer*/
    recognizer rec;                     /*the recognizer*/
#if 0
#if 0
    recognizer_internal_initialize rii; /*the initialization function*/
    recognizer_internal_initialize rii; /*the initialization function*/
#endif
#endif
    rec_info* rinf;                     /*rec_info for recognizer information*/
    rec_info* rinf;                     /*rec_info for recognizer information*/
    static bool intl_init = false;      /*true if recog. manager initted.*/
    static bool intl_init = false;      /*true if recog. manager initted.*/
 
 
    if( intl_init == false ) {
    if( intl_init == false ) {
      intl_init = true;
      intl_init = true;
 
 
      intl_initialize();
      intl_initialize();
    }
    }
 
 
    /*The name takes precedence.*/
    /*The name takes precedence.*/
    rinf = make_rec_info(directory,name,subset);
    rinf = make_rec_info(directory,name,subset);
    if (rinf == NULL) {
    if (rinf == NULL) {
        the_last_error =
        the_last_error =
          dgettext(INTL_DOMAIN,
          dgettext(INTL_DOMAIN,
                   "Ran out of memory during prelinking initialization.");
                   "Ran out of memory during prelinking initialization.");
        return((recognizer)NULL);
        return((recognizer)NULL);
    }
    }
    /*fprintf(stderr, "Got past make_rec_info.\n");*/
    /*fprintf(stderr, "Got past make_rec_info.\n");*/
 
 
    /*Let recognition code create recognizer and initialize*/
    /*Let recognition code create recognizer and initialize*/
    rec = __recognizer_internal_initialize(rinf);
    rec = __recognizer_internal_initialize(rinf);
    if (rec == NULL) {
    if (rec == NULL) {
        return((recognizer)NULL);
        return((recognizer)NULL);
    }
    }
    /*fprintf(stderr, "Did rii.\n");*/
    /*fprintf(stderr, "Did rii.\n");*/
    /*Check whether it's been correctly initialized*/
    /*Check whether it's been correctly initialized*/
 
 
    if( rec->recognizer_load_state == NULL ||
    if( rec->recognizer_load_state == NULL ||
        rec->recognizer_save_state == NULL ||
        rec->recognizer_save_state == NULL ||
        rec->recognizer_load_dictionary == NULL ||
        rec->recognizer_load_dictionary == NULL ||
        rec->recognizer_save_dictionary == NULL ||
        rec->recognizer_save_dictionary == NULL ||
        rec->recognizer_free_dictionary == NULL ||
        rec->recognizer_free_dictionary == NULL ||
        rec->recognizer_add_to_dictionary == NULL ||
        rec->recognizer_add_to_dictionary == NULL ||
        rec->recognizer_delete_from_dictionary == NULL ||
        rec->recognizer_delete_from_dictionary == NULL ||
        rec->recognizer_error == NULL ||
        rec->recognizer_error == NULL ||
        rec->recognizer_set_context == NULL ||
        rec->recognizer_set_context == NULL ||
        rec->recognizer_get_context == NULL ||
        rec->recognizer_get_context == NULL ||
        rec->recognizer_clear == NULL ||
        rec->recognizer_clear == NULL ||
        rec->recognizer_get_buffer == NULL ||
        rec->recognizer_get_buffer == NULL ||
        rec->recognizer_set_buffer == NULL ||
        rec->recognizer_set_buffer == NULL ||
        rec->recognizer_translate == NULL ||
        rec->recognizer_translate == NULL ||
        rec->recognizer_get_extension_functions == NULL ||
        rec->recognizer_get_extension_functions == NULL ||
        rec->recognizer_get_gesture_names == NULL ||
        rec->recognizer_get_gesture_names == NULL ||
        rec->recognizer_set_gesture_action == NULL
        rec->recognizer_set_gesture_action == NULL
       ) {
       ) {
 
 
        recognizer_unload(rec);
        recognizer_unload(rec);
fprintf(stderr, "Unloading b/c null function pointer.\n");
fprintf(stderr, "Unloading b/c null function pointer.\n");
        the_last_error =
        the_last_error =
          dgettext(INTL_DOMAIN,
          dgettext(INTL_DOMAIN,
                   "One or more recognizer function pointers is NULL.");
                   "One or more recognizer function pointers is NULL.");
        return((recognizer)NULL);
        return((recognizer)NULL);
    }
    }
 
 
 
 
    /*Set the rec_info structure.*/
    /*Set the rec_info structure.*/
 
 
    rec->recognizer_info = rinf;
    rec->recognizer_info = rinf;
 
 
    /*Check whether home directory is there for recognizer info.*/
    /*Check whether home directory is there for recognizer info.*/
 
 
/*
/*
 *  ari -- don't bother.  We're not going to load from each user's
 *  ari -- don't bother.  We're not going to load from each user's
 *  home directory at this point.  Instead, we'll use a stupid
 *  home directory at this point.  Instead, we'll use a stupid
 *  little a-b-c file because it loads FAST.
 *  little a-b-c file because it loads FAST.
 *
 *
 *    if( check_for_user_home() < 0 ) {
 *    if( check_for_user_home() < 0 ) {
 *      recognizer_unload(rec);
 *      recognizer_unload(rec);
 *      return((recognizer)NULL);
 *      return((recognizer)NULL);
 *   }
 *   }
 */
 */
    /*We got it!*/
    /*We got it!*/
    /*fprintf(stderr, "Done.\n");*/
    /*fprintf(stderr, "Done.\n");*/
 
 
    return(rec);
    return(rec);
}
}
 
 
/*
/*
 * recognizer_unload - Unload the recognizer.
 * recognizer_unload - Unload the recognizer.
*/
*/
 
 
int
int
recognizer_unload(recognizer rec)
recognizer_unload(recognizer rec)
{
{
#if 0
#if 0
    recognizer_internal_finalize rif;
    recognizer_internal_finalize rif;
#endif
#endif
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    __recognizer_internal_finalize(rec);
    __recognizer_internal_finalize(rec);
 
 
    return(0);
    return(0);
}
}
 
 
/*
/*
 * recognizer_load_state-Get any recognizer state associated with name
 * recognizer_load_state-Get any recognizer state associated with name
 * in dir. Note that name may not be simple file name, since
 * in dir. Note that name may not be simple file name, since
 * there may be more than one file involved. Return 0 if successful,
 * there may be more than one file involved. Return 0 if successful,
 * -1 if not.
 * -1 if not.
*/
*/
 
 
int recognizer_load_state(recognizer rec,char* dir,char* name)
int recognizer_load_state(recognizer rec,char* dir,char* name)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
    return(rec->recognizer_load_state(rec,dir,name));
    return(rec->recognizer_load_state(rec,dir,name));
}
}
 
 
/*
/*
 * recognizer_save_state-Save any recognizer state to name
 * recognizer_save_state-Save any recognizer state to name
 * in dir. Note that name may not be a simple file name, since
 * in dir. Note that name may not be a simple file name, since
 * there may be more than one file involved. Return 0 if successful,
 * there may be more than one file involved. Return 0 if successful,
 * -1 if not.
 * -1 if not.
*/
*/
 
 
int recognizer_save_state(recognizer rec,char* dir,char* name)
int recognizer_save_state(recognizer rec,char* dir,char* name)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_save_state(rec,dir,name));
    return(rec->recognizer_save_state(rec,dir,name));
}
}
 
 
/*
/*
 * recognizer_load_dictionary-Load dictionary, return pointer
 * recognizer_load_dictionary-Load dictionary, return pointer
 * to it, or NULL if error.
 * to it, or NULL if error.
*/
*/
 
 
wordset recognizer_load_dictionary(recognizer rec,char* dir,char* name)
wordset recognizer_load_dictionary(recognizer rec,char* dir,char* name)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(NULL);
        return(NULL);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_load_dictionary(rec,dir,name));
    return(rec->recognizer_load_dictionary(rec,dir,name));
}
}
 
 
/*
/*
 * recognizer_save_dictionary-Save the  dictionary to the file, return 0 if
 * recognizer_save_dictionary-Save the  dictionary to the file, return 0 if
 * OK, -1 if error.
 * OK, -1 if error.
*/
*/
 
 
int recognizer_save_dictionary(recognizer rec,char* dir,char* name,wordset dict)
int recognizer_save_dictionary(recognizer rec,char* dir,char* name,wordset dict)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_save_dictionary(rec,dir,name,dict));
    return(rec->recognizer_save_dictionary(rec,dir,name,dict));
}
}
 
 
/*
/*
 * recognizer_free_dictionary-Free the dictionary, return 0 if
 * recognizer_free_dictionary-Free the dictionary, return 0 if
 * OK, -1 if error.
 * OK, -1 if error.
*/
*/
 
 
int recognizer_free_dictionary(recognizer rec,wordset dict)
int recognizer_free_dictionary(recognizer rec,wordset dict)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_free_dictionary(rec,dict));
    return(rec->recognizer_free_dictionary(rec,dict));
}
}
 
 
/*
/*
 * recognizer_add_to_dictionary-Add word to the dictionary,
 * recognizer_add_to_dictionary-Add word to the dictionary,
 * return 0 if OK, -1 if error.
 * return 0 if OK, -1 if error.
*/
*/
 
 
 
 
int recognizer_add_to_dictionary(recognizer rec,letterset* word,wordset dict)
int recognizer_add_to_dictionary(recognizer rec,letterset* word,wordset dict)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_add_to_dictionary(rec,word,dict));
    return(rec->recognizer_add_to_dictionary(rec,word,dict));
}
}
 
 
/*
/*
 * recognizer_delete_from_dictionary-Delete word from the dictionary,
 * recognizer_delete_from_dictionary-Delete word from the dictionary,
 * return 0 if OK, -1 if error.
 * return 0 if OK, -1 if error.
*/
*/
 
 
int
int
recognizer_delete_from_dictionary(recognizer rec,letterset* word,wordset dict)
recognizer_delete_from_dictionary(recognizer rec,letterset* word,wordset dict)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_delete_from_dictionary(rec,word,dict));
    return(rec->recognizer_delete_from_dictionary(rec,word,dict));
}
}
 
 
/*
/*
 * recognizer_get_info-Get a pointers to the rec_info
 * recognizer_get_info-Get a pointers to the rec_info
 * giving the locales and subsets supported by the recognizer
 * giving the locales and subsets supported by the recognizer
 * and the shared library pathname.
 * and the shared library pathname.
*/
*/
 
 
const rec_info*
const rec_info*
recognizer_get_info(recognizer rec)
recognizer_get_info(recognizer rec)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return((rec_info*)NULL);
        return((rec_info*)NULL);
    }
    }
 
 
    /*Return the rec_info object.*/
    /*Return the rec_info object.*/
 
 
    return(rec->recognizer_info);
    return(rec->recognizer_info);
}
}
 
 
/*
/*
 * recognizer_manager_version-Return the version number string of the
 * recognizer_manager_version-Return the version number string of the
 * recognition manager.
 * recognition manager.
*/
*/
 
 
const char* recognizer_manager_version(recognizer rec)
const char* recognizer_manager_version(recognizer rec)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(NULL);
        return(NULL);
    }
    }
 
 
    return(rec->recognizer_version);
    return(rec->recognizer_version);
 
 
}
}
/*
/*
 * recognizer_error-Return the last error message, or NULL if none.
 * recognizer_error-Return the last error message, or NULL if none.
*/
*/
 
 
char* recognizer_error(recognizer rec)
char* recognizer_error(recognizer rec)
{
{
 
 
    /*Make sure magic numbers right and function there.*/
    /*Make sure magic numbers right and function there.*/
 
 
    if( !RI_CHECK_MAGIC(rec) && the_last_error == NULL ) {
    if( !RI_CHECK_MAGIC(rec) && the_last_error == NULL ) {
      return(dgettext(INTL_DOMAIN,"Bad recognizer object."));
      return(dgettext(INTL_DOMAIN,"Bad recognizer object."));
 
 
    } else if( the_last_error != NULL ) {
    } else if( the_last_error != NULL ) {
      char* error = the_last_error;
      char* error = the_last_error;
 
 
      the_last_error = NULL;
      the_last_error = NULL;
      return(error);
      return(error);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_error(rec));
    return(rec->recognizer_error(rec));
}
}
 
 
/*
/*
 * recognizer_set_context-Set the recognition context for translation.
 * recognizer_set_context-Set the recognition context for translation.
 * Return 0 if successful, -1 if error.
 * Return 0 if successful, -1 if error.
*/
*/
 
 
int recognizer_set_context(recognizer rec,rc* rec_xt)
int recognizer_set_context(recognizer rec,rc* rec_xt)
{
{
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_set_context(rec,rec_xt));
    return(rec->recognizer_set_context(rec,rec_xt));
}
}
 
 
/*
/*
 * recognzier_get_context-Get the recognition context for translation.
 * recognzier_get_context-Get the recognition context for translation.
 * If none or error, return NULL.
 * If none or error, return NULL.
*/
*/
 
 
rc* recognizer_get_context(recognizer rec)
rc* recognizer_get_context(recognizer rec)
{
{
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(NULL);
        return(NULL);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(recognizer_get_context(rec));
    return(recognizer_get_context(rec));
}
}
 
 
/*
/*
 * recognizer_clear-Clear buffer and recognition context.
 * recognizer_clear-Clear buffer and recognition context.
 * Return 0 if success, else -1.
 * Return 0 if success, else -1.
*/
*/
 
 
int recognizer_clear(recognizer rec,bool delete_points_p)
int recognizer_clear(recognizer rec,bool delete_points_p)
{
{
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_clear(rec,delete_points_p));
    return(rec->recognizer_clear(rec,delete_points_p));
}
}
 
 
/*recognizer_get_buffer-Get stroke buffer. Return 0 if success, else -1.*/
/*recognizer_get_buffer-Get stroke buffer. Return 0 if success, else -1.*/
 
 
 
 
int recognizer_get_buffer(recognizer rec, u_int* nstrokes,pen_stroke** strokes)
int recognizer_get_buffer(recognizer rec, u_int* nstrokes,pen_stroke** strokes)
{
{
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_get_buffer(rec,nstrokes,strokes));
    return(rec->recognizer_get_buffer(rec,nstrokes,strokes));
 
 
}
}
 
 
/*
/*
 * recognizer_set_buffer-Set stroke buffer to arg. Return 0 if success, else
 * recognizer_set_buffer-Set stroke buffer to arg. Return 0 if success, else
 * return -1.
 * return -1.
*/
*/
 
 
int recognizer_set_buffer(recognizer rec,u_int nstrokes,pen_stroke* strokes)
int recognizer_set_buffer(recognizer rec,u_int nstrokes,pen_stroke* strokes)
{
{
 
 
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(-1);
        return(-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_set_buffer(rec,nstrokes,strokes));
    return(rec->recognizer_set_buffer(rec,nstrokes,strokes));
 
 
}
}
 
 
/*
/*
 * recognizer_translate-Translate the strokes in the current context, including
 * recognizer_translate-Translate the strokes in the current context, including
 * buffered strokes. If nstrokes == 0 or strokes == NULL, return
 * buffered strokes. If nstrokes == 0 or strokes == NULL, return
 * translation of stroke buffer.
 * translation of stroke buffer.
*/
*/
 
 
int recognizer_translate(recognizer rec,
int recognizer_translate(recognizer rec,
                         u_int nstrokes,
                         u_int nstrokes,
                         pen_stroke* strokes,
                         pen_stroke* strokes,
                         bool correlate_p,
                         bool correlate_p,
                         int* nret,
                         int* nret,
                         rec_alternative** ret)
                         rec_alternative** ret)
{
{
    int retval;
    int retval;
    char msg[80];
    char msg[80];
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN, msg);
        the_last_error = dgettext(INTL_DOMAIN, msg);
        return(-1);
        return(-1);
    }
    }
 
 
/* ari */
/* ari */
/*    {
/*    {
 *      u_int i;
 *      u_int i;
 *      pen_stroke ari_pstr;
 *      pen_stroke ari_pstr;
 *      pen_point* ari_pts;
 *      pen_point* ari_pts;
 *      int ari;
 *      int ari;
 *      for (i = 0; i < nstrokes; i++) {
 *      for (i = 0; i < nstrokes; i++) {
 *      ari_pstr = strokes[i];
 *      ari_pstr = strokes[i];
 *      ari_pts = ari_pstr.ps_pts;
 *      ari_pts = ari_pstr.ps_pts;
 *      fprintf(stderr, "\nrecognizer_translate: ari_pts = %ld, sizeof(Time) = %d, sizeof(ari_pts[0] = %d, %d points are...\n", ari_pts, sizeof(Time), sizeof(ari_pts[0]), ari_pstr.ps_npts);
 *      fprintf(stderr, "\nrecognizer_translate: ari_pts = %ld, sizeof(Time) = %d, sizeof(ari_pts[0] = %d, %d points are...\n", ari_pts, sizeof(Time), sizeof(ari_pts[0]), ari_pstr.ps_npts);
 *      for (ari = 0; ari < ari_pstr.ps_npts; ari++)
 *      for (ari = 0; ari < ari_pstr.ps_npts; ari++)
 *         fprintf(stderr, "%ld -- (%d, %d)  ", ari_pts[ari], ari_pts[ari].x, ari_pts[ari].y);
 *         fprintf(stderr, "%ld -- (%d, %d)  ", ari_pts[ari], ari_pts[ari].x, ari_pts[ari].y);
 *      }
 *      }
 *    }
 *    }
*/
*/
    /*Do the function.*/
    /*Do the function.*/
/* ari -- this is calling cmu_recognizer_translate */
/* ari -- this is calling cmu_recognizer_translate */
    retval = rec->recognizer_translate(rec,
    retval = rec->recognizer_translate(rec,
                                     nstrokes,
                                     nstrokes,
                                     strokes,
                                     strokes,
                                     correlate_p,
                                     correlate_p,
                                     nret,
                                     nret,
                                     ret);
                                     ret);
    return (retval);
    return (retval);
}
}
 
 
 
 
/*
/*
 * recognizer_get_extension_functions-Return a null terminated array
 * recognizer_get_extension_functions-Return a null terminated array
 * of functions providing extended functionality. Their interfaces
 * of functions providing extended functionality. Their interfaces
 * will change depending on the recognizer.
 * will change depending on the recognizer.
*/
*/
 
 
rec_fn* recognizer_get_extension_functions(recognizer rec)
rec_fn* recognizer_get_extension_functions(recognizer rec)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return((rec_fn*)NULL);
        return((rec_fn*)NULL);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_get_extension_functions(rec));
    return(rec->recognizer_get_extension_functions(rec));
}
}
 
 
 
 
/*
/*
 * recognizer_get_gesture_names - Return a null terminated array of
 * recognizer_get_gesture_names - Return a null terminated array of
 * gesture name strings.
 * gesture name strings.
*/
*/
 
 
char**
char**
recognizer_get_gesture_names(recognizer rec)
recognizer_get_gesture_names(recognizer rec)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return(NULL);
        return(NULL);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_get_gesture_names(rec));
    return(rec->recognizer_get_gesture_names(rec));
}
}
 
 
/*
/*
 * recognizer_set_gesture_action-Set the action function for the gesture.
 * recognizer_set_gesture_action-Set the action function for the gesture.
*/
*/
 
 
xgesture
xgesture
recognizer_train_gestures(recognizer rec,char* name,xgesture fn,void* wsinfo)
recognizer_train_gestures(recognizer rec,char* name,xgesture fn,void* wsinfo)
{
{
    /*Make sure magic numbers right.*/
    /*Make sure magic numbers right.*/
 
 
    if( !RI_CHECK_MAGIC(rec) ) {
    if( !RI_CHECK_MAGIC(rec) ) {
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        the_last_error = dgettext(INTL_DOMAIN,"Bad recognizer object.");
        return((xgesture)-1);
        return((xgesture)-1);
    }
    }
 
 
    /*Do the function.*/
    /*Do the function.*/
 
 
    return(rec->recognizer_set_gesture_action(rec,name,fn,wsinfo));
    return(rec->recognizer_set_gesture_action(rec,name,fn,wsinfo));
}
}
 
 
/*
/*
 * Local functions.
 * Local functions.
*/
*/
 
 
/*
/*
 * shared_library_name-Get the full pathname to the shared library,
 * shared_library_name-Get the full pathname to the shared library,
 *    based on the recognizer name and the environment.
 *    based on the recognizer name and the environment.
*/
*/
 
 
 
 
#if 0
#if 0
static char* shared_library_name(char* directory,char* locale,char* name)
static char* shared_library_name(char* directory,char* locale,char* name)
{
{
    char* ret = NULL;
    char* ret = NULL;
    int len = strlen(name);
    int len = strlen(name);
 
 
    /*If directory is there, it takes precedence.*/
    /*If directory is there, it takes precedence.*/
 
 
    if( directory != NULL ) {
    if( directory != NULL ) {
        ret = (char*)safe_malloc(strlen(directory) + len + 2);
        ret = (char*)safe_malloc(strlen(directory) + len + 2);
        strcpy(ret,directory);
        strcpy(ret,directory);
        strcat(ret,"/");
        strcat(ret,"/");
        strcat(ret,name);
        strcat(ret,name);
 
 
    }
    }
    else {
    else {
        char* dir = NULL;
        char* dir = NULL;
 
 
        /*First try the environment variable.*/
        /*First try the environment variable.*/
 
 
        if( (dir = getenv(RECHOME)) == NULL ) {
        if( (dir = getenv(RECHOME)) == NULL ) {
            dir = "REC_DEFAULT_HOME_DIR";
            dir = "REC_DEFAULT_HOME_DIR";
 
 
          }
          }
 
 
        ret = (char*)safe_malloc(strlen(dir) + strlen(locale) + len + 3);
        ret = (char*)safe_malloc(strlen(dir) + strlen(locale) + len + 3);
        /*Form the pathname.*/
        /*Form the pathname.*/
        strcpy(ret,dir);
        strcpy(ret,dir);
        strcat(ret,"/");
        strcat(ret,"/");
        strcat(ret,locale);
        strcat(ret,locale);
        strcat(ret,"/");
        strcat(ret,"/");
        strcat(ret,name);
        strcat(ret,name);
 
 
    }
    }
 
 
    return(ret);
    return(ret);
}
}
#endif
#endif
 
 
/*
/*
 * intl_initialize-Initialize the internationaliztion of messages for
 * intl_initialize-Initialize the internationaliztion of messages for
 * the recognition manager.
 * the recognition manager.
*/
*/
 
 
static void intl_initialize()
static void intl_initialize()
{
{
  char* dirname;
  char* dirname;
 
 
  /*Get recognizer home directory name from environment.*/
  /*Get recognizer home directory name from environment.*/
 
 
  if( (dirname = getenv(RECHOME)) == NULL ) {
  if( (dirname = getenv(RECHOME)) == NULL ) {
    dirname = "REC_DEFAULT_HOME_DIR";
    dirname = "REC_DEFAULT_HOME_DIR";
  }
  }
 
 
  /*Bind the text domain.*/
  /*Bind the text domain.*/
 
 
  bindtextdomain(dirname,INTL_DOMAIN);
  bindtextdomain(dirname,INTL_DOMAIN);
}
}
 
 
 
 
/*make_rec_info-Create a rec_info structure*/
/*make_rec_info-Create a rec_info structure*/
 
 
static rec_info* make_rec_info(char* directory,char* name,char** subset)
static rec_info* make_rec_info(char* directory,char* name,char** subset)
{
{
    int i,len;
    int i,len;
    rec_info* ri;
    rec_info* ri;
    char* locale;
    char* locale;
 
 
    ri = (rec_info*)safe_malloc(sizeof(rec_info));
    ri = (rec_info*)safe_malloc(sizeof(rec_info));
    ri->ri_locale = NULL;
    ri->ri_locale = NULL;
    ri->ri_name = NULL;
    ri->ri_name = NULL;
    ri->ri_subset = NULL;
    ri->ri_subset = NULL;
 
 
    /*Get locale*/
    /*Get locale*/
 
 
    if( (locale = getenv(LANG)) == NULL ) {
    if( (locale = getenv(LANG)) == NULL ) {
        locale = strdup(REC_DEFAULT_LOCALE);
        locale = strdup(REC_DEFAULT_LOCALE);
    }
    }
 
 
    if( (ri->ri_locale = strdup(locale)) == NULL ) {
    if( (ri->ri_locale = strdup(locale)) == NULL ) {
        delete_rec_info(ri);
        delete_rec_info(ri);
        return(NULL);
        return(NULL);
    }
    }
 
 
    /*Get shared library pathname.*/
    /*Get shared library pathname.*/
 
 
/*
/*
 *    if( (ri->ri_name = shared_library_name(directory,locale,name)) == NULL ) {
 *    if( (ri->ri_name = shared_library_name(directory,locale,name)) == NULL ) {
 *      delete_rec_info(ri);
 *      delete_rec_info(ri);
 *      return(NULL);
 *      return(NULL);
 *    }
 *    }
 */
 */
 
 
    /*Initialize the subset information.*/
    /*Initialize the subset information.*/
 
 
    if( subset != NULL ) {
    if( subset != NULL ) {
 
 
        /*Count the subset strings.*/
        /*Count the subset strings.*/
 
 
        for( len = 1; subset[len] != NULL; len++ ) ;
        for( len = 1; subset[len] != NULL; len++ ) ;
 
 
        /*Copy the subset strings.*/
        /*Copy the subset strings.*/
 
 
        ri->ri_subset = (char**)safe_malloc((len +1)*sizeof(char*));
        ri->ri_subset = (char**)safe_malloc((len +1)*sizeof(char*));
 
 
        for( i = 0; i < len; i++ ) {
        for( i = 0; i < len; i++ ) {
            if( subset[i] != NULL ) {
            if( subset[i] != NULL ) {
                if( (ri->ri_subset[i] = strdup(subset[i])) == NULL ) {
                if( (ri->ri_subset[i] = strdup(subset[i])) == NULL ) {
                    delete_rec_info(ri);
                    delete_rec_info(ri);
                    return(NULL);
                    return(NULL);
                }
                }
            } else {
            } else {
                ri->ri_subset[i] = subset[i];
                ri->ri_subset[i] = subset[i];
            }
            }
        }
        }
 
 
        ri->ri_subset[i] = NULL;
        ri->ri_subset[i] = NULL;
 
 
    } else {
    } else {
 
 
        ri->ri_subset = NULL;
        ri->ri_subset = NULL;
    }
    }
 
 
    return(ri);
    return(ri);
}
}
 
 
static void delete_rec_info(rec_info* ri)
static void delete_rec_info(rec_info* ri)
{
{
    if( ri != NULL ) {
    if( ri != NULL ) {
        if( ri->ri_locale != NULL ) {
        if( ri->ri_locale != NULL ) {
            free(ri->ri_locale);
            free(ri->ri_locale);
        }
        }
/*
/*
 *      if( ri->ri_name != NULL ) {
 *      if( ri->ri_name != NULL ) {
 *          free(ri->ri_name);
 *          free(ri->ri_name);
 *      }
 *      }
 */
 */
        if( ri->ri_subset != NULL ) {
        if( ri->ri_subset != NULL ) {
            int i;
            int i;
            for( i = 0; ri->ri_subset[i] != NULL; i++) {
            for( i = 0; ri->ri_subset[i] != NULL; i++) {
                free(ri->ri_subset[i]);
                free(ri->ri_subset[i]);
            }
            }
            free(ri->ri_subset);
            free(ri->ri_subset);
        }
        }
        free(ri);
        free(ri);
    }
    }
}
}
 
 
/*check_for_user_home-Check whether USERRECHOME has been created.*/
/*check_for_user_home-Check whether USERRECHOME has been created.*/
 
 
#if 0
#if 0
static int check_for_user_home()
static int check_for_user_home()
{
{
    char* homedir = getenv(HOME);
    char* homedir = getenv(HOME);
    char* rechome = NULL;
    char* rechome = NULL;
 
 
    if( homedir == NULL ) {
    if( homedir == NULL ) {
        the_last_error = "Home environment variable HOME not set.";
        the_last_error = "Home environment variable HOME not set.";
        return(-1);
        return(-1);
    }
    }
 
 
    rechome = (char*)safe_malloc(strlen(homedir) + strlen(USERRECHOME) + 2);
    rechome = (char*)safe_malloc(strlen(homedir) + strlen(USERRECHOME) + 2);
 
 
    /*Form name.*/
    /*Form name.*/
 
 
    strcpy(rechome,homedir);
    strcpy(rechome,homedir);
    strcat(rechome,"/");
    strcat(rechome,"/");
    strcat(rechome,USERRECHOME);
    strcat(rechome,USERRECHOME);
 
 
    /*Create directory.*/
    /*Create directory.*/
 
 
    if( mkdir(rechome,S_IRWXU | S_IRWXG | S_IRWXO) < 0 ) {
    if( mkdir(rechome,S_IRWXU | S_IRWXG | S_IRWXO) < 0 ) {
 
 
        /*If errno is EEXIST, then OK.*/
        /*If errno is EEXIST, then OK.*/
 
 
        if( errno != EEXIST ) {
        if( errno != EEXIST ) {
            the_last_error = "Error during creation of USERRECHOME.";
            the_last_error = "Error during creation of USERRECHOME.";
            free(rechome);
            free(rechome);
            return(-1);
            return(-1);
        }
        }
    }
    }
 
 
    free(rechome);
    free(rechome);
 
 
    return(0);
    return(0);
}
}
#endif
#endif
 
 
/*
/*
 * Constructor functions for making structures.
 * Constructor functions for making structures.
 *
 *
 *    The general philosophy here is that we control all memory
 *    The general philosophy here is that we control all memory
 *    in connected data structures, *except* for pen_point arrays.
 *    in connected data structures, *except* for pen_point arrays.
 *    There are likely to be lots and lots of points, they are likely
 *    There are likely to be lots and lots of points, they are likely
 *    to come from the window system; so if we wanted to control them,
 *    to come from the window system; so if we wanted to control them,
 *    we would have to copy which would be slow. We require the client
 *    we would have to copy which would be slow. We require the client
 *    to deal with them directly, or the client can give us permission
 *    to deal with them directly, or the client can give us permission
 *    to delete them.
 *    to delete them.
*/
*/
 
 
/*
/*
 * recognizer
 * recognizer
*/
*/
 
 
 
 
recognizer make_recognizer(rec_info* rif)
recognizer make_recognizer(rec_info* rif)
{
{
    recognizer rec;
    recognizer rec;
 
 
    /*Allocate it.*/
    /*Allocate it.*/
 
 
    rec = (recognizer)safe_malloc(sizeof(*rec));
    rec = (recognizer)safe_malloc(sizeof(*rec));
    rec->recognizer_magic = REC_MAGIC;
    rec->recognizer_magic = REC_MAGIC;
    rec->recognizer_version = REC_VERSION;
    rec->recognizer_version = REC_VERSION;
    rec->recognizer_info = rif;
    rec->recognizer_info = rif;
    rec->recognizer_specific = NULL;
    rec->recognizer_specific = NULL;
    rec->recognizer_end_magic = REC_END_MAGIC;
    rec->recognizer_end_magic = REC_END_MAGIC;
    rec->recognizer_load_state = NULL;
    rec->recognizer_load_state = NULL;
    rec->recognizer_save_state = NULL;
    rec->recognizer_save_state = NULL;
    rec->recognizer_load_dictionary = NULL;
    rec->recognizer_load_dictionary = NULL;
    rec->recognizer_save_dictionary = NULL;
    rec->recognizer_save_dictionary = NULL;
    rec->recognizer_free_dictionary = NULL;
    rec->recognizer_free_dictionary = NULL;
    rec->recognizer_add_to_dictionary = NULL;
    rec->recognizer_add_to_dictionary = NULL;
    rec->recognizer_delete_from_dictionary = NULL;
    rec->recognizer_delete_from_dictionary = NULL;
    rec->recognizer_error = NULL;
    rec->recognizer_error = NULL;
    rec->recognizer_set_context = NULL;
    rec->recognizer_set_context = NULL;
    rec->recognizer_get_context = NULL;
    rec->recognizer_get_context = NULL;
    rec->recognizer_clear = NULL;
    rec->recognizer_clear = NULL;
    rec->recognizer_get_buffer = NULL;
    rec->recognizer_get_buffer = NULL;
    rec->recognizer_set_buffer = NULL;
    rec->recognizer_set_buffer = NULL;
    rec->recognizer_translate = NULL;
    rec->recognizer_translate = NULL;
    rec->recognizer_get_extension_functions = NULL;
    rec->recognizer_get_extension_functions = NULL;
    rec->recognizer_get_gesture_names = NULL;
    rec->recognizer_get_gesture_names = NULL;
    rec->recognizer_set_gesture_action = NULL;
    rec->recognizer_set_gesture_action = NULL;
    return(rec);
    return(rec);
}
}
 
 
void delete_recognizer(recognizer rec)
void delete_recognizer(recognizer rec)
{
{
 
 
    if( rec != NULL ) {
    if( rec != NULL ) {
        if( rec->recognizer_info != NULL ) {
        if( rec->recognizer_info != NULL ) {
            delete_rec_info(rec->recognizer_info);
            delete_rec_info(rec->recognizer_info);
        }
        }
        free(rec);
        free(rec);
    }
    }
}
}
 
 
/*
/*
 * rec_alternative
 * rec_alternative
*/
*/
 
 
rec_alternative* make_rec_alternative_array(u_int size)
rec_alternative* make_rec_alternative_array(u_int size)
{
{
    int i;
    int i;
    rec_alternative* ri;
    rec_alternative* ri;
 
 
    ri = (rec_alternative*) safe_malloc(size * sizeof(rec_alternative));
    ri = (rec_alternative*) safe_malloc(size * sizeof(rec_alternative));
 
 
    for( i = 0; i < size; i++ ) {
    for( i = 0; i < size; i++ ) {
        ri[i].ra_elem.re_type = REC_NONE;
        ri[i].ra_elem.re_type = REC_NONE;
        ri[i].ra_elem.re_result.aval = NULL;
        ri[i].ra_elem.re_result.aval = NULL;
        ri[i].ra_elem.re_conf = 0;
        ri[i].ra_elem.re_conf = 0;
        ri[i].ra_nalter = 0;
        ri[i].ra_nalter = 0;
        ri[i].ra_next = NULL;
        ri[i].ra_next = NULL;
    }
    }
 
 
    return(ri);
    return(ri);
}
}
 
 
rec_alternative*
rec_alternative*
  initialize_rec_alternative(rec_alternative* ra,
  initialize_rec_alternative(rec_alternative* ra,
                             u_int nelem)
                             u_int nelem)
{
{
  if( ra != NULL ) {
  if( ra != NULL ) {
    if( (ra->ra_next = make_rec_alternative_array(nelem)) == NULL ) {
    if( (ra->ra_next = make_rec_alternative_array(nelem)) == NULL ) {
      return(NULL);
      return(NULL);
    }
    }
 
 
    ra->ra_nalter = nelem;
    ra->ra_nalter = nelem;
  }
  }
 
 
  return(ra);
  return(ra);
}
}
 
 
void delete_rec_alternative_array(u_int nalter,
void delete_rec_alternative_array(u_int nalter,
                                  rec_alternative* ra,
                                  rec_alternative* ra,
                                  bool delete_points_p)
                                  bool delete_points_p)
{
{
  int i;
  int i;
 
 
    if( ra != NULL ) {
    if( ra != NULL ) {
 
 
      for( i = 0; i < nalter; i++ ) {
      for( i = 0; i < nalter; i++ ) {
        cleanup_rec_element(&ra[i].ra_elem,delete_points_p);
        cleanup_rec_element(&ra[i].ra_elem,delete_points_p);
 
 
        /*Now do the next one down the line.*/
        /*Now do the next one down the line.*/
 
 
        if( ra[i].ra_nalter > 0 ) {
        if( ra[i].ra_nalter > 0 ) {
          delete_rec_alternative_array(ra[i].ra_nalter,
          delete_rec_alternative_array(ra[i].ra_nalter,
                                       ra[i].ra_next,
                                       ra[i].ra_next,
                                       delete_points_p);
                                       delete_points_p);
        }
        }
      }
      }
 
 
      free(ra);
      free(ra);
    }
    }
}
}
 
 
 
 
/*initialize_rec_element-Initialize a recognition element.*/
/*initialize_rec_element-Initialize a recognition element.*/
 
 
rec_element*
rec_element*
initialize_rec_element(rec_element* re,
initialize_rec_element(rec_element* re,
                       char type,
                       char type,
                       u_int size,
                       u_int size,
                       void* trans,
                       void* trans,
                       rec_confidence conf)
                       rec_confidence conf)
{
{
    if( re != NULL ) {
    if( re != NULL ) {
 
 
        re->re_type = type;
        re->re_type = type;
        re->re_conf = conf;
        re->re_conf = conf;
        re->re_result.aval = NULL;
        re->re_result.aval = NULL;
 
 
        switch (type) {
        switch (type) {
 
 
          case REC_GESTURE:
          case REC_GESTURE:
            if( size > 0 && trans != NULL ) {
            if( size > 0 && trans != NULL ) {
                re->re_result.gval =
                re->re_result.gval =
                     (gesture*)safe_malloc(sizeof(gesture));
                     (gesture*)safe_malloc(sizeof(gesture));
                memcpy((void*)re->re_result.gval,trans,sizeof(gesture));
                memcpy((void*)re->re_result.gval,trans,sizeof(gesture));
            }
            }
            break;
            break;
 
 
          case REC_ASCII:
          case REC_ASCII:
          case REC_VAR:
          case REC_VAR:
          case REC_OTHER:
          case REC_OTHER:
            if( size > 0 && trans != NULL ) {
            if( size > 0 && trans != NULL ) {
                re->re_result.aval =
                re->re_result.aval =
                     (char*)safe_malloc((size+1)*sizeof(char));
                     (char*)safe_malloc((size+1)*sizeof(char));
                memcpy((void*)re->re_result.aval,trans,size*sizeof(char));
                memcpy((void*)re->re_result.aval,trans,size*sizeof(char));
                re->re_result.aval[size] = '\000';
                re->re_result.aval[size] = '\000';
            }
            }
            break;
            break;
 
 
          case REC_WCHAR:
          case REC_WCHAR:
            if( size > 0 && trans != NULL ) {
            if( size > 0 && trans != NULL ) {
                re->re_result.wval =
                re->re_result.wval =
                     (wchar_t*)safe_malloc((size+1)*sizeof(wchar_t));
                     (wchar_t*)safe_malloc((size+1)*sizeof(wchar_t));
                memcpy((void*)re->re_result.wval,trans,size*sizeof(wchar_t));
                memcpy((void*)re->re_result.wval,trans,size*sizeof(wchar_t));
                re->re_result.wval[size] = '\000';
                re->re_result.wval[size] = '\000';
            }
            }
            break;
            break;
 
 
          case REC_CORR:
          case REC_CORR:
            if( size > 0 && trans != NULL ) {
            if( size > 0 && trans != NULL ) {
              re->re_result.rcval =
              re->re_result.rcval =
                   (rec_correlation*)safe_malloc(sizeof(rec_correlation));
                   (rec_correlation*)safe_malloc(sizeof(rec_correlation));
              memcpy((void*)re->re_result.rcval,
              memcpy((void*)re->re_result.rcval,
                     trans,
                     trans,
                     sizeof(rec_correlation));
                     sizeof(rec_correlation));
            }
            }
            break;
            break;
 
 
          default:
          default:
            return(NULL);
            return(NULL);
        }
        }
 
 
    }
    }
 
 
    return(re);
    return(re);
}
}
 
 
static void cleanup_rec_element(rec_element* re,bool delete_points_p)
static void cleanup_rec_element(rec_element* re,bool delete_points_p)
{
{
  switch(re->re_type) {
  switch(re->re_type) {
 
 
  case REC_NONE:
  case REC_NONE:
    break;
    break;
 
 
  case REC_ASCII:
  case REC_ASCII:
  case REC_VAR:
  case REC_VAR:
  case REC_WCHAR:
  case REC_WCHAR:
  case REC_OTHER:
  case REC_OTHER:
    free(re->re_result.aval);
    free(re->re_result.aval);
    break;
    break;
 
 
  case REC_GESTURE:
  case REC_GESTURE:
    delete_gesture_array(1,re->re_result.gval,true);
    delete_gesture_array(1,re->re_result.gval,true);
    break;
    break;
 
 
  case REC_CORR:
  case REC_CORR:
    delete_rec_correlation(re->re_result.rcval,
    delete_rec_correlation(re->re_result.rcval,
                           delete_points_p);
                           delete_points_p);
    break;
    break;
 
 
  }
  }
 
 
}
}
 
 
/*
/*
 * rec_correlation
 * rec_correlation
*/
*/
 
 
 
 
rec_correlation*
rec_correlation*
make_rec_correlation(char type,
make_rec_correlation(char type,
                     u_int size,
                     u_int size,
                     void* trans,
                     void* trans,
                     rec_confidence conf,
                     rec_confidence conf,
                     u_int ps_size)
                     u_int ps_size)
{
{
  rec_correlation* rc;
  rec_correlation* rc;
 
 
    rc = (rec_correlation*)safe_malloc(sizeof(rec_correlation));
    rc = (rec_correlation*)safe_malloc(sizeof(rec_correlation));
 
 
    rc->ro_nstrokes = ps_size;
    rc->ro_nstrokes = ps_size;
 
 
    /*First initialize element.*/
    /*First initialize element.*/
 
 
    if( initialize_rec_element(&(rc->ro_elem),
    if( initialize_rec_element(&(rc->ro_elem),
                               type,
                               type,
                               size,
                               size,
                               trans,
                               trans,
                               conf) == NULL ) {
                               conf) == NULL ) {
      return(NULL);
      return(NULL);
    }
    }
 
 
    if( (rc->ro_strokes = make_pen_stroke_array(ps_size)) == NULL ) {
    if( (rc->ro_strokes = make_pen_stroke_array(ps_size)) == NULL ) {
      return(NULL);
      return(NULL);
    }
    }
 
 
    rc->ro_start = (u_int*)safe_malloc(ps_size * sizeof(int));
    rc->ro_start = (u_int*)safe_malloc(ps_size * sizeof(int));
    rc->ro_stop = (u_int*)safe_malloc(ps_size * sizeof(int));
    rc->ro_stop = (u_int*)safe_malloc(ps_size * sizeof(int));
    return(rc);
    return(rc);
}
}
 
 
void delete_rec_correlation(rec_correlation* rc,bool delete_points_p)
void delete_rec_correlation(rec_correlation* rc,bool delete_points_p)
{
{
  if( rc != NULL ) {
  if( rc != NULL ) {
 
 
    cleanup_rec_element(&rc->ro_elem,delete_points_p);
    cleanup_rec_element(&rc->ro_elem,delete_points_p);
 
 
    delete_pen_stroke_array(rc->ro_nstrokes,rc->ro_strokes,delete_points_p);
    delete_pen_stroke_array(rc->ro_nstrokes,rc->ro_strokes,delete_points_p);
 
 
    if( rc->ro_start != NULL ) {
    if( rc->ro_start != NULL ) {
      free(rc->ro_start);
      free(rc->ro_start);
    }
    }
 
 
    if( rc->ro_stop != NULL ) {
    if( rc->ro_stop != NULL ) {
      free(rc->ro_stop);
      free(rc->ro_stop);
    }
    }
 
 
    free(rc);
    free(rc);
  }
  }
 
 
}
}
 
 
 
 
/*
/*
 * rec_fn
 * rec_fn
*/
*/
 
 
 
 
rec_fn* make_rec_fn_array(u_int size)
rec_fn* make_rec_fn_array(u_int size)
{
{
    rec_fn* ri = (rec_fn*)safe_malloc((size + 1) * sizeof(rec_fn));
    rec_fn* ri = (rec_fn*)safe_malloc((size + 1) * sizeof(rec_fn));
    int i;
    int i;
 
 
    for( i = 0; i < size; i++ ) {
    for( i = 0; i < size; i++ ) {
        ri[i] = NULL;
        ri[i] = NULL;
    }
    }
 
 
    ri[i] = NULL;
    ri[i] = NULL;
 
 
    return(ri);
    return(ri);
}
}
 
 
void delete_rec_fn_array(rec_fn* rf)
void delete_rec_fn_array(rec_fn* rf)
{
{
    if( rf != NULL ) {
    if( rf != NULL ) {
        free(rf);
        free(rf);
    }
    }
}
}
 
 
/*
/*
 * pen_stroke
 * pen_stroke
*/
*/
 
 
 
 
pen_stroke* make_pen_stroke_array(u_int size)
pen_stroke* make_pen_stroke_array(u_int size)
{
{
    int i;
    int i;
    pen_stroke* ri;
    pen_stroke* ri;
 
 
    ri = (pen_stroke*) safe_malloc(size * sizeof(pen_stroke));
    ri = (pen_stroke*) safe_malloc(size * sizeof(pen_stroke));
    for( i = 0; i < size; i++ ) {
    for( i = 0; i < size; i++ ) {
        ri[i].ps_npts = 0;
        ri[i].ps_npts = 0;
        ri[i].ps_pts = NULL;
        ri[i].ps_pts = NULL;
        ri[i].ps_nstate = 0;
        ri[i].ps_nstate = 0;
        ri[i].ps_state = NULL;
        ri[i].ps_state = NULL;
    }
    }
 
 
    return(ri);
    return(ri);
}
}
 
 
pen_stroke* initialize_pen_stroke(pen_stroke* ps,
pen_stroke* initialize_pen_stroke(pen_stroke* ps,
                                  u_int npts,
                                  u_int npts,
                                  pen_point* pts,
                                  pen_point* pts,
                                  u_int nstate,
                                  u_int nstate,
                                  u_int* trans,
                                  u_int* trans,
                                  pen_state* state)
                                  pen_state* state)
{
{
  if( ps != NULL ) {
  if( ps != NULL ) {
    ps->ps_npts = npts;
    ps->ps_npts = npts;
    ps->ps_pts = pts;
    ps->ps_pts = pts;
    ps->ps_nstate = nstate;
    ps->ps_nstate = nstate;
    ps->ps_trans = trans;
    ps->ps_trans = trans;
    ps->ps_state = state;
    ps->ps_state = state;
  }
  }
  return (ps);
  return (ps);
}
}
 
 
void delete_pen_stroke_array(u_int size,pen_stroke* ps,bool delete_points_p)
void delete_pen_stroke_array(u_int size,pen_stroke* ps,bool delete_points_p)
{
{
  int i;
  int i;
 
 
    if( ps != NULL ) {
    if( ps != NULL ) {
 
 
      for( i = 0; i < size; i++ ) {
      for( i = 0; i < size; i++ ) {
 
 
            if( ps[i].ps_state != NULL ) {
            if( ps[i].ps_state != NULL ) {
                free(ps[i].ps_state);
                free(ps[i].ps_state);
            }
            }
 
 
            if( ps[i].ps_trans != NULL ) {
            if( ps[i].ps_trans != NULL ) {
                free(ps[i].ps_trans);
                free(ps[i].ps_trans);
            }
            }
 
 
            if( delete_points_p ) {
            if( delete_points_p ) {
                delete_pen_point_array(ps[i].ps_pts);
                delete_pen_point_array(ps[i].ps_pts);
            }
            }
 
 
      }
      }
 
 
      free(ps);
      free(ps);
    }
    }
}
}
 
 
/*
/*
 * pen_point
 * pen_point
*/
*/
 
 
 
 
pen_point* make_pen_point_array(u_int size)
pen_point* make_pen_point_array(u_int size)
{
{
    pen_point* pp = (pen_point*)safe_malloc(size * sizeof(pen_point));
    pen_point* pp = (pen_point*)safe_malloc(size * sizeof(pen_point));
    int i;
    int i;
 
 
    for( i = 0; i < size; i++ ) {
    for( i = 0; i < size; i++ ) {
        pp[i].time = 0;
        pp[i].time = 0;
        pp[i].x = pp[i].y = 0;
        pp[i].x = pp[i].y = 0;
    }
    }
 
 
    return(pp);
    return(pp);
}
}
 
 
void delete_pen_point_array(pen_point* pp)
void delete_pen_point_array(pen_point* pp)
{
{
    if( pp != NULL ) {
    if( pp != NULL ) {
        free(pp);
        free(pp);
    }
    }
}
}
 
 
/*
/*
 * pen_state
 * pen_state
*/
*/
 
 
 
 
pen_state* make_pen_state_array(u_int size)
pen_state* make_pen_state_array(u_int size)
{
{
  int i;
  int i;
 
 
  pen_state* ps = (pen_state*)safe_malloc(size*sizeof(pen_state));
  pen_state* ps = (pen_state*)safe_malloc(size*sizeof(pen_state));
 
 
  for( i = 0; i < size; i++ ) {
  for( i = 0; i < size; i++ ) {
    ps[i].pt_button = 0;
    ps[i].pt_button = 0;
    ps[i].pt_pen = 0;
    ps[i].pt_pen = 0;
    ps[i].pt_pressure = 0;
    ps[i].pt_pressure = 0;
    ps[i].pt_anglex = 0.0;
    ps[i].pt_anglex = 0.0;
    ps[i].pt_angley = 0.0;
    ps[i].pt_angley = 0.0;
    ps[i].pt_barrelrotate = 0.0;
    ps[i].pt_barrelrotate = 0.0;
  }
  }
 
 
  return(ps);
  return(ps);
 
 
}
}
 
 
pen_state* initialize_pen_state(pen_state* ps,
pen_state* initialize_pen_state(pen_state* ps,
                                u_short button,
                                u_short button,
                                u_short pen,
                                u_short pen,
                                short pressure,
                                short pressure,
                                double anglex,
                                double anglex,
                                double angley,
                                double angley,
                                double barrelrotate)
                                double barrelrotate)
{
{
  if( ps != NULL ) {
  if( ps != NULL ) {
    ps->pt_button = button;
    ps->pt_button = button;
    ps->pt_pen = pen;
    ps->pt_pen = pen;
    ps->pt_pressure = pressure;
    ps->pt_pressure = pressure;
    ps->pt_anglex = anglex;
    ps->pt_anglex = anglex;
    ps->pt_angley = angley;
    ps->pt_angley = angley;
    ps->pt_barrelrotate = barrelrotate;
    ps->pt_barrelrotate = barrelrotate;
  }
  }
 
 
  return(ps);
  return(ps);
}
}
 
 
void delete_pen_state_array(pen_state* ps)
void delete_pen_state_array(pen_state* ps)
{
{
  if( ps != NULL ) {
  if( ps != NULL ) {
    free(ps);
    free(ps);
  }
  }
}
}
 
 
/*
/*
 * gesture
 * gesture
*/
*/
 
 
gesture*
gesture*
make_gesture_array(u_int size)
make_gesture_array(u_int size)
{
{
    return((gesture*)safe_malloc(size * sizeof(gesture)));
    return((gesture*)safe_malloc(size * sizeof(gesture)));
}
}
 
 
gesture* initialize_gesture(gesture* g,
gesture* initialize_gesture(gesture* g,
                            char* name,
                            char* name,
                            u_int nhs,
                            u_int nhs,
                            pen_point* hspots,
                            pen_point* hspots,
                            pen_rect bbox,
                            pen_rect bbox,
                            xgesture fn,
                            xgesture fn,
                            void* wsinfo)
                            void* wsinfo)
{
{
    if( g != NULL ) {
    if( g != NULL ) {
 
 
        /*We don't do points, 'cause they come from the window system.*/
        /*We don't do points, 'cause they come from the window system.*/
 
 
        g->g_nhs = nhs;
        g->g_nhs = nhs;
        g->g_hspots = hspots;
        g->g_hspots = hspots;
 
 
        g->g_name = strdup(name);
        g->g_name = strdup(name);
 
 
        g->g_bbox.x = bbox.x;
        g->g_bbox.x = bbox.x;
        g->g_bbox.y = bbox.y;
        g->g_bbox.y = bbox.y;
        g->g_bbox.width = bbox.width;
        g->g_bbox.width = bbox.width;
        g->g_bbox.height = bbox.height;
        g->g_bbox.height = bbox.height;
        g->g_action = fn;
        g->g_action = fn;
        g->g_wsinfo = wsinfo;
        g->g_wsinfo = wsinfo;
    }
    }
 
 
    return(g);
    return(g);
}
}
 
 
void
void
delete_gesture_array(u_int size,gesture* ga,bool delete_points_p)
delete_gesture_array(u_int size,gesture* ga,bool delete_points_p)
{
{
    int i;
    int i;
 
 
    if( ga != NULL ) {
    if( ga != NULL ) {
 
 
      for( i = 0; i < size; i++ ) {
      for( i = 0; i < size; i++ ) {
 
 
        free(ga[i].g_name);
        free(ga[i].g_name);
 
 
        if( delete_points_p ) {
        if( delete_points_p ) {
          delete_pen_point_array(ga[i].g_hspots);
          delete_pen_point_array(ga[i].g_hspots);
        }
        }
      }
      }
 
 
      free(ga);
      free(ga);
    }
    }
}
}
 
 
/*
/*
 * copy fns for stroke buffer management.
 * copy fns for stroke buffer management.
*/
*/
 
 
static pen_stroke*
static pen_stroke*
copy_pen_stroke(pen_stroke* ps1,pen_stroke* ps2)
copy_pen_stroke(pen_stroke* ps1,pen_stroke* ps2)
{
{
  u_int* trans = NULL;
  u_int* trans = NULL;
  pen_state* state = NULL;
  pen_state* state = NULL;
 
 
  if( (trans =
  if( (trans =
       copy_state_trans_array(ps2->ps_nstate,
       copy_state_trans_array(ps2->ps_nstate,
                              ps2->ps_trans)) == NULL ) {
                              ps2->ps_trans)) == NULL ) {
    return(NULL);
    return(NULL);
  }
  }
 
 
  if( (state =
  if( (state =
       copy_pen_state_array(ps2->ps_nstate,
       copy_pen_state_array(ps2->ps_nstate,
                            ps2->ps_state)) == NULL ) {
                            ps2->ps_state)) == NULL ) {
    free(trans);
    free(trans);
    return(NULL);
    return(NULL);
  }
  }
 
 
  initialize_pen_stroke(ps1,
  initialize_pen_stroke(ps1,
                        ps2->ps_npts,
                        ps2->ps_npts,
                        ps2->ps_pts,
                        ps2->ps_pts,
                        ps2->ps_nstate,
                        ps2->ps_nstate,
                        trans,
                        trans,
                        state);
                        state);
  return(ps1);
  return(ps1);
 
 
}
}
 
 
pen_stroke*
pen_stroke*
 copy_pen_stroke_array(u_int nstrokes,
 copy_pen_stroke_array(u_int nstrokes,
                    pen_stroke* strokes)
                    pen_stroke* strokes)
{
{
  int i;
  int i;
  pen_stroke* ps = make_pen_stroke_array(nstrokes);
  pen_stroke* ps = make_pen_stroke_array(nstrokes);
 
 
  if( ps != NULL ) {
  if( ps != NULL ) {
 
 
    for( i = 0; i < nstrokes; i++ ) {
    for( i = 0; i < nstrokes; i++ ) {
 
 
      copy_pen_stroke(&ps[i],&strokes[i]);
      copy_pen_stroke(&ps[i],&strokes[i]);
 
 
    }
    }
 
 
  }
  }
 
 
  return(ps);
  return(ps);
}
}
 
 
pen_state*
pen_state*
 copy_pen_state_array(u_int nstate,pen_state* state)
 copy_pen_state_array(u_int nstate,pen_state* state)
{
{
  pen_state* ps = make_pen_state_array(nstate);
  pen_state* ps = make_pen_state_array(nstate);
  int i;
  int i;
 
 
  if( ps != NULL ) {
  if( ps != NULL ) {
 
 
    for( i = 0; i < nstate; i++ ) {
    for( i = 0; i < nstate; i++ ) {
 
 
      initialize_pen_state(&ps[i],
      initialize_pen_state(&ps[i],
                           state[i].pt_button,
                           state[i].pt_button,
                           state[i].pt_pen,
                           state[i].pt_pen,
                           state[i].pt_pressure,
                           state[i].pt_pressure,
                           state[i].pt_anglex,
                           state[i].pt_anglex,
                           state[i].pt_angley,
                           state[i].pt_angley,
                           state[i].pt_barrelrotate);
                           state[i].pt_barrelrotate);
    }
    }
 
 
  }
  }
 
 
  return(ps);
  return(ps);
}
}
 
 
u_int*
u_int*
 copy_state_trans_array(u_int ntrans,u_int* trans)
 copy_state_trans_array(u_int ntrans,u_int* trans)
{
{
  u_int* pt = (u_int*)safe_malloc(ntrans*sizeof(u_int));
  u_int* pt = (u_int*)safe_malloc(ntrans*sizeof(u_int));
  int i;
  int i;
 
 
  for( i = 0; i < ntrans; i++ ) {
  for( i = 0; i < ntrans; i++ ) {
    pt[i] = trans[i];
    pt[i] = trans[i];
  }
  }
  return(pt);
  return(pt);
 
 
}
}
 
 
pen_stroke*
pen_stroke*
concatenate_pen_strokes(int nstrokes1,
concatenate_pen_strokes(int nstrokes1,
                        pen_stroke* strokes1,
                        pen_stroke* strokes1,
                        int nstrokes2,
                        int nstrokes2,
                        pen_stroke* strokes2,
                        pen_stroke* strokes2,
                        int* nstrokes3,
                        int* nstrokes3,
                        pen_stroke** strokes3)
                        pen_stroke** strokes3)
{
{
  int i;
  int i;
  int ns;
  int ns;
  pen_stroke* ps;
  pen_stroke* ps;
 
 
  /*Measure new strokes*/
  /*Measure new strokes*/
 
 
  ns = nstrokes1 + nstrokes2;
  ns = nstrokes1 + nstrokes2;
 
 
  /*Allocate memory*/
  /*Allocate memory*/
 
 
  if( (ps = make_pen_stroke_array(ns)) == NULL ) {
  if( (ps = make_pen_stroke_array(ns)) == NULL ) {
    return(NULL);
    return(NULL);
  }
  }
 
 
  /*Copy old ones into new.*/
  /*Copy old ones into new.*/
 
 
  for( i = 0; i < nstrokes1; i++ ) {
  for( i = 0; i < nstrokes1; i++ ) {
    if( copy_pen_stroke(&ps[i],&strokes1[i]) == NULL ) {
    if( copy_pen_stroke(&ps[i],&strokes1[i]) == NULL ) {
      delete_pen_stroke_array(ns,ps,false);
      delete_pen_stroke_array(ns,ps,false);
      return(NULL);
      return(NULL);
    }
    }
  }
  }
 
 
  for( ; i < ns; i++ ) {
  for( ; i < ns; i++ ) {
    if( copy_pen_stroke(&ps[i],&strokes2[i - nstrokes1]) == NULL ) {
    if( copy_pen_stroke(&ps[i],&strokes2[i - nstrokes1]) == NULL ) {
      delete_pen_stroke_array(ns,ps,false);
      delete_pen_stroke_array(ns,ps,false);
      return(NULL);
      return(NULL);
    }
    }
  }
  }
 
 
  *nstrokes3 = ns;
  *nstrokes3 = ns;
  *strokes3 = ps;
  *strokes3 = ps;
 
 
  return(ps);
  return(ps);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.