16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
-
+
-
-
-
+
+
+
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
@import ObjFW;
#import "SiteStorage.h"
@interface SiteStorage ()
- (void)_update;
@end
static OFNumber *lengthField, *legacyField, *keyFileField;
@implementation SiteStorage
+ (void)initialize
{
lengthField = [@(UINT8_C(0)) retain];
legacyField = [@(UINT8_C(1)) retain];
keyFileField = [@(UINT8_C(2)) retain];
lengthField = [[OFNumber alloc] initWithUInt8: 0];
legacyField = [[OFNumber alloc] initWithUInt8: 1];
keyFileField = [[OFNumber alloc] initWithUInt8: 2];
}
- (instancetype)init
{
self = [super init];
@try {
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
-
-
+
+
|
legacy: (bool)legacy
keyFile: (OFString *)keyFile
{
@autoreleasepool {
OFMutableDictionary *siteDictionary =
[OFMutableDictionary dictionary];
siteDictionary[lengthField] = @(length);
siteDictionary[legacyField] = @(legacy);
siteDictionary[lengthField] = [OFNumber numberWithSize: length];
siteDictionary[legacyField] = [OFNumber numberWithBool: legacy];
siteDictionary[keyFileField] = keyFile;
[siteDictionary makeImmutable];
_storage[site] = siteDictionary;
[self _update];
|