summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-05-05 10:11:59 -0700
committerH. Peter Anvin <hpa@zytor.com>2011-05-05 10:11:59 -0700
commitad5aab9281b6d67b77537b4aabfe5bc070e7fe99 (patch)
treea21112bd6d5aefa846972c139a422419a2c2693c
parent0b5732e263fa439906b298cdcab8f2dba3f93ce4 (diff)
downloadtftp-hpa-ad5aab9281b6d67b77537b4aabfe5bc070e7fe99.tar.gz
tftpd: constipate struct formats
struct formats should be static const; make it so and mark all users const. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--tftpd/tftpd.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index bdbea6d..1f946f6 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -1023,18 +1023,19 @@ int main(int argc, char **argv)
}
static char *rewrite_access(char *, int, const char **);
-static int validate_access(char *, int, struct formats *, const char **);
-static void tftp_sendfile(struct formats *, struct tftphdr *, int);
-static void tftp_recvfile(struct formats *, struct tftphdr *, int);
+static int validate_access(char *, int, const struct formats *, const char **);
+static void tftp_sendfile(const struct formats *, struct tftphdr *, int);
+static void tftp_recvfile(const struct formats *, struct tftphdr *, int);
struct formats {
const char *f_mode;
char *(*f_rewrite) (char *, int, const char **);
- int (*f_validate) (char *, int, struct formats *, const char **);
- void (*f_send) (struct formats *, struct tftphdr *, int);
- void (*f_recv) (struct formats *, struct tftphdr *, int);
+ int (*f_validate) (char *, int, const struct formats *, const char **);
+ void (*f_send) (const struct formats *, struct tftphdr *, int);
+ void (*f_recv) (const struct formats *, struct tftphdr *, int);
int f_convert;
-} formats[] = {
+};
+static const struct formats formats[] = {
{
"netascii", rewrite_access, validate_access, tftp_sendfile,
tftp_recvfile, 1}, {
@@ -1050,7 +1051,7 @@ int tftp(struct tftphdr *tp, int size)
{
char *cp, *end;
int argn, ecode;
- struct formats *pf = NULL;
+ const struct formats *pf = NULL;
char *origfilename;
char *filename, *mode = NULL;
const char *errmsgptr;
@@ -1418,7 +1419,7 @@ static FILE *file;
* given as we have no login directory.
*/
static int validate_access(char *filename, int mode,
- struct formats *pf, const char **errmsg)
+ const struct formats *pf, const char **errmsg)
{
struct stat stbuf;
int i, len;
@@ -1526,7 +1527,7 @@ static int validate_access(char *filename, int mode,
/*
* Send the requested file.
*/
-static void tftp_sendfile(struct formats *pf, struct tftphdr *oap, int oacklen)
+static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen)
{
struct tftphdr *dp;
struct tftphdr *ap; /* ack packet */
@@ -1624,7 +1625,7 @@ static void tftp_sendfile(struct formats *pf, struct tftphdr *oap, int oacklen)
/*
* Receive a file.
*/
-static void tftp_recvfile(struct formats *pf, struct tftphdr *oap, int oacklen)
+static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oacklen)
{
struct tftphdr *dp;
int n, size;