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);
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;
}
}
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;
}
}
#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
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
BeginDirectory /
Allow all
EndDirectory
-
-BeginVirtualHost nishinbsd-ssd
-EndVirtualHost