Back to index

im-sdk  12.3.91
le_object.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #ifdef HAVE_CONFIG_H
00004 #include "config.h"
00005 #endif
00006 
00007 #include "le_object.h"
00008 
00009 extern char lename_string[];
00010 extern UTFCHAR lename_utf_string[];
00011 extern IMLocale locales[];
00012 
00013 static IMLEName lename = { lename_string, lename_utf_string };
00014 
00015 #define  LE_VERSION    "2.0"
00016 
00017 LeObjectRec *le_object_new()
00018 {
00019     LeObjectRec *le_object = NULL;
00020     IMObjectDescriptorStruct *im_objects, *l;
00021     char auxiliary_object_path[256];
00022 
00023     le_object = (LeObjectRec *) calloc(1, sizeof(LeObjectRec));
00024     if (le_object == NULL)
00025         return (NULL);
00026 
00027     /* initilize the IMObjectDescriptorStruct */
00028     im_objects = (IMObjectDescriptorStruct *) calloc(2, sizeof(IMObjectDescriptorStruct));
00029     if (im_objects == NULL) {
00030        free ((char *)le_object);
00031        return (NULL);
00032     }
00033 
00034     snprintf(auxiliary_object_path, 256,
00035            "./%s/auxiliary_windows/auxiliary_object.so", LE_NAME);
00036     l = im_objects;
00037     l->leid = lename_string;       /* engine id */
00038     l->type = IM_DOWNLOADINGOBJECT_BINGUI_TYPE;  /* object type */
00039     l->name = lename_utf_string;
00040     l->name_length = UTFCHARLen(lename_utf_string);
00041     l->domain = "com.sun";
00042     l->scope = lename_string;
00043 
00044     /* path for .so from /usr/lib/iiim/ */
00045     l->path = (char *) strdup(auxiliary_object_path);
00046 
00047     l->signature = "";
00048     l->basepath = NULL;            /* only for CCDEF */
00049     l->encoding = NULL;            /* only for CCDEF */
00050 
00051     /* initilize the le_object info */
00052     le_object->version = LE_VERSION;
00053 
00054     le_object->lename = (IMLEName *) &lename;
00055     le_object->locales = (IMLocale **) &locales;
00056 
00057     le_object->objects = im_objects;
00058 
00059     return (le_object);
00060 }
00061 
00062 void le_object_destroy(LeObjectRec *le_object)
00063 {
00064     IMObjectDescriptorStruct *im_objects;
00065 
00066     if (le_object == NULL)
00067        return;
00068 
00069     im_objects = le_object->objects;
00070     if (im_objects == NULL)
00071        return;
00072 
00073     if (im_objects->path)
00074        free((char *) im_objects->path);
00075 
00076     free((char *) im_objects);
00077     free((char *) le_object);
00078 
00079     return;
00080 }