home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NET-TOOL.1 / NET-TOOL / net-tools / lib / unix.c < prev   
Encoding:
C/C++ Source or Header  |  1993-12-12  |  1.8 KB  |  88 lines

  1. /*
  2.  * NET-2    This file contains the general hardware types.
  3.  *
  4.  * Version:    @(#)unix.c    1.10    10/07/93
  5.  *
  6.  * Author:    Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  7.  *        Copyright 1993 MicroWalt Corporation
  8.  *
  9.  *        This program is free software; you can redistribute it
  10.  *        and/or  modify it under  the terms of  the GNU General
  11.  *        Public  License as  published  by  the  Free  Software
  12.  *        Foundation;  either  version 2 of the License, or  (at
  13.  *        your option) any later version.
  14.  */
  15. #include "config.h"
  16.  
  17. #include <sys/types.h>
  18. #include <sys/socket.h>
  19. #if HAVE_AFUNIX
  20. #   include <sys/un.h>
  21. #endif
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <errno.h>
  25. #include <ctype.h>
  26. #include <string.h>
  27. #include <unistd.h>
  28. #include "support.h"
  29. #include "pathnames.h"
  30.  
  31.  
  32. /* Display an UNSPEC address. */
  33. static char *
  34. UNSPEC_print(unsigned char *ptr)
  35. {
  36.   static char buff[64];
  37.   char *pos;
  38.   int i;
  39.  
  40.   pos = buff;
  41.   for(i = 0; i < sizeof(struct sockaddr); i++) {
  42.     pos += sprintf(pos, "%02X-", (*ptr++ & 0377));
  43.   }
  44.   buff[strlen(buff) - 1] = '\0';
  45.   return(buff);
  46. }
  47.  
  48.  
  49. /* Display an UNSPEC socket address. */
  50. static char *
  51. UNSPEC_sprint(struct sockaddr *sap, int numeric)
  52. {
  53.   if (sap->sa_family == 0xFFFF || sap->sa_family == 0) return("[NONE SET]");
  54.   return(UNSPEC_print(sap->sa_data));
  55. }
  56.  
  57.  
  58. #if HAVE_AFUNIX
  59.  
  60. /* Display a UNIX domain address. */
  61. static char *
  62. UNIX_print(unsigned char *ptr)
  63. {
  64.   return(ptr);
  65. }
  66.  
  67.  
  68. /* Display a UNIX domain address. */
  69. static char *
  70. UNIX_sprint(struct sockaddr *sap, int numeric)
  71. {
  72.   if (sap->sa_family == 0xFFFF || sap->sa_family == 0) return("[NONE SET]");
  73.   return(UNIX_print(sap->sa_data));
  74. }
  75.  
  76.  
  77. struct aftype unix_aftype = {
  78.   "unix",    "UNIX Domain",        AF_UNIX,    0,
  79.   UNIX_print,    UNIX_sprint,        NULL,        NULL
  80. };
  81. #endif    /* HAVE_AFUNIX */
  82.  
  83.  
  84. struct aftype unspec_aftype = {
  85.   "unspec",    "UNSPEC",        AF_UNSPEC,    0,
  86.   UNSPEC_print,    UNSPEC_sprint,        NULL,        NULL
  87. };
  88.