ObjFW  Diff

Differences From Artifact [5655588497]:

To Artifact [8b92d8f389]:


88
89
90
91
92
93
94
95

96
97
98
99
100
101
102

103
104
105

106
107

108
109

110
111


112
113

114
115
116


117
118

119
120
121
122

123
124
125
126
127

128
129
130
131
132
133

134
135
136
137
138

139
140

141
142
143

144
145

146
147
148

149
150
151
152
153
154
155


156
157
158

159
160
161
162
163
164
165
166
167
168


169
170
171
172
173
174
175
176
177
178
179


180
181
182
183

184
185
186

187
188
189
190

191
192
193

194
195
196
197

198
199
200
201

202
203
204
205
206
207
208

209
210
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233

234
235
236

237
238

239
240

241
242


243
244
245

246
247

248
249
250

251
252
253

254
255
256
257



258
259
260
261
262
263
264
265
266
267

268
269
270
271

272
273
274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
88
89
90
91
92
93
94

95
96
97
98
99
100
101

102
103
104

105
106

107
108

109
110

111
112
113

114
115


116
117
118

119
120
121
122

123
124
125
126
127

128
129
130
131
132
133

134
135
136
137
138

139
140

141
142
143

144
145

146
147
148

149
150
151
152
153
154
155

156
157
158
159

160
161
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
178
179
180


181
182
183
184
185

186
187
188

189
190
191
192

193
194
195

196
197
198
199

200
201
202
203

204
205
206
207
208
209
210

211
212
213
214
215
216
217
218
219

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

236
237
238

239
240

241
242

243
244

245
246
247
248

249
250

251
252
253

254
255
256

257
258
259


260
261
262
263
264
265
266
267
268
269
270
271

272
273
274
275

276
277
278
279
280
281
282
283
284
285

286
287
288
289
290
291
292
293







-
+






-
+


-
+

-
+

-
+

-
+
+

-
+

-
-
+
+

-
+



-
+




-
+





-
+




-
+

-
+


-
+

-
+


-
+






-
+
+


-
+









-
+
+









-
-
+
+



-
+


-
+



-
+


-
+



-
+



-
+






-
+








-
+















-
+


-
+

-
+

-
+

-
+
+


-
+

-
+


-
+


-
+


-
-
+
+
+









-
+



-
+









-
+







{
	return [[[self alloc] initWithString: string
			       relativeToURL: URL] autorelease];
}

