Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/narazaka/shioridll-nim
The SHIORI DLL interface for Nim lang
https://github.com/narazaka/shioridll-nim
shiori ukagaka
Last synced: about 1 month ago
JSON representation
The SHIORI DLL interface for Nim lang
- Host: GitHub
- URL: https://github.com/narazaka/shioridll-nim
- Owner: Narazaka
- Created: 2017-10-07T07:57:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-04T13:11:12.000Z (almost 6 years ago)
- Last Synced: 2024-11-26T13:14:37.893Z (about 1 month ago)
- Topics: shiori, ukagaka
- Language: Nim
- Size: 48.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# shioridll
The SHIORI DLL interface for Nim lang
## Install
```
nimble install shioridll
```## Usage
**[API Document](https://narazaka.github.io/shioridll-nim/)**
[日本語チュートリアル](Tutorial.ja.md)
### How to make SHIORI.DLL
write your myshiori.nim like below...
```nim
import shioridll
import strutilsshioriLoadCallback = proc(str: string): bool =
trueshioriRequestCallback = proc(str: string): string =
if str.contains("SHIORI/2"):
"SHIORI/3.0 400 Bad Reuqest\nCharset: UTF-8\nSender: nimshiori\n\n"
elif str.contains("ID: name"):
"SHIORI/3.0 200 OK\nCharset: UTF-8\nSender: nimshiori\nValue: nimshiori\n\n"
elif str.contains("ID: version"):
"SHIORI/3.0 200 OK\nCharset: UTF-8\nSender: nimshiori\nValue: 0.0.1\n\n"
elif str.contains("ID: craftman"):
"SHIORI/3.0 200 OK\nCharset: UTF-8\nSender: nimshiori\nValue: narazaka\n\n"
elif str.contains("ID: OnBoot"):
"SHIORI/3.0 200 OK\nCharset: UTF-8\nSender: nimshiori\nValue: \\0\\s[0]aaaaaa\\e\n\n"
else:
"SHIORI/3.0 204 No Content\nCharset: UTF-8\nSender: nimshiori\n\n"shioriUnloadCallback = proc(): bool =
true# for test
when appType != "lib":
main("C:\\ssp\\ghost\\nim\\", @[
"GET SHIORI/3.0\nCharset: UTF-8\nSender: embryo\nID: version\n\n",
"GET SHIORI/3.0\nCharset: UTF-8\nSender: embryo\nID: OnBoot\n\n",
])
```then make 32bit dll...
```
nim c --app:lib -d:release --cc:vcc --cpu:i386 myshiori.nim
```You also may be able to use gcc or some other compilers.
### Useful way
You can use [shiori](https://github.com/Narazaka/shiori-nim) module for parsing SHIORI request and building SHIORI response
and can use [shiori_charset_convert](https://github.com/Narazaka/shiori_charset_convert-nim) module for auto converting charset
as below...```nim
import shioridll
import shiori
import shiori_charset_convert
import tablesvar dirpath: string
shioriLoadCallback = proc(dirpathStr: string): bool =
dirpath = dirpathStr
trueshioriRequestCallback = autoConvertShioriMessageCharset(proc(requestStr: string): string =
let request = parseRequest(requestStr)
var response = newResponse(headers = {"Charset": "UTF-8", "Sender": "nimshiori"}.newOrderedTable)
if request.version != "3.0":
response.statusCode = 400
return $responsecase request.id:
of "name":
response.value = "nimshiori"
of "version":
response.value = "0.0.1"
of "craftman":
response.value = "narazaka"
of "OnBoot":
response.value = r"\0\s[0]aaaaaa\e"
else:
response.status = Status.No_Content$response
)shioriUnloadCallback = proc(): bool =
true# for test
when appType != "lib":
main("C:\\ssp\\ghost\\nim\\", @[
"GET SHIORI/3.0\nCharset: UTF-8\nSender: embryo\nID: version\n\n",
"GET SHIORI/3.0\nCharset: UTF-8\nSender: embryo\nID: OnBoot\n\n",
])
```## License
This is released under [MIT License](https://narazaka.net/license/MIT?2017).