{"id":18131480,"url":"https://github.com/crownedgrouse/swab","last_synced_at":"2025-04-15T22:54:06.900Z","repository":{"id":19641210,"uuid":"22893435","full_name":"crownedgrouse/swab","owner":"crownedgrouse","description":"General purpose buffer handling module","archived":false,"fork":false,"pushed_at":"2017-08-31T21:46:10.000Z","size":126,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T02:12:36.641Z","etag":null,"topics":["buffer","ebcdic","hexdump"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crownedgrouse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-12T21:40:30.000Z","updated_at":"2024-05-04T21:56:23.000Z","dependencies_parsed_at":"2022-08-24T14:03:33.843Z","dependency_job_id":null,"html_url":"https://github.com/crownedgrouse/swab","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fswab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fswab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fswab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fswab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crownedgrouse","download_url":"https://codeload.github.com/crownedgrouse/swab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824682,"owners_count":21167345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buffer","ebcdic","hexdump"],"created_at":"2024-11-01T12:07:38.481Z","updated_at":"2025-04-15T22:54:06.875Z","avatar_url":"https://github.com/crownedgrouse.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swab #\n\nGeneral purpose buffer handling module.\n\n## Overview ##\n\nswab can :\n\n* cast data and sort lines.\n* decode, encode and convert data, including EBCDIC. \n* catch data that becomes the new current buffer.\n* match data and return the current buffer or otherwise continue next directives, if any.\n* store a buffer queue and maybe use it later to compose another buffer for instance, by merging or concatenating.\n* do various specialized (or custom) actions. (Pull requests welcome !).\n\nswab give the possibility to debug all or part of the directive chain, to do hexdump *à la* `od` and also ASN1 pretty printing *à la* `openssl asn1parse`. \n\nswab offer a very easy way to chain directives as you would do by chaining commands with pipes in a shell.\nEach step can modify the input buffer that becomes a new current buffer, and so on.\n\n## Documentation ##\n\nA complete documentation is available on all directives.\n\nSimply run `make docs` and open `doc/index.html` in your favorite browser, this will insure you having the documentation related to your version.\n\n## Some examples ##\n\nBring the penultimate line :\n\n```\n[{jump, -2}, {nblines,1}]\n```\n\nAS400 data received in EBCDIC without linefeed, from 128 characters length records :\n\n```\n[{decode,ebcdic}, {fold, 128}]\n```\n\nReplace UID and GID to 0 in a gzip'ed tar :\n\n```\n[{convert, gunzip}, {tar, fakeroot}, {convert, gzip}]\n```\n\nMerge the two first lines and the last line of a string buffer (explained with debug) :\n\n```\nswab:sync([debug, queue}, {debug, on}, {buffer, in_r}, {nblines, 2}, {buffer, in},  \n           {buffer, del}, {jump, -1}, {buffer, in}, {buffer, merge}, {buffer, del}],\n           \"Erlang\\n is \\n not \\ngreat !\").\n\u003c0.32.0\u003e : {debug,on} =\u003e \"Erlang\\n is \\n not \\ngreat !\"\n           []\n\u003c0.32.0\u003e : {buffer,in_r} =\u003e \"Erlang\\n is \\n not \\ngreat !\"\n           [\"Erlang\\n is \\n not \\ngreat !\"]\n\u003c0.32.0\u003e : {nblines,2} =\u003e \"Erlang\\n is \"\n           [\"Erlang\\n is \\n not \\ngreat !\"]\n\u003c0.32.0\u003e : {buffer,in} =\u003e \"Erlang\\n is \"\n           [\"Erlang\\n is \\n not \\ngreat !\",\"Erlang\\n is \"]\n\u003c0.32.0\u003e : {buffer,del} =\u003e \"Erlang\\n is \\n not \\ngreat !\"\n           [\"Erlang\\n is \"]\n\u003c0.32.0\u003e : {jump,-1} =\u003e \"great !\"\n           [\"Erlang\\n is \"]\n\u003c0.32.0\u003e : {buffer,in} =\u003e \"great !\"\n           [\"Erlang\\n is \",\"great !\"]\n\u003c0.32.0\u003e : {buffer,merge} =\u003e \"great !\"\n           [\"Erlang\\n is \\ngreat !\"]\n\u003c0.32.0\u003e : {buffer,del} =\u003e \"Erlang\\n is \\ngreat !\"\n           []\n{ok,\"Erlang\\n is \\ngreat !\"}\n```\n\nHexdump debug :\n\n```\n    swab:sync([{debug,hexdump}], \"Call me Ishmael. Some years ago--never mind how long precisely --having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.\").\n    \u003c0.32.0\u003e : {debug,hexdump} =\u003e \n    00000000  43 61 6c 6c 20 6d 65 20 49 73 68 6d 61 65 6c 2e |Call me Ishmael.|\n    00000010  20 53 6f 6d 65 20 79 65 61 72 73 20 61 67 6f 2d | Some years ago-|\n    00000020  2d 6e 65 76 65 72 20 6d 69 6e 64 20 68 6f 77 20 |-never mind how |\n    00000030  6c 6f 6e 67 20 70 72 65 63 69 73 65 6c 79 20 2d |long precisely -|\n    00000040  2d 68 61 76 69 6e 67 20 6c 69 74 74 6c 65 20 6f |-having little o|\n    00000050  72 20 6e 6f 20 6d 6f 6e 65 79 20 69 6e 20 6d 79 |r no money in my|\n    00000060  20 70 75 72 73 65 2c 20 61 6e 64 20 6e 6f 74 68 | purse, and noth|\n    00000070  69 6e 67 20 70 61 72 74 69 63 75 6c 61 72 20 74 |ing particular t|\n    00000080  6f 20 69 6e 74 65 72 65 73 74 20 6d 65 20 6f 6e |o interest me on|\n    00000090  20 73 68 6f 72 65 2c 20 49 20 74 68 6f 75 67 68 | shore, I though|\n    000000a0  74 20 49 20 77 6f 75 6c 64 20 73 61 69 6c 20 61 |t I would sail a|\n    000000b0  62 6f 75 74 20 61 20 6c 69 74 74 6c 65 20 61 6e |bout a little an|\n    000000c0  64 20 73 65 65 20 74 68 65 20 77 61 74 65 72 79 |d see the watery|\n    000000d0  20 70 61 72 74 20 6f 66 20 74 68 65 20 77 6f 72 | part of the wor|\n    000000e0  6c 64 2e                                        |ld.|\n    {ok,\"Call me Ishmael. Some years ago--never mind how long precisely --having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.\"}\n```\n\nASN1 pretty printing :\n\n```\n    {ok, Der} = file:read_file(\"/tmp/certificate.der\").\n    {ok,\u003c\u003c48,130,3,193,48,130,2,169,160,3,2,1,2,2,9,0,174,28,\n        240,36,102,146,9,116,48,13,6,...\u003e\u003e}\n\n    swab:sync([{debug, asn1_pp}],Der).\n    \u003c0.36.0\u003e : {debug,asn1_pp} =\u003e \n    SEQUENCE\n    .  SEQUENCE\n    .  .  CONSTRUCTOR\n    .  .  .  INTEGER        : 10#2 (16#2)\n    .  .  .  END\n    .  .  INTEGER   : 10#12546166701077694836 (16#AE1CF02466920974)\n    .  .  SEQUENCE\n    .  .  .  OBJECT :  {1,2,840,113549,1,1,5}\n    .  .  .  NULL   : \u003c\u003c\u003e\u003e\n    .  .  .  END\n    .  .  SEQUENCE\n    .  .  .  SET\n    .  .  .  .  SEQUENCE\n    .  .  .  .  .  OBJECT   :  {2,5,4,6}\n    .  .  .  .  .  PRINTABLESTRING  : FR\n    .  .  .  .  .  END\n    .  .  .  .  END\n    .  .  .  SET\n    .  .  .  .  SEQUENCE\n    .  .  .  .  .  OBJECT   :  {2,5,4,8}\n    .  .  .  .  .  VALUE    : Some-State\n    .  .  .  .  .  END\n    .  .  .  .  END\n\n    ---- snip snip -----\n\n    .  .  SEQUENCE\n    .  .  .  UTCTIME        : 120708104913Z (2012-07-08 12:49:13 UTC+2)\n    .  .  .  UTCTIME        : 281211104913Z (2028-12-11 11:49:13 UTC+2)\n    .  .  .  END\n\n    ---- snip snip -----\n\n    .  .  CONSTRUCTOR\n    .  .  .  SEQUENCE\n    .  .  .  .  SEQUENCE\n    .  .  .  .  .  OBJECT   :  {2,5,29,14}\n    .  .  .  .  .  OCTET STRING     : \n    00000000  04 14 cd 81 ab 5c e1 59 b1 a4 f3 4d a1 9a 7e ab |.....\\.Y...M..~.|\n    00000010  ea fc 14 45 19 40                               |...E.@|\n    .  .  .  .  .  END\n\n    ---- snip snip -----\n\n    .  END\n    END\n    {ok,\u003c\u003c48,130,3,193,48,130,2,169,160,3,2,1,2,2,9,0,174,28,\n      240,36,102,146,9,116,48,13,6,...\u003e\u003e}\n```\n\n## Quick Start ##\n\n```\ngit clone git://github.com/crownedgrouse/swab.git\ncd swab\nmake\nerl -pa `pwd`/ebin\n```\n\n## Contributing ##\n\nContributions are welcome. Please use pull-requests.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrownedgrouse%2Fswab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrownedgrouse%2Fswab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrownedgrouse%2Fswab/lists"}