- initWithString: (OFString*)string
{
	char *cString, *cString2 = NULL;
	char *UTF8String, *UTF8String2 = NULL;

	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((cString2 = strdup([string cString])) == NULL)
		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: [string cStringLength]];
			    requestedSize: [string UTF8StringLength]];

		cString = cString2;
		UTF8String = UTF8String2;

		if (!strncmp(cString, "file://", 7)) {
		if (!strncmp(UTF8String, "file://", 7)) {
			scheme = @"file";
			path = [[OFString alloc] initWithCString: cString + 7];
			path = [[OFString alloc]
			    initWithUTF8String: UTF8String + 7];
			return self;
		} else if (!strncmp(cString, "http://", 7)) {
		} else if (!strncmp(UTF8String, "http://", 7)) {
			scheme = @"http";
			cString += 7;
		} else if (!strncmp(cString, "https://", 8)) {
			UTF8String += 7;
		} else if (!strncmp(UTF8String, "https://", 8)) {
			scheme = @"https";
			cString += 8;
			UTF8String += 8;
		} else
			@throw [OFInvalidFormatException newWithClass: isa];

		if ((tmp = strchr(cString, '/')) != NULL) {
		if ((tmp = strchr(UTF8String, '/')) != NULL) {
			*tmp = '\0';
			tmp++;
		}

		if ((tmp2 = strchr(cString, '@')) != NULL) {
		if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
			char *tmp3;

			*tmp2 = '\0';
			tmp2++;

			if ((tmp3 = strchr(cString, ':')) != NULL) {
			if ((tmp3 = strchr(UTF8String, ':')) != NULL) {
				*tmp3 = '\0';
				tmp3++;

				user = [[OFString alloc]
				    initWithCString: cString];
				    initWithUTF8String: UTF8String];
				password = [[OFString alloc]
				    initWithCString: tmp3];
				    initWithUTF8String: tmp3];
			} else
				user = [[OFString alloc]
				    initWithCString: cString];
				    initWithUTF8String: UTF8String];

			cString = tmp2;
			UTF8String = tmp2;
		}

		if ((tmp2 = strchr(cString, ':')) != NULL) {
		if ((tmp2 = strchr(UTF8String, ':')) != NULL) {
			OFAutoreleasePool *pool;
			OFString *portString;

			*tmp2 = '\0';
			tmp2++;

			host = [[OFString alloc] initWithCString: cString];
			host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			pool = [[OFAutoreleasePool alloc] init];
			portString = [OFString stringWithCString: tmp2];
			portString = [OFString stringWithUTF8String: tmp2];

			if ([portString decimalValue] > 65535)
				@throw [OFInvalidFormatException
				    newWithClass: isa];

			port = [portString decimalValue];

			[pool release];
		} else {
			host = [[OFString alloc] initWithCString: cString];
			host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			if ([scheme isEqual: @"http"])
				port = 80;
			else if ([scheme isEqual: @"https"])
				port = 443;
			else
				assert(0);
		}

		if ((cString = tmp) != NULL) {
			if ((tmp = strchr(cString, '#')) != NULL) {
		if ((UTF8String = tmp) != NULL) {
			if ((tmp = strchr(UTF8String, '#')) != NULL) {
				*tmp = '\0';

				fragment = [[OFString alloc]
				    initWithCString: tmp + 1];
				    initWithUTF8String: tmp + 1];
			}

			if ((tmp = strchr(cString, '?')) != NULL) {
			if ((tmp = strchr(UTF8String, '?')) != NULL) {
				*tmp = '\0';

				query = [[OFString alloc]
				    initWithCString: tmp + 1];
				    initWithUTF8String: tmp + 1];
			}

			if ((tmp = strchr(cString, ';')) != NULL) {
			if ((tmp = strchr(UTF8String, ';')) != NULL) {
				*tmp = '\0';

				parameters = [[OFString alloc]
				    initWithCString: tmp + 1];
				    initWithUTF8String: tmp + 1];
			}

			path = [[OFString alloc] initWithFormat: @"/%s",
								 cString];
								 UTF8String];
		} else
			path = @"";
	} @catch (id e) {
		[self release];
		@throw e;
	} @finally {
		free(cString2);
		free(UTF8String2);
	}

	return self;
}

- initWithString: (OFString*)string
   relativeToURL: (OFURL*)URL
{
	char *cString, *cString2 = NULL;
	char *UTF8String, *UTF8String2 = NULL;

	if ([string containsString: @"://"])
		return [self initWithString: string];

	self = [super init];

	@try {
		char *tmp;

		scheme = [URL->scheme copy];
		host = [URL->host copy];
		port = URL->port;
		user = [URL->user copy];
		password = [URL->password copy];

		if ((cString2 = strdup([string cString])) == NULL)
		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: [string cStringLength]];
			    requestedSize: [string UTF8StringLength]];

		cString = cString2;
		UTF8String = UTF8String2;

		if ((tmp = strchr(cString, '#')) != NULL) {
		if ((tmp = strchr(UTF8String, '#')) != NULL) {
			*tmp = '\0';
			fragment = [[OFString alloc] initWithCString: tmp + 1];
			fragment = [[OFString alloc]
			    initWithUTF8String: tmp + 1];
		}

		if ((tmp = strchr(cString, '?')) != NULL) {
		if ((tmp = strchr(UTF8String, '?')) != NULL) {
			*tmp = '\0';
			query = [[OFString alloc] initWithCString: tmp + 1];
			query = [[OFString alloc] initWithUTF8String: tmp + 1];
		}

		if ((tmp = strchr(cString, ';')) != NULL) {
		if ((tmp = strchr(UTF8String, ';')) != NULL) {
			*tmp = '\0';
			parameters = [[OFString alloc]
			    initWithCString: tmp + 1];
			    initWithUTF8String: tmp + 1];
		}

		if (*cString == '/')
			path = [[OFString alloc] initWithCString: cString];
		if (*UTF8String == '/')
			path = [[OFString alloc]
			    initWithUTF8String: UTF8String];
		else {
			OFAutoreleasePool *pool;
			OFString *s;

			pool = [[OFAutoreleasePool alloc] init];

			if ([URL->path hasSuffix: @"/"])
				s = [OFString stringWithFormat: @"%@%s",
								URL->path,
								cString];
								UTF8String];
			else
				s = [OFString stringWithFormat: @"%@/../%s",
								URL->path,
								cString];
								UTF8String];

			path = [resolve_relative_path(s) copy];

			[pool release];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	} @finally {
		free(cString2);
		free(UTF8String2);
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{