Back to index

im-sdk  12.3.91
Typedefs | Enumerations | Functions
iiimp.h File Reference
#include <sys/types.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <iiimp-opcode.h>
#include <iiimp-data.h>
#include <iiimp-keycode.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct iiimf_im
typedef struct iiimf_ic
typedef struct iiimf_message_handler_entry
typedef struct iiimf_stream_proc_data
typedef struct IIIMF_stream
typedef void * IIIMF_stream_private
typedef IIIMF_status(* IIIMF_stream_proc_read )(IIIMF_stream_private private_data, void *buf, size_t nbyte)
typedef IIIMF_status(* IIIMF_stream_proc_write )(IIIMF_stream_private private_data, const void *buf, size_t nbyte)
typedef IIIMF_status(* IIIMF_message_handler_call_func )(IIIMF_im *im, IIIMP_message *message)
typedef
IIIMF_message_handler_status(* 
IIIMF_message_handler )(IIIMF_im *im, IIIMF_ic *ic, IIIMP_message *m)

Enumerations

enum  IIIMF_role { IIIMF_ROLE_CLIENT = 1, IIIMF_ROLE_SERVER = 0 }
enum  IIIMF_message_handler_status { IIIMF_MESSAGE_HANDLER_STATUS_ERROR = -1, IIIMF_MESSAGE_HANDLER_STATUS_NORMAL = 0, IIIMF_MESSAGE_HANDLER_STATUS_STOP = 1 }
enum  IIIMF_status {
  IIIMF_STATUS_FAIL = -1, IIIMF_STATUS_SUCCESS = 0, IIIMF_STATUS_MALLOC = 11, IIIMF_STATUS_ARGUMENT = 12,
  IIIMF_STATUS_PROTOCOL_VERSION = 13, IIIMF_STATUS_CONFIG = 51, IIIMF_STATUS_ROLE = 52, IIIMF_STATUS_OPCODE = 101,
  IIIMF_STATUS_SEQUENCE_REQUEST = 201, IIIMF_STATUS_SEQUENCE_REPLY = 202, IIIMF_STATUS_SEQUENCE_ROLE = 203, IIIMF_STATUS_SEQUENCE_STATE = 204,
  IIIMF_STATUS_SEQUENCE_NEST = 205, IIIMF_STATUS_IM_INVALID = 501, IIIMF_STATUS_IC_INVALID = 502, IIIMF_STATUS_STREAM = 1001,
  IIIMF_STATUS_STREAM_SEND = 1002, IIIMF_STATUS_STREAM_RECEIVE = 1003, IIIMF_STATUS_PACKET = 1004, IIIMF_STATUS_INVALID_ID = 1005,
  IIIMF_STATUS_TIMEOUT = 1006, IIIMF_STATUS_CONNECTION_CLOSED = 2001, IIIMF_STATUS_IIIMCF_START = 10000, IIIMF_STATUS_NO_ATTR_VALUE = 10001,
  IIIMF_STATUS_NO_TEXT_PROPERTY = 10002, IIIMF_STATUS_NO_EVENT = 10003, IIIMF_STATUS_NO_PREEDIT = 10004, IIIMF_STATUS_NO_LOOKUP_CHOICE = 10005,
  IIIMF_STATUS_NO_STATUS_TEXT = 10006, IIIMF_STATUS_NO_COMMITTED_TEXT = 10007, IIIMF_STATUS_CLIENT_RESET_BY_PEER = 10008, IIIMF_STATUS_INVALID_EVENT_TYPE = 10009,
  IIIMF_STATUS_EVENT_NOT_FORWARDED = 10010, IIIMF_STATUS_COMPONENT_DUPLICATED_NAME = 10011, IIIMF_STATUS_COMPONENT_FAIL = 10012, IIIMF_STATUS_NO_COMPONENT = 10013,
  IIIMF_STATUS_STATIC_EVENT_FLOW = 10014, IIIMF_STATUS_FAIL_TO_EVENT_DISPATCH = 10015, IIIMF_STATUS_NO_AUX = 10016, IIIMF_STATUS_NOT_TRIGGER_KEY = 10017,
  IIIMF_STATUS_COMPONENT_INDIFFERENT = 10018
}
enum  IIIMF_message_handler_register_place { IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_HEAD = 0, IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_TAIL = 1, IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_BEFORE = 2, IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_AFTER = 3 }

Functions

void iiimf_perror (IIIMF_status status, const char *str)
IIIMP_data_s * iiimp_data_s_new (void)
IIIMP_data_s * iiimp_data_s_with_protocol_version_new (int protocol_version)
int iiimp_data_s_get_protocol_version (IIIMP_data_s *data_s)
IIIMF_status iiimp_data_s_limit_protocol_version (IIIMP_data_s *data_s, int version)
int iiimp_data_s_capability (IIIMP_data_s *data_s, int capability)
void iiimp_data_s_delete (IIIMP_data_s *im)
IIIMF_status iiimf_create_stream (IIIMF_stream_proc_read proc_read, IIIMF_stream_proc_write proc_write, IIIMF_stream_private priv_data, int timeout, IIIMF_stream **stream_ret)
void iiimf_stream_delete (IIIMF_stream *stream)
IIIMF_status iiimf_stream_send (IIIMF_stream *stream, IIIMP_data_s *data_s, IIIMP_message *message)
IIIMF_status iiimf_stream_receive (IIIMF_stream *stream, IIIMP_data_s *data_s, IIIMP_message **message)
IIIMF_status iiimf_connect_socket_stream (const char *node, const char *service, int timeout, IIIMF_stream **stream_ret)
IIIMF_status iiimf_listen_socket_stream (const char *node, const char *service, int timeout, IIIMF_stream **stream_ret)
IIIMF_status iiimf_accept_socket_stream (IIIMF_stream *stream, IIIMF_stream **stream_ret)
IIIMF_status iiimf_delete_socket_stream (IIIMF_stream *stream)
IIIMF_status iiimf_tls_supported (void)
IIIMF_status iiimf_connect_tls_stream (const char *node, const char *service, int timeout, IIIMF_stream **stream_ret)
IIIMF_status iiimf_listen_tls_stream (const char *node, const char *service, int timeout, IIIMF_stream **stream_ret)
IIIMF_status iiimf_accept_tls_stream (IIIMF_stream *stream, IIIMF_stream **stream_ret)
IIIMF_status iiimf_delete_tls_stream (IIIMF_stream *stream)
IIIMF_status iiimf_tls_set_certificate (IIIMF_stream *stream, const char *cert_file, const char *key_file, const char *ca_file, const char *ca_path)
IIIMF_status iiimf_request_send (IIIMF_im *im, IIIMF_ic *ic, IIIMP_message *message)
IIIMF_status iiimf_request_loop (IIIMF_im *im)
IIIMF_status iiimf_request_reply (IIIMF_im *im, IIIMF_ic *ic, IIIMP_message *message)
IIIMF_status iiimf_im_new (IIIMF_role role, const char *server_node, const char *service, void *client_data, IIIMF_im **im_ret)
void iiimf_im_delete (IIIMF_im *im)
IIIMP_data_s * iiimf_im_data_s (IIIMF_im *im)
void * iiimf_im_data_get (IIIMF_im *im)
void * iiimf_im_data_set (IIIMF_im *im, void *data)
IIIMF_status iiimf_im_fd_set (IIIMF_im *im, int fd)
IIIMF_status iiimf_im_timeout_set (IIIMF_im *im, int fd)
IIIMF_status iiimf_im_start (IIIMF_im *im)
IIIMF_status iiimf_im_end (IIIMF_im *im)
IIIMF_status iiimf_im_server_accept (IIIMF_im *im, void *client_data, IIIMF_im **im_ret)
IIIMF_status iiimf_im_client_type_set (IIIMF_im *im, const char *type)
IIIMF_status iiimf_im_user_set (IIIMF_im *im, const char *username, const char *password)
int iiimf_im_id (IIIMF_im *im)
IIIMF_status iiimf_ic_new (IIIMF_im *im, void *client_data, IIIMF_ic **ic_ret)
void iiimf_ic_delete (IIIMF_ic *ic)
IIIMF_status iiimf_ic_id_set (IIIMF_ic *ic, int ic_id)
void * iiimf_ic_data_get (IIIMF_ic *ic)
void * iiimf_ic_data_set (IIIMF_ic *ic, void *data)
IIIMF_status iiimf_ic_langauage_set (IIIMF_ic *ic, const char *language)
IIIMF_status iiimf_ic_input_method_set (IIIMF_ic *ic, const char *input_method)
IIIMF_status iiimf_ic_preedit_maximum_length_set (IIIMF_ic *ic, int preedit_maximum_length)
int iiimf_ic_id (IIIMF_ic *ic)
const char * iiimf_role_data_client_user_name (IIIMF_im *im)
const char * iiimf_role_data_client_home_dir (IIIMF_im *im)
const char * iiimf_role_data_client_node (IIIMF_im *im)
const char * iiimf_role_data_client_server_node (IIIMF_im *im)
const char * iiimf_role_data_client_service (IIIMF_im *im)
IIIMF_status iiimf_role_data_client_auth_password (IIIMF_im *im, char **password_ret)
IIIMF_status iiimf_message_handler_register (IIIMF_im *im, int opcode, IIIMF_message_handler handler, const char *name, IIIMF_message_handler_register_place place, const char *anchor)
IIIMF_status iiimf_message_handler_unregister (IIIMF_im *im, int opcode, IIIMF_message_handler handler)
IIIMF_status iiimf_message_handler_unregister_name (IIIMF_im *im, const char *name)
IIIMF_status iiimf_data_string_ascii_new (IIIMP_data_s *data_s, const char *ptr, IIIMP_string **ret)
IIIMF_status iiimf_data_im_connect (IIIMF_im *im, IIIMP_message **message_ret)
IIIMF_status iiimf_data_client_descriptor (IIIMF_im *im, IIIMP_client_descriptor **data_ret)

