[
  {
    "path": ".gitignore",
    "content": "*\n!*/\n\n!*.lua\n!*.rst\n!*.md\n\n!.gitignore\n\nwssdl.lua\ntest.lua\n"
  },
  {
    "path": "README.md",
    "content": "# 🝰 wssdl\n\n[![Build Status](https://api.travis-ci.org/diacritic/wssdl.svg?branch=master)](https://travis-ci.org/diacritic/wssdl/builds) \n[![License (GPL)](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://github.com/diacritic/wssdl/blob/master/LICENSE) \n[![Version (Experimental)](https://img.shields.io/github/release/diacritic/wssdl.svg?label=version)](https://github.com/diacritic/wssdl/releases/latest) \n[![Language (Lua)](https://img.shields.io/badge/powered_by-Lua-brightgreen.svg)](https://lua.org) \n[![Gitter chat](https://badges.gitter.im/diacritic/wssdl.png)](https://gitter.im/diacritic/wssdl) \n\nWireshark-Specific Dissector Language\n\n```lua\nwssdl.packet {\n  message     : u8();\n  definition  : i32();\n  done        : utf8z();\n  easy        : ipv4();\n}\n```\n\n## What is this?\n\nwssdl is a domain specific language on top of lua built for the\npurpose of expressing easily message dissectors.\n\n## Documentation\n\n| Stable | Latest |\n| --- | --- |\n[![Stable docs][doc-stable-badge]][doc-stable] | [![Latest docs][doc-latest-badge]][doc-latest]\n\nAlso check out some of the [samples][samples].\n\n## Install\n\n### From the release\n\nGrab the bootstrapped `wssdl.lua` from the [latest release][latest],\nand put it in your Wireshark Plugin directory\n(usually `~/.config/wireshark/plugins`, `~/.wireshark/plugins` or `/usr/lib/wireshark/<version>`)\n\n### From source\n\nThe build toolchain needs lua 5.1 or newer, luarocks and the luafilesystem\nmodule.\n\nClone this repository, and from the root directory call `make install`\nto install it to `~/.config/wireshark/plugins`, or\n`make WS_PLUGIN_DIR=/your/path install` to install it to the path of your choice.\n\n[latest]: https://github.com/diacritic/wssdl/releases/latest\n[samples]: https://github.com/diacritic/wssdl/tree/master/samples\n\n[doc-stable]:       http://wssdl.readthedocs.io/en/stable/?badge=stable\n[doc-latest]:       http://wssdl.readthedocs.io/en/latest/?badge=latest\n[doc-stable-badge]: https://readthedocs.org/projects/wssdl/badge/?version=stable\n[doc-latest-badge]: https://readthedocs.org/projects/wssdl/badge/?version=latest\n"
  },
  {
    "path": "pack.lua",
    "content": "--\n--  Copyright 2016 diacritic <https://diacritic.io>\n--\n--  This program is free software: you can redistribute it and/or modify\n--  it under the terms of the GNU General Public License as published by\n--  the Free Software Foundation, either version 3 of the License, or\n--  (at your option) any later version.\n--\n--  This program is distributed in the hope that it will be useful,\n--  but WITHOUT ANY WARRANTY; without even the implied warranty of\n--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n--  GNU General Public License for more details.\n--\n--  You should have received a copy of the GNU General Public License\n--  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n--\n\nrequire 'luarocks.loader'\n\nlocal fs = require 'lfs'\n\nlocal args = {...}\nlocal root = args[1]:gsub('/$', ''):gsub('\\\\$', '')\nlocal files = {}\n\nfunction scandir(root, path)\n  -- adapted from http://keplerproject.github.com/luafilesystem/examples.html\n  path = path or ''\n  for file in fs.dir(root..path) do\n    if file ~= '.' and file ~= '..' then\n      local f = path .. '/' .. file\n      local attr = lfs.attributes(root..f)\n      assert(type(attr) == 'table')\n      if attr.mode == 'directory' then\n        scandir(root, f)\n      else\n        if file:find('%.lua$') then\n          hndl = (f:gsub('%.lua$', '')\n              :gsub('/', '.')\n              :gsub('\\\\', '.')\n              :gsub('^%.', '')\n            ):gsub('%.init$', '')\n          files[hndl] = io.open(root..f):read('*a')\n              :gsub(' *%-%-[^\\n]*\\n', '')\n        end\n      end\n    end\n  end\n  return files\nend\n\nscandir(root)\n\nacc = { [[\n--\n--  Copyright 2016 diacritic <https://diacritic.io>\n--\n--  This program is free software: you can redistribute it and/or modify\n--  it under the terms of the GNU General Public License as published by\n--  the Free Software Foundation, either version 3 of the License, or\n--  (at your option) any later version.\n--\n--  This program is distributed in the hope that it will be useful,\n--  but WITHOUT ANY WARRANTY; without even the implied warranty of\n--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n--  GNU General Public License for more details.\n--\n--  You should have received a copy of the GNU General Public License\n--  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n--\n]] }\n\nlocal wrapper = { '\\n--------------------------------------\\npackage.preload[\\'', nil, '\\'] = function (...)\\n', nil, '\\nend\\n' }\n\nfor k,v in pairs( files ) do\n  wrapper[2], wrapper[4] = k, v\n  table.insert(acc, table.concat(wrapper))\nend\n\ntable.insert(acc, [[\n-----------------------------------------------\n\ndo\n  if not package.__loadfile then\n    local original_loadfile = loadfile\n    local function lf(file)\n      local hndl = file:gsub('%.lua$', '')\n                       :gsub('/', '.')\n                       :gsub('\\\\', '.')\n                       :gsub('%.init$', '')\n      return package.preload[hndl] or original_loadfile(name)\n    end\n\n    function dofile(name)\n      return lf(name)()\n    end\n\n    loadfile, package.__loadfile = lf, loadfile\n  end\nend\n\nreturn require 'wssdl.core'\n]])\n\nprint(table.concat(acc))\n"
  }
]