icon works
git-svn-id: file:///raid/svn-personal/tewi/trunk@23 8739d7e6-ffea-ec47-b151-bdff447c6205
This commit is contained in:
parent
850a70e9ce
commit
faeeedcae8
|
@ -59,7 +59,7 @@ int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req) {
|
|||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
if(!SSL_has_pending(ssl)) {
|
||||
if(ssl == NULL || !SSL_has_pending(ssl)) {
|
||||
int n = select(FD_SETSIZE, &fds, NULL, NULL, &tv);
|
||||
if(n <= 0) {
|
||||
free(header);
|
||||
|
|
|
@ -40,6 +40,28 @@ int sockcount = 0;
|
|||
SOCKADDR addresses[MAX_PORTS];
|
||||
int sockets[MAX_PORTS];
|
||||
|
||||
/* https://qiita.com/gyu-don/items/5a640c6d2252a860c8cd */
|
||||
int tw_wildcard_match(const char* wildcard, const char* target) {
|
||||
const char *pw = wildcard, *pt = target;
|
||||
|
||||
while(1) {
|
||||
if(*pt == 0) {
|
||||
while(*pw == '*') pw++;
|
||||
return *pw == 0;
|
||||
} else if(*pw == 0) {
|
||||
return 0;
|
||||
} else if(*pw == '*') {
|
||||
return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt);
|
||||
} else if(*pw == '?' || (*pw == *pt)) {
|
||||
pw++;
|
||||
pt++;
|
||||
continue;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void close_socket(int sock) {
|
||||
#ifdef __MINGW32__
|
||||
closesocket(sock);
|
||||
|
@ -274,14 +296,14 @@ char* tw_get_mime(const char* ext, struct tw_config_entry* vhost_entry) {
|
|||
bool set = false;
|
||||
int i;
|
||||
for(i = 0; i < vhost_entry->mime_count; i++) {
|
||||
if(strcmp(vhost_entry->mimes[i].ext, "all") == 0 || (ext != NULL && strcmp(vhost_entry->mimes[i].ext, ext) == 0)) {
|
||||
if(strcmp(vhost_entry->mimes[i].ext, "all") == 0 || (ext != NULL && tw_wildcard_match(vhost_entry->mimes[i].ext, ext))) {
|
||||
mime = vhost_entry->mimes[i].mime;
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
if(!set) {
|
||||
for(i = 0; i < config.root.mime_count; i++) {
|
||||
if(strcmp(config.root.mimes[i].ext, "all") == 0 || (ext != NULL && strcmp(config.root.mimes[i].ext, ext) == 0)) {
|
||||
if(strcmp(config.root.mimes[i].ext, "all") == 0 || (ext != NULL && tw_wildcard_match(config.root.mimes[i].ext, ext))) {
|
||||
mime = config.root.mimes[i].mime;
|
||||
}
|
||||
}
|
||||
|
@ -295,14 +317,14 @@ char* tw_get_icon(const char* mime, struct tw_config_entry* vhost_entry) {
|
|||
bool set = false;
|
||||
int i;
|
||||
for(i = 0; i < vhost_entry->icon_count; i++) {
|
||||
if(strcmp(vhost_entry->icons[i].mime, "all") == 0 || (mime != NULL && strcmp(vhost_entry->icons[i].mime, mime) == 0)) {
|
||||
if(strcmp(vhost_entry->icons[i].mime, "all") == 0 || (mime != NULL && tw_wildcard_match(vhost_entry->icons[i].mime, mime))) {
|
||||
icon = vhost_entry->icons[i].icon;
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
if(!set) {
|
||||
for(i = 0; i < config.root.icon_count; i++) {
|
||||
if(strcmp(config.root.icons[i].mime, "all") == 0 || (mime != NULL && strcmp(config.root.icons[i].mime, mime) == 0)) {
|
||||
if(strcmp(config.root.icons[i].mime, "all") == 0 || (mime != NULL && tw_wildcard_match(config.root.icons[i].mime, mime))) {
|
||||
icon = config.root.icons[i].icon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#LoadModule /home/nishi/SVN/tewi/trunk/Module/mod_example.so
|
||||
|
||||
Listen 8000 8001 8002 8003 8004
|
||||
ListenSSL 8443 8444 8445 8446 8447
|
||||
Listen 80
|
||||
ListenSSL 443
|
||||
|
||||
SSLKey key.pem
|
||||
SSLCertificate cert.pem
|
||||
|
@ -15,7 +15,7 @@ MIMEType .txt text/plain
|
|||
MIMEType .png image/png
|
||||
|
||||
Icon all /icons/unknown.png
|
||||
Icon text/plain /icons/text.png
|
||||
Icon text/* /icons/text.png
|
||||
Icon misc/dir /icons/folder.png
|
||||
Icon misc/parent /icons/parent.png
|
||||
|
||||
|
@ -24,6 +24,3 @@ DocumentRoot /var/www
|
|||
BeginDirectory /
|
||||
Allow all
|
||||
EndDirectory
|
||||
|
||||
BeginVirtualHost nishinbsd-ssd
|
||||
EndVirtualHost
|
||||
|
|
Loading…
Reference in New Issue
Block a user