Back to index

im-sdk  12.3.91
im-select-hotkey-profile.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <sys/types.h>
00004 #if defined(lint) && defined(HAVE_NOTE_H)
00005 #include <note.h>
00006 #endif /* lint && HAVE_NOTE_H */
00007 
00008 #include <iiimp-data.h>
00009 #include <iiimp-opcode.h>
00010 
00011 #include "iiimp-dataP.h"
00012 
00013 
00014 IIIMP_message *
00015 iiimp_select_hotkey_profile_new(
00016     IIIMP_data_s *   data_s,
00017     IIIMP_card16     im_id,
00018     IIIMP_card16     scope_and_profile_id)
00019 {
00020     IIIMP_message *  m;
00021     m = (IIIMP_message *)malloc(sizeof (IIIMP_message));
00022     if (NULL == m) {
00023        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00024        return NULL;
00025     }
00026     m->opcode = IM_SELECT_HOTKEY_PROFILE;
00027     m->im_id = im_id;
00028     m->ic_id = -1;
00029     m->v.select_hotkey_profile.scope_and_profile_id = scope_and_profile_id;
00030     m->v.select_hotkey_profile.scope = -1;
00031     m->v.select_hotkey_profile.profile_id = -1;
00032     return m;
00033 }
00034 
00035 
00036 void
00037 iiimp_select_hotkey_profile_delete(IIIMP_data_s * data_s, IIIMP_message * m)
00038 {
00039 #if defined(lint) && defined(HAVE_NOTE_H)
00040     NOTE(ARGUNUSED(data_s))
00041 #endif /* lint && HAVE_NOTE_H */
00042        free(m);
00043 }
00044 
00045 
00046 uchar_t *
00047 iiimp_select_hotkey_profile_pack(
00048     IIIMP_data_s *   data_s,
00049     IIIMP_card16     im_id,
00050     IIIMP_card16     scope_and_profile_id,
00051     size_t *         buf_size)
00052 {
00053     size_t           nbyte;
00054     int                     length;
00055     uchar_t *        buf;
00056     size_t           rest;
00057     uchar_t *        p;
00058 
00059     nbyte = 0
00060        + 2     /* input method id */
00061        + 2     /* PAD(2) or IC_ID */
00062        + 2;      /* SCOPE and PROFILE ID */
00063 
00064     nbyte += PAD(nbyte);
00065 
00066     length = (nbyte >> 2);
00067     *buf_size = (1 + 3 + nbyte);
00068 
00069     buf = (uchar_t *)malloc(1 + 3 + nbyte);
00070     if (NULL == buf) {
00071        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00072        return NULL;
00073     }
00074 
00075     PUT_PACKET_HEADER(buf, IM_SELECT_HOTKEY_PROFILE, length);
00076 
00077     rest = nbyte;
00078     p = (buf + 4);
00079 
00080     PUTU16(im_id, rest, p, data_s->byte_swap);
00081     PUTU16(0, rest, p, data_s->byte_swap);
00082     PUTU16(scope_and_profile_id, rest, p, data_s->byte_swap);
00083 
00084     return buf;
00085 }
00086 
00087 
00088 IIIMP_message *
00089 iiimp_select_hotkey_profile_unpack(
00090     IIIMP_data_s *   data_s,
00091     IIIMP_card7             opcode,
00092     size_t *         nbyte,
00093     const uchar_t ** ptr)
00094 {
00095     IIIMP_message *                m;
00096     IIIMP_select_hotkey_profile_v *       v;
00097     size_t                         rest;
00098     const uchar_t *                p;
00099 
00100     rest = *nbyte;
00101     p = *ptr;
00102 
00103     if (rest < (2 + 2 + 2 + 2)) {
00104        data_s->status = IIIMP_DATA_INVALID;
00105        return NULL;
00106     }
00107 
00108     m = (IIIMP_message *)malloc(sizeof (IIIMP_message));
00109     if (NULL == m) {
00110        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00111        return NULL;
00112     }
00113     v = &(m->v.select_hotkey_profile);
00114 
00115     m->opcode = opcode;
00116 
00117     GETU16(m->im_id, rest, p, data_s->byte_swap);
00118     m->ic_id = -1;
00119     SKIP16(rest, p);
00120     GET_SCOPE_FOR_HOTKEY(v->scope, p, data_s->byte_swap);
00121     GETU15(v->profile_id, p, data_s->byte_swap);
00122     GETU16(v->scope_and_profile_id, rest, p, data_s->byte_swap);
00123 
00124     *nbyte = rest;
00125     *ptr = p;
00126 
00127     return m;
00128 }
00129 
00130 
00131 void
00132 iiimp_select_hotkey_profile_print(
00133     IIIMP_data_s *   data_s,
00134     IIIMP_message *  m)
00135 {
00136     iiimp_message_header_print(data_s, m->opcode, m->im_id, m->ic_id);
00137     (void)fprintf(data_s->print_fp, "\tSCOPE = %d\n",
00138                 m->v.select_hotkey_profile.scope);
00139     (void)fprintf(data_s->print_fp, "\tPROFILE_ID = %d\n", m->v.select_hotkey_profile.profile_id);
00140 }
00141 
00142 /* Local Variables: */
00143 /* c-file-style: "iiim-project" */
00144 /* End: */