Back to index

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