Remove database iterator, no longer useful after the MIME database change. Proposed by oa.
This commit is contained in:
parent
b3bb3b2f91
commit
a05fdee016
1 changed files with 5 additions and 5 deletions
10
main.c
10
main.c
|
@ -32,15 +32,14 @@ status(const int code, const char *file_mime, const char *lang)
|
||||||
void
|
void
|
||||||
get_file_mime(const char *path, char *type, const ssize_t type_size)
|
get_file_mime(const char *path, char *type, const ssize_t type_size)
|
||||||
{
|
{
|
||||||
struct mimes *iterator = database;
|
|
||||||
char *extension;
|
char *extension;
|
||||||
|
|
||||||
extension = strrchr(path, '.');
|
extension = strrchr(path, '.');
|
||||||
|
|
||||||
/* look for the MIME in the database */
|
/* look for the MIME in the database */
|
||||||
for (int i = 0; i < sizeof(database) / sizeof(struct mimes); i++, iterator++) {
|
for (int i = 0; i < sizeof(database) / sizeof(struct mimes); i++) {
|
||||||
if (strcmp(iterator->extension, extension + 1) == 0) {
|
if (strcmp(database[i].extension, extension + 1) == 0) {
|
||||||
strlcpy(type, iterator->type, type_size);
|
strlcpy(type, database[i].type, type_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +78,7 @@ display_file(const char *path, const char *lang)
|
||||||
fwrite(buffer, sizeof(char), nread, stdout);
|
fwrite(buffer, sizeof(char), nread, stdout);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
} else {
|
} else {
|
||||||
|
/* return an error code and no content */
|
||||||
status(40, "text/gemini", lang);
|
status(40, "text/gemini", lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,10 +94,10 @@ main(int argc, char **argv)
|
||||||
char path [BUFF_LEN_2] = DEFAULT_CHROOT;
|
char path [BUFF_LEN_2] = DEFAULT_CHROOT;
|
||||||
char lang [3] = DEFAULT_LANG;
|
char lang [3] = DEFAULT_LANG;
|
||||||
char user [_SC_LOGIN_NAME_MAX];
|
char user [_SC_LOGIN_NAME_MAX];
|
||||||
struct passwd *pw;
|
|
||||||
int virtualhost = 0;
|
int virtualhost = 0;
|
||||||
int option;
|
int option;
|
||||||
int start_with_gemini;
|
int start_with_gemini;
|
||||||
|
struct passwd *pw;
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, ":d:l:u:v")) != -1) {
|
while ((option = getopt(argc, argv, ":d:l:u:v")) != -1) {
|
||||||
|
|
Loading…
Reference in a new issue