Typedef Documentation

typedef struct iiimf_ic

Definition at line 26 of file iiimp.h.

typedef struct iiimf_im

Definition at line 25 of file iiimp.h.

typedef IIIMF_message_handler_status(* IIIMF_message_handler)(IIIMF_im *im, IIIMF_ic *ic, IIIMP_message *m)

Definition at line 119 of file iiimp.h.

Definition at line 115 of file iiimp.h.

Definition at line 39 of file iiimp.h.

typedef struct IIIMF_stream

Definition at line 102 of file iiimp.h.

typedef void* IIIMF_stream_private

Definition at line 103 of file iiimp.h.

typedef struct iiimf_stream_proc_data

Definition at line 100 of file iiimp.h.

typedef IIIMF_status(* IIIMF_stream_proc_read)(IIIMF_stream_private private_data, void *buf, size_t nbyte)

Definition at line 105 of file iiimp.h.

typedef IIIMF_status(* IIIMF_stream_proc_write)(IIIMF_stream_private private_data, const void *buf, size_t nbyte)

Definition at line 110 of file iiimp.h.


Enumeration Type Documentation

Enumerator:
IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_HEAD 
IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_TAIL 
IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_BEFORE 
IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_AFTER 

Definition at line 124 of file iiimp.h.

Enumerator:
IIIMF_MESSAGE_HANDLER_STATUS_ERROR 
IIIMF_MESSAGE_HANDLER_STATUS_NORMAL 
IIIMF_MESSAGE_HANDLER_STATUS_STOP 

Definition at line 33 of file iiimp.h.

enum IIIMF_role
Enumerator:
IIIMF_ROLE_CLIENT 
IIIMF_ROLE_SERVER 

Definition at line 28 of file iiimp.h.

Enumerator:
IIIMF_STATUS_FAIL 
IIIMF_STATUS_SUCCESS 
IIIMF_STATUS_MALLOC 
IIIMF_STATUS_ARGUMENT 
IIIMF_STATUS_PROTOCOL_VERSION 
IIIMF_STATUS_CONFIG 
IIIMF_STATUS_ROLE 
IIIMF_STATUS_OPCODE 
IIIMF_STATUS_SEQUENCE_REQUEST 
IIIMF_STATUS_SEQUENCE_REPLY 
IIIMF_STATUS_SEQUENCE_ROLE 
IIIMF_STATUS_SEQUENCE_STATE 
IIIMF_STATUS_SEQUENCE_NEST 
IIIMF_STATUS_IM_INVALID 
IIIMF_STATUS_IC_INVALID 
IIIMF_STATUS_STREAM 
IIIMF_STATUS_STREAM_SEND 
IIIMF_STATUS_STREAM_RECEIVE 
IIIMF_STATUS_PACKET 
IIIMF_STATUS_INVALID_ID 
IIIMF_STATUS_TIMEOUT 
IIIMF_STATUS_CONNECTION_CLOSED 
IIIMF_STATUS_IIIMCF_START 
IIIMF_STATUS_NO_ATTR_VALUE 
IIIMF_STATUS_NO_TEXT_PROPERTY 
IIIMF_STATUS_NO_EVENT 
IIIMF_STATUS_NO_PREEDIT 
IIIMF_STATUS_NO_LOOKUP_CHOICE 
IIIMF_STATUS_NO_STATUS_TEXT 
IIIMF_STATUS_NO_COMMITTED_TEXT 
IIIMF_STATUS_CLIENT_RESET_BY_PEER 
IIIMF_STATUS_INVALID_EVENT_TYPE 
IIIMF_STATUS_EVENT_NOT_FORWARDED 
IIIMF_STATUS_COMPONENT_DUPLICATED_NAME 
IIIMF_STATUS_COMPONENT_FAIL 
IIIMF_STATUS_NO_COMPONENT 
IIIMF_STATUS_STATIC_EVENT_FLOW 
IIIMF_STATUS_FAIL_TO_EVENT_DISPATCH 
IIIMF_STATUS_NO_AUX 
IIIMF_STATUS_NOT_TRIGGER_KEY 
IIIMF_STATUS_COMPONENT_INDIFFERENT 

Definition at line 44 of file iiimp.h.


Function Documentation

Definition at line 469 of file stream-socket.c.

