Major overhaul of the portability stuff; port to autoconf 2.52

This commit is contained in:
hpa 2001-11-12 10:03:04 +00:00
parent 4c0a635276
commit 2c31169f57
16 changed files with 236 additions and 176 deletions

View file

@ -1,5 +1,7 @@
all: tftpd
SRCROOT = ..
-include ../MCONFIG
include ../MRULES

View file

@ -15,9 +15,9 @@
* Minor help routines.
*/
#include "config.h" /* Must be included first! */
#include <syslog.h>
#include <signal.h>
#include <string.h>
#include "tftpd.h"
/*

View file

@ -18,19 +18,7 @@
*
*/
#define _XPG4_2 /* Needed on Solaris */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "../config.h"
#include "config.h" /* Must be included first! */
#include "recvfrom.h"
#include "tftpsubs.h"

View file

@ -15,20 +15,16 @@
* Perform regular-expression based filename remapping.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "config.h" /* Must be included first! */
#include <ctype.h>
#include <syslog.h>
#include <sys/types.h> /* FreeBSD 3.3 need this before regex.h */
#include <regex.h>
#include <syslog.h>
#include "tftpd.h"
#include "remap.h"
#define DEADMAN_MAX_STEPS 1024 /* Timeout after this many steps */
#define LINE_MAX 16384 /* Truncate a line at this many bytes */
#define MAXLINE 16384 /* Truncate a line at this many bytes */
#define RULE_REWRITE 0x01 /* This is a rewrite rule */
#define RULE_GLOBAL 0x02 /* Global rule (repeat until no match) */
@ -134,7 +130,7 @@ static int readescstring(char *buf, char **str)
/* Parse a line into a set of instructions */
static int parseline(char *line, struct rule *r, int lineno)
{
char buffer[LINE_MAX];
char buffer[MAXLINE];
char *p;
int rv;
int rxflags = REG_EXTENDED;
@ -211,7 +207,7 @@ static int parseline(char *line, struct rule *r, int lineno)
/* Read a rule file */
struct rule *parserulefile(FILE *f)
{
char line[LINE_MAX];
char line[MAXLINE];
struct rule *first_rule = NULL;
struct rule **last_rule = &first_rule;
struct rule *this_rule = tfmalloc(sizeof(struct rule));
@ -219,7 +215,7 @@ struct rule *parserulefile(FILE *f)
int lineno = 0;
int err = 0;
while ( lineno++, fgets(line, LINE_MAX, f) ) {
while ( lineno++, fgets(line, MAXLINE, f) ) {
rv = parseline(line, this_rule, lineno);
if ( rv < 0 )
err = 1;

View file

@ -35,6 +35,7 @@
* SUCH DAMAGE.
*/
#include "config.h" /* Must be included first */
#include "tftpd.h"
#ifndef lint
@ -203,7 +204,7 @@ main(int argc, char **argv)
int fd = 0;
int standalone = 0; /* Standalone (listen) mode */
char *address = NULL; /* Address to listen to */
int pid;
pid_t pid;
int c;
int setrv;
int waittime = 900; /* Default time to wait for a connect*/
@ -218,7 +219,7 @@ main(int argc, char **argv)
p = strrchr(argv[0], '/');
__progname = (p && p[1]) ? p+1 : argv[0];
openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
openlog(__progname, LOG_PID|LOG_NDELAY, LOG_DAEMON);
while ((c = getopt(argc, argv, "csvla:u:r:t:m:")) != -1)
switch (c) {
@ -358,7 +359,7 @@ main(int argc, char **argv)
/* Daemonize this process */
{
int f = fork();
pid_t f = fork();
if ( f > 0 )
exit(0);
if ( f < 0 ) {

View file

@ -18,45 +18,10 @@
#ifndef TFTPD_TFTPD_H
#define TFTPD_TFTPD_H
#include <stdlib.h>
#include <stdio.h>
#include "../config.h"
#ifdef HAVE_SYSEXITS_H
#include <sysexits.h>
#else
#define EX_USAGE 64 /* command line usage error */
#define EX_DATAERR 65 /* data format error */
#define EX_NOINPUT 66 /* cannot open input */
#define EX_NOUSER 67 /* addressee unknown */
#define EX_NOHOST 68 /* host name unknown */
#define EX_UNAVAILABLE 69 /* service unavailable */
#define EX_SOFTWARE 70 /* internal software error */
#define EX_OSERR 71 /* system error (e.g., can't fork) */
#define EX_OSFILE 72 /* critical OS file missing */
#define EX_CANTCREAT 73 /* can't create (user) output file */
#define EX_IOERR 74 /* input/output error */
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
#define EX_PROTOCOL 76 /* remote error in protocol */
#define EX_NOPERM 77 /* permission denied */
#define EX_CONFIG 78 /* configuration error */
#endif
#ifndef HAVE_SIGSETJMP
#define sigsetjmp(x,y) setjmp(x)
#define siglongjmp(x,y) longjmp(x,y)
#define sigjmp_buf jmp_buf
#endif
void set_signal(int, void (*)(int), int);
void *tfmalloc(size_t);
char *tfstrdup(const char *);
extern int verbosity;
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
#endif