Changeset 23 in Main for trunk/Server
- Timestamp:
- Sep 14, 2024, 10:31:16 PM (2 months ago)
- Location:
- trunk/Server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/http.c
r22 r23 60 60 tv.tv_sec = 5; 61 61 tv.tv_usec = 0; 62 if( !SSL_has_pending(ssl)) {62 if(ssl == NULL || !SSL_has_pending(ssl)) { 63 63 int n = select(FD_SETSIZE, &fds, NULL, NULL, &tv); 64 64 if(n <= 0) { -
trunk/Server/server.c
r22 r23 40 40 SOCKADDR addresses[MAX_PORTS]; 41 41 int sockets[MAX_PORTS]; 42 43 /* https://qiita.com/gyu-don/items/5a640c6d2252a860c8cd */ 44 int tw_wildcard_match(const char* wildcard, const char* target) { 45 const char *pw = wildcard, *pt = target; 46 47 while(1) { 48 if(*pt == 0) { 49 while(*pw == '*') pw++; 50 return *pw == 0; 51 } else if(*pw == 0) { 52 return 0; 53 } else if(*pw == '*') { 54 return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt); 55 } else if(*pw == '?' || (*pw == *pt)) { 56 pw++; 57 pt++; 58 continue; 59 } else { 60 return 0; 61 } 62 } 63 } 42 64 43 65 void close_socket(int sock) { … … 275 297 int i; 276 298 for(i = 0; i < vhost_entry->mime_count; i++) { 277 if(strcmp(vhost_entry->mimes[i].ext, "all") == 0 || (ext != NULL && strcmp(vhost_entry->mimes[i].ext, ext) == 0)) {299 if(strcmp(vhost_entry->mimes[i].ext, "all") == 0 || (ext != NULL && tw_wildcard_match(vhost_entry->mimes[i].ext, ext))) { 278 300 mime = vhost_entry->mimes[i].mime; 279 301 set = true; … … 282 304 if(!set) { 283 305 for(i = 0; i < config.root.mime_count; i++) { 284 if(strcmp(config.root.mimes[i].ext, "all") == 0 || (ext != NULL && strcmp(config.root.mimes[i].ext, ext) == 0)) {306 if(strcmp(config.root.mimes[i].ext, "all") == 0 || (ext != NULL && tw_wildcard_match(config.root.mimes[i].ext, ext))) { 285 307 mime = config.root.mimes[i].mime; 286 308 } … … 296 318 int i; 297 319 for(i = 0; i < vhost_entry->icon_count; i++) { 298 if(strcmp(vhost_entry->icons[i].mime, "all") == 0 || (mime != NULL && strcmp(vhost_entry->icons[i].mime, mime) == 0)) {320 if(strcmp(vhost_entry->icons[i].mime, "all") == 0 || (mime != NULL && tw_wildcard_match(vhost_entry->icons[i].mime, mime))) { 299 321 icon = vhost_entry->icons[i].icon; 300 322 set = true; … … 303 325 if(!set) { 304 326 for(i = 0; i < config.root.icon_count; i++) { 305 if(strcmp(config.root.icons[i].mime, "all") == 0 || (mime != NULL && strcmp(config.root.icons[i].mime, mime) == 0)) {327 if(strcmp(config.root.icons[i].mime, "all") == 0 || (mime != NULL && tw_wildcard_match(config.root.icons[i].mime, mime))) { 306 328 icon = config.root.icons[i].icon; 307 329 }
Note:
See TracChangeset
for help on using the changeset viewer.