Aggiunto README e programmino per il test di gethostbyname e getaddrinfo
authorSimone Piccardi <piccardi@gnulinux.it>
Tue, 27 Aug 2002 16:05:04 +0000 (16:05 +0000)
committerSimone Piccardi <piccardi@gnulinux.it>
Tue, 27 Aug 2002 16:05:04 +0000 (16:05 +0000)
README [new file with mode: 0644]
html/index.html
ipc.tex
sources/gethost.c [new file with mode: 0644]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..11dd99d
--- /dev/null
+++ b/README
@@ -0,0 +1,48 @@
+GaPiL - Istruzioni per la "compilazione"
+-------
+
+Dato che il testo e` scritto in LaTeX e` necessario "compilarlo" per
+poter ottenre un formato stampabile.
+
+Dato l'uso intensivo di vari pacchetti e le dimensioni del tutto, per
+poter compilare il testo completo di GaPiL occorre aumentare le
+risorse che LaTeX alloca per il funzionamento, in particolare deve
+essere editato il file texmf.cnf (in /etc/texmf, su Debian) settando i
+seguenti valori:
+
+hash_extra = 10000
+pool_size = 250000
+pool_free = 15000
+stack_size = 500
+
+Fatto questo con make si puo` ottenere tutto. 
+
+A seconda dell'ultima cosa che ho fatto sul CVS si puo` trovare una
+versione di gapil.tex adattata per generare HTML leggibile, piuttosto
+che gli ordinari PS e PDF.
+
+Nel primo caso sono commentate le due righe:
+%\usepackage{mdwlist}              % scommentare per la stampa (PS e PDF)
+%\usepackage{boxedminipage}        % scommentare per la stampa (PS e PDF)
+mentre e` scommentata la riga:
+\include{compatib}    % commentare per la stampa PS e PDF
+
+Di norma make genera le figure (in eps e pdf da dia), purche' si sia
+in X (dia non puo` essere lanciato altrimenti per convertire i .dia in
+.eps), poi passa alla generazione di HTML con latex2html.
+
+
+
+Se si vuole generare PDF o PS occorrono (verificato che gapil.tex e`
+nel formato corretto) i comandi:
+
+PS:
+latex gapil
+dvips gapil
+
+PDF
+pdflatex gapil
+e pigiare invio agli avvertimenti sui colori.
+
+(prima si devono aver generato le figure con make)
+
index 52a7fec43be7ef0e10fdfa93375e847723523514..b2f4b19eeb6f07be4239dbfe54ff68778b2bca88 100644 (file)
@@ -6,7 +6,8 @@
     <META name="title" content="Guida alla Programmazione in Linux">
     <META name="description" content="Un manuale di programmazione avanzata in
       Linux">
     <META name="title" content="Guida alla Programmazione in Linux">
     <META name="description" content="Un manuale di programmazione avanzata in
       Linux">
-    <META name="keywords" content="programmazione, programmazione linux, POSIX ">
+    <META name="keywords" content="programmazione, programmazione linux, 
+      POSIX, programmazione avanzata ">
     <style type="text/css">
 <!--
  a {text-decoration: none;}
     <style type="text/css">
 <!--
  a {text-decoration: none;}
          </td>
          <td bgcolor="lightblue"> 
            <p>
          </td>
          <td bgcolor="lightblue"> 
            <p>
-             <b>19 - agosto - 2002</b> <br> Sedici capitoli, 355 pagine.
+             <b>20 - agosto - 2002</b> <br> Sedici capitoli, 355 pagine.
            </p>
          </td>
        </tr>
            </p>
          </td>
        </tr>
            </b>
          </td>
          <td bgcolor="lightblue"> 
            </b>
          </td>
          <td bgcolor="lightblue"> 
+           <p>
+             <b>20 - agosto - 2002</b> <br> Completata la stesura preliminare
+             del memory mapped I/O, inserito un esempio di server basato
+             sulle FIFO, completata la versione iniziale dell'introduzione
+             al System V IPC.
+           </p>
            <p>
              <b>7 - agosto - 2002</b> <br> Completata la prima stesura delle
              sezioni relative all'I/O asincrono ed ai segnali real-time,
            <p>
              <b>7 - agosto - 2002</b> <br> Completata la prima stesura delle
              sezioni relative all'I/O asincrono ed ai segnali real-time,
            </p>
            <p>
              <b>22 - luglio - 2002</b> <br> Iniziata la stesura del capitolo
            </p>
            <p>
              <b>22 - luglio - 2002</b> <br> Iniziata la stesura del capitolo
-             sull'I/O avanzato. Completata la sezione su pipe e fifo (in
+             sull'I/O avanzato. Completata la sezione su pipe e FIFO (in
              versione preliminare) inziate le sezioni su I/O asincrono ed una
              sezione aggiuntiva sui segnali real-time nel relativo capitolo.
            </p>
              versione preliminare) inziate le sezioni su I/O asincrono ed una
              sezione aggiuntiva sui segnali real-time nel relativo capitolo.
            </p>
diff --git a/ipc.tex b/ipc.tex
index 286cfdd56565fbb3b1be9e4a4c6b4d4dca990dde..6ecd5b161ddb4e9888c93d8b49a4885e941dd77e 100644 (file)
--- a/ipc.tex
+++ b/ipc.tex
@@ -1582,8 +1582,6 @@ server di \textit{fortunes} usando queste al posto delle fifo. In questo caso
 useremo una coda di messaggi, usando il \acr{pid} del client come valore per
 il tipo di messaggio, per restituire indietro le frasi ai client.
 
 useremo una coda di messaggi, usando il \acr{pid} del client come valore per
 il tipo di messaggio, per restituire indietro le frasi ai client.
 
-
-
 \subsection{Semafori}
 \label{sec:ipc_sysv_sem}
 
 \subsection{Semafori}
 \label{sec:ipc_sysv_sem}
 
@@ -1666,6 +1664,8 @@ struct semid_ds
 \end{table}
 
 
 \end{table}
 
 
+
+
 \subsection{Memoria condivisa}
 \label{sec:ipc_sysv_shm}
 
 \subsection{Memoria condivisa}
 \label{sec:ipc_sysv_shm}
 
diff --git a/sources/gethost.c b/sources/gethost.c
new file mode 100644 (file)
index 0000000..3912dd4
--- /dev/null
@@ -0,0 +1,155 @@
+/* gethost.c
+ * 
+ * Copyright (C) 2001 Simone Piccardi
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/****************************************************************
+ *
+ * Program gethost.c: 
+ * Program to test gethostbyname and getaddrinfo
+ *
+ * Author: Simone Piccardi
+ * Aug. 2002
+ *
+ * Usage: gethost -h give all info's
+ *
+ * $Id: gethost.c,v 1.1 2002/08/27 16:05:04 piccardi Exp $
+ *
+ ****************************************************************/
+/* 
+ * Include needed headers
+ */
+#define _GNU_SOURCE
+#include <errno.h>       /* error definitions and routines */ 
+#include <stdlib.h>      /* C standard library */
+#include <unistd.h>      /* unix standard library */
+#include <stdio.h>      /* standard I/O library */
+#include <string.h>      /* string functions */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+/* Help printing routine */
+void usage(void);
+
+int main(int argc, char *argv[])
+{
+/* 
+ * Variables definition  
+ */
+    int i;
+    int use = 0;
+    struct hostent *host;
+    struct in_addr addr;
+    struct addrinfo hint;
+    struct addrinfo *address;
+    struct sockaddr_in *socket;
+    /*
+     * Input section: decode command line parameters 
+     * Use getopt function
+     */
+    opterr = 0;         /* don't want writing to stderr */
+    while ( (i = getopt(argc, argv, "han")) != -1) {
+       switch (i) {
+       /* 
+        * Handling options 
+        */ 
+       case 'h':   /* help option */
+           printf("Wrong -h option use\n");
+           usage();
+           return -1;
+           break;
+       case 'a':   /* help option */
+           use = 1;
+           break;
+       case 'n':   /* help option */
+           use = 0;
+           break;
+       case '?':   /* unrecognized options */
+           printf("Unrecognized options -%c\n",optopt);
+           usage();
+       default:    /* should not reached */
+           usage();
+       }
+    }
+    /* ***********************************************************
+     * 
+     *          Options processing completed
+     *
+     *               Main code beginning
+     * 
+     * ***********************************************************/
+    if ((argc-optind)!= 1)  {
+        printf("From %d arguments, removed %d options\n", argc, optind);
+        usage();
+    }
+    if (use == 0) {
+       host = gethostbyname(argv[optind]);
+       printf("gethostbyname %s\n", argv[optind]);
+       printf("Official host name %s\n", host->h_name);
+       printf("Address Type %d\n", host->h_addrtype);
+       printf("Address Lenght %d\n", host->h_length);
+       addr.s_addr = *( (unsigned long *)host->h_addr);
+       printf("Address  %s\n", inet_ntoa(addr));
+    } else {
+/*     host = getipnodebyname(argv[optind], AF_INET, 0, &i); */
+/*     if (!host) printf("Error\n"); */
+/*     printf("getipnodebyname %s, error %d\n", argv[optind], i); */
+/*     printf("Official host name %s\n", host->h_name); */
+/*     printf("Address Type %d\n", host->h_addrtype); */
+/*     printf("Address Lenght %d\n", host->h_length); */
+/*     addr.s_addr = *( (unsigned long *)host->h_addr); */
+/*     printf("Address  %s\n", inet_ntoa(addr)); */
+       hint.ai_flags = 0;
+       hint.ai_family = PF_INET;
+       hint.ai_socktype = 0;
+       hint.ai_protocol = 0;
+       hint.ai_addrlen = 0;
+       hint.ai_addr = NULL;
+       hint.ai_canonname = NULL;
+       hint.ai_next = NULL;
+       if (i = getaddrinfo(argv[optind], "telnet", &hint, &address)) {
+           printf("getaddrinfo %s = %s \n", argv[optind], gai_strerror(i));
+       } else {
+           printf("Address flag %d\n", address->ai_flags);
+           printf("Address family %d\n", address->ai_family);
+           printf("Address socket type %d\n", address->ai_socktype);
+           printf("Address protocol %d\n", address->ai_protocol);
+           printf("Address lenght %d\n", address->ai_addrlen);
+           printf("Canonical name %s\n", address->ai_canonname);
+           socket = (struct sockaddr_in *) address->ai_addr;
+           printf("Address %s\n", inet_ntoa(socket->sin_addr));
+           printf("Port %d\n", htons(socket->sin_port));
+           printf("Family %d\n", socket->sin_family);
+           
+       }
+    }
+    return 0;
+}
+/*
+ * routine to print usage info and exit
+ */
+void usage(void) {
+    printf("Program gehost: test host name functions  \n");
+    printf("Usage:\n");
+    printf("  gethost [-h] address \n");
+    printf("  -h          print this help\n");
+    printf("  -a          use getaddrinfo\n");
+    printf("  -n          use gethostbyname\n");
+    
+    exit(1);
+}
+