Back to index

im-sdk  12.3.91
Classes | Functions
role-data-client.h File Reference
#include <iiimp.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  IIIMF_role_data_client

Functions

IIIMF_status iiimf_role_data_client_new (const char *server_node, const char *service, IIIMF_role_data_client **client)
void iiimf_role_data_client_delete (IIIMF_role_data_client *client)

Class Documentation

struct IIIMF_role_data_client

Definition at line 13 of file role-data-client.h.

Class Members
char * home_dir
char * node
char * os_arch
char * os_name
char * os_version
char * password
char * server_node
char * service
char * type
char * user_name
char * X_display_name
char * X_server_vendor

Function Documentation

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

{
    if (client->user_name) free(client->user_name);
    if (client->password) free(client->password);
    if (client->home_dir) free(client->home_dir);
    if (client->node) free(client->node);
    if (client->server_node) free(client->server_node);
    if (client->service) free(client->service);
    if (client->type) free(client->type);
    if (client->os_name) free(client->os_name);
    if (client->os_arch) free(client->os_arch);
    if (client->os_version) free(client->os_version);
    if (client->X_display_name) free(client->X_display_name);
    if (client->X_server_vendor) free(client->X_server_vendor);

    free(client);
}

Here is the caller graph for this function:

IIIMF_status iiimf_role_data_client_new ( const char *  server_node,
const char *  service,
IIIMF_role_data_client **  client 
)

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

{
    IIIMF_role_data_client *       client;
    struct passwd *         pwd;
    IIIMF_status            status;
    struct utsname          name;

    status = IIIMF_STATUS_CONFIG;

    client = (IIIMF_role_data_client *)malloc(sizeof (IIIMF_role_data_client));
    if (NULL == client) return IIIMF_STATUS_MALLOC;

    client->user_name = NULL;
    client->home_dir = NULL;
    client->node = NULL;

    client->server_node = ((NULL == server_node) ? NULL : strdup(server_node));
    client->service = ((NULL == service) ? NULL : strdup(service));

    client->type = strdup(CLIENT_TYPE);

    client->os_name = NULL;
    client->os_arch = NULL;
    client->os_version = NULL;
    client->X_display_name = NULL;
    client->X_server_vendor = NULL;

    pwd = getpwuid(geteuid());
    if (NULL == pwd) {
       iiimf_role_data_client_delete(client);
       return IIIMF_STATUS_CONFIG;
    }

    client->user_name = strdup(pwd->pw_name);
    client->home_dir = strdup(pwd->pw_dir);

    endpwent();

    if ((NULL == client->user_name) ||
       (NULL == client->home_dir) ||
       ((NULL != server_node) && (NULL == client->server_node)) ||
       ((NULL != service) && (NULL == client->service))) {
       iiimf_role_data_client_delete(client);
       return IIIMF_STATUS_MALLOC;
    }

    if (-1 == uname(&name)) {
       iiimf_role_data_client_delete(client);
       return IIIMF_STATUS_CONFIG;
    }

    client->node = strdup(name.nodename);

    client->os_name = strdup(name.sysname);
    client->os_version = strdup(name.release);

#if defined(OS_ARCH)
    client->os_arch = strdup(OS_ARCH);
#else /* !OS_ARCH */
#if defined(HAVE_SYSINFO) && defined(SI_ARCHITECTURE)
    ret = sysinfo(SI_ARCHITECTURE, arch, sizeof (arch));
    if (-1 == ret) {
       client->os_arch = NULL;
    } else if ((0 == strcmp(arch, "sparc")) ||
              (0 == strcmp(arch, "ppc"))) {
       client->os_arch = strdup(arch);
    } else if (0 == strcmp(arch, "i386")) {
       client->os_arch = strdup("x86");
    } else {
       client->os_arch = strdup("Unknown");
    }
#else /* !HAVE_SYSINFO || !SI_ARCHITECTURE */
    client->os_arch = strdup("Unknown");
#endif /* !HAVE_SYSINFO || !SI_ARCHITECTURE */
#endif /* !OS_ARCH */

    if ((NULL == server_node) && (NULL == service)) {
       status = iiimf_role_data_client_environ_server(client);
       if (IIIMF_STATUS_SUCCESS != status) {
           status = iiimf_role_data_client_file_server(client);
       }
       if (IIIMF_STATUS_SUCCESS != status) {
           status = iiimf_role_data_client_file_compat_server(client);
       }
    }

    if (NULL == client->server_node) {
       client->server_node = strdup(NODE_DEFAULT);
    }
    if (NULL == client->service) {
       client->service = strdup(SERVICE_DEFAULT);
    }
    if ((NULL == client->node) || (NULL == client->service)) {
       iiimf_role_data_client_delete(client);
       return IIIMF_STATUS_MALLOC;
    }

    *client_ret = client;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function: