* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
-#include <stdio.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
+#include <stdio.h> /* standard I/O library */
/*
* Program AcctCtrl
#include <stdio.h> /* standard I/O library */
#include <stdlib.h> /* C standard library */
#include <string.h> /* C strings library */
-#include <wait.h>
+#include <wait.h> /* process termination constants and functions */
#include <fcntl.h> /* file control functions */
-#include <assert.h>
+#include <assert.h> /* C assertion functions */
#include <time.h> /* date and time constants, types and functions */
#include"macros.h"
#include <stdio.h> /* standard I/O library */
#include <stdlib.h> /* C standard library */
#include <string.h> /* C strings library */
-#include <wait.h> /* */
+#include <wait.h> /* process termination constants and functions */
#include <fcntl.h> /* file control functions */
-#include <assert.h>
+#include <assert.h> /* C assertion functions */
#include <time.h> /* date and time constants, types and functions */
*
* Author: S. Piccardi Jan. 2003
*
- * $Id: DirMonitor.c,v 1.8 2003/05/02 09:55:13 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
#include "Gapil.h"
#include "macros.h"
*
* Author: S. Piccardi Jan. 2003
*
- * $Id: DirScan.c,v 1.4 2003/05/02 09:55:13 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <stdio.h>
-#include <unistd.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <stdio.h> /* standard I/O library */
+#include <unistd.h> /* unix standard library */
/*
* Function DirScan:
#include <unistd.h> /* unix standard library */
#include <stdio.h> /* standard I/O library */
#include <string.h> /* C strings library */
-#include <limits.h> /* system limits values */
+#include <limits.h> /* system limits constants, types and functions */
/* Help printing routine */
void usage(void);
*
* Usage: flock -h give all info's
*
- * $Id: Flock.c,v 1.5 2003/05/02 09:55:13 piccardi Exp $
- *
*****************************************************************************/
/*
* Include needed headers
/*
* Variables definition
*/
- int type = F_UNLCK; /* lock type: default to unlock (invalid) */
- off_t start = 0; /* start of the locked region: default to 0 */
- off_t len = 0; /* length of the locked region: default to 0 */
- int fd, res, i; /* internal variables */
- int bsd = 0; /* semantic type: default to POSIX */
- int cmd = F_SETLK; /* lock command: default to non-blocking */
- struct flock lock; /* file lock structure */
+ int type = F_UNLCK; /* lock type: default to unlock (invalid) */
+ off_t start = 0; /* start of the locked region: default to 0 */
+ off_t len = 0; /* length of the locked region: default to 0 */
+ int fd, res, i; /* internal variables */
+ int bsd = 0; /* semantic type: default to POSIX */
+ int cmd = F_SETLK; /* lock command: default to non-blocking */
+ struct flock lock; /* file lock structure */
/*
* Input section: decode command line parameters
* Use getopt function
/*
* Handling options
*/
- case 'h': /* help option */
+ case 'h': /* help option */
printf("Wrong -h option use\n");
usage();
return -1;
break;
- case 's': /* take start point of the lock */
- start = strtol(optarg, NULL, 10); /* convert input */
+ case 's': /* take start point of the lock */
+ start = strtol(optarg, NULL, 10); /* convert input */
break;
- case 'l': /* take length of the lock */
- len = strtol(optarg, NULL, 10); /* convert input */
+ case 'l': /* take length of the lock */
+ len = strtol(optarg, NULL, 10); /* convert input */
break;
- case 'w': /* set type to write lock */
+ case 'w': /* set type to write lock */
type = F_WRLCK;
break;
- case 'r': /* set type to read lock */
+ case 'r': /* set type to read lock */
type = F_RDLCK;
break;
- case 'b': /* set lock to blocking */
+ case 'b': /* set lock to blocking */
cmd = F_SETLKW;
break;
- case 'f': /* enable BSD semantic */
+ case 'f': /* enable BSD semantic */
bsd = 1;
break;
- case '?': /* unrecognized options */
+ case '?': /* unrecognized options */
printf("Unrecognized options -%c\n",optopt);
usage();
- default: /* should not reached */
+ default: /* should not reached */
usage();
}
}
* Main code beginning
*
* ***********************************************************/
- if ((argc - optind) != 1) { /* There must be remaing parameters */
+ if ((argc - optind) != 1) { /* There must be remaing parameters */
printf("Wrong number of arguments %d\n", argc - optind);
usage();
}
- if (type == F_UNLCK) { /* There must be a -w or -r option set */
+ if (type == F_UNLCK) { /* There must be a -w or -r option set */
printf("You should set a read or a write lock\n");
usage();
}
- fd = open(argv[optind], O_RDONLY); /* open the file to be locked */
- if (fd < 0) { /* on error exit */
+ fd = open(argv[optind], O_RDONLY); /* open the file to be locked */
+ if (fd < 0) { /* on error exit */
perror("Wrong filename");
exit(1);
}
/* do lock */
- if (bsd) { /* if BSD locking */
+ if (bsd) { /* BSD locking */
/* rewrite cmd for suitables flock operation values */
- if (cmd == F_SETLK) { /* if no-blocking */
- cmd = LOCK_NB; /* set the value for flock operation */
- } else { /* else */
- cmd = 0; /* default is null */
+ if (cmd == F_SETLK) { /* if no-blocking set for flock operation */
+ cmd = LOCK_NB;
+ } else { /* else default is null */
+ cmd = 0;
}
- if (type == F_RDLCK) cmd |= LOCK_SH; /* set for shared lock */
- if (type == F_WRLCK) cmd |= LOCK_EX; /* set for exclusive lock */
- res = flock(fd, cmd); /* esecute lock */
- } else { /* if POSIX locking */
+ if (type == F_RDLCK) cmd |= LOCK_SH; /* set for shared lock */
+ if (type == F_WRLCK) cmd |= LOCK_EX; /* set for exclusive lock */
+ res = flock(fd, cmd); /* esecute lock */
+ } else { /* POSIX locking */
/* setting flock structure */
- lock.l_type = type; /* set type: read or write */
+ lock.l_type = type; /* set type: read or write */
lock.l_whence = SEEK_SET; /* start from the beginning of the file */
- lock.l_start = start; /* set the start of the locked region */
- lock.l_len = len; /* set the length of the locked region */
- res = fcntl(fd, cmd, &lock); /* do lock */
+ lock.l_start = start; /* set the start of the locked region */
+ lock.l_len = len; /* set the length of the locked region */
+ res = fcntl(fd, cmd, &lock); /* do lock */
}
/* check lock results */
- if (res) { /* on error exit */
+ if (res) { /* on error exit */
perror("Failed lock");
exit(1);
- } else { /* else write message */
+ } else { /* else write message */
printf("Lock acquired\n");
}
- pause(); /* stop the process, use a signal to exit */
+ pause(); /* stop the process, use a signal to exit */
return 0;
}
/*
*
* Usage: forktest -h give all info's
*
- * $Id: ForkTest.c,v 1.10 2003/05/02 09:55:13 piccardi Exp $
- *
****************************************************************/
/*
* Include needed headers
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
#include <stdio.h> /* standard I/O library */
-#include <errno.h>> /* error definitions and routines */
+#include <stdlib.h> /* C standard library */
+#include <errno.h> /* error definitions and routines */
#include <fcntl.h> /* file control functions */
+#include <string.h> /* C strings library */
+#include <limits.h> /* system limits constants, types and functions */
#include "macros.h"
* Main code beginning
*
* ***********************************************************/
- snprintf(fifoname, 80, "/tmp/fortune.%d", getpid()); /* compose name */
- if (mkfifo(fifoname, 0622)) { /* open client fifo */
+ snprintf(fifoname, 80, "/tmp/fortune.%d", getpid()); /* compose name */
+ if (mkfifo(fifoname, 0622)) { /* open client fifo */
if (errno!=EEXIST) {
perror("Cannot create well known fifo");
exit(-1);
}
}
- fifo_server = open(fortunefilename, O_WRONLY); /* open server fifo */
+ fifo_server = open(fortunefilename, O_WRONLY); /* open server fifo */
if (fifo_server < 0) {
perror("Cannot open well known fifo");
exit(-1);
}
debug("%s\n", fifoname);
nread = write(fifo_server, fifoname, strlen(fifoname)+1); /* write name */
- close(fifo_server); /* close server fifo */
- fifo_client = open(fifoname, O_RDONLY); /* open client fifo */
+ close(fifo_server); /* close server fifo */
+ fifo_client = open(fifoname, O_RDONLY); /* open client fifo */
if (fifo_client < 0) {
perror("Cannot open well known fifo");
exit(-1);
}
- nread = read(fifo_client, buffer, sizeof(buffer)); /* read answer */
- printf("%s", buffer); /* print fortune */
- close(fifo_client); /* close client */
+ nread = read(fifo_client, buffer, sizeof(buffer)); /* read answer */
+ printf("%s", buffer); /* print fortune */
+ close(fifo_client); /* close client */
unlink(fifoname); /* remove client fifo */
}
/*
* routine to print usage info and exit
*/
void usage(void) {
- printf("Elementary fortune server\n");
+ printf("Elementary fortune client\n");
printf("Usage:\n");
- printf(" fortune [-h] [-f] \n");
+ printf(" fortune [-h] \n");
printf(" -h print this help\n");
- printf(" -f filename set file for fortunes\n");
exit(1);
}
/*
* Include needed headers
*/
-#include <sys/types.h> /* predefined types */
+#include <sys/types.h> /* primitive system data types */
#include <sys/stat.h> /* file characteristics constants and functions */
#include <unistd.h> /* unix standard library */
#include <stdio.h> /* standard I/O library */
* Author: Simone Piccardi
* Jun. 2001
*
- * $Id: FullRead.c,v 1.4 2003/07/27 23:41:04 piccardi Exp $
- *
****************************************************************/
-#include <unistd.h>
-#include <errno.h>
+#include <unistd.h> /* unix standard library */
+#include <errno.h> /* error definitions and routines */
ssize_t FullRead(int fd, void *buf, size_t count)
{
* Author: Simone Piccardi
* Jun. 2001
*
- * $Id: FullWrite.c,v 1.4 2003/07/27 23:41:04 piccardi Exp $
- *
****************************************************************/
-#include <unistd.h>
-#include <errno.h>
+#include <unistd.h> /* unix standard library */
+#include <errno.h> /* error definitions and routines */
ssize_t FullWrite(int fd, const void *buf, size_t count)
{
*
* Author: S. Piccardi, Dec 2002
*
- * $Id: LockFile.c,v 1.4 2003/05/02 09:55:14 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h> /* unix standard functions */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <unistd.h> /* unix standard library */
#include <fcntl.h> /* file control functions */
/*
* Function LockFile:
*
* Author: S. Piccardi Dec. 2002
*
- * $Id: Mutex.c,v 1.7 2003/05/02 09:55:14 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/sem.h> /* IPC semaphore declarations */
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <sys/sem.h> /* SysV semaphores */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
#include <fcntl.h> /* file control functions */
-#include <signal.h> /* signal handling declarations */
+#include <signal.h> /* signal constants, types and functions */
#include "Gapil.h"
/*
*
* Author: S. Piccardi Jan. 2003
*
- * $Id: PXDirMonitor.c,v 1.1 2003/05/02 09:50:55 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
#include "Gapil.h"
#include "macros.h"
*
* Author: S. Piccardi Jan. 2003
*
- * $Id: ReadMonitor.c,v 1.5 2003/05/02 09:55:14 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
#include "Gapil.h"
#include "macros.h"
* Author: Simone Piccardi
* Jun. 2001
*
- * $Id: SetTermAttr.c,v 1.3 2003/05/02 09:55:14 piccardi Exp $
- *
****************************************************************/
-#include <unistd.h>
-#include <termios.h>
-#include <errno.h>
+#include <unistd.h> /* unix standard library */
+#include <termios.h> /* terminals constants, types and functions */
+#include <errno.h> /* error definitions and routines */
int SetTermAttr(int fd, tcflag_t flag)
{
* Author: S. Piccardi
*
***************************************************************/
-#include <sys/shm.h> /* SysV IPC shared memory */
-#include <sys/types.h> /* primitive system data types */
-#include <sys/stat.h>
-#include <stdio.h> /* standard I/O functions */
-#include <fcntl.h> /* file control functions */
-#include <signal.h> /* signal constants, types and functions */
-#include <unistd.h> /* unix standard library */
+#include <sys/shm.h> /* SysV shared memory */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <stdio.h> /* standard I/O library */
+#include <fcntl.h> /* file control functions */
+#include <signal.h> /* signal constants, types and functions */
+#include <unistd.h> /* unix standard library */
#include <sys/mman.h>
-#include <string.h> /* C strings library */
-#include <errno.h> /* error definitions and routines */
+#include <string.h> /* C strings library */
+#include <errno.h> /* error definitions and routines */
#include "macros.h"
/* *************************************************************************
*
* Author: S. Piccardi Dec. 2002
*
- * $Id: SigHand.c,v 1.7 2003/05/06 14:05:12 piccardi Exp $
- *
*****************************************************************************/
-#include <errno.h> /* error simbol definitions */
-#include <stdio.h> /* standard I/O functions */
-#include <signal.h> /* signal handling declarations */
-#include <sys/types.h>
-#include <sys/wait.h>
+#include <errno.h> /* error definitions and routines */
+#include <stdio.h> /* standard I/O library */
+#include <signal.h> /* signal constants, types and functions */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/wait.h> /* process termination constants and functions */
#include "Gapil.h"
#include "macros.h"
* Generic handler for SIGCHLD signal
*
* Simone Piccardi Dec. 2002
- * $Id: SigHand.c,v 1.7 2003/05/06 14:05:12 piccardi Exp $
*/
void HandSigCHLD(int sig)
{
* Include needed headers
*/
#include <unistd.h> /* unix standard library */
-#include <signal.h> /* POSIX signal library */
+#include <signal.h> /* signal constants, types and functions */
void alarm_hand(int);
#include <string.h> /* C strings library */
#include <errno.h> /* error definitions and routines */
#include <sys/socket.h> /* socket constants, types and functions */
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netdb.h>
+#include <arpa/inet.h> /* IP addresses conversion utilities */
+#include <netdb.h> /* C resolver library */
#include "macros.h"
/**************************************************************************
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <errno.h> /* error definitions and routines */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <errno.h> /* error definitions and routines */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <errno.h> /* error definitions and routines */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <errno.h> /* error definitions and routines */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <errno.h> /* error definitions and routines */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
#include <syslog.h> /* syslog system functions */
-#include <signal.h> /* signal functions */
+#include <signal.h> /* signal constants, types and functions */
#include <errno.h> /* error definitions and routines */
#include <string.h> /* C strings library */
#include <stdlib.h> /* C standard library */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
*
* File WriteShm.c:
*
- * An example of POSIX shared memory use: wwrite some content to a
+ * An example of POSIX shared memory use: write some content to a
* shared memory segment
*
* Author: S. Piccardi Jan. 2003
*
*****************************************************************************/
-#include <sys/types.h> /* primitive system data types */
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h> /* unix standard library */
-#include <stdio.h> /* standard I/O library */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
+#include <stdio.h> /* standard I/O library */
#include "Gapil.h"
#include "macros.h"
/*
* Handling options
*/
- case 's': /* set pause (in sec.) */
+ case 's': /* set pause (in sec.) */
size = strtol(optarg, NULL, 10);
break;
- case 'f': /* set pause (in sec.) */
+ case 'f': /* set pause (in sec.) */
file_name = optarg;
break;
- case 'h': /* help option */
+ case 'h': /* help option */
printf("Wrong -h option use\n");
usage();
return -1;
break;
- case '?': /* unrecognized options */
+ case '?': /* unrecognized options */
printf("Unrecognized options -%c\n",optopt);
usage();
- default: /* should not reached */
+ default: /* should not reached */
usage();
}
}
* Main code beginning
*
* ***********************************************************/
- if ((argc - optind) != 1) { /* There must be remaing parameters */
+ if ((argc - optind) != 1) { /* There must be remaing parameters */
printf("Wrong number of arguments %d\n", argc - optind);
usage();
}
+ /* get a Mutex */
mutex_file = tempnam("/tmp","mutex");
- if ((mutex = CreateMutex(mutex_file)) == -1) { /* get a Mutex */
+ if ((mutex = CreateMutex(mutex_file)) == -1) {
perror("Cannot create mutex");
goto errmutex;
}
* Author: S. Piccardi Dec. 2005
*
*****************************************************************************/
-#include <stdlib.h> /* C standard library */
-#include <stdio.h> /* I/O standard library */
-#include <unistd.h>
+#include <stdlib.h> /* C standard library */
+#include <stdio.h> /* standard I/O library */
+#include <unistd.h> /* unix standard library */
#include <sys/capability.h>
/*
* Author: S. Piccardi
* May. 2003
*
- * $Id: endian.c,v 1.5 2003/08/16 18:30:21 piccardi Exp $
- *
***************************************************************/
int endian(void)
-#include<stdio.h>
+/* endtest.c
+ *
+ * Copyright (C) 2003 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 endtest: program to detect endianess
+ *
+ * Author: S. Piccardi
+ * May. 2003
+ *
+ ***************************************************************/
+
+#include<stdio.h> /* standard I/O library */
+
int main(int argc, char *argv[])
{
int i, val = 0xABCDEF01;
#include <sys/inotify.h> /* Linux inotify interface */
#include <sys/epoll.h> /* Linux epoll interface */
#include <stdlib.h> /* C standard library */
-#include <unistd.h> /* Unix standard library */
+#include <unistd.h> /* unix standard library */
#include <errno.h> /* error definitions and routines */
#include <stdio.h> /* standard I/O library */
#include <string.h> /* C strings library */
#include <fcntl.h> /* file control function */
-#include <sys/ioctl.h> /* ioctl function */
+#include <sys/ioctl.h> /* ioctl syscall and constants */
#include "macros.h"
* Author: Simone Piccardi
* Mar. 2005
*
- * $Id$
- *
****************************************************************/
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h> /* include standard I/O library */
+#include <unistd.h> /* unix standard library */
+#include <errno.h> /* error definitions and routines */
+#include <stdio.h> /* standard I/O library */
size_t full_fread(FILE *file, void *buf, size_t count)
{
* Author: Simone Piccardi
* Mar. 2005
*
- * $Id$
- *
****************************************************************/
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h> /* include standard I/O library */
+#include <unistd.h> /* unix standard library */
+#include <errno.h> /* error definitions and routines */
+#include <stdio.h> /* standard I/O library */
size_t full_fwrite(FILE *file, const void *buf, size_t count)
{
/* gethost.c
*
- * Copyright (C) 2001 Simone Piccardi
+ * Copyright (C) 2005 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
#include <string.h> /* C strings library */
#include <sys/types.h> /* primitive system data types */
#include <sys/socket.h> /* socket constants, types and functions */
-#include <netdb.h>
+#include <netdb.h> /* C resolver library */
-/* Help printing routine */
-void usage(void);
-int main(int argc, char *argv[])
-{
/*
- * Variables definition
+ * Function and globals definitions
+ */
+void usage(void); /* Help printing routine */
+
+/*
+ * Main program
*/
+int main(int argc, char *argv[])
+{
+ /*
+ * Variables definition
+ */
int i;
int use = 0;
struct hostent *host;
#include <stdlib.h> /* C standard library */
#include <unistd.h> /* unix standard library */
#include <string.h> /* C strings library */
-#include <limits.h>
+#include <limits.h> /* system limits constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
* Author: S. Piccardi Sep. 2006
*
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h> /* C standard library */
-#include <stdio.h> /* I/O standard library */
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <arpa/inet.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <stdio.h> /* standard I/O library */
+#include <unistd.h> /* unix standard library */
+#include <sys/socket.h> /* socket constants, types and functions */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
+#include <sys/ioctl.h> /* ioctl syscall and constants */
+#include <net/if.h> /* network interfaces constants and types */
/*
* Program iflist
#include <sys/stat.h> /* file characteristics constants and functions */
#include <sys/inotify.h> /* Linux inotify interface */
#include <stdlib.h> /* C standard library */
-#include <unistd.h> /* Unix standard library */
+#include <unistd.h> /* unix standard library */
#include <errno.h> /* error definitions and routines */
#include <stdio.h> /* standard I/O library */
#include <string.h> /* C strings library */
#include <fcntl.h> /* file control functions */
-#include <sys/ioctl.h> /* ioctl function */
+#include <sys/ioctl.h> /* ioctl syscall and constants */
#include "macros.h"
* Author: Simone Piccardi
* Sep. 2006
*
- * $Id$
- *
****************************************************************/
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <errno.h> /* error code */
+#include <sys/socket.h> /* socket constants, types and functions */
+#include <netinet/in.h> /* IPv4 and IPv6 constants and types */
+#include <netinet/tcp.h> /* TCP constants and types */
+#include <errno.h> /* error definitions and routines */
#
int is_closing(int sock)
{
#include <sys/stat.h> /* file characteristics constants and functions */
#include <unistd.h> /* unix standard library */
#include <stdlib.h> /* C standard library */
-#include <stdio.h> /* I/O standard library */
-#include <arpa/inet.h>
+#include <stdio.h> /* standard I/O library */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
-#include <netinet/in.h>
-#include <netdb.h>
+#include <netinet/in.h> /* IPv4 and IPv6 constants and types */
+#include <netdb.h> /* C resolver library */
#include "Gapil.h"
/*
#include <sys/types.h> /* primitive system data types */
#include <sys/stat.h> /* file characteristics constants and functions */
#include <stdlib.h> /* C standard library */
-#include <stdio.h> /* I/O standard library */
+#include <stdio.h> /* standard I/O library */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h>
-#include <netdb.h>
+#include <arpa/inet.h> /* IP addresses conversion utilities */
+#include <netdb.h> /* C resolver library */
*
* Author: S. Piccardi Jan. 2003
*
- * $Id: myls.c,v 1.4 2003/05/02 09:55:14 piccardi Exp $
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
#include "Gapil.h"
/*
*/
/*****************************************************************************
*
- * File myls.c: An example ls done after a chroot
+ * File mylschroot.c: An example ls done after a chroot
+ * List files and their size inside a given directory inside a chroot
*
* Author: S. Piccardi Mar. 2005
*
- * $Id$
- *
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h>
+/*
+ * Include needed headers
+ */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
#include "Gapil.h"
-/*
- * Program myls
- *
- * List files and their size inside a given directory
+
+/*
+ * Function and globals definitions
*/
-/* Help printing routine */
-void usage(void);
-/* computation function for DirScan */
-int do_ls(struct dirent * direntry);
+void usage(void); /* Help printing routine */
+int do_ls(struct dirent * direntry); /* computation function for DirScan */
+/*
+ * Main program
+ */
int main(int argc, char *argv[])
{
int i;
* Include needed headers
*/
#define _XOPEN_SOURCE
-#include <limits.h> /* system limits */
+#include <limits.h> /* system limits constants, types and functions */
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
*
* Usage: echod -h give all info
*
- * $Id: select_echod.c,v 1.2 2003/12/25 22:16:06 piccardi Exp $
- *
****************************************************************/
/*
* Include needed headers
*/
#include <sys/types.h> /* primitive system data types */
#include <unistd.h> /* unix standard library */
-#include <arpa/inet.h> /* IP addresses conversion utiliites */
+#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
#define _GNU_SOURCE
#include <sys/types.h> /* primitive system data types */
#include <sys/stat.h> /* file characteristics constants and functions */
-#include <unistd.h> /* unix standard library */
#include <stdlib.h> /* C standard library */
+#include <stdio.h> /* standard I/O library */
+#include <unistd.h> /* unix standard library */
#include <arpa/inet.h> /* IP addresses conversion utilities */
#include <sys/socket.h> /* socket constants, types and functions */
-#include <stdio.h> /* standard I/O library */
#include <time.h> /* date and time constants, types and functions */
#include <syslog.h> /* syslog system functions */
#include <signal.h> /* signal constants, types and functions */
#include <errno.h> /* error definitions and routines */
#include <string.h> /* C strings library */
+#include <dirent.h> /* directory operation constants and functions */
#include "Gapil.h"
+/*
+ * Function and globals definitions
+ */
#define BACKLOG 10
#define MAXLINE 256
int demonize = 1; /* daemon use option: default is daemon */
int debugging = 0; /* debug info printing option: default is no debug */
-
-/* Subroutines declaration */
struct code_page {
char * code;
char * name;
void print_headers(FILE *file, struct code_page code);
void print_error(FILE *file, struct code_page page, char * string);
-/* Program beginning */
-int main(int argc, char *argv[])
+/*
+ * Main program
+ */int main(int argc, char *argv[])
{
-/*
- * Variables definition
- */
+ /*
+ * Variables definition
+ */
int list_fd, conn_fd;
int compat = 0;
int reroot = 0;