diff options
Diffstat (limited to 'node_modules/locutus/php/net-gopher')
4 files changed, 90 insertions, 0 deletions
diff --git a/node_modules/locutus/php/net-gopher/gopher_parsedir.js b/node_modules/locutus/php/net-gopher/gopher_parsedir.js new file mode 100644 index 0000000..d681c9c --- /dev/null +++ b/node_modules/locutus/php/net-gopher/gopher_parsedir.js @@ -0,0 +1,84 @@ +'use strict'; + +module.exports = function gopher_parsedir(dirent) { + // eslint-disable-line camelcase + // discuss at: http://locutus.io/php/gopher_parsedir/ + // original by: Brett Zamir (http://brett-zamir.me) + // example 1: var entry = gopher_parsedir('0All about my gopher site.\t/allabout.txt\tgopher.example.com\t70\u000d\u000a') + // example 1: entry.title + // returns 1: 'All about my gopher site.' + + /* Types + * 0 = plain text file + * 1 = directory menu listing + * 2 = CSO search query + * 3 = error message + * 4 = BinHex encoded text file + * 5 = binary archive file + * 6 = UUEncoded text file + * 7 = search engine query + * 8 = telnet session pointer + * 9 = binary file + * g = Graphics file format, primarily a GIF file + * h = HTML file + * i = informational message + * s = Audio file format, primarily a WAV file + */ + + var entryPattern = /^(.)(.*?)\t(.*?)\t(.*?)\t(.*?)\u000d\u000a$/; + var entry = dirent.match(entryPattern); + + if (entry === null) { + throw new Error('Could not parse the directory entry'); + // return false; + } + + var type = entry[1]; + switch (type) { + case 'i': + // GOPHER_INFO + type = 255; + break; + case '1': + // GOPHER_DIRECTORY + type = 1; + break; + case '0': + // GOPHER_DOCUMENT + type = 0; + break; + case '4': + // GOPHER_BINHEX + type = 4; + break; + case '5': + // GOPHER_DOSBINARY + type = 5; + break; + case '6': + // GOPHER_UUENCODED + type = 6; + break; + case '9': + // GOPHER_BINARY + type = 9; + break; + case 'h': + // GOPHER_HTTP + type = 254; + break; + default: + return { + type: -1, + data: dirent + }; // GOPHER_UNKNOWN + } + return { + type: type, + title: entry[2], + path: entry[3], + host: entry[4], + port: entry[5] + }; +}; +//# sourceMappingURL=gopher_parsedir.js.map
\ No newline at end of file diff --git a/node_modules/locutus/php/net-gopher/gopher_parsedir.js.map b/node_modules/locutus/php/net-gopher/gopher_parsedir.js.map new file mode 100644 index 0000000..cd57753 --- /dev/null +++ b/node_modules/locutus/php/net-gopher/gopher_parsedir.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/php/net-gopher/gopher_parsedir.js"],"names":["module","exports","gopher_parsedir","dirent","entryPattern","entry","match","Error","type","data","title","path","host","port"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,eAAT,CAA0BC,MAA1B,EAAkC;AAAE;AACnD;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;;;;AAiBA,MAAIC,eAAe,6CAAnB;AACA,MAAIC,QAAQF,OAAOG,KAAP,CAAaF,YAAb,CAAZ;;AAEA,MAAIC,UAAU,IAAd,EAAoB;AAClB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACA;AACD;;AAED,MAAIC,OAAOH,MAAM,CAAN,CAAX;AACA,UAAQG,IAAR;AACE,SAAK,GAAL;AACA;AACEA,aAAO,GAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,GAAP;AACA;AACF;AACE,aAAO;AACLA,cAAM,CAAC,CADF;AAELC,cAAMN;AAFD,OAAP,CAlCJ,CAqCM;AArCN;AAuCA,SAAO;AACLK,UAAMA,IADD;AAELE,WAAOL,MAAM,CAAN,CAFF;AAGLM,UAAMN,MAAM,CAAN,CAHD;AAILO,UAAMP,MAAM,CAAN,CAJD;AAKLQ,UAAMR,MAAM,CAAN;AALD,GAAP;AAOD,CA/ED","file":"gopher_parsedir.js","sourcesContent":["module.exports = function gopher_parsedir (dirent) { // eslint-disable-line camelcase\n // discuss at: http://locutus.io/php/gopher_parsedir/\n // original by: Brett Zamir (http://brett-zamir.me)\n // example 1: var entry = gopher_parsedir('0All about my gopher site.\\t/allabout.txt\\tgopher.example.com\\t70\\u000d\\u000a')\n // example 1: entry.title\n // returns 1: 'All about my gopher site.'\n\n /* Types\n * 0 = plain text file\n * 1 = directory menu listing\n * 2 = CSO search query\n * 3 = error message\n * 4 = BinHex encoded text file\n * 5 = binary archive file\n * 6 = UUEncoded text file\n * 7 = search engine query\n * 8 = telnet session pointer\n * 9 = binary file\n * g = Graphics file format, primarily a GIF file\n * h = HTML file\n * i = informational message\n * s = Audio file format, primarily a WAV file\n */\n\n var entryPattern = /^(.)(.*?)\\t(.*?)\\t(.*?)\\t(.*?)\\u000d\\u000a$/\n var entry = dirent.match(entryPattern)\n\n if (entry === null) {\n throw new Error('Could not parse the directory entry')\n // return false;\n }\n\n var type = entry[1]\n switch (type) {\n case 'i':\n // GOPHER_INFO\n type = 255\n break\n case '1':\n // GOPHER_DIRECTORY\n type = 1\n break\n case '0':\n // GOPHER_DOCUMENT\n type = 0\n break\n case '4':\n // GOPHER_BINHEX\n type = 4\n break\n case '5':\n // GOPHER_DOSBINARY\n type = 5\n break\n case '6':\n // GOPHER_UUENCODED\n type = 6\n break\n case '9':\n // GOPHER_BINARY\n type = 9\n break\n case 'h':\n // GOPHER_HTTP\n type = 254\n break\n default:\n return {\n type: -1,\n data: dirent\n } // GOPHER_UNKNOWN\n }\n return {\n type: type,\n title: entry[2],\n path: entry[3],\n host: entry[4],\n port: entry[5]\n }\n}\n"]}
\ No newline at end of file diff --git a/node_modules/locutus/php/net-gopher/index.js b/node_modules/locutus/php/net-gopher/index.js new file mode 100644 index 0000000..47d7848 --- /dev/null +++ b/node_modules/locutus/php/net-gopher/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports['gopher_parsedir'] = require('./gopher_parsedir'); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/locutus/php/net-gopher/index.js.map b/node_modules/locutus/php/net-gopher/index.js.map new file mode 100644 index 0000000..f881fd4 --- /dev/null +++ b/node_modules/locutus/php/net-gopher/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/php/net-gopher/index.js"],"names":["module","exports","require"],"mappings":";;AAAAA,OAAOC,OAAP,CAAe,iBAAf,IAAoCC,QAAQ,mBAAR,CAApC","file":"index.js","sourcesContent":["module.exports['gopher_parsedir'] = require('./gopher_parsedir')\n"]}
\ No newline at end of file |