*/
#define OPTHELP(NOVAL, VAL, SHORT, LONG, HELPPFX, HELPARG, HELPLINE, HELPOPT) \
- HELPPFX("usage") HELPLINE("agedu [options] action [action...]") \
+ HELPPFX("usage") HELPLINE(PNAME " [options] action [action...]") \
HELPPFX("actions") \
VAL(SCAN) SHORT(s) LONG(scan) \
HELPARG("directory") HELPOPT("scan and index a directory") \
triewalk *tw;
indexbuild *ib;
const struct trie_file *tf;
- char *filename = "agedu.dat";
+ char *filename = PNAME ".dat";
int doing_opts = 1;
enum { TEXT, HTML, SCAN, DUMP, SCANDUMP, LOAD, HTTPD };
struct action {
auth = HTTPD_AUTH_MAGIC | HTTPD_AUTH_BASIC;
else if (!strcmp(optval, "help") ||
!strcmp(optval, "list")) {
- printf("agedu: supported HTTP authentication types"
+ printf(PNAME ": supported HTTP authentication types"
" are:\n"
" magic use Linux /proc/net/tcp to"
" determine owner of peer socket\n"
char *buf = fgetline(stdin);
unsigned newpathsep;
buf[strcspn(buf, "\r\n")] = '\0';
- if (1 != sscanf(buf, "agedu dump file. pathsep=%x",
+ if (1 != sscanf(buf, DUMPHDR "%x",
&newpathsep)) {
fprintf(stderr, "%s: header in dump file not recognised\n",
PNAME);
return 1;
}
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
ctx->datafile_dev = st.st_dev;
}
if (mode == SCANDUMP)
- printf("agedu dump file. pathsep=%02x\n", (unsigned char)pathsep);
+ printf(DUMPHDR "%02x\n", (unsigned char)pathsep);
/*
* Scan the directory tree, and write out the trie component
* will take; enlarge the file, and memory-map it.
*/
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
totalsize = index_compute_size(st.st_size, count);
if (lseek(fd, totalsize-1, SEEK_SET) < 0) {
- perror("agedu: lseek");
+ perror(PNAME ": lseek");
return 1;
}
if (write(fd, "\0", 1) < 1) {
- perror("agedu: write");
+ perror(PNAME ": write");
return 1;
}
mappedfile = mmap(NULL, totalsize, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0);
if (!mappedfile) {
- perror("agedu: mmap");
+ perror(PNAME ": mmap");
return 1;
}
return 1;
}
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
totalsize = st.st_size;
mappedfile = mmap(NULL, totalsize, PROT_READ, MAP_SHARED, fd, 0);
if (!mappedfile) {
- perror("agedu: mmap");
+ perror(PNAME ": mmap");
return 1;
}
pathsep = trie_pathsep(mappedfile);
return 1;
}
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
totalsize = st.st_size;
mappedfile = mmap(NULL, totalsize, PROT_READ, MAP_SHARED, fd, 0);
if (!mappedfile) {
- perror("agedu: mmap");
+ perror(PNAME ": mmap");
return 1;
}
pathsep = trie_pathsep(mappedfile);
return 1;
}
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
totalsize = st.st_size;
mappedfile = mmap(NULL, totalsize, PROT_READ, MAP_SHARED, fd, 0);
if (!mappedfile) {
- perror("agedu: mmap");
+ perror(PNAME ": mmap");
return 1;
}
pathsep = trie_pathsep(mappedfile);
maxpathlen = trie_maxpathlen(mappedfile);
buf = snewn(maxpathlen, char);
- printf("agedu dump file. pathsep=%02x\n", (unsigned char)pathsep);
+ printf(DUMPHDR "%02x\n", (unsigned char)pathsep);
tw = triewalk_new(mappedfile);
while ((tf = triewalk_next(tw, buf)) != NULL)
dump_line(buf, tf);
return 1;
}
if (fstat(fd, &st) < 0) {
- perror("agedu: fstat");
+ perror(PNAME ": fstat");
return 1;
}
totalsize = st.st_size;
mappedfile = mmap(NULL, totalsize, PROT_READ, MAP_SHARED, fd, 0);
if (!mappedfile) {
- perror("agedu: mmap");
+ perror(PNAME ": mmap");
return 1;
}
pathsep = trie_pathsep(mappedfile);
#include <netinet/in.h>
#include <syslog.h>
+#include "agedu.h"
#include "malloc.h"
#include "html.h"
#include "httpd.h"
{
return dupfmt("HTTP/1.1 %s %s\r\n"
"Date: %D\r\n"
- "Server: agedu\r\n"
+ "Server: " PNAME "\r\n"
"Connection: close\r\n"
"%s"
"Content-Type: text/html; charset=US-ASCII\r\n"
return dupfmt("HTTP/1.1 200 OK\r\n"
"Date: %D\r\n"
"Expires: %D\r\n"
- "Server: agedu\r\n"
+ "Server: " PNAME "\r\n"
"Connection: close\r\n"
"Content-Type: %s\r\n"
"\r\n"
/* Restore the request to the way we received it. */
*z2 = c2;
*z1 = c1;
- text = dupfmt("<code>agedu</code> received the HTTP request"
+ text = dupfmt("<code>" PNAME "</code> received the HTTP request"
" \"<code>%h</code>\", which contains no URL.",
line);
ret = http_error("400", "Bad request", NULL, text);
if (!magic_access && !auth_correct) {
if (auth_string && !auth_provided) {
ret = http_error("401", "Unauthorized",
- "WWW-Authenticate: Basic realm=\"agedu\"\r\n",
- "Please authenticate to view these pages.");
+ "WWW-Authenticate: Basic realm=\""PNAME"\"\r",
+ "\nPlease authenticate to view these pages.");
} else {
ret = http_error("403", "Forbidden", NULL,
"This is a restricted-access set of pages.");
if (dcfg->basicauthdata) {
userpass = dcfg->basicauthdata;
} else {
- sprintf(username, "agedu");
+ strcpy(username, PNAME);
rname = "/dev/urandom";
fd = open(rname, O_RDONLY);
if (fd < 0) {
if (authmask != HTTPD_AUTH_NONE)
printf("Web server is unauthenticated\n");
} else {
- fprintf(stderr, "agedu: authentication method not supported\n");
+ fprintf(stderr, PNAME ": authentication method not supported\n");
exit(1);
}
if (!dcfg->address) {