Back to index

im-sdk  12.3.91
im-lookup-choice-start.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 #include "print-misc.h"
00013 
00014 
00015 IIIMP_message *
00016 iiimp_lookup_choice_start_new(
00017     IIIMP_data_s *   data_s,
00018     IIIMP_card16     im_id,
00019     IIIMP_card16     ic_id,
00020     int                     master,
00021     int                     choice_per_window,
00022     int                     rows,
00023     int                     columns,
00024     int                     direction,
00025     int                     label_owner)
00026 {
00027     IIIMP_message *  m;
00028     m = (IIIMP_message *)malloc(sizeof (IIIMP_message));
00029     if (NULL == m) {
00030        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00031        return NULL;
00032     }
00033     m->opcode = IM_LOOKUP_CHOICE_START;
00034     m->im_id = im_id;
00035     m->ic_id = ic_id;
00036     m->v.lookup_choice_start.master = master;
00037     m->v.lookup_choice_start.choice_per_window = choice_per_window;
00038     m->v.lookup_choice_start.rows = rows;
00039     m->v.lookup_choice_start.columns = columns;
00040     m->v.lookup_choice_start.direction = direction;
00041     m->v.lookup_choice_start.label_owner = label_owner;
00042     return m;
00043 }
00044 
00045 
00046 void
00047 iiimp_lookup_choice_start_delete(IIIMP_data_s * data_s, IIIMP_message * m)
00048 {
00049 #if defined(lint) && defined(HAVE_NOTE_H)
00050     NOTE(ARGUNUSED(data_s))
00051 #endif /* lint && HAVE_NOTE_H */
00052     if (NULL == m) return;
00053     free(m);
00054     return;
00055 }
00056 
00057 
00058 uchar_t *
00059 iiimp_lookup_choice_start_pack(
00060     IIIMP_data_s *   data_s,
00061     IIIMP_card16     im_id,
00062     IIIMP_card16     ic_id,
00063     int                     master,
00064     int                     choice_per_window,
00065     int                     rows,
00066     int                     columns,
00067     int                     direction,
00068     int                     label_owner,
00069     size_t *         buf_size)
00070 {
00071     size_t           nbyte;
00072     int                     length;
00073     uchar_t *        buf;
00074     size_t           rest;
00075     uchar_t *        p;
00076 
00077     nbyte = 0;
00078     nbyte += 2;      /* input method id */
00079     nbyte += 2;      /* input context id */
00080     nbyte += 2;      /* which is master */
00081     nbyte += 2;      /* choice per window */
00082     nbyte += 2;      /* number of rows */
00083     nbyte += 2;      /* number of columns */
00084     nbyte += 2;      /* drawing up direction */
00085     nbyte += 2;      /* which owns label */
00086 
00087     length = (nbyte >> 2);
00088     *buf_size = (1 + 3 + nbyte);
00089 
00090     buf = (uchar_t *)malloc(1 + 3 + nbyte);
00091     if (NULL == buf) {
00092        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00093        return NULL;
00094     }
00095 
00096     PUT_PACKET_HEADER(buf, IM_LOOKUP_CHOICE_START, length);
00097 
00098     rest = nbyte;
00099     p = (buf + 4);
00100 
00101     PUTU16(im_id, rest, p, data_s->byte_swap);
00102     PUTU16(ic_id, rest, p, data_s->byte_swap);
00103     PUTU16(master, rest, p, data_s->byte_swap);
00104     PUTU16(choice_per_window, rest, p, data_s->byte_swap);
00105     PUTU16(rows, rest, p, data_s->byte_swap);
00106     PUTU16(columns, rest, p, data_s->byte_swap);
00107     PUTU16(direction, rest, p, data_s->byte_swap);
00108     PUTU16(label_owner, rest, p, data_s->byte_swap);
00109 
00110     return buf;
00111 }
00112 
00113 
00114 IIIMP_message *
00115 iiimp_lookup_choice_start_unpack(
00116     IIIMP_data_s *   data_s,
00117     IIIMP_card7             opcode,
00118     size_t *         nbyte,
00119     const uchar_t ** ptr)
00120 {
00121     IIIMP_message *                m;
00122     IIIMP_lookup_choice_start_v *  v;
00123     size_t                         rest;
00124     const uchar_t *                p;
00125 
00126     rest = *nbyte;
00127     p = *ptr;
00128 
00129     if (rest < (2 + 2 + 2 + 2 + 2 + 2 + 2 + 2)) {
00130        data_s->status = IIIMP_DATA_INVALID;
00131        return NULL;
00132     }
00133 
00134     m = (IIIMP_message *)malloc(sizeof (IIIMP_message));
00135     if (NULL == m) {
00136        data_s->status = IIIMP_DATA_MALLOC_ERROR;
00137        return NULL;
00138     }
00139     v = &(m->v.lookup_choice_start);
00140 
00141     m->opcode = opcode;
00142 
00143     GETU16(m->im_id, rest, p, data_s->byte_swap);
00144     GETU16(m->ic_id, rest, p, data_s->byte_swap);
00145     GETU16(v->master, rest, p, data_s->byte_swap);
00146     GETU16(v->choice_per_window, rest, p, data_s->byte_swap);
00147     GETU16(v->rows, rest, p, data_s->byte_swap);
00148     GETU16(v->columns, rest, p, data_s->byte_swap);
00149     GETU16(v->direction, rest, p, data_s->byte_swap);
00150     GETU16(v->label_owner, rest, p, data_s->byte_swap);
00151 
00152     *nbyte = rest;
00153     *ptr = p;
00154 
00155     return m;
00156 }
00157 
00158 
00159 void
00160 iiimp_lookup_choice_start_print(
00161     IIIMP_data_s *   data_s,
00162     IIIMP_message *  m)
00163 {
00164     IIIMP_lookup_choice_start_v *  v;
00165 
00166     v = &(m->v.lookup_choice_start);
00167     iiimp_message_header_print(data_s, m->opcode, m->im_id, m->ic_id);
00168 
00169     (void)fputc('\t', data_s->print_fp);
00170 
00171     (void)fprintf(data_s->print_fp, "%s ",
00172                 lookup_choice_master_string_get(v->master));
00173     (void)fprintf(data_s->print_fp, "choices_per_window=%d ",
00174                 v->choice_per_window);
00175     (void)fprintf(data_s->print_fp, "rows=%d ", v->rows);
00176     (void)fprintf(data_s->print_fp, "columns=%d\n", v->columns);
00177     (void)fputc('\t', data_s->print_fp);
00178     (void)fprintf(data_s->print_fp, "%s ",
00179                 lookup_choice_direction_string_get(v->direction));
00180     (void)fputc('\t', data_s->print_fp);
00181     (void)fprintf(data_s->print_fp, "%s",
00182                 lookup_choice_label_owner_string_get(v->label_owner));
00183     (void)fputc('\n', data_s->print_fp);
00184 }
00185 
00186 
00187 /* Local Variables: */
00188 /* c-file-style: "iiim-project" */
00189 /* End: */