home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sockpli.zip / NETDB.COP < prev    next >
Text File  |  1995-06-27  |  13KB  |  294 lines

  1.  %dcl #_NETDB_32H char ext;
  2.  %if #_NETDB_32H = '' %then
  3.   %do;
  4.     %dcl #_NETDB_32H char ext;
  5.     %#_NETDB_32H = 'Y';
  6.  /************************************************************/
  7.  /* Copyright (c) 1980, 1983, 1988 Regents of the University */
  8.  /* of California                                            */
  9.  /*                                                          */
  10.  /* All rights reserved.                                     */
  11.  /*                                                          */
  12.  /* Redistribution and use in source and binary forms are    */
  13.  /* permitted provided that this notice is preserved and     */
  14.  /* that due credit is given to the University of California */
  15.  /* at Berkeley. The name of the University may not be used  */
  16.  /* to endorse or promote products derived from this software*/
  17.  /* without specific prior written permission. This software */
  18.  /* is provided 'as is' without express or implied warranty. */
  19.  /*                                                          */
  20.  /*       @(#)netdb.h     5.9 (Berkeley 4/5/88)              */
  21.  /*                                                          */
  22.  /************************************************************/
  23.  
  24.  /*----------------------------------------------------------*/
  25.  /* Structures returned by network                           */
  26.  /* data base library.  All addresses                        */
  27.  /* are supplied in host order, and                          */
  28.  /* returned in network order (suitable                      */
  29.  /* for use in system calls).                                */
  30.  /*----------------------------------------------------------*/
  31.  
  32.  define structure
  33.    1 hostent,
  34.      2 h_name                     /* official name of host   */
  35.                                   pointer,
  36.  /*                               --------                   */
  37.      2 h_aliases                  /* alias list              */
  38.                                   pointer,
  39.  /*                               --------                   */
  40.      2 h_addrtype                 /* host address type       */
  41.                                   fixed bin(31),
  42.  /*                               --------------             */
  43.      2 h_length                   /* length of address */
  44.                                   fixed bin(31),
  45.  /*                               --------------             */
  46.      2 h_addr_list                /* list of addr from namsrv*/
  47.                                   pointer;
  48.  /*                               --------                   */
  49.  
  50.  define alias @hostent handle hostent;
  51.  
  52.  /*----------------------------------------------------------*/
  53.  /* Assumption here is that a network number                 */
  54.  /* fits in 32 bits -- probably a poor one.                  */
  55.  /*----------------------------------------------------------*/
  56.  
  57.  define structure
  58.    1 netent,
  59.      2 n_name                     /* official name of net    */
  60.                                   pointer,
  61.  /*                               --------                   */
  62.      2 n_aliases                  /* alias list              */
  63.                                   pointer,
  64.  /*                               --------                   */
  65.      2 n_addrtype                 /* net address type        */
  66.                                   fixed bin(31),
  67.  /*                               --------------             */
  68.      2 n_net                      /* network #               */
  69.                                   unsigned fixed bin(31);
  70.  /*                               ----------------------     */
  71.  
  72.  define alias @netent handle netent;
  73.  
  74.  define structure
  75.    1 servent,
  76.      2 s_name                     /* official service name   */
  77.                                   pointer,
  78.  /*                               --------                   */
  79.      2 s_aliases                  /* alias list              */
  80.                                   pointer,
  81.  /*                               --------                   */
  82.      2 s_port                     /* port #                  */
  83.                                   fixed bin(31),
  84.  /*                               --------------             */
  85.      2 s_proto                    /* protocol to use         */
  86.                                   pointer;
  87.  /*                               -------                    */
  88.  
  89.  define alias @servent handle servent;
  90.  
  91.  define structure
  92.    1 protoent,
  93.      2 p_name                     /* official protocol name  */
  94.                                   pointer,
  95.  /*                               --------                   */
  96.      2 p_aliases                  /* alias list              */
  97.                                   pointer,
  98.  /*                               --------                   */
  99.      2 p_proto                    /* protocol #              */
  100.                                   fixed bin(31);
  101.  /*                               --------------             */
  102.  
  103.  define alias @protoent handle protoent;
  104.  
  105.  %INCLUDE IN;
  106.    %dcl (#MAXALIASES,
  107.          #MAXADDRS,
  108.          #MAXLINELEN,
  109.          #HOSTBUFSIZE) char;
  110.    %#MAXALIASES  = '35';
  111.    %#MAXADDRS    = '35';
  112.    %#MAXLINELEN  = '1024';
  113.    %#HOSTBUFSIZE = '513';
  114.  
  115.  /*----------------------------------------------------------*/
  116.  /* After a successful call to gethostby│name/addr│_r() the  */
  117.  /* structure hostent_data will contain the data to which    */
  118.  /* pointers in the hostent structure will point to.         */
  119.  /*----------------------------------------------------------*/
  120.  
  121.  define structure
  122.    1 hostent_data,
  123.      2 host_addr                  /* host address pointer    */
  124.                                   type in_addr,
  125.  /*                               -------------              */
  126.      2 h_addr_ptrs (#MAXADDRS)    /* host address            */
  127.                                   pointer,
  128.  /*                               --------                   */
  129.      2 hostaddr
  130.                                   char(#MAXADDRS) varyingz,
  131.  /*                               -------------------------  */
  132.      2 hostbuf                    /* host data               */
  133.                                   char(#HOSTBUFSIZE) varyingz,
  134.  /*                               ---------------------------*/
  135.      2 host_aliases (#MAXALIASES)
  136.                                   pointer,
  137.  /*                               --------                   */
  138.      2 host_addrs (2)
  139.                                   pointer,
  140.  /*                               --------                   */
  141.      2 hostf
  142.                                   pointer,
  143.  /*                               -------                    */
  144.      2 stayopen                   /* AIX addon               */
  145.                                   fixed bin(31),
  146.  /*                               -------                    */
  147.      2 host_addresses (#MAXADDRS) /* As per defect 48367     */
  148.                                   unsigned fixed bin (31);
  149.  /*                               ------------------------   */
  150.  
  151.  define structure            /* should be considered opaque  */
  152.    1 servent_data,
  153.      2 serv_fp
  154.                                   pointer,
  155.  /*                               --------                   */
  156.  %dcl line char ext;
  157.  if %line  = '' then
  158.  %deact line;
  159.      2 line
  160.  if %line  = '' then
  161.  %act line;
  162.                                   char(#MAXLINELEN) varyingz,
  163.  /*                               ---------------------------*/
  164.      2 serv_aliases (#MAXALIASES)
  165.                                   pointer,
  166.  /*                               --------                   */
  167.      2 #serv_stayopen
  168.                                   fixed bin(31);
  169.  /*                               --------------             */
  170.  
  171.     dcl gethostbyname_r entry (
  172.            pointer,
  173.            handle hostent,
  174.            handle hostent_data)
  175.              returns( fixed bin(31) byvalue )
  176.               options(linkage(system) byvalue nodescriptor) external;
  177.     dcl gethostbyaddr_r entry (
  178.            pointer,
  179.            fixed bin(31),
  180.            fixed bin(31),
  181.            handle hostent,
  182.            handle hostent_data)
  183.              returns( fixed bin(31) byvalue )
  184.               options(linkage(system) byvalue nodescriptor) external;
  185.     dcl getservbyname_r entry (
  186.            pointer,
  187.            pointer,
  188.            handle servent,
  189.            handle servent_data)
  190.              returns( fixed bin(31) byvalue )
  191.               options(linkage(system) byvalue nodescriptor) external;
  192.     dcl gethostname entry (
  193.            pointer,
  194.            fixed bin(31))
  195.              returns( fixed bin(31) byvalue )
  196.               options(linkage(system) byvalue nodescriptor) external;
  197.     dcl gethostbyname entry (
  198.            pointer)
  199.              returns( type @hostent byvalue )
  200.               options(linkage(system) byvalue nodescriptor) external;
  201.     dcl gethostbyaddr entry (
  202.            pointer, fixed bin (31), fixed bin (31))
  203.              returns( type @hostent byvalue )
  204.               options(linkage(system) byvalue nodescriptor) external;
  205.     dcl getnetbyname entry (
  206.            pointer)
  207.              returns( type @netent byvalue )
  208.               options(linkage(system) byvalue nodescriptor) external;
  209.     dcl getnetbyaddr entry (
  210.            ULONG, fixed bin (31))
  211.              returns( type @netent byvalue )
  212.               options(linkage(system) byvalue nodescriptor) external;
  213.     dcl getservbyname entry (
  214.            pointer, pointer)
  215.              returns( type @servent byvalue )
  216.               options(linkage(system) byvalue nodescriptor) external;
  217.     dcl getservbyport entry (
  218.            fixed bin (31), pointer)
  219.              returns( type @servent byvalue )
  220.               options(linkage(system) byvalue nodescriptor) external;
  221.     dcl getservent entry
  222.              returns( type @servent byvalue )
  223.               options(linkage(system) byvalue nodescriptor) external;
  224.     dcl getprotobyname entry (
  225.            pointer)
  226.              returns( type @protoent byvalue )
  227.               options(linkage(system) byvalue nodescriptor) external;
  228.     dcl getprotobynumber entry (
  229.            fixed bin (31))
  230.              returns( type @protoent byvalue )
  231.               options(linkage(system) byvalue nodescriptor) external;
  232.     dcl sethostent entry (
  233.            fixed bin(31) )
  234.               options(linkage(system) byvalue nodescriptor) external;
  235.     dcl gethostent entry
  236.              returns( type @hostent byvalue )
  237.               options(linkage(system) byvalue nodescriptor) external;
  238.     dcl endhostent entry
  239.               options(linkage(system) byvalue nodescriptor) external;
  240.     dcl setnetent entry (
  241.            fixed bin(31) )
  242.               options(linkage(system) byvalue nodescriptor) external;
  243.     dcl getnetent entry
  244.              returns( type @netent byvalue )
  245.               options(linkage(system) byvalue nodescriptor) external;
  246.     dcl endnetent entry
  247.               options(linkage(system) byvalue nodescriptor) external;
  248.     dcl setprotoent entry (
  249.            fixed bin(31) )
  250.               options(linkage(system) byvalue nodescriptor) external;
  251.     dcl getprotoent entry
  252.              returns( type @protoent byvalue )
  253.               options(linkage(system) byvalue nodescriptor) external;
  254.     dcl endprotoent entry
  255.               options(linkage(system) byvalue nodescriptor) external;
  256.     dcl setservent entry (
  257.            fixed bin(31) )
  258.               options(linkage(system) byvalue nodescriptor) external;
  259.     dcl endservent entry
  260.               options(linkage(system) byvalue nodescriptor) external;
  261.  
  262.  /*----------------------------------------------------------*/
  263.  /* Error return codes from gethostbyname() & gethostbyaddr()*/
  264.  /* (left in extern int h_errno).                            */
  265.  /*----------------------------------------------------------*/
  266.  
  267.  dcl h_errno fixed bin(31);
  268.  
  269.     dcl HOST_NOT_FOUND       /* Authoritative Answer Host    */
  270.                              /* not found                    */
  271.                              fixed bin(31) init(1);
  272.  /*                          ----------------------          */
  273.     dcl TRY_AGAIN            /* Non-Authoratitive Host not   */
  274.                              /* found or SERVERFAIL          */
  275.                              fixed bin(31) init(2);
  276.  /*                          ----------------------          */
  277.     dcl NO_RECOVERY          /* Non-recov. errors FORMERR,   */
  278.                              /* REFUSED, NOTIMP              */
  279.                              fixed bin(31) init(3);
  280.  /*                          ----------------------          */
  281.     dcl NO_DATA              /* Valid name, no data record   */
  282.                              /* of requested type            */
  283.                              fixed bin(31) init(4);
  284.  /*                          ----------------------          */
  285.  
  286.  %dcl NO_ADDRESS char ext;
  287.  %NO_ADDRESS='NO_DATA';
  288.     %dcl @NO_ADDRESS char ext;
  289.     %@NO_ADDRESS='@NO_DATA';
  290.  /* no address, look for MX record */
  291.  
  292.   %end;
  293.  /* __NETDB_32H  */
  294.