Versione di debug funzionante, la salvo prima di rimuovere tutto per mettere
[gapil.git] / sources / SockAddr.c
1 /* SockAddr.c
2  * 
3  * Copyright (C) 2004 Simone Piccardi
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or (at
8  * your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /***************************************************************
20  *
21  * File SockAddr.c 
22  * Routines for socket address resolution. 
23  *
24  *
25  * Author: S. Piccardi
26  *
27  * $Id$
28  *
29  ***************************************************************/
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <stdio.h>          /* standard I/O functions */
33 #include <signal.h>         /* signal handling declarations */
34 #include <unistd.h>
35 #include <string.h>
36 #include <errno.h>
37 #include <sys/socket.h>     /* socket function and declaration */
38 #include <netdb.h>          /* resolver functions */
39
40
41 #include "macros.h"
42 /* *************************************************************************
43  *
44  *  Functions for socket address automatic resolution
45  *
46  * ************************************************************************* */
47 /*
48  * Function tcp_socket
49  * Create and attach a SysV shared memory segment to the current process.
50  *
51  * First call get a shared memory segment with KEY key access and size SIZE,
52  * by creating it with R/W privilege for the user (this is the meaning of
53  * the ored flags). The function return an identifier shmid used for any 
54  * further reference to the shared memory segment. 
55  * Second call attach the shared memory segment to this process and return a
56  * pointer to it (of void * type). 
57  * Then initialize shared memory to the given value
58  *
59  * Input:  an host name
60  *         a service name
61  * Return: the IP address of the host in a sockaddr structure
62  */
63 int tcp_addr(char * address, char * service, struct sockaddr * sa) 
64 {
65     struct addrinfo hints = {
66         ai_flag: AI_CANONNAME, 
67         ai_family: PF_UNSPEC,
68         ai_socktype: SOCK_STREAM,
69         ai_protocol: 7
70     }
71     
72
73     /* OK, exit */
74     return 0;
75 }