1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4extern "C" {
5 pub type _IO_wide_data;
6 pub type _IO_codecvt;
7 pub type _IO_marker;
8 pub type RedisModuleCommand;
9 pub type clusterSlotToKeyMapping;
10 pub type clusterState;
11 fn dictAdd(
12 d: *mut dict,
13 key: *mut libc::c_void,
14 val: *mut libc::c_void,
15 ) -> libc::c_int;
16 fn fclose(__stream: *mut FILE) -> libc::c_int;
17 fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE;
18 fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int;
19 fn sdsnewlen(init: *const libc::c_void, initlen: size_t) -> sds;
20 fn sdsdup(s: sds) -> sds;
21 fn sdsfree(s: sds);
22 fn sdsfromlonglong(value: libc::c_longlong) -> sds;
23 fn qsort(
24 __base: *mut libc::c_void,
25 __nmemb: size_t,
26 __size: size_t,
27 __compar: __compar_fn_t,
28 );
29 fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
30 fn zmalloc(size: size_t) -> *mut libc::c_void;
31 fn zcalloc(size: size_t) -> *mut libc::c_void;
32 fn zrealloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void;
33 fn zfree(ptr: *mut libc::c_void);
34 fn fixedpoint_d2string(
35 dst: *mut libc::c_char,
36 dstlen: size_t,
37 dvalue: libc::c_double,
38 fractional_digits: libc::c_int,
39 ) -> libc::c_int;
40 fn lpGetValue(
41 p: *mut libc::c_uchar,
42 slen: *mut libc::c_uint,
43 lval: *mut libc::c_longlong,
44 ) -> *mut libc::c_uchar;
45 fn lpNext(lp: *mut libc::c_uchar, p: *mut libc::c_uchar) -> *mut libc::c_uchar;
46 static mut server: redisServer;
47 static mut shared: sharedObjectsStruct;
48 fn addReplyNull(c: *mut client);
49 fn addReplyNullArray(c: *mut client);
50 fn addReplyBulkCBuffer(c: *mut client, p: *const libc::c_void, len: size_t);
51 fn addReply(c: *mut client, obj: *mut robj);
52 fn addReplyBulkSds(c: *mut client, s: sds);
53 fn addReplyErrorObject(c: *mut client, err: *mut robj);
54 fn addReplyError(c: *mut client, err: *const libc::c_char);
55 fn addReplyHumanLongDouble(c: *mut client, d: f64);
56 fn addReplyLongLong(c: *mut client, ll: libc::c_longlong);
57 fn addReplyArrayLen(c: *mut client, length: libc::c_long);
58 fn replaceClientCommandVector(
59 c: *mut client,
60 argc: libc::c_int,
61 argv: *mut *mut robj,
62 );
63 fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
64 fn decrRefCount(o: *mut robj);
65 fn incrRefCount(o: *mut robj);
66 fn createObject(type_0: libc::c_int, ptr: *mut libc::c_void) -> *mut robj;
67 fn createRawStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
68 fn createZsetObject() -> *mut robj;
69 fn checkType(c: *mut client, o: *mut robj, type_0: libc::c_int) -> libc::c_int;
70 fn getLongLongFromObjectOrReply(
71 c: *mut client,
72 o: *mut robj,
73 target: *mut libc::c_longlong,
74 msg: *const libc::c_char,
75 ) -> libc::c_int;
76 fn getDoubleFromObjectOrReply(
77 c: *mut client,
78 o: *mut robj,
79 target: *mut libc::c_double,
80 msg: *const libc::c_char,
81 ) -> libc::c_int;
82 fn zslInsert(
83 zsl: *mut zskiplist,
84 score: libc::c_double,
85 ele: sds,
86 ) -> *mut zskiplistNode;
87 fn zslFirstInRange(
88 zsl: *mut zskiplist,
89 range: *mut zrangespec,
90 ) -> *mut zskiplistNode;
91 fn zzlGetScore(sptr: *mut libc::c_uchar) -> libc::c_double;
92 fn zzlNext(
93 zl: *mut libc::c_uchar,
94 eptr: *mut *mut libc::c_uchar,
95 sptr: *mut *mut libc::c_uchar,
96 );
97 fn zzlFirstInRange(
98 zl: *mut libc::c_uchar,
99 range: *mut zrangespec,
100 ) -> *mut libc::c_uchar;
101 fn zsetConvertToListpackIfNeeded(
102 zobj: *mut robj,
103 maxelelen: size_t,
104 totelelen: size_t,
105 );
106 fn zsetScore(
107 zobj: *mut robj,
108 member: sds,
109 score: *mut libc::c_double,
110 ) -> libc::c_int;
111 fn zslValueLteMax(value: libc::c_double, spec: *mut zrangespec) -> libc::c_int;
112 fn notifyKeyspaceEvent(
113 type_0: libc::c_int,
114 event: *mut libc::c_char,
115 key: *mut robj,
116 dbid: libc::c_int,
117 );
118 fn lookupKeyRead(db: *mut redisDb, key: *mut robj) -> *mut robj;
119 fn lookupKeyReadOrReply(
120 c: *mut client,
121 key: *mut robj,
122 reply: *mut robj,
123 ) -> *mut robj;
124 fn setKey(
125 c: *mut client,
126 db: *mut redisDb,
127 key: *mut robj,
128 val: *mut robj,
129 flags: libc::c_int,
130 );
131 fn dbDelete(db: *mut redisDb, key: *mut robj) -> libc::c_int;
132 fn signalModifiedKey(c: *mut client, db: *mut redisDb, key: *mut robj);
133 fn zaddCommand(c: *mut client);
134 fn _serverAssert(
135 estr: *const libc::c_char,
136 file: *const libc::c_char,
137 line: libc::c_int,
138 );
139 fn geohashGetCoordRange(long_range: *mut GeoHashRange, lat_range: *mut GeoHashRange);
140 fn geohashEncode(
141 long_range: *const GeoHashRange,
142 lat_range: *const GeoHashRange,
143 longitude: libc::c_double,
144 latitude: libc::c_double,
145 step: uint8_t,
146 hash: *mut GeoHashBits,
147 ) -> libc::c_int;
148 fn geohashEncodeWGS84(
149 longitude: libc::c_double,
150 latitude: libc::c_double,
151 step: uint8_t,
152 hash: *mut GeoHashBits,
153 ) -> libc::c_int;
154 fn geohashDecode(
155 long_range: GeoHashRange,
156 lat_range: GeoHashRange,
157 hash: GeoHashBits,
158 area: *mut GeoHashArea,
159 ) -> libc::c_int;
160 fn geohashCalculateAreasByShapeWGS84(shape: *mut GeoShape) -> GeoHashRadius;
161 fn geohashGetDistance(
162 lon1d: libc::c_double,
163 lat1d: libc::c_double,
164 lon2d: libc::c_double,
165 lat2d: libc::c_double,
166 ) -> libc::c_double;
167 fn geohashGetDistanceIfInRectangle(
168 width_m: libc::c_double,
169 height_m: libc::c_double,
170 x1: libc::c_double,
171 y1: libc::c_double,
172 x2: libc::c_double,
173 y2: libc::c_double,
174 distance: *mut libc::c_double,
175 ) -> libc::c_int;
176 fn geohashDecodeToLongLatWGS84(
177 hash: GeoHashBits,
178 xy: *mut libc::c_double,
179 ) -> libc::c_int;
180 fn geohashAlign52Bits(hash: GeoHashBits) -> GeoHashFix52Bits;
181 fn geohashGetDistanceIfInRadiusWGS84(
182 x1: libc::c_double,
183 y1: libc::c_double,
184 x2: libc::c_double,
185 y2: libc::c_double,
186 radius: libc::c_double,
187 distance: *mut libc::c_double,
188 ) -> libc::c_int;
189 fn pqsort(
190 a: *mut libc::c_void,
191 n: size_t,
192 es: size_t,
193 cmp: Option::<
194 unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
195 >,
196 lrange: size_t,
197 rrange: size_t,
198 );
199}
200pub type __uint8_t = libc::c_uchar;
201pub type __int16_t = libc::c_short;
202pub type __uint16_t = libc::c_ushort;
203pub type __int32_t = libc::c_int;
204pub type __uint32_t = libc::c_uint;
205pub type __int64_t = libc::c_long;
206pub type __uint64_t = libc::c_ulong;
207pub type __uint_least64_t = __uint64_t;
208pub type __mode_t = libc::c_uint;
209pub type __off_t = libc::c_long;
210pub type __off64_t = libc::c_long;
211pub type __pid_t = libc::c_int;
212pub type __time_t = libc::c_long;
213pub type __ssize_t = libc::c_long;
214pub type __sig_atomic_t = libc::c_int;
215pub type size_t = libc::c_ulong;
216#[derive(Copy, Clone)]
217#[repr(C)]
218pub struct iovec {
219 pub iov_base: *mut libc::c_void,
220 pub iov_len: size_t,
221}
222pub type mode_t = __mode_t;
223pub type off_t = __off64_t;
224pub type pid_t = __pid_t;
225pub type ssize_t = __ssize_t;
226pub type time_t = __time_t;
227pub type int16_t = __int16_t;
228pub type int32_t = __int32_t;
229pub type int64_t = __int64_t;
230pub type pthread_t = libc::c_ulong;
231#[derive(Copy, Clone)]
232#[repr(C)]
233pub struct _IO_FILE {
234 pub _flags: libc::c_int,
235 pub _IO_read_ptr: *mut libc::c_char,
236 pub _IO_read_end: *mut libc::c_char,
237 pub _IO_read_base: *mut libc::c_char,
238 pub _IO_write_base: *mut libc::c_char,
239 pub _IO_write_ptr: *mut libc::c_char,
240 pub _IO_write_end: *mut libc::c_char,
241 pub _IO_buf_base: *mut libc::c_char,
242 pub _IO_buf_end: *mut libc::c_char,
243 pub _IO_save_base: *mut libc::c_char,
244 pub _IO_backup_base: *mut libc::c_char,
245 pub _IO_save_end: *mut libc::c_char,
246 pub _markers: *mut _IO_marker,
247 pub _chain: *mut _IO_FILE,
248 pub _fileno: libc::c_int,
249 pub _flags2: libc::c_int,
250 pub _old_offset: __off_t,
251 pub _cur_column: libc::c_ushort,
252 pub _vtable_offset: libc::c_schar,
253 pub _shortbuf: [libc::c_char; 1],
254 pub _lock: *mut libc::c_void,
255 pub _offset: __off64_t,
256 pub _codecvt: *mut _IO_codecvt,
257 pub _wide_data: *mut _IO_wide_data,
258 pub _freeres_list: *mut _IO_FILE,
259 pub _freeres_buf: *mut libc::c_void,
260 pub __pad5: size_t,
261 pub _mode: libc::c_int,
262 pub _unused2: [libc::c_char; 20],
263}
264pub type _IO_lock_t = ();
265pub type FILE = _IO_FILE;
266pub type uint8_t = __uint8_t;
267pub type uint16_t = __uint16_t;
268pub type uint32_t = __uint32_t;
269pub type uint64_t = __uint64_t;
270pub type uint_least64_t = __uint_least64_t;
271pub type sds = *mut libc::c_char;
272#[derive(Copy, Clone)]
273#[repr(C, packed)]
274pub struct sdshdr8 {
275 pub len: uint8_t,
276 pub alloc: uint8_t,
277 pub flags: libc::c_uchar,
278 pub buf: [libc::c_char; 0],
279}
280#[derive(Copy, Clone)]
281#[repr(C, packed)]
282pub struct sdshdr16 {
283 pub len: uint16_t,
284 pub alloc: uint16_t,
285 pub flags: libc::c_uchar,
286 pub buf: [libc::c_char; 0],
287}
288#[derive(Copy, Clone)]
289#[repr(C, packed)]
290pub struct sdshdr32 {
291 pub len: uint32_t,
292 pub alloc: uint32_t,
293 pub flags: libc::c_uchar,
294 pub buf: [libc::c_char; 0],
295}
296#[derive(Copy, Clone)]
297#[repr(C, packed)]
298pub struct sdshdr64 {
299 pub len: uint64_t,
300 pub alloc: uint64_t,
301 pub flags: libc::c_uchar,
302 pub buf: [libc::c_char; 0],
303}
304#[derive(Copy, Clone)]
305#[repr(C)]
306pub struct aeEventLoop {
307 pub maxfd: libc::c_int,
308 pub setsize: libc::c_int,
309 pub timeEventNextId: libc::c_longlong,
310 pub events: *mut aeFileEvent,
311 pub fired: *mut aeFiredEvent,
312 pub timeEventHead: *mut aeTimeEvent,
313 pub stop: libc::c_int,
314 pub apidata: *mut libc::c_void,
315 pub beforesleep: Option::<aeBeforeSleepProc>,
316 pub aftersleep: Option::<aeBeforeSleepProc>,
317 pub flags: libc::c_int,
318}
319pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
320#[derive(Copy, Clone)]
321#[repr(C)]
322pub struct aeTimeEvent {
323 pub id: libc::c_longlong,
324 pub when: monotime,
325 pub timeProc: Option::<aeTimeProc>,
326 pub finalizerProc: Option::<aeEventFinalizerProc>,
327 pub clientData: *mut libc::c_void,
328 pub prev: *mut aeTimeEvent,
329 pub next: *mut aeTimeEvent,
330 pub refcount: libc::c_int,
331}
332pub type aeEventFinalizerProc = unsafe extern "C" fn(
333 *mut aeEventLoop,
334 *mut libc::c_void,
335) -> ();
336pub type aeTimeProc = unsafe extern "C" fn(
337 *mut aeEventLoop,
338 libc::c_longlong,
339 *mut libc::c_void,
340) -> libc::c_int;
341pub type monotime = uint64_t;
342#[derive(Copy, Clone)]
343#[repr(C)]
344pub struct aeFiredEvent {
345 pub fd: libc::c_int,
346 pub mask: libc::c_int,
347}
348#[derive(Copy, Clone)]
349#[repr(C)]
350pub struct aeFileEvent {
351 pub mask: libc::c_int,
352 pub rfileProc: Option::<aeFileProc>,
353 pub wfileProc: Option::<aeFileProc>,
354 pub clientData: *mut libc::c_void,
355}
356pub type aeFileProc = unsafe extern "C" fn(
357 *mut aeEventLoop,
358 libc::c_int,
359 *mut libc::c_void,
360 libc::c_int,
361) -> ();
362#[derive(Copy, Clone)]
363#[repr(C)]
364pub struct connection {
365 pub type_0: *mut ConnectionType,
366 pub state: ConnectionState,
367 pub flags: libc::c_short,
368 pub refs: libc::c_short,
369 pub last_errno: libc::c_int,
370 pub private_data: *mut libc::c_void,
371 pub conn_handler: ConnectionCallbackFunc,
372 pub write_handler: ConnectionCallbackFunc,
373 pub read_handler: ConnectionCallbackFunc,
374 pub fd: libc::c_int,
375}
376pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
377pub type ConnectionState = libc::c_uint;
378pub const CONN_STATE_ERROR: ConnectionState = 5;
379pub const CONN_STATE_CLOSED: ConnectionState = 4;
380pub const CONN_STATE_CONNECTED: ConnectionState = 3;
381pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
382pub const CONN_STATE_CONNECTING: ConnectionState = 1;
383pub const CONN_STATE_NONE: ConnectionState = 0;
384#[derive(Copy, Clone)]
385#[repr(C)]
386pub struct ConnectionType {
387 pub ae_handler: Option::<
388 unsafe extern "C" fn(
389 *mut aeEventLoop,
390 libc::c_int,
391 *mut libc::c_void,
392 libc::c_int,
393 ) -> (),
394 >,
395 pub connect: Option::<
396 unsafe extern "C" fn(
397 *mut connection,
398 *const libc::c_char,
399 libc::c_int,
400 *const libc::c_char,
401 ConnectionCallbackFunc,
402 ) -> libc::c_int,
403 >,
404 pub write: Option::<
405 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
406 >,
407 pub writev: Option::<
408 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
409 >,
410 pub read: Option::<
411 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
412 >,
413 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
414 pub accept: Option::<
415 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
416 >,
417 pub set_write_handler: Option::<
418 unsafe extern "C" fn(
419 *mut connection,
420 ConnectionCallbackFunc,
421 libc::c_int,
422 ) -> libc::c_int,
423 >,
424 pub set_read_handler: Option::<
425 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
426 >,
427 pub get_last_error: Option::<
428 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
429 >,
430 pub blocking_connect: Option::<
431 unsafe extern "C" fn(
432 *mut connection,
433 *const libc::c_char,
434 libc::c_int,
435 libc::c_longlong,
436 ) -> libc::c_int,
437 >,
438 pub sync_write: Option::<
439 unsafe extern "C" fn(
440 *mut connection,
441 *mut libc::c_char,
442 ssize_t,
443 libc::c_longlong,
444 ) -> ssize_t,
445 >,
446 pub sync_read: Option::<
447 unsafe extern "C" fn(
448 *mut connection,
449 *mut libc::c_char,
450 ssize_t,
451 libc::c_longlong,
452 ) -> ssize_t,
453 >,
454 pub sync_readline: Option::<
455 unsafe extern "C" fn(
456 *mut connection,
457 *mut libc::c_char,
458 ssize_t,
459 libc::c_longlong,
460 ) -> ssize_t,
461 >,
462 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
463}
464#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
465#[repr(C)]
466pub struct redisObject {
467 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
468 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
469 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
470 pub type_0_encoding_lru: [u8; 4],
471 pub refcount: libc::c_int,
472 pub ptr: *mut libc::c_void,
473}
474pub type atomic_int = libc::c_int;
475pub type atomic_uint = libc::c_uint;
476pub type atomic_llong = libc::c_longlong;
477pub type __compar_fn_t = Option::<
478 unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
479>;
480pub type sig_atomic_t = __sig_atomic_t;
481#[derive(Copy, Clone)]
482#[repr(C)]
483pub struct hdr_histogram {
484 pub lowest_discernible_value: int64_t,
485 pub highest_trackable_value: int64_t,
486 pub unit_magnitude: int32_t,
487 pub significant_figures: int32_t,
488 pub sub_bucket_half_count_magnitude: int32_t,
489 pub sub_bucket_half_count: int32_t,
490 pub sub_bucket_mask: int64_t,
491 pub sub_bucket_count: int32_t,
492 pub bucket_count: int32_t,
493 pub min_value: int64_t,
494 pub max_value: int64_t,
495 pub normalizing_index_offset: int32_t,
496 pub conversion_ratio: libc::c_double,
497 pub counts_len: int32_t,
498 pub total_count: int64_t,
499 pub counts: *mut int64_t,
500}
501pub type mstime_t = libc::c_longlong;
502pub type ustime_t = libc::c_longlong;
503#[derive(Copy, Clone)]
504#[repr(C)]
505pub struct dictEntry {
506 pub key: *mut libc::c_void,
507 pub v: C2RustUnnamed,
508 pub next: *mut dictEntry,
509 pub metadata: [*mut libc::c_void; 0],
510}
511#[derive(Copy, Clone)]
512#[repr(C)]
513pub union C2RustUnnamed {
514 pub val: *mut libc::c_void,
515 pub u64_0: uint64_t,
516 pub s64: int64_t,
517 pub d: libc::c_double,
518}
519#[derive(Copy, Clone)]
520#[repr(C)]
521pub struct dict {
522 pub type_0: *mut dictType,
523 pub ht_table: [*mut *mut dictEntry; 2],
524 pub ht_used: [libc::c_ulong; 2],
525 pub rehashidx: libc::c_long,
526 pub pauserehash: int16_t,
527 pub ht_size_exp: [libc::c_schar; 2],
528}
529#[derive(Copy, Clone)]
530#[repr(C)]
531pub struct dictType {
532 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
533 pub keyDup: Option::<
534 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
535 >,
536 pub valDup: Option::<
537 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
538 >,
539 pub keyCompare: Option::<
540 unsafe extern "C" fn(
541 *mut dict,
542 *const libc::c_void,
543 *const libc::c_void,
544 ) -> libc::c_int,
545 >,
546 pub keyDestructor: Option::<
547 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
548 >,
549 pub valDestructor: Option::<
550 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
551 >,
552 pub expandAllowed: Option::<
553 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
554 >,
555 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
556}
557#[derive(Copy, Clone)]
558#[repr(C)]
559pub struct listNode {
560 pub prev: *mut listNode,
561 pub next: *mut listNode,
562 pub value: *mut libc::c_void,
563}
564#[derive(Copy, Clone)]
565#[repr(C)]
566pub struct list {
567 pub head: *mut listNode,
568 pub tail: *mut listNode,
569 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
570 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
571 pub match_0: Option::<
572 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
573 >,
574 pub len: libc::c_ulong,
575}
576#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
577#[repr(C)]
578pub struct raxNode {
579 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
580 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
581 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
582 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
583 pub iskey_isnull_iscompr_size: [u8; 4],
584 pub data: [libc::c_uchar; 0],
585}
586#[derive(Copy, Clone)]
587#[repr(C)]
588pub struct rax {
589 pub head: *mut raxNode,
590 pub numele: uint64_t,
591 pub numnodes: uint64_t,
592}
593pub type pause_type = libc::c_uint;
594pub const CLIENT_PAUSE_ALL: pause_type = 2;
595pub const CLIENT_PAUSE_WRITE: pause_type = 1;
596pub const CLIENT_PAUSE_OFF: pause_type = 0;
597#[derive(Copy, Clone)]
598#[repr(C)]
599pub struct pause_event {
600 pub type_0: pause_type,
601 pub end: mstime_t,
602}
603pub type robj = redisObject;
604pub type RedisModuleUserChangedFunc = Option::<
605 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
606>;
607#[derive(Copy, Clone)]
608#[repr(C)]
609pub struct redisDb {
610 pub dict: *mut dict,
611 pub expires: *mut dict,
612 pub blocking_keys: *mut dict,
613 pub ready_keys: *mut dict,
614 pub watched_keys: *mut dict,
615 pub id: libc::c_int,
616 pub avg_ttl: libc::c_longlong,
617 pub expires_cursor: libc::c_ulong,
618 pub defrag_later: *mut list,
619 pub slots_to_keys: *mut clusterSlotToKeyMapping,
620}
621#[derive(Copy, Clone)]
622#[repr(C)]
623pub struct multiCmd {
624 pub argv: *mut *mut robj,
625 pub argv_len: libc::c_int,
626 pub argc: libc::c_int,
627 pub cmd: *mut redisCommand,
628}
629#[derive(Copy, Clone)]
630#[repr(C)]
631pub struct redisCommand {
632 pub declared_name: *const libc::c_char,
633 pub summary: *const libc::c_char,
634 pub complexity: *const libc::c_char,
635 pub since: *const libc::c_char,
636 pub doc_flags: libc::c_int,
637 pub replaced_by: *const libc::c_char,
638 pub deprecated_since: *const libc::c_char,
639 pub group: redisCommandGroup,
640 pub history: *mut commandHistory,
641 pub tips: *mut *const libc::c_char,
642 pub proc_0: Option::<redisCommandProc>,
643 pub arity: libc::c_int,
644 pub flags: uint64_t,
645 pub acl_categories: uint64_t,
646 pub key_specs_static: [keySpec; 4],
647 pub getkeys_proc: Option::<redisGetKeysProc>,
648 pub subcommands: *mut redisCommand,
649 pub args: *mut redisCommandArg,
650 pub microseconds: libc::c_longlong,
651 pub calls: libc::c_longlong,
652 pub rejected_calls: libc::c_longlong,
653 pub failed_calls: libc::c_longlong,
654 pub id: libc::c_int,
655 pub fullname: sds,
656 pub latency_histogram: *mut hdr_histogram,
657 pub key_specs: *mut keySpec,
658 pub legacy_range_key_spec: keySpec,
659 pub num_args: libc::c_int,
660 pub num_history: libc::c_int,
661 pub num_tips: libc::c_int,
662 pub key_specs_num: libc::c_int,
663 pub key_specs_max: libc::c_int,
664 pub subcommands_dict: *mut dict,
665 pub parent: *mut redisCommand,
666 pub module_cmd: *mut RedisModuleCommand,
667}
668#[derive(Copy, Clone)]
669#[repr(C)]
670pub struct keySpec {
671 pub notes: *const libc::c_char,
672 pub flags: uint64_t,
673 pub begin_search_type: kspec_bs_type,
674 pub bs: C2RustUnnamed_3,
675 pub find_keys_type: kspec_fk_type,
676 pub fk: C2RustUnnamed_0,
677}
678#[derive(Copy, Clone)]
679#[repr(C)]
680pub union C2RustUnnamed_0 {
681 pub range: C2RustUnnamed_2,
682 pub keynum: C2RustUnnamed_1,
683}
684#[derive(Copy, Clone)]
685#[repr(C)]
686pub struct C2RustUnnamed_1 {
687 pub keynumidx: libc::c_int,
688 pub firstkey: libc::c_int,
689 pub keystep: libc::c_int,
690}
691#[derive(Copy, Clone)]
692#[repr(C)]
693pub struct C2RustUnnamed_2 {
694 pub lastkey: libc::c_int,
695 pub keystep: libc::c_int,
696 pub limit: libc::c_int,
697}
698pub type kspec_fk_type = libc::c_uint;
699pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
700pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
701pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
702pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
703#[derive(Copy, Clone)]
704#[repr(C)]
705pub union C2RustUnnamed_3 {
706 pub index: C2RustUnnamed_5,
707 pub keyword: C2RustUnnamed_4,
708}
709#[derive(Copy, Clone)]
710#[repr(C)]
711pub struct C2RustUnnamed_4 {
712 pub keyword: *const libc::c_char,
713 pub startfrom: libc::c_int,
714}
715#[derive(Copy, Clone)]
716#[repr(C)]
717pub struct C2RustUnnamed_5 {
718 pub pos: libc::c_int,
719}
720pub type kspec_bs_type = libc::c_uint;
721pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
722pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
723pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
724pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
725#[derive(Copy, Clone)]
726#[repr(C)]
727pub struct redisCommandArg {
728 pub name: *const libc::c_char,
729 pub type_0: redisCommandArgType,
730 pub key_spec_index: libc::c_int,
731 pub token: *const libc::c_char,
732 pub summary: *const libc::c_char,
733 pub since: *const libc::c_char,
734 pub flags: libc::c_int,
735 pub deprecated_since: *const libc::c_char,
736 pub subargs: *mut redisCommandArg,
737 pub num_args: libc::c_int,
738}
739pub type redisCommandArgType = libc::c_uint;
740pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
741pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
742pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
743pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
744pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
745pub const ARG_TYPE_KEY: redisCommandArgType = 3;
746pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
747pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
748pub const ARG_TYPE_STRING: redisCommandArgType = 0;
749pub type redisGetKeysProc = unsafe extern "C" fn(
750 *mut redisCommand,
751 *mut *mut robj,
752 libc::c_int,
753 *mut getKeysResult,
754) -> libc::c_int;
755#[derive(Copy, Clone)]
756#[repr(C)]
757pub struct getKeysResult {
758 pub keysbuf: [keyReference; 256],
759 pub keys: *mut keyReference,
760 pub numkeys: libc::c_int,
761 pub size: libc::c_int,
762}
763#[derive(Copy, Clone)]
764#[repr(C)]
765pub struct keyReference {
766 pub pos: libc::c_int,
767 pub flags: libc::c_int,
768}
769pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
770#[derive(Copy, Clone)]
771#[repr(C)]
772pub struct client {
773 pub id: uint64_t,
774 pub flags: uint64_t,
775 pub conn: *mut connection,
776 pub resp: libc::c_int,
777 pub db: *mut redisDb,
778 pub name: *mut robj,
779 pub querybuf: sds,
780 pub qb_pos: size_t,
781 pub querybuf_peak: size_t,
782 pub argc: libc::c_int,
783 pub argv: *mut *mut robj,
784 pub argv_len: libc::c_int,
785 pub original_argc: libc::c_int,
786 pub original_argv: *mut *mut robj,
787 pub argv_len_sum: size_t,
788 pub cmd: *mut redisCommand,
789 pub lastcmd: *mut redisCommand,
790 pub realcmd: *mut redisCommand,
791 pub user: *mut user,
792 pub reqtype: libc::c_int,
793 pub multibulklen: libc::c_int,
794 pub bulklen: libc::c_long,
795 pub reply: *mut list,
796 pub reply_bytes: libc::c_ulonglong,
797 pub deferred_reply_errors: *mut list,
798 pub sentlen: size_t,
799 pub ctime: time_t,
800 pub duration: libc::c_long,
801 pub slot: libc::c_int,
802 pub cur_script: *mut dictEntry,
803 pub lastinteraction: time_t,
804 pub obuf_soft_limit_reached_time: time_t,
805 pub authenticated: libc::c_int,
806 pub replstate: libc::c_int,
807 pub repl_start_cmd_stream_on_ack: libc::c_int,
808 pub repldbfd: libc::c_int,
809 pub repldboff: off_t,
810 pub repldbsize: off_t,
811 pub replpreamble: sds,
812 pub read_reploff: libc::c_longlong,
813 pub reploff: libc::c_longlong,
814 pub repl_applied: libc::c_longlong,
815 pub repl_ack_off: libc::c_longlong,
816 pub repl_ack_time: libc::c_longlong,
817 pub repl_last_partial_write: libc::c_longlong,
818 pub psync_initial_offset: libc::c_longlong,
819 pub replid: [libc::c_char; 41],
820 pub slave_listening_port: libc::c_int,
821 pub slave_addr: *mut libc::c_char,
822 pub slave_capa: libc::c_int,
823 pub slave_req: libc::c_int,
824 pub mstate: multiState,
825 pub btype: libc::c_int,
826 pub bpop: blockingState,
827 pub woff: libc::c_longlong,
828 pub watched_keys: *mut list,
829 pub pubsub_channels: *mut dict,
830 pub pubsub_patterns: *mut list,
831 pub pubsubshard_channels: *mut dict,
832 pub peerid: sds,
833 pub sockname: sds,
834 pub client_list_node: *mut listNode,
835 pub postponed_list_node: *mut listNode,
836 pub pending_read_list_node: *mut listNode,
837 pub auth_callback: RedisModuleUserChangedFunc,
838 pub auth_callback_privdata: *mut libc::c_void,
839 pub auth_module: *mut libc::c_void,
840 pub client_tracking_redirection: uint64_t,
841 pub client_tracking_prefixes: *mut rax,
842 pub last_memory_usage: size_t,
843 pub last_memory_type: libc::c_int,
844 pub mem_usage_bucket_node: *mut listNode,
845 pub mem_usage_bucket: *mut clientMemUsageBucket,
846 pub ref_repl_buf_node: *mut listNode,
847 pub ref_block_pos: size_t,
848 pub buf_peak: size_t,
849 pub buf_peak_last_reset_time: mstime_t,
850 pub bufpos: libc::c_int,
851 pub buf_usable_size: size_t,
852 pub buf: *mut libc::c_char,
853}
854#[derive(Copy, Clone)]
855#[repr(C)]
856pub struct clientMemUsageBucket {
857 pub clients: *mut list,
858 pub mem_usage_sum: size_t,
859}
860#[derive(Copy, Clone)]
861#[repr(C)]
862pub struct blockingState {
863 pub count: libc::c_long,
864 pub timeout: mstime_t,
865 pub keys: *mut dict,
866 pub target: *mut robj,
867 pub blockpos: blockPos,
868 pub xread_count: size_t,
869 pub xread_group: *mut robj,
870 pub xread_consumer: *mut robj,
871 pub xread_group_noack: libc::c_int,
872 pub numreplicas: libc::c_int,
873 pub reploffset: libc::c_longlong,
874 pub module_blocked_handle: *mut libc::c_void,
875}
876#[derive(Copy, Clone)]
877#[repr(C)]
878pub struct blockPos {
879 pub wherefrom: libc::c_int,
880 pub whereto: libc::c_int,
881}
882#[derive(Copy, Clone)]
883#[repr(C)]
884pub struct multiState {
885 pub commands: *mut multiCmd,
886 pub count: libc::c_int,
887 pub cmd_flags: libc::c_int,
888 pub cmd_inv_flags: libc::c_int,
889 pub argv_len_sums: size_t,
890 pub alloc_count: libc::c_int,
891}
892#[derive(Copy, Clone)]
893#[repr(C)]
894pub struct user {
895 pub name: sds,
896 pub flags: uint32_t,
897 pub passwords: *mut list,
898 pub selectors: *mut list,
899 pub acl_string: *mut robj,
900}
901#[derive(Copy, Clone)]
902#[repr(C)]
903pub struct commandHistory {
904 pub since: *const libc::c_char,
905 pub changes: *const libc::c_char,
906}
907pub type redisCommandGroup = libc::c_uint;
908pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
909pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
910pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
911pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
912pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
913pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
914pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
915pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
916pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
917pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
918pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
919pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
920pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
921pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
922pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
923pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
924pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
925pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
926#[derive(Copy, Clone)]
927#[repr(C)]
928pub struct replBacklog {
929 pub ref_repl_buf_node: *mut listNode,
930 pub unindexed_count: size_t,
931 pub blocks_index: *mut rax,
932 pub histlen: libc::c_longlong,
933 pub offset: libc::c_longlong,
934}
935#[derive(Copy, Clone)]
936#[repr(C)]
937pub struct saveparam {
938 pub seconds: time_t,
939 pub changes: libc::c_int,
940}
941#[derive(Copy, Clone)]
942#[repr(C)]
943pub struct sentinelConfig {
944 pub pre_monitor_cfg: *mut list,
945 pub monitor_cfg: *mut list,
946 pub post_monitor_cfg: *mut list,
947}
948#[derive(Copy, Clone)]
949#[repr(C)]
950pub struct sharedObjectsStruct {
951 pub crlf: *mut robj,
952 pub ok: *mut robj,
953 pub err: *mut robj,
954 pub emptybulk: *mut robj,
955 pub czero: *mut robj,
956 pub cone: *mut robj,
957 pub pong: *mut robj,
958 pub space: *mut robj,
959 pub queued: *mut robj,
960 pub null: [*mut robj; 4],
961 pub nullarray: [*mut robj; 4],
962 pub emptymap: [*mut robj; 4],
963 pub emptyset: [*mut robj; 4],
964 pub emptyarray: *mut robj,
965 pub wrongtypeerr: *mut robj,
966 pub nokeyerr: *mut robj,
967 pub syntaxerr: *mut robj,
968 pub sameobjecterr: *mut robj,
969 pub outofrangeerr: *mut robj,
970 pub noscripterr: *mut robj,
971 pub loadingerr: *mut robj,
972 pub slowevalerr: *mut robj,
973 pub slowscripterr: *mut robj,
974 pub slowmoduleerr: *mut robj,
975 pub bgsaveerr: *mut robj,
976 pub masterdownerr: *mut robj,
977 pub roslaveerr: *mut robj,
978 pub execaborterr: *mut robj,
979 pub noautherr: *mut robj,
980 pub noreplicaserr: *mut robj,
981 pub busykeyerr: *mut robj,
982 pub oomerr: *mut robj,
983 pub plus: *mut robj,
984 pub messagebulk: *mut robj,
985 pub pmessagebulk: *mut robj,
986 pub subscribebulk: *mut robj,
987 pub unsubscribebulk: *mut robj,
988 pub psubscribebulk: *mut robj,
989 pub punsubscribebulk: *mut robj,
990 pub del: *mut robj,
991 pub unlink: *mut robj,
992 pub rpop: *mut robj,
993 pub lpop: *mut robj,
994 pub lpush: *mut robj,
995 pub rpoplpush: *mut robj,
996 pub lmove: *mut robj,
997 pub blmove: *mut robj,
998 pub zpopmin: *mut robj,
999 pub zpopmax: *mut robj,
1000 pub emptyscan: *mut robj,
1001 pub multi: *mut robj,
1002 pub exec: *mut robj,
1003 pub left: *mut robj,
1004 pub right: *mut robj,
1005 pub hset: *mut robj,
1006 pub srem: *mut robj,
1007 pub xgroup: *mut robj,
1008 pub xclaim: *mut robj,
1009 pub script: *mut robj,
1010 pub replconf: *mut robj,
1011 pub eval: *mut robj,
1012 pub persist: *mut robj,
1013 pub set: *mut robj,
1014 pub pexpireat: *mut robj,
1015 pub pexpire: *mut robj,
1016 pub time: *mut robj,
1017 pub pxat: *mut robj,
1018 pub absttl: *mut robj,
1019 pub retrycount: *mut robj,
1020 pub force: *mut robj,
1021 pub justid: *mut robj,
1022 pub entriesread: *mut robj,
1023 pub lastid: *mut robj,
1024 pub ping: *mut robj,
1025 pub setid: *mut robj,
1026 pub keepttl: *mut robj,
1027 pub load: *mut robj,
1028 pub createconsumer: *mut robj,
1029 pub getack: *mut robj,
1030 pub special_asterick: *mut robj,
1031 pub special_equals: *mut robj,
1032 pub default_username: *mut robj,
1033 pub redacted: *mut robj,
1034 pub ssubscribebulk: *mut robj,
1035 pub sunsubscribebulk: *mut robj,
1036 pub smessagebulk: *mut robj,
1037 pub select: [*mut robj; 10],
1038 pub integers: [*mut robj; 10000],
1039 pub mbulkhdr: [*mut robj; 32],
1040 pub bulkhdr: [*mut robj; 32],
1041 pub maphdr: [*mut robj; 32],
1042 pub sethdr: [*mut robj; 32],
1043 pub minstring: sds,
1044 pub maxstring: sds,
1045}
1046#[derive(Copy, Clone)]
1047#[repr(C)]
1048pub struct zskiplistNode {
1049 pub ele: sds,
1050 pub score: libc::c_double,
1051 pub backward: *mut zskiplistNode,
1052 pub level: [zskiplistLevel; 0],
1053}
1054#[derive(Copy, Clone)]
1055#[repr(C)]
1056pub struct zskiplistLevel {
1057 pub forward: *mut zskiplistNode,
1058 pub span: libc::c_ulong,
1059}
1060#[derive(Copy, Clone)]
1061#[repr(C)]
1062pub struct zskiplist {
1063 pub header: *mut zskiplistNode,
1064 pub tail: *mut zskiplistNode,
1065 pub length: libc::c_ulong,
1066 pub level: libc::c_int,
1067}
1068#[derive(Copy, Clone)]
1069#[repr(C)]
1070pub struct zset {
1071 pub dict: *mut dict,
1072 pub zsl: *mut zskiplist,
1073}
1074#[derive(Copy, Clone)]
1075#[repr(C)]
1076pub struct clientBufferLimitsConfig {
1077 pub hard_limit_bytes: libc::c_ulonglong,
1078 pub soft_limit_bytes: libc::c_ulonglong,
1079 pub soft_limit_seconds: time_t,
1080}
1081#[derive(Copy, Clone)]
1082#[repr(C)]
1083pub struct redisOp {
1084 pub argv: *mut *mut robj,
1085 pub argc: libc::c_int,
1086 pub dbid: libc::c_int,
1087 pub target: libc::c_int,
1088}
1089#[derive(Copy, Clone)]
1090#[repr(C)]
1091pub struct redisOpArray {
1092 pub ops: *mut redisOp,
1093 pub numops: libc::c_int,
1094 pub capacity: libc::c_int,
1095}
1096#[derive(Copy, Clone)]
1097#[repr(C)]
1098pub struct malloc_stats {
1099 pub zmalloc_used: size_t,
1100 pub process_rss: size_t,
1101 pub allocator_allocated: size_t,
1102 pub allocator_active: size_t,
1103 pub allocator_resident: size_t,
1104}
1105#[derive(Copy, Clone)]
1106#[repr(C)]
1107pub struct socketFds {
1108 pub fd: [libc::c_int; 16],
1109 pub count: libc::c_int,
1110}
1111#[derive(Copy, Clone)]
1112#[repr(C)]
1113pub struct redisTLSContextConfig {
1114 pub cert_file: *mut libc::c_char,
1115 pub key_file: *mut libc::c_char,
1116 pub key_file_pass: *mut libc::c_char,
1117 pub client_cert_file: *mut libc::c_char,
1118 pub client_key_file: *mut libc::c_char,
1119 pub client_key_file_pass: *mut libc::c_char,
1120 pub dh_params_file: *mut libc::c_char,
1121 pub ca_cert_file: *mut libc::c_char,
1122 pub ca_cert_dir: *mut libc::c_char,
1123 pub protocols: *mut libc::c_char,
1124 pub ciphers: *mut libc::c_char,
1125 pub ciphersuites: *mut libc::c_char,
1126 pub prefer_server_ciphers: libc::c_int,
1127 pub session_caching: libc::c_int,
1128 pub session_cache_size: libc::c_int,
1129 pub session_cache_timeout: libc::c_int,
1130}
1131pub type aof_file_type = libc::c_uint;
1132pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
1133pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
1134pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
1135#[derive(Copy, Clone)]
1136#[repr(C)]
1137pub struct aofInfo {
1138 pub file_name: sds,
1139 pub file_seq: libc::c_longlong,
1140 pub file_type: aof_file_type,
1141}
1142#[derive(Copy, Clone)]
1143#[repr(C)]
1144pub struct aofManifest {
1145 pub base_aof_info: *mut aofInfo,
1146 pub incr_aof_list: *mut list,
1147 pub history_aof_list: *mut list,
1148 pub curr_base_file_seq: libc::c_longlong,
1149 pub curr_incr_file_seq: libc::c_longlong,
1150 pub dirty: libc::c_int,
1151}
1152#[derive(Copy, Clone)]
1153#[repr(C)]
1154pub struct redisServer {
1155 pub pid: pid_t,
1156 pub main_thread_id: pthread_t,
1157 pub configfile: *mut libc::c_char,
1158 pub executable: *mut libc::c_char,
1159 pub exec_argv: *mut *mut libc::c_char,
1160 pub dynamic_hz: libc::c_int,
1161 pub config_hz: libc::c_int,
1162 pub umask: mode_t,
1163 pub hz: libc::c_int,
1164 pub in_fork_child: libc::c_int,
1165 pub db: *mut redisDb,
1166 pub commands: *mut dict,
1167 pub orig_commands: *mut dict,
1168 pub el: *mut aeEventLoop,
1169 pub errors: *mut rax,
1170 pub lruclock: atomic_uint,
1171 pub shutdown_asap: sig_atomic_t,
1172 pub shutdown_mstime: mstime_t,
1173 pub last_sig_received: libc::c_int,
1174 pub shutdown_flags: libc::c_int,
1175 pub activerehashing: libc::c_int,
1176 pub active_defrag_running: libc::c_int,
1177 pub pidfile: *mut libc::c_char,
1178 pub arch_bits: libc::c_int,
1179 pub cronloops: libc::c_int,
1180 pub runid: [libc::c_char; 41],
1181 pub sentinel_mode: libc::c_int,
1182 pub initial_memory_usage: size_t,
1183 pub always_show_logo: libc::c_int,
1184 pub in_exec: libc::c_int,
1185 pub busy_module_yield_flags: libc::c_int,
1186 pub busy_module_yield_reply: *const libc::c_char,
1187 pub core_propagates: libc::c_int,
1188 pub propagate_no_multi: libc::c_int,
1189 pub module_ctx_nesting: libc::c_int,
1190 pub ignore_warnings: *mut libc::c_char,
1191 pub client_pause_in_transaction: libc::c_int,
1192 pub thp_enabled: libc::c_int,
1193 pub page_size: size_t,
1194 pub moduleapi: *mut dict,
1195 pub sharedapi: *mut dict,
1196 pub module_configs_queue: *mut dict,
1197 pub loadmodule_queue: *mut list,
1198 pub module_pipe: [libc::c_int; 2],
1199 pub child_pid: pid_t,
1200 pub child_type: libc::c_int,
1201 pub port: libc::c_int,
1202 pub tls_port: libc::c_int,
1203 pub tcp_backlog: libc::c_int,
1204 pub bindaddr: [*mut libc::c_char; 16],
1205 pub bindaddr_count: libc::c_int,
1206 pub bind_source_addr: *mut libc::c_char,
1207 pub unixsocket: *mut libc::c_char,
1208 pub unixsocketperm: libc::c_uint,
1209 pub ipfd: socketFds,
1210 pub tlsfd: socketFds,
1211 pub sofd: libc::c_int,
1212 pub socket_mark_id: uint32_t,
1213 pub cfd: socketFds,
1214 pub clients: *mut list,
1215 pub clients_to_close: *mut list,
1216 pub clients_pending_write: *mut list,
1217 pub clients_pending_read: *mut list,
1218 pub slaves: *mut list,
1219 pub monitors: *mut list,
1220 pub current_client: *mut client,
1221 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1222 pub clients_timeout_table: *mut rax,
1223 pub fixed_time_expire: libc::c_long,
1224 pub in_nested_call: libc::c_int,
1225 pub clients_index: *mut rax,
1226 pub client_pause_type: pause_type,
1227 pub postponed_clients: *mut list,
1228 pub client_pause_end_time: mstime_t,
1229 pub client_pause_per_purpose: [*mut pause_event; 3],
1230 pub neterr: [libc::c_char; 256],
1231 pub migrate_cached_sockets: *mut dict,
1232 pub next_client_id: uint_least64_t,
1233 pub protected_mode: libc::c_int,
1234 pub io_threads_num: libc::c_int,
1235 pub io_threads_do_reads: libc::c_int,
1236 pub io_threads_active: libc::c_int,
1237 pub events_processed_while_blocked: libc::c_longlong,
1238 pub enable_protected_configs: libc::c_int,
1239 pub enable_debug_cmd: libc::c_int,
1240 pub enable_module_cmd: libc::c_int,
1241 pub loading: sig_atomic_t,
1242 pub async_loading: sig_atomic_t,
1243 pub loading_total_bytes: off_t,
1244 pub loading_rdb_used_mem: off_t,
1245 pub loading_loaded_bytes: off_t,
1246 pub loading_start_time: time_t,
1247 pub loading_process_events_interval_bytes: off_t,
1248 pub stat_starttime: time_t,
1249 pub stat_numcommands: libc::c_longlong,
1250 pub stat_numconnections: libc::c_longlong,
1251 pub stat_expiredkeys: libc::c_longlong,
1252 pub stat_expired_stale_perc: libc::c_double,
1253 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1254 pub stat_expire_cycle_time_used: libc::c_longlong,
1255 pub stat_evictedkeys: libc::c_longlong,
1256 pub stat_evictedclients: libc::c_longlong,
1257 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1258 pub stat_last_eviction_exceeded_time: monotime,
1259 pub stat_keyspace_hits: libc::c_longlong,
1260 pub stat_keyspace_misses: libc::c_longlong,
1261 pub stat_active_defrag_hits: libc::c_longlong,
1262 pub stat_active_defrag_misses: libc::c_longlong,
1263 pub stat_active_defrag_key_hits: libc::c_longlong,
1264 pub stat_active_defrag_key_misses: libc::c_longlong,
1265 pub stat_active_defrag_scanned: libc::c_longlong,
1266 pub stat_total_active_defrag_time: libc::c_longlong,
1267 pub stat_last_active_defrag_time: monotime,
1268 pub stat_peak_memory: size_t,
1269 pub stat_aof_rewrites: libc::c_longlong,
1270 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1271 pub stat_rdb_saves: libc::c_longlong,
1272 pub stat_fork_time: libc::c_longlong,
1273 pub stat_fork_rate: libc::c_double,
1274 pub stat_total_forks: libc::c_longlong,
1275 pub stat_rejected_conn: libc::c_longlong,
1276 pub stat_sync_full: libc::c_longlong,
1277 pub stat_sync_partial_ok: libc::c_longlong,
1278 pub stat_sync_partial_err: libc::c_longlong,
1279 pub slowlog: *mut list,
1280 pub slowlog_entry_id: libc::c_longlong,
1281 pub slowlog_log_slower_than: libc::c_longlong,
1282 pub slowlog_max_len: libc::c_ulong,
1283 pub cron_malloc_stats: malloc_stats,
1284 pub stat_net_input_bytes: atomic_llong,
1285 pub stat_net_output_bytes: atomic_llong,
1286 pub stat_net_repl_input_bytes: atomic_llong,
1287 pub stat_net_repl_output_bytes: atomic_llong,
1288 pub stat_current_cow_peak: size_t,
1289 pub stat_current_cow_bytes: size_t,
1290 pub stat_current_cow_updated: monotime,
1291 pub stat_current_save_keys_processed: size_t,
1292 pub stat_current_save_keys_total: size_t,
1293 pub stat_rdb_cow_bytes: size_t,
1294 pub stat_aof_cow_bytes: size_t,
1295 pub stat_module_cow_bytes: size_t,
1296 pub stat_module_progress: libc::c_double,
1297 pub stat_clients_type_memory: [size_t; 4],
1298 pub stat_cluster_links_memory: size_t,
1299 pub stat_unexpected_error_replies: libc::c_longlong,
1300 pub stat_total_error_replies: libc::c_longlong,
1301 pub stat_dump_payload_sanitizations: libc::c_longlong,
1302 pub stat_io_reads_processed: libc::c_longlong,
1303 pub stat_io_writes_processed: libc::c_longlong,
1304 pub stat_total_reads_processed: atomic_llong,
1305 pub stat_total_writes_processed: atomic_llong,
1306 pub inst_metric: [C2RustUnnamed_6; 5],
1307 pub stat_reply_buffer_shrinks: libc::c_longlong,
1308 pub stat_reply_buffer_expands: libc::c_longlong,
1309 pub verbosity: libc::c_int,
1310 pub maxidletime: libc::c_int,
1311 pub tcpkeepalive: libc::c_int,
1312 pub active_expire_enabled: libc::c_int,
1313 pub active_expire_effort: libc::c_int,
1314 pub active_defrag_enabled: libc::c_int,
1315 pub sanitize_dump_payload: libc::c_int,
1316 pub skip_checksum_validation: libc::c_int,
1317 pub jemalloc_bg_thread: libc::c_int,
1318 pub active_defrag_ignore_bytes: size_t,
1319 pub active_defrag_threshold_lower: libc::c_int,
1320 pub active_defrag_threshold_upper: libc::c_int,
1321 pub active_defrag_cycle_min: libc::c_int,
1322 pub active_defrag_cycle_max: libc::c_int,
1323 pub active_defrag_max_scan_fields: libc::c_ulong,
1324 pub client_max_querybuf_len: size_t,
1325 pub dbnum: libc::c_int,
1326 pub supervised: libc::c_int,
1327 pub supervised_mode: libc::c_int,
1328 pub daemonize: libc::c_int,
1329 pub set_proc_title: libc::c_int,
1330 pub proc_title_template: *mut libc::c_char,
1331 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1332 pub pause_cron: libc::c_int,
1333 pub latency_tracking_enabled: libc::c_int,
1334 pub latency_tracking_info_percentiles: *mut libc::c_double,
1335 pub latency_tracking_info_percentiles_len: libc::c_int,
1336 pub aof_enabled: libc::c_int,
1337 pub aof_state: libc::c_int,
1338 pub aof_fsync: libc::c_int,
1339 pub aof_filename: *mut libc::c_char,
1340 pub aof_dirname: *mut libc::c_char,
1341 pub aof_no_fsync_on_rewrite: libc::c_int,
1342 pub aof_rewrite_perc: libc::c_int,
1343 pub aof_rewrite_min_size: off_t,
1344 pub aof_rewrite_base_size: off_t,
1345 pub aof_current_size: off_t,
1346 pub aof_last_incr_size: off_t,
1347 pub aof_fsync_offset: off_t,
1348 pub aof_flush_sleep: libc::c_int,
1349 pub aof_rewrite_scheduled: libc::c_int,
1350 pub aof_buf: sds,
1351 pub aof_fd: libc::c_int,
1352 pub aof_selected_db: libc::c_int,
1353 pub aof_flush_postponed_start: time_t,
1354 pub aof_last_fsync: time_t,
1355 pub aof_rewrite_time_last: time_t,
1356 pub aof_rewrite_time_start: time_t,
1357 pub aof_cur_timestamp: time_t,
1358 pub aof_timestamp_enabled: libc::c_int,
1359 pub aof_lastbgrewrite_status: libc::c_int,
1360 pub aof_delayed_fsync: libc::c_ulong,
1361 pub aof_rewrite_incremental_fsync: libc::c_int,
1362 pub rdb_save_incremental_fsync: libc::c_int,
1363 pub aof_last_write_status: libc::c_int,
1364 pub aof_last_write_errno: libc::c_int,
1365 pub aof_load_truncated: libc::c_int,
1366 pub aof_use_rdb_preamble: libc::c_int,
1367 pub aof_bio_fsync_status: atomic_int,
1368 pub aof_bio_fsync_errno: atomic_int,
1369 pub aof_manifest: *mut aofManifest,
1370 pub aof_disable_auto_gc: libc::c_int,
1371 pub dirty: libc::c_longlong,
1372 pub dirty_before_bgsave: libc::c_longlong,
1373 pub rdb_last_load_keys_expired: libc::c_longlong,
1374 pub rdb_last_load_keys_loaded: libc::c_longlong,
1375 pub saveparams: *mut saveparam,
1376 pub saveparamslen: libc::c_int,
1377 pub rdb_filename: *mut libc::c_char,
1378 pub rdb_compression: libc::c_int,
1379 pub rdb_checksum: libc::c_int,
1380 pub rdb_del_sync_files: libc::c_int,
1381 pub lastsave: time_t,
1382 pub lastbgsave_try: time_t,
1383 pub rdb_save_time_last: time_t,
1384 pub rdb_save_time_start: time_t,
1385 pub rdb_bgsave_scheduled: libc::c_int,
1386 pub rdb_child_type: libc::c_int,
1387 pub lastbgsave_status: libc::c_int,
1388 pub stop_writes_on_bgsave_err: libc::c_int,
1389 pub rdb_pipe_read: libc::c_int,
1390 pub rdb_child_exit_pipe: libc::c_int,
1391 pub rdb_pipe_conns: *mut *mut connection,
1392 pub rdb_pipe_numconns: libc::c_int,
1393 pub rdb_pipe_numconns_writing: libc::c_int,
1394 pub rdb_pipe_buff: *mut libc::c_char,
1395 pub rdb_pipe_bufflen: libc::c_int,
1396 pub rdb_key_save_delay: libc::c_int,
1397 pub key_load_delay: libc::c_int,
1398 pub child_info_pipe: [libc::c_int; 2],
1399 pub child_info_nread: libc::c_int,
1400 pub also_propagate: redisOpArray,
1401 pub replication_allowed: libc::c_int,
1402 pub logfile: *mut libc::c_char,
1403 pub syslog_enabled: libc::c_int,
1404 pub syslog_ident: *mut libc::c_char,
1405 pub syslog_facility: libc::c_int,
1406 pub crashlog_enabled: libc::c_int,
1407 pub memcheck_enabled: libc::c_int,
1408 pub use_exit_on_panic: libc::c_int,
1409 pub shutdown_timeout: libc::c_int,
1410 pub shutdown_on_sigint: libc::c_int,
1411 pub shutdown_on_sigterm: libc::c_int,
1412 pub replid: [libc::c_char; 41],
1413 pub replid2: [libc::c_char; 41],
1414 pub master_repl_offset: libc::c_longlong,
1415 pub second_replid_offset: libc::c_longlong,
1416 pub slaveseldb: libc::c_int,
1417 pub repl_ping_slave_period: libc::c_int,
1418 pub repl_backlog: *mut replBacklog,
1419 pub repl_backlog_size: libc::c_longlong,
1420 pub repl_backlog_time_limit: time_t,
1421 pub repl_no_slaves_since: time_t,
1422 pub repl_min_slaves_to_write: libc::c_int,
1423 pub repl_min_slaves_max_lag: libc::c_int,
1424 pub repl_good_slaves_count: libc::c_int,
1425 pub repl_diskless_sync: libc::c_int,
1426 pub repl_diskless_load: libc::c_int,
1427 pub repl_diskless_sync_delay: libc::c_int,
1428 pub repl_diskless_sync_max_replicas: libc::c_int,
1429 pub repl_buffer_mem: size_t,
1430 pub repl_buffer_blocks: *mut list,
1431 pub masteruser: *mut libc::c_char,
1432 pub masterauth: sds,
1433 pub masterhost: *mut libc::c_char,
1434 pub masterport: libc::c_int,
1435 pub repl_timeout: libc::c_int,
1436 pub master: *mut client,
1437 pub cached_master: *mut client,
1438 pub repl_syncio_timeout: libc::c_int,
1439 pub repl_state: libc::c_int,
1440 pub repl_transfer_size: off_t,
1441 pub repl_transfer_read: off_t,
1442 pub repl_transfer_last_fsync_off: off_t,
1443 pub repl_transfer_s: *mut connection,
1444 pub repl_transfer_fd: libc::c_int,
1445 pub repl_transfer_tmpfile: *mut libc::c_char,
1446 pub repl_transfer_lastio: time_t,
1447 pub repl_serve_stale_data: libc::c_int,
1448 pub repl_slave_ro: libc::c_int,
1449 pub repl_slave_ignore_maxmemory: libc::c_int,
1450 pub repl_down_since: time_t,
1451 pub repl_disable_tcp_nodelay: libc::c_int,
1452 pub slave_priority: libc::c_int,
1453 pub replica_announced: libc::c_int,
1454 pub slave_announce_port: libc::c_int,
1455 pub slave_announce_ip: *mut libc::c_char,
1456 pub propagation_error_behavior: libc::c_int,
1457 pub repl_ignore_disk_write_error: libc::c_int,
1458 pub master_replid: [libc::c_char; 41],
1459 pub master_initial_offset: libc::c_longlong,
1460 pub repl_slave_lazy_flush: libc::c_int,
1461 pub clients_waiting_acks: *mut list,
1462 pub get_ack_from_slaves: libc::c_int,
1463 pub maxclients: libc::c_uint,
1464 pub maxmemory: libc::c_ulonglong,
1465 pub maxmemory_clients: ssize_t,
1466 pub maxmemory_policy: libc::c_int,
1467 pub maxmemory_samples: libc::c_int,
1468 pub maxmemory_eviction_tenacity: libc::c_int,
1469 pub lfu_log_factor: libc::c_int,
1470 pub lfu_decay_time: libc::c_int,
1471 pub proto_max_bulk_len: libc::c_longlong,
1472 pub oom_score_adj_values: [libc::c_int; 3],
1473 pub oom_score_adj: libc::c_int,
1474 pub disable_thp: libc::c_int,
1475 pub blocked_clients: libc::c_uint,
1476 pub blocked_clients_by_type: [libc::c_uint; 8],
1477 pub unblocked_clients: *mut list,
1478 pub ready_keys: *mut list,
1479 pub tracking_clients: libc::c_uint,
1480 pub tracking_table_max_keys: size_t,
1481 pub tracking_pending_keys: *mut list,
1482 pub sort_desc: libc::c_int,
1483 pub sort_alpha: libc::c_int,
1484 pub sort_bypattern: libc::c_int,
1485 pub sort_store: libc::c_int,
1486 pub hash_max_listpack_entries: size_t,
1487 pub hash_max_listpack_value: size_t,
1488 pub set_max_intset_entries: size_t,
1489 pub zset_max_listpack_entries: size_t,
1490 pub zset_max_listpack_value: size_t,
1491 pub hll_sparse_max_bytes: size_t,
1492 pub stream_node_max_bytes: size_t,
1493 pub stream_node_max_entries: libc::c_longlong,
1494 pub list_max_listpack_size: libc::c_int,
1495 pub list_compress_depth: libc::c_int,
1496 pub unixtime: atomic_int,
1497 pub timezone: time_t,
1498 pub daylight_active: libc::c_int,
1499 pub mstime: mstime_t,
1500 pub ustime: ustime_t,
1501 pub blocking_op_nesting: size_t,
1502 pub blocked_last_cron: libc::c_longlong,
1503 pub pubsub_channels: *mut dict,
1504 pub pubsub_patterns: *mut dict,
1505 pub notify_keyspace_events: libc::c_int,
1506 pub pubsubshard_channels: *mut dict,
1507 pub cluster_enabled: libc::c_int,
1508 pub cluster_port: libc::c_int,
1509 pub cluster_node_timeout: mstime_t,
1510 pub cluster_configfile: *mut libc::c_char,
1511 pub cluster: *mut clusterState,
1512 pub cluster_migration_barrier: libc::c_int,
1513 pub cluster_allow_replica_migration: libc::c_int,
1514 pub cluster_slave_validity_factor: libc::c_int,
1515 pub cluster_require_full_coverage: libc::c_int,
1516 pub cluster_slave_no_failover: libc::c_int,
1517 pub cluster_announce_ip: *mut libc::c_char,
1518 pub cluster_announce_hostname: *mut libc::c_char,
1519 pub cluster_preferred_endpoint_type: libc::c_int,
1520 pub cluster_announce_port: libc::c_int,
1521 pub cluster_announce_tls_port: libc::c_int,
1522 pub cluster_announce_bus_port: libc::c_int,
1523 pub cluster_module_flags: libc::c_int,
1524 pub cluster_allow_reads_when_down: libc::c_int,
1525 pub cluster_config_file_lock_fd: libc::c_int,
1526 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1527 pub cluster_drop_packet_filter: libc::c_int,
1528 pub script_caller: *mut client,
1529 pub busy_reply_threshold: mstime_t,
1530 pub pre_command_oom_state: libc::c_int,
1531 pub script_disable_deny_script: libc::c_int,
1532 pub lazyfree_lazy_eviction: libc::c_int,
1533 pub lazyfree_lazy_expire: libc::c_int,
1534 pub lazyfree_lazy_server_del: libc::c_int,
1535 pub lazyfree_lazy_user_del: libc::c_int,
1536 pub lazyfree_lazy_user_flush: libc::c_int,
1537 pub latency_monitor_threshold: libc::c_longlong,
1538 pub latency_events: *mut dict,
1539 pub acl_filename: *mut libc::c_char,
1540 pub acllog_max_len: libc::c_ulong,
1541 pub requirepass: sds,
1542 pub acl_pubsub_default: libc::c_int,
1543 pub watchdog_period: libc::c_int,
1544 pub system_memory_size: size_t,
1545 pub tls_cluster: libc::c_int,
1546 pub tls_replication: libc::c_int,
1547 pub tls_auth_clients: libc::c_int,
1548 pub tls_ctx_config: redisTLSContextConfig,
1549 pub server_cpulist: *mut libc::c_char,
1550 pub bio_cpulist: *mut libc::c_char,
1551 pub aof_rewrite_cpulist: *mut libc::c_char,
1552 pub bgsave_cpulist: *mut libc::c_char,
1553 pub sentinel_config: *mut sentinelConfig,
1554 pub failover_end_time: mstime_t,
1555 pub force_failover: libc::c_int,
1556 pub target_replica_host: *mut libc::c_char,
1557 pub target_replica_port: libc::c_int,
1558 pub failover_state: libc::c_int,
1559 pub cluster_allow_pubsubshard_when_down: libc::c_int,
1560 pub reply_buffer_peak_reset_time: libc::c_long,
1561 pub reply_buffer_resizing_enabled: libc::c_int,
1562}
1563#[derive(Copy, Clone)]
1564#[repr(C)]
1565pub struct C2RustUnnamed_6 {
1566 pub last_sample_time: libc::c_longlong,
1567 pub last_sample_count: libc::c_longlong,
1568 pub samples: [libc::c_longlong; 16],
1569 pub idx: libc::c_int,
1570}
1571#[derive(Copy, Clone)]
1572#[repr(C)]
1573pub struct zrangespec {
1574 pub min: libc::c_double,
1575 pub max: libc::c_double,
1576 pub minex: libc::c_int,
1577 pub maxex: libc::c_int,
1578}
1579#[derive(Copy, Clone)]
1580#[repr(C)]
1581pub struct geoArray {
1582 pub array: *mut geoPoint,
1583 pub buckets: size_t,
1584 pub used: size_t,
1585}
1586#[derive(Copy, Clone)]
1587#[repr(C)]
1588pub struct geoPoint {
1589 pub longitude: libc::c_double,
1590 pub latitude: libc::c_double,
1591 pub dist: libc::c_double,
1592 pub score: libc::c_double,
1593 pub member: *mut libc::c_char,
1594}
1595#[derive(Copy, Clone)]
1596#[repr(C)]
1597pub struct GeoShape {
1598 pub type_0: libc::c_int,
1599 pub xy: [libc::c_double; 2],
1600 pub conversion: libc::c_double,
1601 pub bounds: [libc::c_double; 4],
1602 pub t: C2RustUnnamed_7,
1603}
1604#[derive(Copy, Clone)]
1605#[repr(C)]
1606pub union C2RustUnnamed_7 {
1607 pub radius: libc::c_double,
1608 pub r: C2RustUnnamed_8,
1609}
1610#[derive(Copy, Clone)]
1611#[repr(C)]
1612pub struct C2RustUnnamed_8 {
1613 pub height: libc::c_double,
1614 pub width: libc::c_double,
1615}
1616#[derive(Copy, Clone)]
1617#[repr(C)]
1618pub struct GeoHashRadius {
1619 pub hash: GeoHashBits,
1620 pub area: GeoHashArea,
1621 pub neighbors: GeoHashNeighbors,
1622}
1623#[derive(Copy, Clone)]
1624#[repr(C)]
1625pub struct GeoHashNeighbors {
1626 pub north: GeoHashBits,
1627 pub east: GeoHashBits,
1628 pub west: GeoHashBits,
1629 pub south: GeoHashBits,
1630 pub north_east: GeoHashBits,
1631 pub south_east: GeoHashBits,
1632 pub north_west: GeoHashBits,
1633 pub south_west: GeoHashBits,
1634}
1635#[derive(Copy, Clone)]
1636#[repr(C)]
1637pub struct GeoHashBits {
1638 pub bits: uint64_t,
1639 pub step: uint8_t,
1640}
1641#[derive(Copy, Clone)]
1642#[repr(C)]
1643pub struct GeoHashArea {
1644 pub hash: GeoHashBits,
1645 pub longitude: GeoHashRange,
1646 pub latitude: GeoHashRange,
1647}
1648#[derive(Copy, Clone)]
1649#[repr(C)]
1650pub struct GeoHashRange {
1651 pub min: libc::c_double,
1652 pub max: libc::c_double,
1653}
1654pub type GeoHashFix52Bits = uint64_t;
1655#[inline]
1656unsafe extern "C" fn sdslen(s: sds) -> size_t {
1657 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1658 as libc::c_uchar;
1659 match flags as libc::c_int & 7 as libc::c_int {
1660 0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
1661 1 => {
1662 return (*(s
1663 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1664 as *mut sdshdr8))
1665 .len as size_t;
1666 }
1667 2 => {
1668 return (*(s
1669 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
1670 as *mut sdshdr16))
1671 .len as size_t;
1672 }
1673 3 => {
1674 return (*(s
1675 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
1676 as *mut sdshdr32))
1677 .len as size_t;
1678 }
1679 4 => {
1680 return (*(s
1681 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
1682 as *mut sdshdr64))
1683 .len;
1684 }
1685 _ => {}
1686 }
1687 return 0 as libc::c_int as size_t;
1688}
1689#[no_mangle]
1690pub unsafe extern "C" fn geoArrayCreate() -> *mut geoArray {
1691 let mut ga: *mut geoArray = zmalloc(
1692 core::mem::size_of::<geoArray>() as libc::c_ulong,
1693 ) as *mut geoArray;
1694 (*ga).array = 0 as *mut geoPoint;
1695 (*ga).buckets = 0 as libc::c_int as size_t;
1696 (*ga).used = 0 as libc::c_int as size_t;
1697 return ga;
1698}
1699#[no_mangle]
1700pub unsafe extern "C" fn geoArrayAppend(
1701 mut ga: *mut geoArray,
1702 mut xy: *mut libc::c_double,
1703 mut dist: libc::c_double,
1704 mut score: libc::c_double,
1705 mut member: *mut libc::c_char,
1706) -> *mut geoPoint {
1707 if (*ga).used == (*ga).buckets {
1708 (*ga)
1709 .buckets = if (*ga).buckets == 0 as libc::c_int as libc::c_ulong {
1710 8 as libc::c_int as libc::c_ulong
1711 } else {
1712 ((*ga).buckets).wrapping_mul(2 as libc::c_int as libc::c_ulong)
1713 };
1714 (*ga)
1715 .array = zrealloc(
1716 (*ga).array as *mut libc::c_void,
1717 (core::mem::size_of::<geoPoint>() as libc::c_ulong)
1718 .wrapping_mul((*ga).buckets),
1719 ) as *mut geoPoint;
1720 }
1721 let mut gp: *mut geoPoint = ((*ga).array).offset((*ga).used as isize);
1722 (*gp).longitude = *xy.offset(0 as libc::c_int as isize);
1723 (*gp).latitude = *xy.offset(1 as libc::c_int as isize);
1724 (*gp).dist = dist;
1725 (*gp).member = member;
1726 (*gp).score = score;
1727 (*ga).used = ((*ga).used).wrapping_add(1);
1728 return gp;
1729}
1730#[no_mangle]
1731pub unsafe extern "C" fn geoArrayFree(mut ga: *mut geoArray) {
1732 let mut i: size_t = 0;
1733 i = 0 as libc::c_int as size_t;
1734 while i < (*ga).used {
1735 sdsfree((*((*ga).array).offset(i as isize)).member);
1736 i = i.wrapping_add(1);
1737 }
1738 zfree((*ga).array as *mut libc::c_void);
1739 zfree(ga as *mut libc::c_void);
1740}
1741#[no_mangle]
1742pub unsafe extern "C" fn decodeGeohash(
1743 mut bits: libc::c_double,
1744 mut xy: *mut libc::c_double,
1745) -> libc::c_int {
1746 let mut hash: GeoHashBits = {
1747 let mut init = GeoHashBits {
1748 bits: bits as uint64_t,
1749 step: 26 as libc::c_int as uint8_t,
1750 };
1751 init
1752 };
1753 return geohashDecodeToLongLatWGS84(hash, xy);
1754}
1755#[no_mangle]
1756pub unsafe extern "C" fn extractLongLatOrReply(
1757 mut c: *mut client,
1758 mut argv: *mut *mut robj,
1759 mut xy: *mut libc::c_double,
1760) -> libc::c_int {
1761 let mut i: libc::c_int = 0;
1762 i = 0 as libc::c_int;
1763 while i < 2 as libc::c_int {
1764 if getDoubleFromObjectOrReply(
1765 c,
1766 *argv.offset(i as isize),
1767 xy.offset(i as isize),
1768 0 as *const libc::c_char,
1769 ) != 0 as libc::c_int
1770 {
1771 return -(1 as libc::c_int);
1772 }
1773 i += 1;
1774 }
1775 if *xy.offset(0 as libc::c_int as isize) < -(180 as libc::c_int) as libc::c_double
1776 || *xy.offset(0 as libc::c_int as isize) > 180 as libc::c_int as libc::c_double
1777 || *xy.offset(1 as libc::c_int as isize) < -85.05112878f64
1778 || *xy.offset(1 as libc::c_int as isize) > 85.05112878f64
1779 {
1780 addReplyErrorFormat(
1781 c,
1782 b"-ERR invalid longitude,latitude pair %f,%f\r\n\0" as *const u8
1783 as *const libc::c_char,
1784 *xy.offset(0 as libc::c_int as isize),
1785 *xy.offset(1 as libc::c_int as isize),
1786 );
1787 return -(1 as libc::c_int);
1788 }
1789 return 0 as libc::c_int;
1790}
1791#[no_mangle]
1792pub unsafe extern "C" fn longLatFromMember(
1793 mut zobj: *mut robj,
1794 mut member: *mut robj,
1795 mut xy: *mut libc::c_double,
1796) -> libc::c_int {
1797 let mut score: libc::c_double = 0 as libc::c_int as libc::c_double;
1798 if zsetScore(zobj, (*member).ptr as sds, &mut score) == -(1 as libc::c_int) {
1799 return -(1 as libc::c_int);
1800 }
1801 if decodeGeohash(score, xy) == 0 {
1802 return -(1 as libc::c_int);
1803 }
1804 return 0 as libc::c_int;
1805}
1806#[no_mangle]
1807pub unsafe extern "C" fn extractUnitOrReply(
1808 mut c: *mut client,
1809 mut unit: *mut robj,
1810) -> libc::c_double {
1811 let mut u: *mut libc::c_char = (*unit).ptr as *mut libc::c_char;
1812 if strcasecmp(u, b"m\0" as *const u8 as *const libc::c_char) == 0 {
1813 return 1 as libc::c_int as libc::c_double
1814 } else if strcasecmp(u, b"km\0" as *const u8 as *const libc::c_char) == 0 {
1815 return 1000 as libc::c_int as libc::c_double
1816 } else if strcasecmp(u, b"ft\0" as *const u8 as *const libc::c_char) == 0 {
1817 return 0.3048f64
1818 } else if strcasecmp(u, b"mi\0" as *const u8 as *const libc::c_char) == 0 {
1819 return 1609.34f64
1820 } else {
1821 addReplyError(
1822 c,
1823 b"unsupported unit provided. please use M, KM, FT, MI\0" as *const u8
1824 as *const libc::c_char,
1825 );
1826 return -(1 as libc::c_int) as libc::c_double;
1827 };
1828}
1829#[no_mangle]
1830pub unsafe extern "C" fn extractDistanceOrReply(
1831 mut c: *mut client,
1832 mut argv: *mut *mut robj,
1833 mut conversion: *mut libc::c_double,
1834 mut radius: *mut libc::c_double,
1835) -> libc::c_int {
1836 let mut distance: libc::c_double = 0.;
1837 if getDoubleFromObjectOrReply(
1838 c,
1839 *argv.offset(0 as libc::c_int as isize),
1840 &mut distance,
1841 b"need numeric radius\0" as *const u8 as *const libc::c_char,
1842 ) != 0 as libc::c_int
1843 {
1844 return -(1 as libc::c_int);
1845 }
1846 if distance < 0 as libc::c_int as libc::c_double {
1847 addReplyError(
1848 c,
1849 b"radius cannot be negative\0" as *const u8 as *const libc::c_char,
1850 );
1851 return -(1 as libc::c_int);
1852 }
1853 if !radius.is_null() {
1854 *radius = distance;
1855 }
1856 let mut to_meters: libc::c_double = extractUnitOrReply(
1857 c,
1858 *argv.offset(1 as libc::c_int as isize),
1859 );
1860 if to_meters < 0 as libc::c_int as libc::c_double {
1861 return -(1 as libc::c_int);
1862 }
1863 if !conversion.is_null() {
1864 *conversion = to_meters;
1865 }
1866 return 0 as libc::c_int;
1867}
1868#[no_mangle]
1869pub unsafe extern "C" fn extractBoxOrReply(
1870 mut c: *mut client,
1871 mut argv: *mut *mut robj,
1872 mut conversion: *mut libc::c_double,
1873 mut width: *mut libc::c_double,
1874 mut height: *mut libc::c_double,
1875) -> libc::c_int {
1876 let mut h: libc::c_double = 0.;
1877 let mut w: libc::c_double = 0.;
1878 if getDoubleFromObjectOrReply(
1879 c,
1880 *argv.offset(0 as libc::c_int as isize),
1881 &mut w,
1882 b"need numeric width\0" as *const u8 as *const libc::c_char,
1883 ) != 0 as libc::c_int
1884 || getDoubleFromObjectOrReply(
1885 c,
1886 *argv.offset(1 as libc::c_int as isize),
1887 &mut h,
1888 b"need numeric height\0" as *const u8 as *const libc::c_char,
1889 ) != 0 as libc::c_int
1890 {
1891 return -(1 as libc::c_int);
1892 }
1893 if h < 0 as libc::c_int as libc::c_double || w < 0 as libc::c_int as libc::c_double {
1894 addReplyError(
1895 c,
1896 b"height or width cannot be negative\0" as *const u8 as *const libc::c_char,
1897 );
1898 return -(1 as libc::c_int);
1899 }
1900 if !height.is_null() {
1901 *height = h;
1902 }
1903 if !width.is_null() {
1904 *width = w;
1905 }
1906 let mut to_meters: libc::c_double = extractUnitOrReply(
1907 c,
1908 *argv.offset(2 as libc::c_int as isize),
1909 );
1910 if to_meters < 0 as libc::c_int as libc::c_double {
1911 return -(1 as libc::c_int);
1912 }
1913 if !conversion.is_null() {
1914 *conversion = to_meters;
1915 }
1916 return 0 as libc::c_int;
1917}
1918#[no_mangle]
1919pub unsafe extern "C" fn addReplyDoubleDistance(
1920 mut c: *mut client,
1921 mut d: libc::c_double,
1922) {
1923 let mut dbuf: [libc::c_char; 128] = [0; 128];
1924 let dlen: libc::c_int = fixedpoint_d2string(
1925 dbuf.as_mut_ptr(),
1926 core::mem::size_of::<[libc::c_char; 128]>() as libc::c_ulong,
1927 d,
1928 4 as libc::c_int,
1929 );
1930 addReplyBulkCBuffer(c, dbuf.as_mut_ptr() as *const libc::c_void, dlen as size_t);
1931}
1932#[no_mangle]
1933pub unsafe extern "C" fn geoWithinShape(
1934 mut shape: *mut GeoShape,
1935 mut score: libc::c_double,
1936 mut xy: *mut libc::c_double,
1937 mut distance: *mut libc::c_double,
1938) -> libc::c_int {
1939 if decodeGeohash(score, xy) == 0 {
1940 return -(1 as libc::c_int);
1941 }
1942 if (*shape).type_0 == 1 as libc::c_int {
1943 if geohashGetDistanceIfInRadiusWGS84(
1944 (*shape).xy[0 as libc::c_int as usize],
1945 (*shape).xy[1 as libc::c_int as usize],
1946 *xy.offset(0 as libc::c_int as isize),
1947 *xy.offset(1 as libc::c_int as isize),
1948 (*shape).t.radius * (*shape).conversion,
1949 distance,
1950 ) == 0
1951 {
1952 return -(1 as libc::c_int);
1953 }
1954 } else if (*shape).type_0 == 2 as libc::c_int {
1955 if geohashGetDistanceIfInRectangle(
1956 (*shape).t.r.width * (*shape).conversion,
1957 (*shape).t.r.height * (*shape).conversion,
1958 (*shape).xy[0 as libc::c_int as usize],
1959 (*shape).xy[1 as libc::c_int as usize],
1960 *xy.offset(0 as libc::c_int as isize),
1961 *xy.offset(1 as libc::c_int as isize),
1962 distance,
1963 ) == 0
1964 {
1965 return -(1 as libc::c_int);
1966 }
1967 }
1968 return 0 as libc::c_int;
1969}
1970#[no_mangle]
1971pub unsafe extern "C" fn geoGetPointsInRange(
1972 mut zobj: *mut robj,
1973 mut min: libc::c_double,
1974 mut max: libc::c_double,
1975 mut shape: *mut GeoShape,
1976 mut ga: *mut geoArray,
1977 mut limit: libc::c_ulong,
1978) -> libc::c_int {
1979 let mut range: zrangespec = {
1980 let mut init = zrangespec {
1981 min: min,
1982 max: max,
1983 minex: 0 as libc::c_int,
1984 maxex: 1 as libc::c_int,
1985 };
1986 init
1987 };
1988 let mut origincount: size_t = (*ga).used;
1989 if (*zobj).encoding() as libc::c_int == 11 as libc::c_int {
1990 let mut zl: *mut libc::c_uchar = (*zobj).ptr as *mut libc::c_uchar;
1991 let mut eptr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
1992 let mut sptr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
1993 let mut vstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
1994 let mut vlen: libc::c_uint = 0 as libc::c_int as libc::c_uint;
1995 let mut vlong: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
1996 let mut score: libc::c_double = 0 as libc::c_int as libc::c_double;
1997 eptr = zzlFirstInRange(zl, &mut range);
1998 if eptr.is_null() {
1999 return 0 as libc::c_int;
2000 }
2001 sptr = lpNext(zl, eptr);
2002 while !eptr.is_null() {
2003 let mut xy: [libc::c_double; 2] = [0.; 2];
2004 let mut distance: libc::c_double = 0 as libc::c_int as libc::c_double;
2005 score = zzlGetScore(sptr);
2006 if zslValueLteMax(score, &mut range) == 0 {
2007 break;
2008 }
2009 vstr = lpGetValue(eptr, &mut vlen, &mut vlong);
2010 if geoWithinShape(shape, score, xy.as_mut_ptr(), &mut distance)
2011 == 0 as libc::c_int
2012 {
2013 let mut member: *mut libc::c_char = if vstr.is_null() {
2014 sdsfromlonglong(vlong)
2015 } else {
2016 sdsnewlen(vstr as *const libc::c_void, vlen as size_t)
2017 };
2018 geoArrayAppend(ga, xy.as_mut_ptr(), distance, score, member);
2019 }
2020 if (*ga).used != 0 && limit != 0 && (*ga).used >= limit {
2021 break;
2022 }
2023 zzlNext(zl, &mut eptr, &mut sptr);
2024 }
2025 } else if (*zobj).encoding() as libc::c_int == 7 as libc::c_int {
2026 let mut zs: *mut zset = (*zobj).ptr as *mut zset;
2027 let mut zsl: *mut zskiplist = (*zs).zsl;
2028 let mut ln: *mut zskiplistNode = 0 as *mut zskiplistNode;
2029 ln = zslFirstInRange(zsl, &mut range);
2030 if ln.is_null() {
2031 return 0 as libc::c_int;
2032 }
2033 while !ln.is_null() {
2034 let mut xy_0: [libc::c_double; 2] = [0.; 2];
2035 let mut distance_0: libc::c_double = 0 as libc::c_int as libc::c_double;
2036 if zslValueLteMax((*ln).score, &mut range) == 0 {
2037 break;
2038 }
2039 if geoWithinShape(shape, (*ln).score, xy_0.as_mut_ptr(), &mut distance_0)
2040 == 0 as libc::c_int
2041 {
2042 geoArrayAppend(
2043 ga,
2044 xy_0.as_mut_ptr(),
2045 distance_0,
2046 (*ln).score,
2047 sdsdup((*ln).ele),
2048 );
2049 }
2050 if (*ga).used != 0 && limit != 0 && (*ga).used >= limit {
2051 break;
2052 }
2053 ln = (*((*ln).level).as_mut_ptr().offset(0 as libc::c_int as isize)).forward;
2054 }
2055 }
2056 return ((*ga).used).wrapping_sub(origincount) as libc::c_int;
2057}
2058#[no_mangle]
2059pub unsafe extern "C" fn scoresOfGeoHashBox(
2060 mut hash: GeoHashBits,
2061 mut min: *mut GeoHashFix52Bits,
2062 mut max: *mut GeoHashFix52Bits,
2063) {
2064 *min = geohashAlign52Bits(hash);
2065 hash.bits = (hash.bits).wrapping_add(1);
2066 *max = geohashAlign52Bits(hash);
2067}
2068#[no_mangle]
2069pub unsafe extern "C" fn membersOfGeoHashBox(
2070 mut zobj: *mut robj,
2071 mut hash: GeoHashBits,
2072 mut ga: *mut geoArray,
2073 mut shape: *mut GeoShape,
2074 mut limit: libc::c_ulong,
2075) -> libc::c_int {
2076 let mut min: GeoHashFix52Bits = 0;
2077 let mut max: GeoHashFix52Bits = 0;
2078 scoresOfGeoHashBox(hash, &mut min, &mut max);
2079 return geoGetPointsInRange(
2080 zobj,
2081 min as libc::c_double,
2082 max as libc::c_double,
2083 shape,
2084 ga,
2085 limit,
2086 );
2087}
2088#[no_mangle]
2089pub unsafe extern "C" fn membersOfAllNeighbors(
2090 mut zobj: *mut robj,
2091 mut n: *const GeoHashRadius,
2092 mut shape: *mut GeoShape,
2093 mut ga: *mut geoArray,
2094 mut limit: libc::c_ulong,
2095) -> libc::c_int {
2096 let mut neighbors: [GeoHashBits; 9] = [GeoHashBits { bits: 0, step: 0 }; 9];
2097 let mut i: libc::c_uint = 0;
2098 let mut count: libc::c_uint = 0 as libc::c_int as libc::c_uint;
2099 let mut last_processed: libc::c_uint = 0 as libc::c_int as libc::c_uint;
2100 let mut debugmsg: libc::c_int = 0 as libc::c_int;
2101 neighbors[0 as libc::c_int as usize] = (*n).hash;
2102 neighbors[1 as libc::c_int as usize] = (*n).neighbors.north;
2103 neighbors[2 as libc::c_int as usize] = (*n).neighbors.south;
2104 neighbors[3 as libc::c_int as usize] = (*n).neighbors.east;
2105 neighbors[4 as libc::c_int as usize] = (*n).neighbors.west;
2106 neighbors[5 as libc::c_int as usize] = (*n).neighbors.north_east;
2107 neighbors[6 as libc::c_int as usize] = (*n).neighbors.north_west;
2108 neighbors[7 as libc::c_int as usize] = (*n).neighbors.south_east;
2109 neighbors[8 as libc::c_int as usize] = (*n).neighbors.south_west;
2110 i = 0 as libc::c_int as libc::c_uint;
2111 while (i as libc::c_ulong)
2112 < (core::mem::size_of::<[GeoHashBits; 9]>() as libc::c_ulong)
2113 .wrapping_div(core::mem::size_of::<GeoHashBits>() as libc::c_ulong)
2114 {
2115 if neighbors[i as usize].bits == 0 && neighbors[i as usize].step == 0 {
2116 if debugmsg != 0 {
2117 let mut fp: *mut FILE = fopen(
2118 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2119 b"a\0" as *const u8 as *const libc::c_char,
2120 );
2121 fprintf(
2122 fp,
2123 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2124 b"geo.c\0" as *const u8 as *const libc::c_char,
2125 (*core::mem::transmute::<
2126 &[u8; 22],
2127 &[libc::c_char; 22],
2128 >(b"membersOfAllNeighbors\0"))
2129 .as_ptr(),
2130 384 as libc::c_int,
2131 );
2132 fprintf(
2133 fp,
2134 b"neighbors[%d] is zero\0" as *const u8 as *const libc::c_char,
2135 i,
2136 );
2137 fprintf(fp, b"\n\0" as *const u8 as *const libc::c_char);
2138 fclose(fp);
2139 }
2140 } else {
2141 if debugmsg != 0 {
2142 let mut long_range: GeoHashRange = GeoHashRange { min: 0., max: 0. };
2143 let mut lat_range: GeoHashRange = GeoHashRange { min: 0., max: 0. };
2144 geohashGetCoordRange(&mut long_range, &mut lat_range);
2145 let mut myarea: GeoHashArea = {
2146 let mut init = GeoHashArea {
2147 hash: {
2148 let mut init = GeoHashBits {
2149 bits: 0 as libc::c_int as uint64_t,
2150 step: 0,
2151 };
2152 init
2153 },
2154 longitude: GeoHashRange { min: 0., max: 0. },
2155 latitude: GeoHashRange { min: 0., max: 0. },
2156 };
2157 init
2158 };
2159 geohashDecode(long_range, lat_range, neighbors[i as usize], &mut myarea);
2160 let mut fp_0: *mut FILE = fopen(
2161 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2162 b"a\0" as *const u8 as *const libc::c_char,
2163 );
2164 fprintf(
2165 fp_0,
2166 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2167 b"geo.c\0" as *const u8 as *const libc::c_char,
2168 (*core::mem::transmute::<
2169 &[u8; 22],
2170 &[libc::c_char; 22],
2171 >(b"membersOfAllNeighbors\0"))
2172 .as_ptr(),
2173 396 as libc::c_int,
2174 );
2175 fprintf(
2176 fp_0,
2177 b"neighbors[%d]:\n\0" as *const u8 as *const libc::c_char,
2178 i,
2179 );
2180 fprintf(fp_0, b"\n\0" as *const u8 as *const libc::c_char);
2181 fclose(fp_0);
2182 let mut fp_1: *mut FILE = fopen(
2183 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2184 b"a\0" as *const u8 as *const libc::c_char,
2185 );
2186 fprintf(
2187 fp_1,
2188 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2189 b"geo.c\0" as *const u8 as *const libc::c_char,
2190 (*core::mem::transmute::<
2191 &[u8; 22],
2192 &[libc::c_char; 22],
2193 >(b"membersOfAllNeighbors\0"))
2194 .as_ptr(),
2195 397 as libc::c_int,
2196 );
2197 fprintf(
2198 fp_1,
2199 b"area.longitude.min: %f\n\0" as *const u8 as *const libc::c_char,
2200 myarea.longitude.min,
2201 );
2202 fprintf(fp_1, b"\n\0" as *const u8 as *const libc::c_char);
2203 fclose(fp_1);
2204 let mut fp_2: *mut FILE = fopen(
2205 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2206 b"a\0" as *const u8 as *const libc::c_char,
2207 );
2208 fprintf(
2209 fp_2,
2210 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2211 b"geo.c\0" as *const u8 as *const libc::c_char,
2212 (*core::mem::transmute::<
2213 &[u8; 22],
2214 &[libc::c_char; 22],
2215 >(b"membersOfAllNeighbors\0"))
2216 .as_ptr(),
2217 398 as libc::c_int,
2218 );
2219 fprintf(
2220 fp_2,
2221 b"area.longitude.max: %f\n\0" as *const u8 as *const libc::c_char,
2222 myarea.longitude.max,
2223 );
2224 fprintf(fp_2, b"\n\0" as *const u8 as *const libc::c_char);
2225 fclose(fp_2);
2226 let mut fp_3: *mut FILE = fopen(
2227 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2228 b"a\0" as *const u8 as *const libc::c_char,
2229 );
2230 fprintf(
2231 fp_3,
2232 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2233 b"geo.c\0" as *const u8 as *const libc::c_char,
2234 (*core::mem::transmute::<
2235 &[u8; 22],
2236 &[libc::c_char; 22],
2237 >(b"membersOfAllNeighbors\0"))
2238 .as_ptr(),
2239 399 as libc::c_int,
2240 );
2241 fprintf(
2242 fp_3,
2243 b"area.latitude.min: %f\n\0" as *const u8 as *const libc::c_char,
2244 myarea.latitude.min,
2245 );
2246 fprintf(fp_3, b"\n\0" as *const u8 as *const libc::c_char);
2247 fclose(fp_3);
2248 let mut fp_4: *mut FILE = fopen(
2249 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2250 b"a\0" as *const u8 as *const libc::c_char,
2251 );
2252 fprintf(
2253 fp_4,
2254 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2255 b"geo.c\0" as *const u8 as *const libc::c_char,
2256 (*core::mem::transmute::<
2257 &[u8; 22],
2258 &[libc::c_char; 22],
2259 >(b"membersOfAllNeighbors\0"))
2260 .as_ptr(),
2261 400 as libc::c_int,
2262 );
2263 fprintf(
2264 fp_4,
2265 b"area.latitude.max: %f\n\0" as *const u8 as *const libc::c_char,
2266 myarea.latitude.max,
2267 );
2268 fprintf(fp_4, b"\n\0" as *const u8 as *const libc::c_char);
2269 fclose(fp_4);
2270 let mut fp_5: *mut FILE = fopen(
2271 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2272 b"a\0" as *const u8 as *const libc::c_char,
2273 );
2274 fprintf(
2275 fp_5,
2276 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2277 b"geo.c\0" as *const u8 as *const libc::c_char,
2278 (*core::mem::transmute::<
2279 &[u8; 22],
2280 &[libc::c_char; 22],
2281 >(b"membersOfAllNeighbors\0"))
2282 .as_ptr(),
2283 401 as libc::c_int,
2284 );
2285 fprintf(fp_5, b"\n\0" as *const u8 as *const libc::c_char);
2286 fprintf(fp_5, b"\n\0" as *const u8 as *const libc::c_char);
2287 fclose(fp_5);
2288 }
2289 if last_processed != 0
2290 && neighbors[i as usize].bits == neighbors[last_processed as usize].bits
2291 && neighbors[i as usize].step as libc::c_int
2292 == neighbors[last_processed as usize].step as libc::c_int
2293 {
2294 if debugmsg != 0 {
2295 let mut fp_6: *mut FILE = fopen(
2296 b"/tmp/log.txt\0" as *const u8 as *const libc::c_char,
2297 b"a\0" as *const u8 as *const libc::c_char,
2298 );
2299 fprintf(
2300 fp_6,
2301 b"%s:%s:%d:\t\0" as *const u8 as *const libc::c_char,
2302 b"geo.c\0" as *const u8 as *const libc::c_char,
2303 (*core::mem::transmute::<
2304 &[u8; 22],
2305 &[libc::c_char; 22],
2306 >(b"membersOfAllNeighbors\0"))
2307 .as_ptr(),
2308 413 as libc::c_int,
2309 );
2310 fprintf(
2311 fp_6,
2312 b"Skipping processing of %d, same as previous\n\0" as *const u8
2313 as *const libc::c_char,
2314 i,
2315 );
2316 fprintf(fp_6, b"\n\0" as *const u8 as *const libc::c_char);
2317 fclose(fp_6);
2318 }
2319 } else {
2320 if (*ga).used != 0 && limit != 0 && (*ga).used >= limit {
2321 break;
2322 }
2323 count = count
2324 .wrapping_add(
2325 membersOfGeoHashBox(
2326 zobj,
2327 neighbors[i as usize],
2328 ga,
2329 shape,
2330 limit,
2331 ) as libc::c_uint,
2332 );
2333 last_processed = i;
2334 }
2335 }
2336 i = i.wrapping_add(1);
2337 }
2338 return count as libc::c_int;
2339}
2340unsafe extern "C" fn sort_gp_asc(
2341 mut a: *const libc::c_void,
2342 mut b: *const libc::c_void,
2343) -> libc::c_int {
2344 let mut gpa: *const geoPoint = a as *const geoPoint;
2345 let mut gpb: *const geoPoint = b as *const geoPoint;
2346 if (*gpa).dist > (*gpb).dist {
2347 return 1 as libc::c_int
2348 } else if (*gpa).dist == (*gpb).dist {
2349 return 0 as libc::c_int
2350 } else {
2351 return -(1 as libc::c_int)
2352 };
2353}
2354unsafe extern "C" fn sort_gp_desc(
2355 mut a: *const libc::c_void,
2356 mut b: *const libc::c_void,
2357) -> libc::c_int {
2358 return -sort_gp_asc(a, b);
2359}
2360#[no_mangle]
2361pub unsafe extern "C" fn geoaddCommand(mut c: *mut client) {
2362 let mut xx: libc::c_int = 0 as libc::c_int;
2363 let mut nx: libc::c_int = 0 as libc::c_int;
2364 let mut longidx: libc::c_int = 2 as libc::c_int;
2365 let mut i: libc::c_int = 0;
2366 while longidx < (*c).argc {
2367 let mut opt: *mut libc::c_char = (**((*c).argv).offset(longidx as isize)).ptr
2368 as *mut libc::c_char;
2369 if strcasecmp(opt, b"nx\0" as *const u8 as *const libc::c_char) == 0 {
2370 nx = 1 as libc::c_int;
2371 } else if strcasecmp(opt, b"xx\0" as *const u8 as *const libc::c_char) == 0 {
2372 xx = 1 as libc::c_int;
2373 } else if !(strcasecmp(opt, b"ch\0" as *const u8 as *const libc::c_char) == 0) {
2374 break;
2375 }
2376 longidx += 1;
2377 }
2378 if ((*c).argc - longidx) % 3 as libc::c_int != 0 || xx != 0 && nx != 0 {
2379 addReplyErrorObject(c, shared.syntaxerr);
2380 return;
2381 }
2382 let mut elements: libc::c_int = ((*c).argc - longidx) / 3 as libc::c_int;
2383 let mut argc: libc::c_int = longidx + elements * 2 as libc::c_int;
2384 let mut argv: *mut *mut robj = zcalloc(
2385 (argc as libc::c_ulong)
2386 .wrapping_mul(core::mem::size_of::<*mut robj>() as libc::c_ulong),
2387 ) as *mut *mut robj;
2388 let ref mut fresh0 = *argv.offset(0 as libc::c_int as isize);
2389 *fresh0 = createRawStringObject(
2390 b"zadd\0" as *const u8 as *const libc::c_char,
2391 4 as libc::c_int as size_t,
2392 );
2393 i = 1 as libc::c_int;
2394 while i < longidx {
2395 let ref mut fresh1 = *argv.offset(i as isize);
2396 *fresh1 = *((*c).argv).offset(i as isize);
2397 incrRefCount(*argv.offset(i as isize));
2398 i += 1;
2399 }
2400 i = 0 as libc::c_int;
2401 while i < elements {
2402 let mut xy: [libc::c_double; 2] = [0.; 2];
2403 if extractLongLatOrReply(
2404 c,
2405 ((*c).argv).offset(longidx as isize).offset((i * 3 as libc::c_int) as isize),
2406 xy.as_mut_ptr(),
2407 ) == -(1 as libc::c_int)
2408 {
2409 i = 0 as libc::c_int;
2410 while i < argc {
2411 if !(*argv.offset(i as isize)).is_null() {
2412 decrRefCount(*argv.offset(i as isize));
2413 }
2414 i += 1;
2415 }
2416 zfree(argv as *mut libc::c_void);
2417 return;
2418 }
2419 let mut hash: GeoHashBits = GeoHashBits { bits: 0, step: 0 };
2420 geohashEncodeWGS84(
2421 xy[0 as libc::c_int as usize],
2422 xy[1 as libc::c_int as usize],
2423 26 as libc::c_int as uint8_t,
2424 &mut hash,
2425 );
2426 let mut bits: GeoHashFix52Bits = geohashAlign52Bits(hash);
2427 let mut score: *mut robj = createObject(
2428 0 as libc::c_int,
2429 sdsfromlonglong(bits as libc::c_longlong) as *mut libc::c_void,
2430 );
2431 let mut val: *mut robj = *((*c).argv)
2432 .offset((longidx + i * 3 as libc::c_int + 2 as libc::c_int) as isize);
2433 let ref mut fresh2 = *argv.offset((longidx + i * 2 as libc::c_int) as isize);
2434 *fresh2 = score;
2435 let ref mut fresh3 = *argv
2436 .offset((longidx + 1 as libc::c_int + i * 2 as libc::c_int) as isize);
2437 *fresh3 = val;
2438 incrRefCount(val);
2439 i += 1;
2440 }
2441 replaceClientCommandVector(c, argc, argv);
2442 zaddCommand(c);
2443}
2444#[no_mangle]
2445pub unsafe extern "C" fn georadiusGeneric(
2446 mut c: *mut client,
2447 mut srcKeyIndex: libc::c_int,
2448 mut flags: libc::c_int,
2449) {
2450 let mut storekey: *mut robj = 0 as *mut robj;
2451 let mut storedist: libc::c_int = 0 as libc::c_int;
2452 let mut zobj: *mut robj = lookupKeyRead(
2453 (*c).db,
2454 *((*c).argv).offset(srcKeyIndex as isize),
2455 );
2456 if checkType(c, zobj, 3 as libc::c_int) != 0 {
2457 return;
2458 }
2459 let mut base_args: libc::c_int = 0;
2460 let mut shape: GeoShape = {
2461 let mut init = GeoShape {
2462 type_0: 0 as libc::c_int,
2463 xy: [0.; 2],
2464 conversion: 0.,
2465 bounds: [0.; 4],
2466 t: C2RustUnnamed_7 { radius: 0. },
2467 };
2468 init
2469 };
2470 if flags & (1 as libc::c_int) << 0 as libc::c_int != 0 {
2471 base_args = 6 as libc::c_int;
2472 shape.type_0 = 1 as libc::c_int;
2473 if extractLongLatOrReply(
2474 c,
2475 ((*c).argv).offset(2 as libc::c_int as isize),
2476 (shape.xy).as_mut_ptr(),
2477 ) == -(1 as libc::c_int)
2478 {
2479 return;
2480 }
2481 if extractDistanceOrReply(
2482 c,
2483 ((*c).argv).offset(base_args as isize).offset(-(2 as libc::c_int as isize)),
2484 &mut shape.conversion,
2485 &mut shape.t.radius,
2486 ) != 0 as libc::c_int
2487 {
2488 return;
2489 }
2490 } else if flags & (1 as libc::c_int) << 1 as libc::c_int != 0 && zobj.is_null() {
2491 base_args = 5 as libc::c_int;
2492 } else if flags & (1 as libc::c_int) << 1 as libc::c_int != 0 {
2493 base_args = 5 as libc::c_int;
2494 shape.type_0 = 1 as libc::c_int;
2495 let mut member: *mut robj = *((*c).argv).offset(2 as libc::c_int as isize);
2496 if longLatFromMember(zobj, member, (shape.xy).as_mut_ptr())
2497 == -(1 as libc::c_int)
2498 {
2499 addReplyError(
2500 c,
2501 b"could not decode requested zset member\0" as *const u8
2502 as *const libc::c_char,
2503 );
2504 return;
2505 }
2506 if extractDistanceOrReply(
2507 c,
2508 ((*c).argv).offset(base_args as isize).offset(-(2 as libc::c_int as isize)),
2509 &mut shape.conversion,
2510 &mut shape.t.radius,
2511 ) != 0 as libc::c_int
2512 {
2513 return;
2514 }
2515 } else if flags & (1 as libc::c_int) << 3 as libc::c_int != 0 {
2516 base_args = 2 as libc::c_int;
2517 if flags & (1 as libc::c_int) << 4 as libc::c_int != 0 {
2518 base_args = 3 as libc::c_int;
2519 storekey = *((*c).argv).offset(1 as libc::c_int as isize);
2520 }
2521 } else {
2522 addReplyError(
2523 c,
2524 b"Unknown georadius search type\0" as *const u8 as *const libc::c_char,
2525 );
2526 return;
2527 }
2528 let mut withdist: libc::c_int = 0 as libc::c_int;
2529 let mut withhash: libc::c_int = 0 as libc::c_int;
2530 let mut withcoords: libc::c_int = 0 as libc::c_int;
2531 let mut frommember: libc::c_int = 0 as libc::c_int;
2532 let mut fromloc: libc::c_int = 0 as libc::c_int;
2533 let mut byradius: libc::c_int = 0 as libc::c_int;
2534 let mut bybox: libc::c_int = 0 as libc::c_int;
2535 let mut sort: libc::c_int = 0 as libc::c_int;
2536 let mut any: libc::c_int = 0 as libc::c_int;
2537 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2538 if (*c).argc > base_args {
2539 let mut remaining: libc::c_int = (*c).argc - base_args;
2540 let mut i: libc::c_int = 0 as libc::c_int;
2541 while i < remaining {
2542 let mut arg: *mut libc::c_char = (**((*c).argv)
2543 .offset((base_args + i) as isize))
2544 .ptr as *mut libc::c_char;
2545 if strcasecmp(arg, b"withdist\0" as *const u8 as *const libc::c_char) == 0 {
2546 withdist = 1 as libc::c_int;
2547 } else if strcasecmp(arg, b"withhash\0" as *const u8 as *const libc::c_char)
2548 == 0
2549 {
2550 withhash = 1 as libc::c_int;
2551 } else if strcasecmp(arg, b"withcoord\0" as *const u8 as *const libc::c_char)
2552 == 0
2553 {
2554 withcoords = 1 as libc::c_int;
2555 } else if strcasecmp(arg, b"any\0" as *const u8 as *const libc::c_char) == 0
2556 {
2557 any = 1 as libc::c_int;
2558 } else if strcasecmp(arg, b"asc\0" as *const u8 as *const libc::c_char) == 0
2559 {
2560 sort = 1 as libc::c_int;
2561 } else if strcasecmp(arg, b"desc\0" as *const u8 as *const libc::c_char) == 0
2562 {
2563 sort = 2 as libc::c_int;
2564 } else if strcasecmp(arg, b"count\0" as *const u8 as *const libc::c_char)
2565 == 0 && (i + 1 as libc::c_int) < remaining
2566 {
2567 if getLongLongFromObjectOrReply(
2568 c,
2569 *((*c).argv).offset((base_args + i + 1 as libc::c_int) as isize),
2570 &mut count,
2571 0 as *const libc::c_char,
2572 ) != 0 as libc::c_int
2573 {
2574 return;
2575 }
2576 if count <= 0 as libc::c_int as libc::c_longlong {
2577 addReplyError(
2578 c,
2579 b"COUNT must be > 0\0" as *const u8 as *const libc::c_char,
2580 );
2581 return;
2582 }
2583 i += 1;
2584 } else if strcasecmp(arg, b"store\0" as *const u8 as *const libc::c_char)
2585 == 0 && (i + 1 as libc::c_int) < remaining
2586 && flags & (1 as libc::c_int) << 2 as libc::c_int == 0
2587 && flags & (1 as libc::c_int) << 3 as libc::c_int == 0
2588 {
2589 storekey = *((*c).argv)
2590 .offset((base_args + i + 1 as libc::c_int) as isize);
2591 storedist = 0 as libc::c_int;
2592 i += 1;
2593 } else if strcasecmp(arg, b"storedist\0" as *const u8 as *const libc::c_char)
2594 == 0 && (i + 1 as libc::c_int) < remaining
2595 && flags & (1 as libc::c_int) << 2 as libc::c_int == 0
2596 && flags & (1 as libc::c_int) << 3 as libc::c_int == 0
2597 {
2598 storekey = *((*c).argv)
2599 .offset((base_args + i + 1 as libc::c_int) as isize);
2600 storedist = 1 as libc::c_int;
2601 i += 1;
2602 } else if strcasecmp(arg, b"storedist\0" as *const u8 as *const libc::c_char)
2603 == 0 && flags & (1 as libc::c_int) << 3 as libc::c_int != 0
2604 && flags & (1 as libc::c_int) << 4 as libc::c_int != 0
2605 {
2606 storedist = 1 as libc::c_int;
2607 } else if strcasecmp(
2608 arg,
2609 b"frommember\0" as *const u8 as *const libc::c_char,
2610 ) == 0 && (i + 1 as libc::c_int) < remaining
2611 && flags & (1 as libc::c_int) << 3 as libc::c_int != 0 && fromloc == 0
2612 {
2613 if zobj.is_null() {
2614 frommember = 1 as libc::c_int;
2615 i += 1;
2616 } else {
2617 if longLatFromMember(
2618 zobj,
2619 *((*c).argv).offset((base_args + i + 1 as libc::c_int) as isize),
2620 (shape.xy).as_mut_ptr(),
2621 ) == -(1 as libc::c_int)
2622 {
2623 addReplyError(
2624 c,
2625 b"could not decode requested zset member\0" as *const u8
2626 as *const libc::c_char,
2627 );
2628 return;
2629 }
2630 frommember = 1 as libc::c_int;
2631 i += 1;
2632 }
2633 } else if strcasecmp(
2634 arg,
2635 b"fromlonlat\0" as *const u8 as *const libc::c_char,
2636 ) == 0 && (i + 2 as libc::c_int) < remaining
2637 && flags & (1 as libc::c_int) << 3 as libc::c_int != 0 && frommember == 0
2638 {
2639 if extractLongLatOrReply(
2640 c,
2641 ((*c).argv)
2642 .offset(base_args as isize)
2643 .offset(i as isize)
2644 .offset(1 as libc::c_int as isize),
2645 (shape.xy).as_mut_ptr(),
2646 ) == -(1 as libc::c_int)
2647 {
2648 return;
2649 }
2650 fromloc = 1 as libc::c_int;
2651 i += 2 as libc::c_int;
2652 } else if strcasecmp(arg, b"byradius\0" as *const u8 as *const libc::c_char)
2653 == 0 && (i + 2 as libc::c_int) < remaining
2654 && flags & (1 as libc::c_int) << 3 as libc::c_int != 0 && bybox == 0
2655 {
2656 if extractDistanceOrReply(
2657 c,
2658 ((*c).argv)
2659 .offset(base_args as isize)
2660 .offset(i as isize)
2661 .offset(1 as libc::c_int as isize),
2662 &mut shape.conversion,
2663 &mut shape.t.radius,
2664 ) != 0 as libc::c_int
2665 {
2666 return;
2667 }
2668 shape.type_0 = 1 as libc::c_int;
2669 byradius = 1 as libc::c_int;
2670 i += 2 as libc::c_int;
2671 } else if strcasecmp(arg, b"bybox\0" as *const u8 as *const libc::c_char)
2672 == 0 && (i + 3 as libc::c_int) < remaining
2673 && flags & (1 as libc::c_int) << 3 as libc::c_int != 0 && byradius == 0
2674 {
2675 if extractBoxOrReply(
2676 c,
2677 ((*c).argv)
2678 .offset(base_args as isize)
2679 .offset(i as isize)
2680 .offset(1 as libc::c_int as isize),
2681 &mut shape.conversion,
2682 &mut shape.t.r.width,
2683 &mut shape.t.r.height,
2684 ) != 0 as libc::c_int
2685 {
2686 return;
2687 }
2688 shape.type_0 = 2 as libc::c_int;
2689 bybox = 1 as libc::c_int;
2690 i += 3 as libc::c_int;
2691 } else {
2692 addReplyErrorObject(c, shared.syntaxerr);
2693 return;
2694 }
2695 i += 1;
2696 }
2697 }
2698 if !storekey.is_null() && (withdist != 0 || withhash != 0 || withcoords != 0) {
2699 addReplyErrorFormat(
2700 c,
2701 b"%s is not compatible with WITHDIST, WITHHASH and WITHCOORD options\0"
2702 as *const u8 as *const libc::c_char,
2703 if flags & (1 as libc::c_int) << 4 as libc::c_int != 0 {
2704 b"GEOSEARCHSTORE\0" as *const u8 as *const libc::c_char
2705 } else {
2706 b"STORE option in GEORADIUS\0" as *const u8 as *const libc::c_char
2707 },
2708 );
2709 return;
2710 }
2711 if flags & (1 as libc::c_int) << 3 as libc::c_int != 0
2712 && !(frommember != 0 || fromloc != 0)
2713 {
2714 addReplyErrorFormat(
2715 c,
2716 b"exactly one of FROMMEMBER or FROMLONLAT can be specified for %s\0"
2717 as *const u8 as *const libc::c_char,
2718 (**((*c).argv).offset(0 as libc::c_int as isize)).ptr as *mut libc::c_char,
2719 );
2720 return;
2721 }
2722 if flags & (1 as libc::c_int) << 3 as libc::c_int != 0
2723 && !(byradius != 0 || bybox != 0)
2724 {
2725 addReplyErrorFormat(
2726 c,
2727 b"exactly one of BYRADIUS and BYBOX can be specified for %s\0" as *const u8
2728 as *const libc::c_char,
2729 (**((*c).argv).offset(0 as libc::c_int as isize)).ptr as *mut libc::c_char,
2730 );
2731 return;
2732 }
2733 if any != 0 && count == 0 {
2734 addReplyErrorFormat(
2735 c,
2736 b"the ANY argument requires COUNT argument\0" as *const u8
2737 as *const libc::c_char,
2738 );
2739 return;
2740 }
2741 if zobj.is_null() {
2742 if !storekey.is_null() {
2743 if dbDelete((*c).db, storekey) != 0 {
2744 signalModifiedKey(c, (*c).db, storekey);
2745 notifyKeyspaceEvent(
2746 (1 as libc::c_int) << 2 as libc::c_int,
2747 b"del\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2748 storekey,
2749 (*(*c).db).id,
2750 );
2751 server.dirty += 1;
2752 }
2753 addReply(c, shared.czero);
2754 } else {
2755 addReply(c, shared.emptyarray);
2756 }
2757 return;
2758 }
2759 if count != 0 as libc::c_int as libc::c_longlong && sort == 0 as libc::c_int
2760 && any == 0
2761 {
2762 sort = 1 as libc::c_int;
2763 }
2764 let mut georadius: GeoHashRadius = geohashCalculateAreasByShapeWGS84(&mut shape);
2765 let mut ga: *mut geoArray = geoArrayCreate();
2766 membersOfAllNeighbors(
2767 zobj,
2768 &mut georadius,
2769 &mut shape,
2770 ga,
2771 (if any != 0 { count } else { 0 as libc::c_int as libc::c_longlong })
2772 as libc::c_ulong,
2773 );
2774 if (*ga).used == 0 as libc::c_int as libc::c_ulong && storekey.is_null() {
2775 addReply(c, shared.emptyarray);
2776 geoArrayFree(ga);
2777 return;
2778 }
2779 let mut result_length: libc::c_long = (*ga).used as libc::c_long;
2780 let mut returned_items: libc::c_long = (if count
2781 == 0 as libc::c_int as libc::c_longlong
2782 || (result_length as libc::c_longlong) < count
2783 {
2784 result_length as libc::c_longlong
2785 } else {
2786 count
2787 }) as libc::c_long;
2788 let mut option_length: libc::c_long = 0 as libc::c_int as libc::c_long;
2789 if sort != 0 as libc::c_int {
2790 let mut sort_gp_callback: Option::<
2791 unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
2792 > = None;
2793 if sort == 1 as libc::c_int {
2794 sort_gp_callback = Some(
2795 sort_gp_asc
2796 as unsafe extern "C" fn(
2797 *const libc::c_void,
2798 *const libc::c_void,
2799 ) -> libc::c_int,
2800 );
2801 } else if sort == 2 as libc::c_int {
2802 sort_gp_callback = Some(
2803 sort_gp_desc
2804 as unsafe extern "C" fn(
2805 *const libc::c_void,
2806 *const libc::c_void,
2807 ) -> libc::c_int,
2808 );
2809 }
2810 if returned_items == result_length {
2811 qsort(
2812 (*ga).array as *mut libc::c_void,
2813 result_length as size_t,
2814 core::mem::size_of::<geoPoint>() as libc::c_ulong,
2815 sort_gp_callback,
2816 );
2817 } else {
2818 pqsort(
2819 (*ga).array as *mut libc::c_void,
2820 result_length as size_t,
2821 core::mem::size_of::<geoPoint>() as libc::c_ulong,
2822 sort_gp_callback,
2823 0 as libc::c_int as size_t,
2824 (returned_items - 1 as libc::c_int as libc::c_long) as size_t,
2825 );
2826 }
2827 }
2828 if storekey.is_null() {
2829 if withdist != 0 {
2830 option_length += 1;
2831 }
2832 if withcoords != 0 {
2833 option_length += 1;
2834 }
2835 if withhash != 0 {
2836 option_length += 1;
2837 }
2838 addReplyArrayLen(c, returned_items);
2839 let mut i_0: libc::c_int = 0;
2840 i_0 = 0 as libc::c_int;
2841 while (i_0 as libc::c_long) < returned_items {
2842 let mut gp: *mut geoPoint = ((*ga).array).offset(i_0 as isize);
2843 (*gp).dist /= shape.conversion;
2844 if option_length != 0 {
2845 addReplyArrayLen(c, option_length + 1 as libc::c_int as libc::c_long);
2846 }
2847 addReplyBulkSds(c, (*gp).member);
2848 (*gp).member = 0 as *mut libc::c_char;
2849 if withdist != 0 {
2850 addReplyDoubleDistance(c, (*gp).dist);
2851 }
2852 if withhash != 0 {
2853 addReplyLongLong(c, (*gp).score as libc::c_longlong);
2854 }
2855 if withcoords != 0 {
2856 addReplyArrayLen(c, 2 as libc::c_int as libc::c_long);
2857 addReplyHumanLongDouble(c, ((*gp).longitude) as f64);
2858 addReplyHumanLongDouble(c, ((*gp).latitude) as f64);
2859 }
2860 i_0 += 1;
2861 }
2862 } else {
2863 let mut zobj_0: *mut robj = 0 as *mut robj;
2864 let mut zs: *mut zset = 0 as *mut zset;
2865 let mut i_1: libc::c_int = 0;
2866 let mut maxelelen: size_t = 0 as libc::c_int as size_t;
2867 let mut totelelen: size_t = 0 as libc::c_int as size_t;
2868 if returned_items != 0 {
2869 zobj_0 = createZsetObject();
2870 zs = (*zobj_0).ptr as *mut zset;
2871 }
2872 i_1 = 0 as libc::c_int;
2873 while (i_1 as libc::c_long) < returned_items {
2874 let mut znode: *mut zskiplistNode = 0 as *mut zskiplistNode;
2875 let mut gp_0: *mut geoPoint = ((*ga).array).offset(i_1 as isize);
2876 (*gp_0).dist /= shape.conversion;
2877 let mut score: libc::c_double = if storedist != 0 {
2878 (*gp_0).dist
2879 } else {
2880 (*gp_0).score
2881 };
2882 let mut elelen: size_t = sdslen((*gp_0).member);
2883 if maxelelen < elelen {
2884 maxelelen = elelen;
2885 }
2886 totelelen = (totelelen as libc::c_ulong).wrapping_add(elelen) as size_t
2887 as size_t;
2888 znode = zslInsert((*zs).zsl, score, (*gp_0).member);
2889 if dictAdd(
2890 (*zs).dict,
2891 (*gp_0).member as *mut libc::c_void,
2892 &mut (*znode).score as *mut libc::c_double as *mut libc::c_void,
2893 ) == 0 as libc::c_int
2894 {} else {
2895 _serverAssert(
2896 b"dictAdd(zs->dict,gp->member,&znode->score) == DICT_OK\0"
2897 as *const u8 as *const libc::c_char,
2898 b"geo.c\0" as *const u8 as *const libc::c_char,
2899 825 as libc::c_int,
2900 );
2901 unreachable!();
2902 };
2903 (*gp_0).member = 0 as *mut libc::c_char;
2904 i_1 += 1;
2905 }
2906 if returned_items != 0 {
2907 zsetConvertToListpackIfNeeded(zobj_0, maxelelen, totelelen);
2908 setKey(c, (*c).db, storekey, zobj_0, 0 as libc::c_int);
2909 decrRefCount(zobj_0);
2910 notifyKeyspaceEvent(
2911 (1 as libc::c_int) << 7 as libc::c_int,
2912 (if flags & (1 as libc::c_int) << 3 as libc::c_int != 0 {
2913 b"geosearchstore\0" as *const u8 as *const libc::c_char
2914 } else {
2915 b"georadiusstore\0" as *const u8 as *const libc::c_char
2916 }) as *mut libc::c_char,
2917 storekey,
2918 (*(*c).db).id,
2919 );
2920 server.dirty += returned_items as libc::c_longlong;
2921 } else if dbDelete((*c).db, storekey) != 0 {
2922 signalModifiedKey(c, (*c).db, storekey);
2923 notifyKeyspaceEvent(
2924 (1 as libc::c_int) << 2 as libc::c_int,
2925 b"del\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2926 storekey,
2927 (*(*c).db).id,
2928 );
2929 server.dirty += 1;
2930 }
2931 addReplyLongLong(c, returned_items as libc::c_longlong);
2932 }
2933 geoArrayFree(ga);
2934}
2935#[no_mangle]
2936pub unsafe extern "C" fn georadiusCommand(mut c: *mut client) {
2937 georadiusGeneric(c, 1 as libc::c_int, (1 as libc::c_int) << 0 as libc::c_int);
2938}
2939#[no_mangle]
2940pub unsafe extern "C" fn georadiusbymemberCommand(mut c: *mut client) {
2941 georadiusGeneric(c, 1 as libc::c_int, (1 as libc::c_int) << 1 as libc::c_int);
2942}
2943#[no_mangle]
2944pub unsafe extern "C" fn georadiusroCommand(mut c: *mut client) {
2945 georadiusGeneric(
2946 c,
2947 1 as libc::c_int,
2948 (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 2 as libc::c_int,
2949 );
2950}
2951#[no_mangle]
2952pub unsafe extern "C" fn georadiusbymemberroCommand(mut c: *mut client) {
2953 georadiusGeneric(
2954 c,
2955 1 as libc::c_int,
2956 (1 as libc::c_int) << 1 as libc::c_int | (1 as libc::c_int) << 2 as libc::c_int,
2957 );
2958}
2959#[no_mangle]
2960pub unsafe extern "C" fn geosearchCommand(mut c: *mut client) {
2961 georadiusGeneric(c, 1 as libc::c_int, (1 as libc::c_int) << 3 as libc::c_int);
2962}
2963#[no_mangle]
2964pub unsafe extern "C" fn geosearchstoreCommand(mut c: *mut client) {
2965 georadiusGeneric(
2966 c,
2967 2 as libc::c_int,
2968 (1 as libc::c_int) << 3 as libc::c_int | (1 as libc::c_int) << 4 as libc::c_int,
2969 );
2970}
2971#[no_mangle]
2972pub unsafe extern "C" fn geohashCommand(mut c: *mut client) {
2973 let mut geoalphabet: *mut libc::c_char = b"0123456789bcdefghjkmnpqrstuvwxyz\0"
2974 as *const u8 as *const libc::c_char as *mut libc::c_char;
2975 let mut j: libc::c_int = 0;
2976 let mut zobj: *mut robj = lookupKeyRead(
2977 (*c).db,
2978 *((*c).argv).offset(1 as libc::c_int as isize),
2979 );
2980 if checkType(c, zobj, 3 as libc::c_int) != 0 {
2981 return;
2982 }
2983 addReplyArrayLen(c, ((*c).argc - 2 as libc::c_int) as libc::c_long);
2984 j = 2 as libc::c_int;
2985 while j < (*c).argc {
2986 let mut score: libc::c_double = 0.;
2987 if zobj.is_null()
2988 || zsetScore(zobj, (**((*c).argv).offset(j as isize)).ptr as sds, &mut score)
2989 == -(1 as libc::c_int)
2990 {
2991 addReplyNull(c);
2992 } else {
2993 let mut xy: [libc::c_double; 2] = [0.; 2];
2994 if decodeGeohash(score, xy.as_mut_ptr()) == 0 {
2995 addReplyNull(c);
2996 } else {
2997 let mut r: [GeoHashRange; 2] = [GeoHashRange { min: 0., max: 0. }; 2];
2998 let mut hash: GeoHashBits = GeoHashBits { bits: 0, step: 0 };
2999 r[0 as libc::c_int as usize]
3000 .min = -(180 as libc::c_int) as libc::c_double;
3001 r[0 as libc::c_int as usize].max = 180 as libc::c_int as libc::c_double;
3002 r[1 as libc::c_int as usize]
3003 .min = -(90 as libc::c_int) as libc::c_double;
3004 r[1 as libc::c_int as usize].max = 90 as libc::c_int as libc::c_double;
3005 geohashEncode(
3006 &mut *r.as_mut_ptr().offset(0 as libc::c_int as isize),
3007 &mut *r.as_mut_ptr().offset(1 as libc::c_int as isize),
3008 xy[0 as libc::c_int as usize],
3009 xy[1 as libc::c_int as usize],
3010 26 as libc::c_int as uint8_t,
3011 &mut hash,
3012 );
3013 let mut buf: [libc::c_char; 12] = [0; 12];
3014 let mut i: libc::c_int = 0;
3015 i = 0 as libc::c_int;
3016 while i < 11 as libc::c_int {
3017 let mut idx: libc::c_int = 0;
3018 if i == 10 as libc::c_int {
3019 idx = 0 as libc::c_int;
3020 } else {
3021 idx = (hash.bits
3022 >> 52 as libc::c_int
3023 - (i + 1 as libc::c_int) * 5 as libc::c_int
3024 & 0x1f as libc::c_int as libc::c_ulong) as libc::c_int;
3025 }
3026 buf[i as usize] = *geoalphabet.offset(idx as isize);
3027 i += 1;
3028 }
3029 buf[11 as libc::c_int as usize] = '\0' as i32 as libc::c_char;
3030 addReplyBulkCBuffer(
3031 c,
3032 buf.as_mut_ptr() as *const libc::c_void,
3033 11 as libc::c_int as size_t,
3034 );
3035 }
3036 }
3037 j += 1;
3038 }
3039}
3040#[no_mangle]
3041pub unsafe extern "C" fn geoposCommand(mut c: *mut client) {
3042 let mut j: libc::c_int = 0;
3043 let mut zobj: *mut robj = lookupKeyRead(
3044 (*c).db,
3045 *((*c).argv).offset(1 as libc::c_int as isize),
3046 );
3047 if checkType(c, zobj, 3 as libc::c_int) != 0 {
3048 return;
3049 }
3050 addReplyArrayLen(c, ((*c).argc - 2 as libc::c_int) as libc::c_long);
3051 j = 2 as libc::c_int;
3052 while j < (*c).argc {
3053 let mut score: libc::c_double = 0.;
3054 if zobj.is_null()
3055 || zsetScore(zobj, (**((*c).argv).offset(j as isize)).ptr as sds, &mut score)
3056 == -(1 as libc::c_int)
3057 {
3058 addReplyNullArray(c);
3059 } else {
3060 let mut xy: [libc::c_double; 2] = [0.; 2];
3061 if decodeGeohash(score, xy.as_mut_ptr()) == 0 {
3062 addReplyNullArray(c);
3063 } else {
3064 addReplyArrayLen(c, 2 as libc::c_int as libc::c_long);
3065 addReplyHumanLongDouble(
3066 c,
3067 (xy[0 as libc::c_int as usize]) as f64,
3068 );
3069 addReplyHumanLongDouble(
3070 c,
3071 (xy[1 as libc::c_int as usize]) as f64,
3072 );
3073 }
3074 }
3075 j += 1;
3076 }
3077}
3078#[no_mangle]
3079pub unsafe extern "C" fn geodistCommand(mut c: *mut client) {
3080 let mut to_meter: libc::c_double = 1 as libc::c_int as libc::c_double;
3081 if (*c).argc == 5 as libc::c_int {
3082 to_meter = extractUnitOrReply(c, *((*c).argv).offset(4 as libc::c_int as isize));
3083 if to_meter < 0 as libc::c_int as libc::c_double {
3084 return;
3085 }
3086 } else if (*c).argc > 5 as libc::c_int {
3087 addReplyErrorObject(c, shared.syntaxerr);
3088 return;
3089 }
3090 let mut zobj: *mut robj = 0 as *mut robj;
3091 zobj = lookupKeyReadOrReply(
3092 c,
3093 *((*c).argv).offset(1 as libc::c_int as isize),
3094 shared.null[(*c).resp as usize],
3095 );
3096 if zobj.is_null() || checkType(c, zobj, 3 as libc::c_int) != 0 {
3097 return;
3098 }
3099 let mut score1: libc::c_double = 0.;
3100 let mut score2: libc::c_double = 0.;
3101 let mut xyxy: [libc::c_double; 4] = [0.; 4];
3102 if zsetScore(
3103 zobj,
3104 (**((*c).argv).offset(2 as libc::c_int as isize)).ptr as sds,
3105 &mut score1,
3106 ) == -(1 as libc::c_int)
3107 || zsetScore(
3108 zobj,
3109 (**((*c).argv).offset(3 as libc::c_int as isize)).ptr as sds,
3110 &mut score2,
3111 ) == -(1 as libc::c_int)
3112 {
3113 addReplyNull(c);
3114 return;
3115 }
3116 if decodeGeohash(score1, xyxy.as_mut_ptr()) == 0
3117 || decodeGeohash(score2, xyxy.as_mut_ptr().offset(2 as libc::c_int as isize))
3118 == 0
3119 {
3120 addReplyNull(c);
3121 } else {
3122 addReplyDoubleDistance(
3123 c,
3124 geohashGetDistance(
3125 xyxy[0 as libc::c_int as usize],
3126 xyxy[1 as libc::c_int as usize],
3127 xyxy[2 as libc::c_int as usize],
3128 xyxy[3 as libc::c_int as usize],
3129 ) / to_meter,
3130 );
3131 };
3132}