No description
Find a file
2025-02-19 01:18:18 +09:00
.github/workflows no fail-fast 2025-02-19 01:05:28 +09:00
example with shiori_charset_convert 2018-01-21 04:44:17 +09:00
.gitignore ignore dll 2018-01-21 06:46:23 +09:00
Makefile Revert "Merge pull request #2 from Narazaka/feature/cstring" 2018-01-20 15:13:30 +09:00
Readme.md with shiori_charset_convert 2018-01-21 04:44:17 +09:00
shioridll.nim Merge pull request #4 from tukinami/master 2025-02-19 01:01:06 +09:00
shioridll.nimble revert nim ver 2025-02-19 01:12:17 +09:00
Tutorial.ja.md Update Tutorial.ja.md 2019-01-04 22:11:11 +09:00

shioridll

The SHIORI DLL interface for Nim lang

Install

nimble install shioridll

Usage

API Document

日本語チュートリアル

How to make SHIORI.DLL

write your myshiori.nim like below...

import shioridll
import strutils

shioriLoadCallback = proc(str: string): bool =
  true

shioriRequestCallback = 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 module for parsing SHIORI request and building SHIORI response and can use shiori_charset_convert module for auto converting charset as below...

import shioridll
import shiori
import shiori_charset_convert
import tables

var dirpath: string

shioriLoadCallback = proc(dirpathStr: string): bool =
  dirpath = dirpathStr
  true

shioriRequestCallback = 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 $response

  case 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.