diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6950fbe --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,41 @@ +name: CI +on: [push,pull_request] + +jobs: + win: + strategy: + fail-fast: false + max-parallel: 2 + matrix: + include: [ + {msystem: MINGW32, toolchain: mingw-w64-i686, version: x32 }, + {msystem: MINGW64, toolchain: mingw-w64-x86_64, version: x64 }, + ] + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - name: Install msys2 build environment + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + update: false + install: base-devel git ${{ matrix.toolchain }}-toolchain upx + + - run: git config --global core.autocrlf input + shell: bash + + - uses: actions/checkout@v2 + + - name: Build plugin + shell: msys2 {0} + run: | + make + upx miniweb.exe + + - uses: actions/upload-artifact@v2 + with: + name: miniweb_${{ matrix.version }} + path: | + ./miniweb.exe diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25a7384 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +*.exe diff --git a/Makefile b/Makefile index 1ac6c35..9cbd2eb 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ DEFINES= ifdef WINDIR DEFINES+= -DWIN32 -LDADD += -lws2_32 -lshell32 -liphlpapi +LDADD += -lws2_32 -lshell32 -liphlpapi -s OS="Win32" else #CFLAGS+= -fPIC diff --git a/README.md b/README.md index 4342a1a..b3fb697 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,39 @@ See [License note](./miniweb-avih/LICENSE.md). based is at branch `svn-orig-rev-208` of this repository (the original project seems unmaintained since 2013.). + +## Building on Windows with msys2 + +```shell +pacman -S mingw-w64-x86_64-toolchain upx # And press enter to install all +msys2 -mingw64 # Start msys2 with path to use mingw64 +make +upx miniweb.exe # Optional, compress the exe file +``` + +## Adding a new MIME type + +In httpint.h:55 section, add your new file extension: +```c +#define FILEEXT_SVG DEFDWORD('S', 'V', 'G', 0) +``` + +In http.c:2269 section, add the mapping between the new file extension and the offset of the filetype: +```c + case FILEEXT_SVG: return HTTPFILETYPE_SVG; +``` + +In httpapi.h:56 section add the new offset at the end of enum: +```c + HTTPFILETYPE_SVG, +``` + +In http.c:76 section add your new MIME type at the end of the table, to match exactly the same position as the entry in the above enum: +```c + "image/svg+xml", +``` + + ### [Original project description below] ## MiniWeb diff --git a/http.c b/http.c index 238940b..1481494 100644 --- a/http.c +++ b/http.c @@ -100,6 +100,7 @@ const char* contentTypeTable[]={ "application/x-mpegURL", "application/sdp", "application/binhex", + "image/svg+xml", }; char* defaultPages[]={"index.htm","index.html","default.htm","main.xul"}; @@ -2286,6 +2287,7 @@ int mwGetContentType(const char *pchExtname) case FILEEXT_3GP: return HTTPFILETYPE_3GP; case FILEEXT_ASF: return HTTPFILETYPE_ASF; case FILEEXT_SDP: return HTTPFILETYPE_SDP; + case FILEEXT_SVG: return HTTPFILETYPE_SVG; } } else if (pchExtname[4]=='\0' || pchExtname[4]=='?') { memcpy(&dwExt, pchExtname, sizeof(dwExt)); diff --git a/httpapi.h b/httpapi.h index 137c72e..1d022f5 100644 --- a/httpapi.h +++ b/httpapi.h @@ -80,6 +80,7 @@ typedef enum { HTTPFILETYPE_M3U8, HTTPFILETYPE_SDP, HTTPFILETYPE_HEX, + HTTPFILETYPE_SVG, } HttpFileType; #define MAXPOSTPARAMS 50 diff --git a/httpint.h b/httpint.h index a131b0d..6cc8a2f 100644 --- a/httpint.h +++ b/httpint.h @@ -78,6 +78,7 @@ #define FILEEXT_TS DEFDWORD('T', 'S', 0, 0) #define FILEEXT_M3U8 DEFDWORD('M', '3' - 32, 'U', '8' - 32) #define FILEEXT_SDP DEFDWORD('S', 'D', 'P', 0) +#define FILEEXT_SVG DEFDWORD('S', 'V', 'G', 0) // Settings for http server #define HTTP_EXPIRATION_TIME (120/*secs*/)