initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

8
node_modules/bplist-creator/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/build/*
node_modules
*.node
*.sh
*.swp
.lock*
npm-debug.log
.idea

64
node_modules/bplist-creator/README.md generated vendored Normal file
View File

@@ -0,0 +1,64 @@
bplist-parser
=============
Binary Mac OS X Plist (property list) creator.
## Installation
```bash
$ npm install bplist-creator
```
## Quick Examples
```javascript
var bplist = require('bplist-creator');
var buffer = bplist({
key1: [1, 2, 3]
});
```
## Real/Double/Float handling
Javascript don't have different types for `1` and `1.0`. This package
will automatically store numbers as the appropriate type, but can't
detect floats that is also integers.
If you need to force a value to be written with the `real` type pass
an instance of `Real`.
```javascript
var buffer = bplist({
backgroundRed: new bplist.Real(1),
backgroundGreen: new bplist.Real(0),
backgroundBlue: new bplist.Real(0)
});
```
In `xml` the corresponding tags is `<integer>` and `<real>`.
## License
(The MIT License)
Copyright (c) 2012 Near Infinity Corporation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

445
node_modules/bplist-creator/bplistCreator.js generated vendored Normal file
View File

@@ -0,0 +1,445 @@
'use strict';
// adapted from http://code.google.com/p/plist/source/browse/trunk/src/main/java/com/dd/plist/BinaryPropertyListWriter.java
var streamBuffers = require("stream-buffers");
var debug = false;
function Real(value) {
this.value = value;
}
module.exports = function(dicts) {
var buffer = new streamBuffers.WritableStreamBuffer();
buffer.write(new Buffer("bplist00"));
if (debug) {
console.log('create', require('util').inspect(dicts, false, 10));
}
if (dicts instanceof Array && dicts.length === 1) {
dicts = dicts[0];
}
var entries = toEntries(dicts);
if (debug) {
console.log('entries', entries);
}
var idSizeInBytes = computeIdSizeInBytes(entries.length);
var offsets = [];
var offsetSizeInBytes;
var offsetTableOffset;
updateEntryIds();
entries.forEach(function(entry, entryIdx) {
offsets[entryIdx] = buffer.size();
if (!entry) {
buffer.write(0x00);
} else {
write(entry);
}
});
writeOffsetTable();
writeTrailer();
return buffer.getContents();
function updateEntryIds() {
var strings = {};
var entryId = 0;
entries.forEach(function(entry) {
if (entry.id) {
return;
}
if (entry.type === 'string') {
if (!entry.bplistOverride && strings.hasOwnProperty(entry.value)) {
entry.type = 'stringref';
entry.id = strings[entry.value];
} else {
strings[entry.value] = entry.id = entryId++;
}
} else {
entry.id = entryId++;
}
});
entries = entries.filter(function(entry) {
return (entry.type !== 'stringref');
});
}
function writeTrailer() {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer');
}
// 6 null bytes
buffer.write(new Buffer([0, 0, 0, 0, 0, 0]));
// size of an offset
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', offsetSizeInBytes);
}
writeByte(offsetSizeInBytes);
// size of a ref
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', idSizeInBytes);
}
writeByte(idSizeInBytes);
// number of objects
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer(number of objects):', entries.length);
}
writeLong(entries.length);
// top object
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer(top object)');
}
writeLong(0);
// offset table offset
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeTrailer(offset table offset):', offsetTableOffset);
}
writeLong(offsetTableOffset);
}
function writeOffsetTable() {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeOffsetTable');
}
offsetTableOffset = buffer.size();
offsetSizeInBytes = computeOffsetSizeInBytes(offsetTableOffset);
offsets.forEach(function(offset) {
writeBytes(offset, offsetSizeInBytes);
});
}
function write(entry) {
switch (entry.type) {
case 'dict':
writeDict(entry);
break;
case 'number':
case 'double':
writeNumber(entry);
break;
case 'UID':
writeUID(entry);
break;
case 'array':
writeArray(entry);
break;
case 'boolean':
writeBoolean(entry);
break;
case 'string':
case 'string-utf16':
writeString(entry);
break;
case 'date':
writeDate(entry);
break;
case 'data':
writeData(entry);
break;
default:
throw new Error("unhandled entry type: " + entry.type);
}
}
function writeDate(entry) {
writeByte(0x33);
var date = (Date.parse(entry.value)/1000) - 978307200
writeDouble(date)
}
function writeDict(entry) {
if (debug) {
var keysStr = entry.entryKeys.map(function(k) {return k.id;});
var valsStr = entry.entryValues.map(function(k) {return k.id;});
console.log('0x' + buffer.size().toString(16), 'writeDict', '(id: ' + entry.id + ')', '(keys: ' + keysStr + ')', '(values: ' + valsStr + ')');
}
writeIntHeader(0xD, entry.entryKeys.length);
entry.entryKeys.forEach(function(entry) {
writeID(entry.id);
});
entry.entryValues.forEach(function(entry) {
writeID(entry.id);
});
}
function writeNumber(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeNumber', entry.value, ' (type: ' + entry.type + ')', '(id: ' + entry.id + ')');
}
if (entry.type !== 'double' && parseFloat(entry.value.toFixed()) == entry.value) {
if (entry.value < 0) {
writeByte(0x13);
writeBytes(entry.value, 8);
} else if (entry.value <= 0xff) {
writeByte(0x10);
writeBytes(entry.value, 1);
} else if (entry.value <= 0xffff) {
writeByte(0x11);
writeBytes(entry.value, 2);
} else if (entry.value <= 0xffffffff) {
writeByte(0x12);
writeBytes(entry.value, 4);
} else {
writeByte(0x13);
writeBytes(entry.value, 8);
}
} else {
writeByte(0x23);
writeDouble(entry.value);
}
}
function writeUID(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeUID', entry.value, ' (type: ' + entry.type + ')', '(id: ' + entry.id + ')');
}
writeIntHeader(0x8, 0x0);
writeID(entry.value);
}
function writeArray(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeArray (length: ' + entry.entries.length + ')', '(id: ' + entry.id + ')');
}
writeIntHeader(0xA, entry.entries.length);
entry.entries.forEach(function(e) {
writeID(e.id);
});
}
function writeBoolean(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeBoolean', entry.value, '(id: ' + entry.id + ')');
}
writeByte(entry.value ? 0x09 : 0x08);
}
function writeString(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeString', entry.value, '(id: ' + entry.id + ')');
}
if (entry.type === 'string-utf16' || mustBeUtf16(entry.value)) {
var utf16 = new Buffer(entry.value, 'ucs2');
writeIntHeader(0x6, utf16.length / 2);
// needs to be big endian so swap the bytes
for (var i = 0; i < utf16.length; i += 2) {
var t = utf16[i + 0];
utf16[i + 0] = utf16[i + 1];
utf16[i + 1] = t;
}
buffer.write(utf16);
} else {
var utf8 = new Buffer(entry.value, 'ascii');
writeIntHeader(0x5, utf8.length);
buffer.write(utf8);
}
}
function writeData(entry) {
if (debug) {
console.log('0x' + buffer.size().toString(16), 'writeData', entry.value, '(id: ' + entry.id + ')');
}
writeIntHeader(0x4, entry.value.length);
buffer.write(entry.value);
}
function writeLong(l) {
writeBytes(l, 8);
}
function writeByte(b) {
buffer.write(new Buffer([b]));
}
function writeDouble(v) {
var buf = new Buffer(8);
buf.writeDoubleBE(v, 0);
buffer.write(buf);
}
function writeIntHeader(kind, value) {
if (value < 15) {
writeByte((kind << 4) + value);
} else if (value < 256) {
writeByte((kind << 4) + 15);
writeByte(0x10);
writeBytes(value, 1);
} else if (value < 65536) {
writeByte((kind << 4) + 15);
writeByte(0x11);
writeBytes(value, 2);
} else {
writeByte((kind << 4) + 15);
writeByte(0x12);
writeBytes(value, 4);
}
}
function writeID(id) {
writeBytes(id, idSizeInBytes);
}
function writeBytes(value, bytes) {
// write low-order bytes big-endian style
var buf = new Buffer(bytes);
var z = 0;
// javascript doesn't handle large numbers
while (bytes > 4) {
buf[z++] = 0;
bytes--;
}
for (var i = bytes - 1; i >= 0; i--) {
buf[z++] = value >> (8 * i);
}
buffer.write(buf);
}
function mustBeUtf16(string) {
return Buffer.byteLength(string, 'utf8') != string.length;
}
};
function toEntries(dicts) {
if (dicts.bplistOverride) {
return [dicts];
}
if (dicts instanceof Array) {
return toEntriesArray(dicts);
} else if (dicts instanceof Buffer) {
return [
{
type: 'data',
value: dicts
}
];
} else if (dicts instanceof Real) {
return [
{
type: 'double',
value: dicts.value
}
];
} else if (typeof(dicts) === 'object') {
if (dicts instanceof Date) {
return [
{
type: 'date',
value: dicts
}
]
} else if (Object.keys(dicts).length == 1 && typeof(dicts.UID) === 'number') {
return [
{
type: 'UID',
value: dicts.UID
}
]
} else {
return toEntriesObject(dicts);
}
} else if (typeof(dicts) === 'string') {
return [
{
type: 'string',
value: dicts
}
];
} else if (typeof(dicts) === 'number') {
return [
{
type: 'number',
value: dicts
}
];
} else if (typeof(dicts) === 'boolean') {
return [
{
type: 'boolean',
value: dicts
}
];
} else {
throw new Error('unhandled entry: ' + dicts);
}
}
function toEntriesArray(arr) {
if (debug) {
console.log('toEntriesArray');
}
var results = [
{
type: 'array',
entries: []
}
];
arr.forEach(function(v) {
var entry = toEntries(v);
results[0].entries.push(entry[0]);
results = results.concat(entry);
});
return results;
}
function toEntriesObject(dict) {
if (debug) {
console.log('toEntriesObject');
}
var results = [
{
type: 'dict',
entryKeys: [],
entryValues: []
}
];
Object.keys(dict).forEach(function(key) {
var entryKey = toEntries(key);
results[0].entryKeys.push(entryKey[0]);
results = results.concat(entryKey[0]);
});
Object.keys(dict).forEach(function(key) {
var entryValue = toEntries(dict[key]);
results[0].entryValues.push(entryValue[0]);
results = results.concat(entryValue);
});
return results;
}
function computeOffsetSizeInBytes(maxOffset) {
if (maxOffset < 256) {
return 1;
}
if (maxOffset < 65536) {
return 2;
}
if (maxOffset < 4294967296) {
return 4;
}
return 8;
}
function computeIdSizeInBytes(numberOfIds) {
if (numberOfIds < 256) {
return 1;
}
if (numberOfIds < 65536) {
return 2;
}
return 4;
}
module.exports.Real = Real;

85
node_modules/bplist-creator/package.json generated vendored Normal file
View File

@@ -0,0 +1,85 @@
{
"_args": [
[
"bplist-creator@0.0.7",
"/home/bernhard/freifunk-app/node_modules/simple-plist"
]
],
"_from": "bplist-creator@0.0.7",
"_id": "bplist-creator@0.0.7",
"_inCache": true,
"_installable": true,
"_location": "/bplist-creator",
"_nodeVersion": "5.11.1",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/bplist-creator-0.0.7.tgz_1472949121897_0.6429064173717052"
},
"_npmUser": {
"email": "joe@fernsroth.com",
"name": "joeferner"
},
"_npmVersion": "3.8.6",
"_phantomChildren": {},
"_requested": {
"name": "bplist-creator",
"raw": "bplist-creator@0.0.7",
"rawSpec": "0.0.7",
"scope": null,
"spec": "0.0.7",
"type": "version"
},
"_requiredBy": [
"/simple-plist"
],
"_resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz",
"_shasum": "37df1536092824b87c42f957b01344117372ae45",
"_shrinkwrap": null,
"_spec": "bplist-creator@0.0.7",
"_where": "/home/bernhard/freifunk-app/node_modules/simple-plist",
"author": {
"name": "https://github.com/nearinfinity/node-bplist-parser.git"
},
"bugs": {
"url": "https://github.com/nearinfinity/node-bplist-creator/issues"
},
"dependencies": {
"stream-buffers": "~2.2.0"
},
"description": "Binary Mac OS X Plist (property list) creator.",
"devDependencies": {
"bplist-parser": "~0.1.0",
"nodeunit": "0.9.1"
},
"directories": {},
"dist": {
"shasum": "37df1536092824b87c42f957b01344117372ae45",
"tarball": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz"
},
"gitHead": "d39765ffd3fa678104fefc444a63ba6b60eee797",
"homepage": "https://github.com/nearinfinity/node-bplist-creator#readme",
"keywords": [
"bplist",
"creator",
"plist"
],
"license": "MIT",
"main": "bplistCreator.js",
"maintainers": [
{
"name": "joeferner",
"email": "joe@fernsroth.com"
}
],
"name": "bplist-creator",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/nearinfinity/node-bplist-creator.git"
},
"scripts": {
"test": "./node_modules/nodeunit/bin/nodeunit test"
},
"version": "0.0.7"
}

BIN
node_modules/bplist-creator/test/airplay.bplist generated vendored Normal file

Binary file not shown.

BIN
node_modules/bplist-creator/test/binaryData.bplist generated vendored Normal file

Binary file not shown.

197
node_modules/bplist-creator/test/creatorTest.js generated vendored Normal file
View File

@@ -0,0 +1,197 @@
'use strict';
var fs = require('fs');
var path = require('path');
var nodeunit = require('nodeunit');
var bplistParser = require('bplist-parser');
var bplistCreator = require('../');
module.exports = {
// 'iTunes Small': function(test) {
// var file = path.join(__dirname, "iTunes-small.bplist");
// testFile(test, file);
// },
'sample1': function(test) {
var file = path.join(__dirname, "sample1.bplist");
testFile(test, file);
},
'sample2': function(test) {
var file = path.join(__dirname, "sample2.bplist");
testFile(test, file);
},
'binary data': function(test) {
var file = path.join(__dirname, "binaryData.bplist");
testFile(test, file);
},
'airplay': function(test) {
var file = path.join(__dirname, "airplay.bplist");
testFile(test, file);
},
// 'utf16': function(test) {
// var file = path.join(__dirname, "utf16.bplist");
// testFile(test, file);
// },
// 'uid': function(test) {
// var file = path.join(__dirname, "uid.bplist");
// testFile(test, file);
// }
};
function testFile(test, file) {
fs.readFile(file, function(err, fileData) {
if (err) {
return test.done(err);
}
bplistParser.parseFile(file, function(err, dicts) {
if (err) {
return test.done(err);
}
// airplay overrides
if (dicts && dicts[0] && dicts[0].loadedTimeRanges && dicts[0].loadedTimeRanges[0] && dicts[0].loadedTimeRanges[0].hasOwnProperty('start')) {
dicts[0].loadedTimeRanges[0].start = {
bplistOverride: true,
type: 'double',
value: dicts[0].loadedTimeRanges[0].start
};
}
if (dicts && dicts[0] && dicts[0].loadedTimeRanges && dicts[0].seekableTimeRanges[0] && dicts[0].seekableTimeRanges[0].hasOwnProperty('start')) {
dicts[0].seekableTimeRanges[0].start = {
bplistOverride: true,
type: 'double',
value: dicts[0].seekableTimeRanges[0].start
};
}
if (dicts && dicts[0] && dicts[0].hasOwnProperty('rate')) {
dicts[0].rate = {
bplistOverride: true,
type: 'double',
value: dicts[0].rate
};
}
// utf16
if (dicts && dicts[0] && dicts[0].hasOwnProperty('NSHumanReadableCopyright')) {
dicts[0].NSHumanReadableCopyright = {
bplistOverride: true,
type: 'string-utf16',
value: dicts[0].NSHumanReadableCopyright
};
}
if (dicts && dicts[0] && dicts[0].hasOwnProperty('CFBundleExecutable')) {
dicts[0].CFBundleExecutable = {
bplistOverride: true,
type: 'string',
value: dicts[0].CFBundleExecutable
};
}
if (dicts && dicts[0] && dicts[0].CFBundleURLTypes && dicts[0].CFBundleURLTypes[0] && dicts[0].CFBundleURLTypes[0].hasOwnProperty('CFBundleURLSchemes')) {
dicts[0].CFBundleURLTypes[0].CFBundleURLSchemes[0] = {
bplistOverride: true,
type: 'string',
value: dicts[0].CFBundleURLTypes[0].CFBundleURLSchemes[0]
};
}
if (dicts && dicts[0] && dicts[0].hasOwnProperty('CFBundleDisplayName')) {
dicts[0].CFBundleDisplayName = {
bplistOverride: true,
type: 'string',
value: dicts[0].CFBundleDisplayName
};
}
if (dicts && dicts[0] && dicts[0].hasOwnProperty('DTPlatformBuild')) {
dicts[0].DTPlatformBuild = {
bplistOverride: true,
type: 'string',
value: dicts[0].DTPlatformBuild
};
}
var buf = bplistCreator(dicts);
compareBuffers(test, buf, fileData);
return test.done();
});
});
}
function compareBuffers(test, buf1, buf2) {
if (buf1.length !== buf2.length) {
printBuffers(buf1, buf2);
return test.fail("buffer size mismatch. found: " + buf1.length + ", expected: " + buf2.length + ".");
}
for (var i = 0; i < buf1.length; i++) {
if (buf1[i] !== buf2[i]) {
printBuffers(buf1, buf2);
return test.fail("buffer mismatch at offset 0x" + i.toString(16) + ". found: 0x" + buf1[i].toString(16) + ", expected: 0x" + buf2[i].toString(16) + ".");
}
}
}
function printBuffers(buf1, buf2) {
var i, t;
for (var lineOffset = 0; lineOffset < buf1.length || lineOffset < buf2.length; lineOffset += 16) {
var line = '';
t = ('000000000' + lineOffset.toString(16));
line += t.substr(t.length - 8) + ': ';
for (i = 0; i < 16; i++) {
if (i == 8) {
line += ' ';
}
if (lineOffset + i < buf1.length) {
t = ('00' + buf1[lineOffset + i].toString(16));
line += t.substr(t.length - 2) + ' ';
} else {
line += ' ';
}
}
line += ' ';
for (i = 0; i < 16; i++) {
if (lineOffset + i < buf1.length) {
t = String.fromCharCode(buf1[lineOffset + i]);
if (t < ' ' || t > '~') {
t = '.';
}
line += t;
} else {
line += ' ';
}
}
line += ' - ';
for (i = 0; i < 16; i++) {
if (i == 8) {
line += ' ';
}
if (lineOffset + i < buf2.length) {
t = ('00' + buf2[lineOffset + i].toString(16));
line += t.substr(t.length - 2) + ' ';
} else {
line += ' ';
}
}
line += ' ';
for (i = 0; i < 16; i++) {
if (lineOffset + i < buf2.length) {
t = String.fromCharCode(buf2[lineOffset + i]);
if (t < ' ' || t > '~') {
t = '.';
}
line += t;
} else {
line += ' ';
}
}
console.log(line);
}
}

BIN
node_modules/bplist-creator/test/iTunes-small.bplist generated vendored Normal file

Binary file not shown.

BIN
node_modules/bplist-creator/test/sample1.bplist generated vendored Normal file

Binary file not shown.

BIN
node_modules/bplist-creator/test/sample2.bplist generated vendored Normal file

Binary file not shown.

BIN
node_modules/bplist-creator/test/uid.bplist generated vendored Normal file

Binary file not shown.

BIN
node_modules/bplist-creator/test/utf16.bplist generated vendored Normal file

Binary file not shown.