
#include <rpcrts.h>

typedef    rpc_char name[41];
typedef    rpc_char name_list[401];
typedef    rpc_long way_status;

rpc_handle h_way;

rpc_long way_request(service, version, compatibility, pref_addresses, 
        address_length, address)
    name service;
    rpc_integer version;
    rpc_integer compatibility;
    name_list pref_addresses;
    rpc_integer address_length;
    name address;

{   rpc_message *rpc_p_buf;
    register rpc_integer rpc_a;
    register rpc_integer rpc_b;
    rpc_long rpc_ret;

    c_begin(rpc_p_buf, h_way, /*vers=*/7130, /*proc=*/1);
   for (rpc_b = 0; rpc_b <= 40; rpc_b++)
   if (service[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, service[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
   pck_integer(rpc_p_buf, version);
   pck_integer(rpc_p_buf, compatibility);
   for (rpc_b = 0; rpc_b <= 400; rpc_b++)
   if (pref_addresses[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, pref_addresses[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
   pck_integer(rpc_p_buf, address_length);
    c_call(h_way, rpc_p_buf, -1);
    rpc_p_buf->m_index = RETURN_HEADER_LENGTH;
    upk_long(rpc_p_buf, rpc_ret);
   upk_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   upk_char(rpc_p_buf, address[rpc_a]);
   }
   address[rpc_b] = '\0';
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
    c_dispose(rpc_p_buf);
    return(rpc_ret);
    }

rpc_long way_register(service, version, compatibility, address)
    name service;
    rpc_integer version;
    rpc_integer compatibility;
    name address;

{   rpc_message *rpc_p_buf;
    register rpc_integer rpc_a;
    register rpc_integer rpc_b;
    rpc_long rpc_ret;

    c_begin(rpc_p_buf, h_way, /*vers=*/7130, /*proc=*/2);
   for (rpc_b = 0; rpc_b <= 40; rpc_b++)
   if (service[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, service[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
   pck_integer(rpc_p_buf, version);
   pck_integer(rpc_p_buf, compatibility);
   for (rpc_b = 0; rpc_b <= 40; rpc_b++)
   if (address[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, address[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
    c_call(h_way, rpc_p_buf, -1);
    rpc_p_buf->m_index = RETURN_HEADER_LENGTH;
    upk_long(rpc_p_buf, rpc_ret);
    c_dispose(rpc_p_buf);
    return(rpc_ret);
    }

rpc_long way_unregister(service, version, address)
    name service;
    rpc_integer version;
    name address;

{   rpc_message *rpc_p_buf;
    register rpc_integer rpc_a;
    register rpc_integer rpc_b;
    rpc_long rpc_ret;

    c_begin(rpc_p_buf, h_way, /*vers=*/7130, /*proc=*/3);
   for (rpc_b = 0; rpc_b <= 40; rpc_b++)
   if (service[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, service[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
   pck_integer(rpc_p_buf, version);
   for (rpc_b = 0; rpc_b <= 40; rpc_b++)
   if (address[rpc_b] == '\0') break;
   pck_integer(rpc_p_buf, rpc_b);
   for (rpc_a = 0; rpc_a < rpc_b; rpc_a++) {
   pck_char(rpc_p_buf, address[rpc_a]);
   }
    if (rpc_p_buf->m_index%2) rpc_p_buf->m_index++;
    c_call(h_way, rpc_p_buf, -1);
    rpc_p_buf->m_index = RETURN_HEADER_LENGTH;
    upk_long(rpc_p_buf, rpc_ret);
    c_dispose(rpc_p_buf);
    return(rpc_ret);
    }

open_way()
{   rpc_status       status;

    c_open(status, h_way, "way                                     ");
    c_report_error(status);
    }
close_way()
{   rpc_status       status;

    c_close(status, h_way);
    c_report_error(status);
    }