{
    IIIMF_stream_socket_private *sockpriv = (IIIMF_stream_socket_private*) stream->private_data;
    IIIMF_status     status;
    struct sockaddr  address;
    socklen_t        address_len;
    int                     fd;
#if defined(HAVE_POLL)
    struct pollfd    fds[1];
    int                     poll_ret;
#else /* !HAVE_POLL */
    fd_set           fdvar;
    struct timeval   timeout;
    int                     select_ret;

    timeout.tv_sec = sockpriv->timeout / 1000;
    timeout.tv_usec = sockpriv->timeout % 1000;
#endif /* !HAVE_POLL */

    if (sockpriv->flags != IIIMF_STREAM_SOCKET_LISTEN)
       return IIIMF_STATUS_ARGUMENT;

    if (0 <= sockpriv->timeout) {
#if defined(HAVE_POLL)
       fds[0].fd = sockpriv->fd;
       fds[0].events = POLLIN;
       poll_ret = poll(fds, 1, sockpriv->timeout);
       if (0 == poll_ret) {
           return IIIMF_STATUS_TIMEOUT;
       } else if (-1 == poll_ret) {
           return IIIMF_STATUS_STREAM;
       }
#else /* !HAVE_POLL */
       do {
           FD_ZERO(&fdvar);
           FD_SET(sockpriv->fd, &fdvar);
           select_ret = select(sockpriv->fd + 1, NULL,
                            &fdvar, NULL, &timeout);
       } while ((-1 == select_ret) && (EINTR == errno));
       if (-1 == select_ret) return IIIMF_STATUS_TIMEOUT;
#endif /* !HAVE_POLL */
    }
    address_len = (sizeof (address));
    fd = accept(sockpriv->fd, &address, &address_len);
    if (-1 == fd) return IIIMF_STATUS_STREAM;

    {
       IIIMF_stream *stream_new;
       IIIMF_stream_socket_private *sockpriv_new;

       sockpriv_new = create_sockpriv(IIIMF_STREAM_SOCKET_OPEN, fd,
                                   sockpriv->timeout);
       if (!sockpriv_new) {
           close(fd);
           return IIIMF_STATUS_MALLOC;
       }
       status = iiimf_create_stream(stream_socket_read, stream_socket_write,
                                 sockpriv_new, sockpriv->timeout, &stream_new);
       if (status != IIIMF_STATUS_SUCCESS) return status;
       *stream_ret = stream_new;
    }

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Definition at line 28 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}
IIIMF_status iiimf_connect_socket_stream ( const char *  node,
const char *  service,
int  timeout,
IIIMF_stream **  stream_ret 
)

Definition at line 167 of file stream-socket.c.

{
    int                     fd;
    int                     fd_flag;

#if defined(HAVE_GETADDRINFO)
    int                     e;
    struct addrinfo *       res;
    struct addrinfo *       aip;
    struct addrinfo  hints;

#if defined(HAVE_UNIX_SOCKET)
    if (*node == '/') {
       return create_socket_stream_unix(node, service, timeout, stream_ret);
    }
#endif
    fd = -1;

    (void)memset(&hints, 0, sizeof (hints));
    hints.ai_flags = AI_CANONNAME;
    hints.ai_socktype = SOCK_STREAM;

    e = getaddrinfo(node, service, &hints, &res);
    if (0 != e) {
       return -1;
    }

    for (aip = res; NULL != aip; aip = aip->ai_next) {
       fd = socket(aip->ai_family, aip->ai_socktype, aip->ai_protocol);
       if (-1 == fd) {
           break;
       }

       if (-1 == connect(fd, aip->ai_addr, aip->ai_addrlen)) {
           (void)close(fd);
           fd = -1;
           continue;
       } else {
           break;
       }
    }

    freeaddrinfo(res);

    if (-1 == fd) return IIIMF_STATUS_STREAM;

#else /* !HAVE_GETADDRINFO */

#if defined(WIN32)
    unsigned short int      port_number;
#else /* !WIN32 */
    int                     port_number;
#endif /* !WIN32 */
    int                     r;
    int                     optval;
    unsigned long    in_addr;
    struct hostent * hostp;
    struct sockaddr_in      addr;
    struct servent * srvp;

#if defined(HAVE_UNIX_SOCKET)
    if (*node == '/') {
       return create_socket_stream_unix(node, service, timeout, stream_ret);
    }
#endif
#if defined(WIN32)
    start_winsock(1, 1);
#endif

    fd = socket(PF_INET, SOCK_STREAM, 0);
    if (fd < 0 ) return IIIMF_STATUS_STREAM;

    port_number = 0;

    (void)memset((char *)(&addr), 0, sizeof (addr));
    addr.sin_family = PF_INET;

    if (0 < strlen(service)) {
       srvp = getservbyname(service, "tcp");
       if (NULL != srvp) {
           port_number = srvp->s_port;
       }
       (void)endservent();
       if (0 == port_number) {
           port_number = atoi(service);
       }
    }
    if (0 == port_number) {
       port_number = 9010;
    }
    addr.sin_port = htons(port_number);
    in_addr = inet_addr(node);
    if ((unsigned long)(-1) != in_addr) {
       (void)memcpy(&addr.sin_addr, &in_addr, sizeof (in_addr));
    } else {
       hostp = gethostbyname(node);
       if (NULL == hostp) {
#if defined(WIN32)
           (void)sock_close(fd);
#else /* !WIN32 */
           (void)close(fd);
#endif /* !WIN32 */
           return IIIMF_STATUS_STREAM;
       }

       if (0 < hostp->h_length) {
           (void)memcpy(&addr.sin_addr, hostp->h_addr,
                      hostp->h_length);
       } else {
#if defined(WIN32)
           sock_close(fd);
#else /* !WIN32 */
           (void)close(fd);
#endif /* !WIN32 */
           return IIIMF_STATUS_STREAM;
       }
    }

    r = connect(fd, (struct sockaddr *)(&addr), sizeof (addr));
#if defined(WIN32)
    if (SOCKET_ERROR == r) {
       sock_close(fd);
       return IIIMF_STATUS_STREAM;
    }
#else /* !WIN32 */
    if (r < 0) {
       (void)close(fd);
       return IIIMF_STATUS_STREAM;
    }
#endif /* !WIN32 */
#endif /* !HAVE_GETADDRINFO */

    fd_flag = fcntl(fd, F_GETFD);
    fd_flag |= FD_CLOEXEC;
    (void)fcntl(fd, F_SETFD, fd_flag);

    {
       IIIMF_status st;
       IIIMF_stream *stream;
       IIIMF_stream_socket_private *sockpriv;

       sockpriv = create_sockpriv(IIIMF_STREAM_SOCKET_OPEN, fd,
                               timeout);
       if (!sockpriv) {
           close(fd);
           return IIIMF_STATUS_MALLOC;
       }

       st = iiimf_create_stream(stream_socket_read, stream_socket_write,
                             sockpriv, timeout, &stream);
       if (st != IIIMF_STATUS_SUCCESS) return st;
       *stream_ret = stream;
    }

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimf_connect_tls_stream ( const char *  node,
const char *  service,
int  timeout,
IIIMF_stream **  stream_ret 
)

Definition at line 48 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}

Here is the caller graph for this function:

IIIMF_status iiimf_create_stream ( IIIMF_stream_proc_read  proc_read,
IIIMF_stream_proc_write  proc_write,
IIIMF_stream_private  priv_data,
int  timeout,
IIIMF_stream **  stream_ret 
)

Definition at line 10 of file stream.c.

{
    IIIMF_stream *          stream;

    stream = (IIIMF_stream *)malloc(sizeof (IIIMF_stream));
    if (NULL == stream) {
       free(stream);
       return IIIMF_STATUS_MALLOC;
    }
    stream->timeout = timeout;
    stream->private_data = private_data;
    stream->proc_read = proc_read;
    stream->proc_write = proc_write;

    *stream_ret = stream;

    return IIIMF_STATUS_SUCCESS;
}

Here is the caller graph for this function:

Definition at line 107 of file data-util.c.

