File: inet_ntop.c

package info (click to toggle)
sane-backends-extras 1.0.19.11
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,632 kB
  • ctags: 3,610
  • sloc: ansic: 36,869; sh: 8,313; makefile: 1,048
file content (35 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "../include/sane/config.h"

#ifndef HAVE_INET_NTOP

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


const char *
inet_ntop (int af, const void *src, char *dst, size_t cnt)
{
  struct in_addr in;
  char *text_addr;

#ifdef HAVE_INET_NTOA
  if (af == AF_INET)
    {
      memcpy (&in.s_addr, src, sizeof (in.s_addr));
      text_addr = inet_ntoa (in);
      if (text_addr && dst)
	{
	  strncpy (dst, text_addr, cnt);
	  return dst;
	}
      else
	return 0;
    }
#endif /* HAVE_INET_NTOA */
  return 0;
}

#endif /* !HAVE_INET_NTOP */