{
    IIIMP_data_s *          data_s;
    IIIMF_status            s_type;
    IIIMF_status            s_os_n;
    IIIMF_status            s_os_a;
    IIIMF_status            s_os_v;
    IIIMF_status            s_X_dn;
    IIIMF_status            s_X_sv;
    IIIMP_client_descriptor *      data;
    IIIMP_string *          type;
    IIIMP_string *          os_name;
    IIIMP_string *          os_arch;
    IIIMP_string *          os_ver;
    IIIMP_string *          X_display_name;
    IIIMP_string *          X_server_vendor;
    IIIMF_role_data_client *       cl;

    if (1 != im->role) return IIIMF_STATUS_ROLE;

    data = NULL;

    s_X_dn = IIIMF_STATUS_SUCCESS;
    s_X_sv = IIIMF_STATUS_SUCCESS;
    X_display_name = NULL;
    X_server_vendor = NULL;

    cl = im->role_data.client;

    data_s = im->data_s;

    s_type = iiimf_data_string_ascii_new(data_s, cl->type, &type);
    s_os_n = iiimf_data_string_ascii_new(data_s, cl->os_name, &os_name);
    s_os_a = iiimf_data_string_ascii_new(data_s, cl->os_arch, &os_arch);
    s_os_v = iiimf_data_string_ascii_new(data_s, cl->os_version, &os_ver);
    if ((NULL != cl->X_display_name) && (NULL != cl->X_server_vendor)) {
       s_X_dn = iiimf_data_string_ascii_new(data_s,
                                        cl->X_display_name,
                                        &X_display_name);
       s_X_sv = iiimf_data_string_ascii_new(data_s,
                                        cl->X_server_vendor,
                                        &X_server_vendor);
    }

    data = iiimp_client_descriptor_new(im->data_s,
                                   type, os_name, os_arch, os_ver,
                                   X_display_name, X_server_vendor);

    if ((IIIMF_STATUS_SUCCESS != s_type) ||
       (IIIMF_STATUS_SUCCESS != s_os_n) ||
       (IIIMF_STATUS_SUCCESS != s_os_a) ||
       (IIIMF_STATUS_SUCCESS != s_os_v) ||
       (IIIMF_STATUS_SUCCESS != s_X_dn) ||
       (IIIMF_STATUS_SUCCESS != s_X_sv) ||
       (NULL == data)) {
       iiimp_string_delete(data_s, type);
       iiimp_string_delete(data_s, os_name);
       iiimp_string_delete(data_s, os_arch);
       iiimp_string_delete(data_s, os_ver);
       iiimp_string_delete(data_s, X_display_name);
       iiimp_string_delete(data_s, X_server_vendor);
       return IIIMF_STATUS_FAIL;
    }

    *data_ret = data;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_data_im_connect ( IIIMF_im *  im,
IIIMP_message **  message_ret 
)

Definition at line 44 of file data-util.c.

{
    IIIMF_status     status;
    IIIMP_message *  message;
    IIIMP_string *   user_name;
    IIIMP_string *   auth;
    int                     len;
    char *           user;
    char *           password;
    int                     user_name_len;
    int                     node_len;
    char *           p;

    if (IIIMF_ROLE_CLIENT != im->role) return IIIMF_STATUS_ROLE;

    status = iiimf_role_data_client_auth_password(im, &password);
    if (IIIMF_STATUS_SUCCESS != status) return status;

    user_name_len = strlen(im->role_data.client->user_name);
    node_len = strlen(im->role_data.client->node);

    len = (user_name_len + 1 + node_len + 1 + strlen(password));
    user = (char *)malloc(len + 1);
    if (NULL == user) {
       free(password);
       return IIIMF_STATUS_MALLOC;
    }

    p = user;
    (void)strcpy(p, im->role_data.client->user_name);
    p += user_name_len;
    *p = '@';
    p += 1;
    (void)strcpy(p, im->role_data.client->node);
    p += node_len;
    *p = '#';
    p += 1;
    (void)strcpy(p, password);

    free(password);

    status = iiimf_data_string_ascii_new(im->data_s, user, &user_name);
    free(user);
    if (IIIMF_STATUS_SUCCESS != status) {
       return status;
    }

    auth = NULL;

    message = iiimp_connect_new(im->data_s, user_name, auth);

    if (NULL == message) {
       iiimp_string_delete(im->data_s, user_name);
       return IIIMF_STATUS_FAIL;
    }

    *message_ret = message;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_data_string_ascii_new ( IIIMP_data_s *  data_s,
const char *  ptr,
IIIMP_string **  ret 
)

Definition at line 10 of file data-util.c.

{
    IIIMP_string *   str;
    IIIMP_card16 *   p;
    size_t           len;
    size_t           nbyte;
    int                     i;

    len = strlen(ptr);
    nbyte = ((sizeof (IIIMP_card16)) * len);

    p = (IIIMP_card16 *)malloc(nbyte);
    if (NULL == p) return IIIMF_STATUS_MALLOC;

    for (i = 0; i < len; i++) {
       *(p + i) = *(ptr + i);
    }

    str = iiimp_string_new(data_s, len, p);
    free(p);

    if (NULL == str) {
       return IIIMF_STATUS_FAIL;
    }

    *ret = str;
    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 538 of file stream-socket.c.

{
    IIIMF_stream_socket_private *sockpriv = (IIIMF_stream_socket_private*) stream->private_data;
    
    if (sockpriv->fd > 0) close(sockpriv->fd);
    delete_sockpriv(sockpriv);
    iiimf_stream_delete(stream);
    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 59 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}

Here is the caller graph for this function:

void* iiimf_ic_data_get ( IIIMF_ic *  ic)

Definition at line 70 of file input-context.c.

{
    return ic->client_data;
}
void* iiimf_ic_data_set ( IIIMF_ic *  ic,
void *  data 
)

Definition at line 77 of file input-context.c.

{
    void *    p;
    p = ic->client_data;
    ic->client_data = client_data;
    return p;
}
void iiimf_ic_delete ( IIIMF_ic *  ic)

Definition at line 38 of file input-context.c.

{
    IIIMF_im *       im;
    IIIMF_ic *       p;

    im = ic->im;

    if (ic == im->ic_list) {
       im->ic_list = ic->next;
    } else {
       for (p = im->ic_list; NULL != p; p = p->next) {
           if (p->next == ic) {
              p->next = ic->next;
           }
       }
    }

    iiimp_string_list_delete(im->data_s, ic->language_list);
    free(ic);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int iiimf_ic_id ( IIIMF_ic *  ic)

Definition at line 143 of file input-context.c.

{
    return ic->ic_id;
}
IIIMF_status iiimf_ic_id_set ( IIIMF_ic *  ic,
int  ic_id 
)

Definition at line 61 of file input-context.c.

{
    ic->ic_id = ic_id;
    return IIIMF_STATUS_SUCCESS;
}
IIIMF_status iiimf_ic_input_method_set ( IIIMF_ic *  ic,
const char *  input_method 
)

Definition at line 112 of file input-context.c.

{
    IIIMF_status     status;
    IIIMP_string *   p;

    if (NULL == input_method) {
       iiimp_string_delete(ic->im->data_s, ic->input_method);
       ic->input_method = NULL;
       return IIIMF_STATUS_SUCCESS;
    }

    status = iiimf_data_string_ascii_new(ic->im->data_s, input_method, &p);
    if (IIIMF_STATUS_SUCCESS != status) {
       return status;
    }
    iiimp_string_delete(ic->im->data_s, ic->input_method);
    ic->input_method = p;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_ic_langauage_set ( IIIMF_ic *  ic,
const char *  language 
)

Definition at line 89 of file input-context.c.

{
    IIIMF_status     status;
    IIIMP_string *   p;

    if (NULL == language) {
       iiimp_string_delete(ic->im->data_s, ic->language);
       ic->language = NULL;
       return IIIMF_STATUS_SUCCESS;
    }

    status = iiimf_data_string_ascii_new(ic->im->data_s, language, &p);
    if (IIIMF_STATUS_SUCCESS != status) {
       return status;
    }
    iiimp_string_delete(ic->im->data_s, ic->language);
    ic->language = p;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_ic_new ( IIIMF_im *  im,
void *  client_data,
IIIMF_ic **  ic_ret 
)

Definition at line 10 of file input-context.c.

{
    IIIMF_ic *       ic;

    if (NULL == im) return IIIMF_STATUS_IM_INVALID;

    ic = (IIIMF_ic *)malloc(sizeof (IIIMF_ic));
    if (NULL == ic) return IIIMF_STATUS_MALLOC;

    ic->ic_id = 0;
    ic->state = 0;
    ic->im = im;
    ic->language = NULL;
    ic->input_method = NULL;
    ic->language_list = NULL;
    ic->preedit_maximum_length = -1;
    ic->client_data = client_data;
    ic->next = im->ic_list;
    im->ic_list = ic;

    *ic_ret = ic;
    return IIIMF_STATUS_SUCCESS;
}
IIIMF_status iiimf_ic_preedit_maximum_length_set ( IIIMF_ic *  ic,
int  preedit_maximum_length 
)

Definition at line 135 of file input-context.c.

{
    ic->preedit_maximum_length = preedit_maximum_length;
    return IIIMF_STATUS_SUCCESS;
}
IIIMF_status iiimf_im_client_type_set ( IIIMF_im *  im,
const char *  type 
)

Definition at line 405 of file role-data-client.c.

{
    char *    p;
    p = strdup(type);
    if (NULL == p) return IIIMF_STATUS_MALLOC;
    free(im->role_data.client->type);
    im->role_data.client->type = p;
    return IIIMF_STATUS_SUCCESS;
}
void* iiimf_im_data_get ( IIIMF_im *  im)

Definition at line 133 of file input-method.c.

{
    return im->client_data;
}
IIIMP_data_s* iiimf_im_data_s ( IIIMF_im *  im)

Definition at line 150 of file input-method.c.

{
    return im->data_s;
}
void* iiimf_im_data_set ( IIIMF_im *  im,
void *  data 
)

Definition at line 140 of file input-method.c.

{
    void *    p;
    p = im->client_data;
    im->client_data = client_data;
    return p;
}
void iiimf_im_delete ( IIIMF_im *  im)

Definition at line 104 of file input-method.c.

{
    IIIMF_ic *       ic;
    IIIMF_ic *       ic_next;

    for (ic = im->ic_list; NULL != ic; ic = ic_next) {
       ic_next = ic->next;
       iiimf_ic_delete(ic);
    }

    switch (im->role) {
    case IIIMF_ROLE_CLIENT:
       iiimf_role_data_client_delete(im->role_data.client);
       break;
    case IIIMF_ROLE_SERVER:
       iiimf_role_data_server_delete(im->role_data.server);
       break;
    }

    iiimf_stream_delete(im->stream);
    iiimf_message_handler_entry_delete(im->message_handler);
    free(im->message_pending);
    iiimp_data_s_delete(im->data_s);

    free(im);
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimf_im_end ( IIIMF_im *  im)

Definition at line 194 of file input-method.c.

{
    return im->stream->proc_close(im->stream->proc_data);
}
IIIMF_status iiimf_im_fd_set ( IIIMF_im *  im,
int  fd 
)

Definition at line 173 of file input-method.c.

{
    return iiimf_stream_fd_set(im->stream, fd);
}
int iiimf_im_id ( IIIMF_im *  im)

Definition at line 209 of file input-method.c.

{
    return im->im_id;
}
IIIMF_status iiimf_im_new ( IIIMF_role  role,
const char *  server_node,
const char *  service,
void *  client_data,
IIIMF_im **  im_ret 
)

Definition at line 14 of file input-method.c.

{
    IIIMF_im *              im;
    IIIMF_status     status;
    size_t           size;

    im = (IIIMF_im *)malloc(sizeof (IIIMF_im));
    if (NULL == im) return IIIMF_STATUS_MALLOC;

    im->im_id = -1;

    im->data_s = NULL;

    im->role = role;
    im->state = 0;

    im->message_pending = NULL;
    im->message_depth = 0;
    im->message_depth_maximum = 8;

    im->role_data.client = NULL;
    im->role_data.server = NULL;

    im->message_handler_call = iiimf_message_handler_call;
    im->message_handler = NULL;

    im->ic_list = NULL;

    im->stream = NULL;

    im->client_data = client_data;

    im->data_s = iiimp_data_s_new();
    if (NULL == im->data_s) {
       iiimf_im_delete(im);
       return IIIMF_STATUS_FAIL;
    }

    size = ((sizeof (IIIMF_message_pending)) * im->message_depth_maximum);
    im->message_pending = (IIIMF_message_pending *)malloc(size);
    if (NULL == im->message_pending) {
       iiimf_im_delete(im);
       return IIIMF_STATUS_MALLOC;
    }

    switch (role) {
    case IIIMF_ROLE_CLIENT:
       status = iiimf_role_data_client_new(server_node, service,
                                       &(im->role_data.client));
       if (IIIMF_STATUS_SUCCESS != status) {
           iiimf_im_delete(im);
           return status;
       }
       break;
    case IIIMF_ROLE_SERVER:
       status = iiimf_role_data_server_new(service, &(im->role_data.server));
       if (IIIMF_STATUS_SUCCESS != status) {
           iiimf_im_delete(im);
           return status;
       }
       break;
    default:
       iiimf_im_delete(im);
       return IIIMF_STATUS_ARGUMENT;
    }

    status = iiimf_message_handler_entry_new(&(im->message_handler));
    if (IIIMF_STATUS_SUCCESS != status) {
       iiimf_im_delete(im);
       return status;
    }

    status = iiimf_stream_new(role, &(im->stream));
    if (IIIMF_STATUS_SUCCESS != status) {
       iiimf_im_delete(im);
       return status;
    }

    *im_ret = im;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_im_server_accept ( IIIMF_im *  im,
void *  client_data,
IIIMF_im **  im_ret 
)

Definition at line 201 of file input-method.c.

{
    return im->stream->proc_accept(im, im->stream->proc_data, client_data,
                               im_ret);
}
IIIMF_status iiimf_im_start ( IIIMF_im *  im)

Definition at line 187 of file input-method.c.

{
    return im->stream->proc_open(im, im->stream->proc_data);
}
IIIMF_status iiimf_im_timeout_set ( IIIMF_im *  im,
int  fd 
)

Definition at line 180 of file input-method.c.

{
    return iiimf_stream_timeout_set(im->stream, timeout);
}
IIIMF_status iiimf_im_user_set ( IIIMF_im *  im,
const char *  username,
const char *  password 
)

Definition at line 418 of file role-data-client.c.

{
    IIIMF_role_data_client *       client;

    client = im->role_data.client;
    if (username) {
       if (client->user_name) free(client->user_name);
       client->user_name = strdup(username);
    }
    if (password) {
       if (client->password) free(client->password);
       client->password = strdup(password);
    }

    return IIIMF_STATUS_SUCCESS;
}
IIIMF_status iiimf_listen_socket_stream ( const char *  node,
const char *  service,
int  timeout,
IIIMF_stream **  stream_ret 
)

Definition at line 330 of file stream-socket.c.

{
    int                     fd;
    int                     fd_flag;
    int                     optval;
    int                     r = 0;

#if defined(HAVE_GETADDRINFO)
    int                     e;
    struct addrinfo *       a;
    struct addrinfo *       aip;
    struct addrinfo  hints;

    fd = -1;

    (void)memset(&hints, 0, sizeof (hints));
    hints.ai_flags = AI_PASSIVE;
    hints.ai_socktype = SOCK_STREAM;

    e = getaddrinfo(NULL, service, &hints, &aip);
    if (0 != e) return IIIMF_STATUS_STREAM;

    for (a = aip; NULL != a; a = a->ai_next) {
       fd = socket(a->ai_family, a->ai_socktype, a->ai_protocol);
       if (-1 != fd) {
           r = bind(fd, aip->ai_addr, sizeof (struct sockaddr));
           if (-1 != r) break;
           (void)close(fd);
           fd = -1;
       }
    }
    freeaddrinfo(aip);
    if ((-1 == fd) || (-1 == r)) return IIIMF_STATUS_STREAM;
    r = listen(fd, 5);
    if (-1 == r) return IIIMF_STATUS_STREAM;
#else /* !HAVE_GETADDRINFO */

#if defined(WIN32)
    unsigned short int      port_number;
#else /* !WIN32 */
    int                     port_number;
#endif /* !WIN32 */
#if defined(PF_INET6) && defined(ENABLE_IPV6)
    struct sockaddr_in6     addr;
#else /* !PF_INET6 && ENABLE_IPV6 */
    struct sockaddr_in      addr;
#endif /* !PF_INET6 && ENABLE_IPV6 */
    struct servent * srvp;

#if defined(WIN32)
    start_winsock(1, 1);
#endif

#if defined(PF_INET6) && defined(ENABLE_IPV6)
    fd = socket(PF_INET6, SOCK_STREAM, 0);
#else /* !PF_INET6 && ENABLE_IPV6 */
    fd = socket(PF_INET, SOCK_STREAM, 0);
#endif /* !PF_INET6 && ENABLE_IPV6 */

    if (fd < 0 ) return IIIMF_STATUS_STREAM;

    port_number = 0;

    if (0 < strlen(service)) {
       srvp = getservbyname(service, "tcp");
       if (NULL != srvp) {
           port_number = srvp->s_port;
       }
       (void)endservent();
       if (0 == port_number) {
           port_number = atoi(service);
       }
    }
    if (0 == port_number) {
       port_number = 9010;
    }

    (void)memset((char *)(&addr), 0, sizeof (addr));
#if defined(PF_INET6) && defined(ENABLE_IPV6)
    addr.sin6_family = PF_INET6;
    addr.sin6_flowinfo = 0;
    addr.sin6_port = htons(port_number);
    addr.sin6_addr = in6addr_any;
#else /* !PF_INET6 && ENABLE_IPV6 */
    addr.sin_family = PF_INET;
    addr.sin_port = htons(port_number);
#endif /* !PF_INET6 && ENABLE_IPV6 */

    if ((bind(fd, (struct sockaddr *)(&addr), sizeof (addr)) < 0) ||
       (listen(fd, 5) < 0) ) {
#if defined(WIN32)
       sock_close(fd);
#else /* !WIN32 */
       (void)close(fd);
#endif /* !WIN32 */
       return IIIMF_STATUS_STREAM;
    }
#endif /* !HAVE_GETADDRINFO */

    optval = 1;
    r = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
    if (-1 == r) {
#if defined(WIN32)
       sock_close(fd);
#else /* !WIN32 */
       (void)close(fd);
#endif /* !WIN32 */
       return IIIMF_STATUS_STREAM;
    }

    fd_flag = fcntl(fd, F_GETFD);
    fd_flag |= FD_CLOEXEC;
    (void)fcntl(fd, F_SETFD, fd_flag);

    {
       IIIMF_status st;
       IIIMF_stream *stream;
       IIIMF_stream_socket_private *sockpriv;

       sockpriv = create_sockpriv(IIIMF_STREAM_SOCKET_LISTEN, fd, timeout);
       if (!sockpriv) {
           close(fd);
           return IIIMF_STATUS_MALLOC;
       }

       st = iiimf_create_stream(NULL, NULL, sockpriv, timeout, &stream);
       if (st != IIIMF_STATUS_SUCCESS) return st;
       *stream_ret = stream;
    }

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_listen_tls_stream ( const char *  node,
const char *  service,
int  timeout,
IIIMF_stream **  stream_ret 
)

Definition at line 37 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}
IIIMF_status iiimf_message_handler_register ( IIIMF_im *  im,
int  opcode,
IIIMF_message_handler  handler,
const char *  name,
IIIMF_message_handler_register_place  place,
const char *  anchor 
)

Definition at line 88 of file handler.c.

{
    IIIMF_message_handler_entry *  entry;
    IIIMF_message_handler_entry *  entry_prev;
    IIIMF_message_handler_entry *  entry_new;

    if (0x7f < opcode) return IIIMF_STATUS_OPCODE;

    entry_new = iiimf_message_handler_entry_item_new(name, handler);
    if (NULL == entry_new) return IIIMF_STATUS_MALLOC;

    entry = *(im->message_handler + opcode);

    switch (place) {
    case IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_HEAD:
       entry = NULL;
       break;
    case IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_TAIL:
       if (NULL != entry) {
           for (; NULL != entry->next; entry = entry->next) {
           }
       }
       break;
    case IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_BEFORE:
       entry_prev = NULL;
       for (; NULL != entry; entry = entry->next) {
           if (0 == strcmp(entry->name, anchor)) break;
           entry_prev = entry;
       }
       if (NULL == entry) {
           iiimf_message_handler_entry_item_delete(entry_new);
           return IIIMF_STATUS_ARGUMENT;
       }
       entry = entry_prev;
       break;
    case IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_AFTER:
       for (; NULL != entry; entry = entry->next) {
           if (0 == strcmp(entry->name, anchor)) break;
       }
       if (NULL == entry) {
           iiimf_message_handler_entry_item_delete(entry_new);
           return IIIMF_STATUS_ARGUMENT;
       }
       break;
    default:
       return IIIMF_STATUS_ARGUMENT;
    }

    if (NULL == entry) {
       entry_new->next = *(im->message_handler + opcode);
       *(im->message_handler + opcode) = entry_new;
    } else {
       entry_new->next = entry->next;
       entry->next = entry_new;
    }

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

IIIMF_status iiimf_message_handler_unregister ( IIIMF_im *  im,
int  opcode,
IIIMF_message_handler  handler 
)

Definition at line 155 of file handler.c.

{
    IIIMF_message_handler_entry *  entry;
    IIIMF_message_handler_entry *  entry_next;
    IIIMF_message_handler_entry *  entry_prev;

    if (0x7f < opcode) return IIIMF_STATUS_OPCODE;

    entry = *(im->message_handler + opcode);

    if (NULL == entry->proc) return IIIMF_STATUS_ARGUMENT;

    if (handler == entry->proc) {
       entry_next = entry->next;
       if (NULL != entry_next) {
           entry->proc = entry_next->proc;
           entry->next = entry_next->next;
           free(entry_next);
       }
       return IIIMF_STATUS_SUCCESS;
    }

    for (entry_prev = entry, entry = entry->next;
        NULL != entry;
        entry_prev = entry, entry = entry->next) {
       if (handler == entry->proc) {
           entry_prev->proc = entry->next->proc;
           entry_prev->next = entry->next->next;
           free(entry);
           return IIIMF_STATUS_SUCCESS;
       }
    }

    return IIIMF_STATUS_ARGUMENT;
}
IIIMF_status iiimf_message_handler_unregister_name ( IIIMF_im *  im,
const char *  name 
)

Definition at line 196 of file handler.c.

{
    IIIMF_status                   status;
    int                                   opcode;
    IIIMF_message_handler_entry *  entry;
    IIIMF_message_handler_entry *  entry_prev;

    status = IIIMF_STATUS_FAIL;

    for (opcode = 0; opcode < 128; opcode++) {
       entry = *(im->message_handler + opcode);
       if (NULL == entry) continue;

       entry_prev = NULL;
       for (; NULL != entry; entry = entry->next) {
           if (0 == strcmp(entry->name, name)) break;
           entry_prev = entry;
       }
       if (NULL != entry) {
           if (NULL == entry_prev) {
              *(im->message_handler + opcode) = entry->next;
           } else {
              entry_prev->next = entry->next;
           }
           iiimf_message_handler_entry_item_delete(entry);
           status = IIIMF_STATUS_SUCCESS;
       }
    }

    return status;
}

Here is the call graph for this function:

void iiimf_perror ( IIIMF_status  status,
const char *  str 
)

Definition at line 69 of file perror.c.

{
    const char *     p;
#if defined(HAVE_DGETTEXT) && defined(IIIMF_MESSAGE_DIRNAME)
    char *           dirname;
#endif /* HAVE_DGETTEXT && IIIMF_MESSAGE_DIRNAME */

    p = status_string(status);

#if defined(HAVE_DGETTEXT)
#if defined(IIIMF_MESSAGE_DIRNAME)
    dirname = bindtextdomain(IIIMF_MESSAGE_DOMAIN, NULL);
    bindtextdomain(IIIMF_MESSAGE_DOMAIN, IIIMF_MESSAGE_DIRNAME);
#endif /* IIIMF_MESSAGE_DOMAIN */
    p = dgettext(IIIMF_MESSAGE_DOMAIN, p);
#endif /* HAVE_DGETTEXT */

    if ((NULL == str) || ('\0' == *str)) {
       (void)fprintf(stderr, "%s\n", p);
    } else {
       (void)fprintf(stderr, "%s: %s\n", str, p);
    }

#if defined(HAVE_DGETTEXT) && defined(IIIMF_MESSAGE_DIRNAME)
    if (NULL != dirname) {
       bindtextdomain(IIIMF_MESSAGE_DOMAIN, dirname);
    }
#endif /* HAVE_DGETTEXT && IIIMF_MESSAGE_DOMAIN */

    return;
}

Here is the call graph for this function:

IIIMF_status iiimf_request_loop ( IIIMF_im *  im)

Definition at line 70 of file request.c.

{
    IIIMF_ic *              ic;
    IIIMP_message *  message;
    IIIMF_status     status;
    IIIMP_data_s *   data_s;

    ic = NULL;
    message = NULL;
    data_s = im->data_s;

    for (;;) {
       if (NULL != message) {
           iiimp_message_delete(data_s, message);
       }

       status = iiimf_stream_receive(im->stream, data_s, &message);
       if (IIIMF_STATUS_SUCCESS != status) return status;

       status = iiimf_message_sequence(im, ic, message,
                                   IIIMF_MESSAGE_ATTR_RECEIVE);
       if (IIIMF_STATUS_SUCCESS != status) break;

       status = (im->message_handler_call)(im, message);
       if (IIIMF_STATUS_SUCCESS != status) {
           break;
       }

       if (-1 == message->ic_id) {
           ic = NULL;
       } else {
           for (ic = im->ic_list; NULL != ic; ic = ic->next) {
              if (message->ic_id == ic->ic_id) break;
           }
           if (NULL == ic) return IIIMF_STATUS_IC_INVALID;
       }

       status = iiimf_request_reply(im, ic, message);
       if (IIIMF_STATUS_SUCCESS != status) break;
    }

    if (NULL != message) {
       iiimp_message_delete(data_s, message);
    }

    return status;
}

Here is the call graph for this function:

IIIMF_status iiimf_request_reply ( IIIMF_im *  im,
IIIMF_ic *  ic,
IIIMP_message message 
)

Definition at line 329 of file request-reply.c.

{
    IIIMF_status     status;
    uchar_t *        message;
    size_t           nbyte;
    int                     opcode;
    IIIMP_message    message_dummy;

    opcode = iiimf_opcode_reply_internal(message_original->opcode);
    if (IM_NOP == opcode) return IIIMF_STATUS_SUCCESS;

    message_dummy.opcode = opcode;
    message_dummy.length = 8;
    message_dummy.im_id = message_original->im_id;
    message_dummy.ic_id = message_original->ic_id;
    status = iiimf_message_sequence(im, ic, &message_dummy,
                                IIIMF_MESSAGE_ATTR_SEND);
    if (IIIMF_STATUS_SUCCESS != status) {
       if (IIIMF_STATUS_SEQUENCE_REQUEST == status) {
           return IIIMF_STATUS_SUCCESS;
       } else {
           return status;
       }
    }

    message = message_reply_pack_func[opcode](im, ic, opcode, message_original,
                                         &nbyte);
    if (NULL == message) return IIIMF_STATUS_FAIL;

    status = im->stream->proc_write(im->stream->private_data, message, nbyte);

    free(message);

    return status;
}

Here is the caller graph for this function:

IIIMF_status iiimf_request_send ( IIIMF_im *  im,
IIIMF_ic *  ic,
IIIMP_message message 
)

Definition at line 12 of file request.c.

{
    IIIMF_status     status;
    int                     opcode_reply;
    IIIMP_message *  message_receive;

    message_receive = NULL;

    status = iiimf_message_sequence(im, ic, message, IIIMF_MESSAGE_ATTR_SEND);
    if (IIIMF_STATUS_SUCCESS != status) return status;

    status = iiimf_stream_send(im->stream, im->data_s, message);
    if (IIIMF_STATUS_SUCCESS != status) return status;

    opcode_reply = iiimf_opcode_reply_internal(message->opcode);
    if (IM_NOP == opcode_reply) return IIIMF_STATUS_SUCCESS;

    for (;;) {
       if (NULL != message_receive) {
           iiimp_message_delete(im->data_s, message_receive);
       }

       status = iiimf_stream_receive(im->stream, im->data_s, &message_receive);
       if (IIIMF_STATUS_SUCCESS != status) break;

       status = iiimf_message_sequence(im, ic, message_receive,
                                   IIIMF_MESSAGE_ATTR_RECEIVE);
       if (IIIMF_STATUS_SUCCESS != status) break;

       if (IM_CREATEIC_REPLY == message_receive->opcode) {
           ic->ic_id = message_receive->ic_id;
       }

       status = (im->message_handler_call)(im, message_receive);
       if (IIIMF_STATUS_SUCCESS != status) {
           break;
       }

       if (opcode_reply == message_receive->opcode) {
           break;
       }

       status = iiimf_request_reply(im, ic, message_receive);
       if (IIIMF_STATUS_SUCCESS != status) break;
    }

    if (NULL != message_receive) {
       iiimp_message_delete(im->data_s, message_receive);
    }

    return status;
}

Here is the call graph for this function:

IIIMF_status iiimf_role_data_client_auth_password ( IIIMF_im *  im,
char **  password_ret 
)

Definition at line 698 of file role-data-client.c.

{

#if 0
    char *    password;
    int              fd;
    int              len;
    int              i;
    char      pwd_buf[AUTH_PASSWORD_LEN + 1];

    if (im->role_data.client->password) {
       *password_ret = strdup(im->role_data.client->password);
       if (!(*password_ret)) return IIIMF_STATUS_MALLOC;
    } else {
       password = NULL;
       fd = -1;

       fd = auth_password_file_open(im->role_data.client->home_dir);
       if (-1 == fd) return IIIMF_STATUS_CONFIG;

       len = read(fd, pwd_buf, AUTH_PASSWORD_LEN);
       (void)close(fd);

       if (AUTH_PASSWORD_LEN != len) return IIIMF_STATUS_CONFIG;

       for (i = 0; i < AUTH_PASSWORD_LEN; i++) {
           if (0 == isalnum(pwd_buf[i])) {
              return IIIMF_STATUS_CONFIG;
           }
       }
       if (AUTH_PASSWORD_LEN != i) {
           return IIIMF_STATUS_CONFIG;
       }

       password = malloc(AUTH_PASSWORD_LEN + 1);
       if (NULL == password) return IIIMF_STATUS_MALLOC;
       (void)memcpy(password, pwd_buf, AUTH_PASSWORD_LEN);
       *(password + AUTH_PASSWORD_LEN) = '\0';

       *password_ret = password;
    }

#endif
    *password_ret = strdup("");
    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* iiimf_role_data_client_home_dir ( IIIMF_im *  im)

Definition at line 58 of file role-data-client.c.

{
    return im->role_data.client->home_dir;
}
const char* iiimf_role_data_client_node ( IIIMF_im *  im)

Definition at line 65 of file role-data-client.c.

{
    return im->role_data.client->node;
}
const char* iiimf_role_data_client_server_node ( IIIMF_im *  im)

Definition at line 72 of file role-data-client.c.

{
    return im->role_data.client->server_node;
}
const char* iiimf_role_data_client_service ( IIIMF_im *  im)

Definition at line 79 of file role-data-client.c.

{
    return im->role_data.client->service;
}
const char* iiimf_role_data_client_user_name ( IIIMF_im *  im)

Definition at line 51 of file role-data-client.c.

{
    return im->role_data.client->user_name;
}
void iiimf_stream_delete ( IIIMF_stream stream)

Definition at line 35 of file stream.c.

{
    if (NULL == stream) return;
    free(stream);

    return;
}

Here is the caller graph for this function:

IIIMF_status iiimf_stream_receive ( IIIMF_stream stream,
IIIMP_data_s *  data_s,
IIIMP_message **  message 
)

Definition at line 86 of file stream.c.

{
    IIIMF_status     status;
    const uchar_t *  ptr;
    uchar_t *        p;
    size_t           nbyte;
    IIIMP_message *  message;
    uchar_t          header[8];
    int                     header_len;
    int                     length;
    int                     opcode;
    uchar_t *        buf;

    if (!stream->proc_read) return IIIMF_STATUS_STREAM;
    status = (*stream->proc_read)(stream->private_data, header, 8);
    if (IIIMF_STATUS_SUCCESS != status) return status;

    opcode = header[0];
    if (0x80 & opcode) {
       if ((0xe0 & header[4]) || (0x00 == header[4])) {
           return IIIMF_STATUS_PACKET;
       }
       length = (((header[4] << 24) +
                 (header[5] << 16) +
                 (header[6] << 8) +
                 (header[7] << 0)) << 2);
       header_len = 8;
    } else {
       length = (((header[1] << 16) +
                 (header[2] << 8) +
                 (header[3] << 0)) << 2);
       header_len = 4;
    }
    if (length < 4) return IIIMF_STATUS_PACKET;

    if (4 == length) {
       buf = (header + 4);
    } else {
       buf = (uchar_t *)malloc(length);
       if (NULL == buf) return IIIMF_STATUS_MALLOC;
       p = buf;

       if (8 != header_len) {
           (void)memcpy(buf, header + 4, 4);
           p += 4;
       }

       status = (*stream->proc_read)(stream->private_data, p,
                                  length - (8 - header_len));
       if (IIIMF_STATUS_SUCCESS != status) {
           free(buf);
           return status;
       }
    }

    ptr = buf;
    nbyte = length;
    message = iiimp_message_unpack(data_s, header[0], &nbyte, &ptr);
    if ((header + 4) != buf) {
       free(buf);
    }
    if (NULL == message) return IIIMF_STATUS_FAIL;

    *message_ret = message;

    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimf_stream_send ( IIIMF_stream stream,
IIIMP_data_s *  data_s,
IIIMP_message message 
)

Definition at line 45 of file stream.c.

{
    IIIMF_status     status;
    uchar_t *        ptr;
    size_t           nbyte;

    if (!stream->proc_write) return IIIMF_STATUS_STREAM;

    status = IIIMF_STATUS_SUCCESS;

    ptr = iiimp_message_pack(data_s, message, &nbyte);
    if (NULL == ptr) {
       switch (iiimp_data_status(data_s)) {
       case IIIMP_DATA_MALLOC_ERROR:
           status = IIIMF_STATUS_MALLOC;
           break;
       case IIIMP_DATA_INVALID:
           status = IIIMF_STATUS_PACKET;
           break;
       case IIIMP_DATA_PROTOCOL_VERSION_ERROR:
           status = IIIMF_STATUS_PROTOCOL_VERSION;
           break;
       default:
           status = IIIMF_STATUS_FAIL;
           break;
       }
       return status;
    }

    status = (*stream->proc_write)(stream->private_data, ptr, nbyte);

    free(ptr);

    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimf_tls_set_certificate ( IIIMF_stream stream,
const char *  cert_file,
const char *  key_file,
const char *  ca_file,
const char *  ca_path 
)

Definition at line 10 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}

Here is the caller graph for this function:

Definition at line 22 of file stream-tls.c.

{
    return IIIMF_STATUS_FAIL;
}

Here is the caller graph for this function:

int iiimp_data_s_capability ( IIIMP_data_s *  data_s,
int  capability 
)

Definition at line 59 of file iiimp-misc.c.

{
    int       list_index;
    int       bit_index;

    if ((NULL == data_s) || (NULL == data_s->capability)) return 0;

    return iiimp_card32_list_bit_p(data_s, data_s->capability, capability);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_data_s_delete ( IIIMP_data_s *  im)

Definition at line 81 of file iiimp-misc.c.

{
    if (NULL == data_s) return;
    (void)iiimp_data_print_fp(data_s, NULL);
    (void)iiimp_attribute_id_destroy(data_s);
    (void)iiimp_card32_list_delete(data_s, data_s->capability);
    free(data_s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int iiimp_data_s_get_protocol_version ( IIIMP_data_s *  data_s)

Definition at line 11 of file iiimp-misc.c.

{
    return data_s->protocol_version;
}

Here is the caller graph for this function:

IIIMF_status iiimp_data_s_limit_protocol_version ( IIIMP_data_s *  data_s,
int  version 
)

Definition at line 20 of file iiimp-misc.c.

{
    if (version > data_s->protocol_version)
       return IIIMF_STATUS_PROTOCOL_VERSION;
    data_s->protocol_version = version;

    return IIIMF_STATUS_SUCCESS;
}

Here is the caller graph for this function:

IIIMP_data_s* iiimp_data_s_new ( void  )

Definition at line 74 of file iiimp-misc.c.

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_data_s* iiimp_data_s_with_protocol_version_new ( int  protocol_version)

Definition at line 34 of file iiimp-misc.c.

{
    IIIMP_data_s *   data_s;

    if (protocol_version >= 0x100) {
       return NULL;
    }

    data_s = (IIIMP_data_s *)malloc(sizeof (IIIMP_data_s));
    if (NULL == data_s) return NULL;
    data_s->byte_swap = 0;
    data_s->attribute_id = NULL;
    data_s->status = 0;
    data_s->print_fp = stdout;
    data_s->print_flag = 0;
    data_s->protocol_version = protocol_version;
    data_s->capability = NULL;

    return data_s;
}

Here is the caller graph for this function: