1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4
5extern "C" {
6 pub type _IO_wide_data;
7 pub type _IO_codecvt;
8 pub type _IO_marker;
9 pub type RedisModuleCtx;
10 pub type RedisModuleDefragCtx;
11 pub type RedisModuleInfoCtx;
12 pub type RedisModuleKeyOptCtx;
13 pub type RedisModuleCommand;
14 fn sdsdup(s: sds) -> sds;
15 fn sdscmp(s1: sds, s2: sds) -> libc::c_int;
16 fn __errno_location() -> *mut libc::c_int;
17 fn strtol(
18 _: *const libc::c_char,
19 _: *mut *mut libc::c_char,
20 _: libc::c_int,
21 ) -> libc::c_long;
22 fn strtoul(
23 _: *const libc::c_char,
24 _: *mut *mut libc::c_char,
25 _: libc::c_int,
26 ) -> libc::c_ulong;
27 fn exit(_: libc::c_int) -> !;
28 fn memcpy(
29 _: *mut libc::c_void,
30 _: *const libc::c_void,
31 _: libc::c_ulong,
32 ) -> *mut libc::c_void;
33 fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
34 fn dictCreate(type_0: *mut dictType) -> *mut dict;
35 fn dictAddRaw(
36 d: *mut dict,
37 key: *mut libc::c_void,
38 existing: *mut *mut dictEntry,
39 ) -> *mut dictEntry;
40 fn dictAddOrFind(d: *mut dict, key: *mut libc::c_void) -> *mut dictEntry;
41 fn dictDelete(d: *mut dict, key: *const libc::c_void) -> libc::c_int;
42 fn dictUnlink(d: *mut dict, key: *const libc::c_void) -> *mut dictEntry;
43 fn dictFreeUnlinkedEntry(d: *mut dict, he: *mut dictEntry);
44 fn dictRelease(d: *mut dict);
45 fn dictFind(d: *mut dict, key: *const libc::c_void) -> *mut dictEntry;
46 fn dictGetSafeIterator(d: *mut dict) -> *mut dictIterator;
47 fn dictNext(iter: *mut dictIterator) -> *mut dictEntry;
48 fn dictReleaseIterator(iter: *mut dictIterator);
49 fn dictGetFairRandomKey(d: *mut dict) -> *mut dictEntry;
50 fn dictEmpty(
51 d: *mut dict,
52 callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
53 );
54 fn dictScan(
55 d: *mut dict,
56 v: libc::c_ulong,
57 fn_0: Option::<dictScanFunction>,
58 bucketfn: Option::<dictScanBucketFunction>,
59 privdata: *mut libc::c_void,
60 ) -> libc::c_ulong;
61 fn listCreate() -> *mut list;
62 fn listRelease(list: *mut list);
63 fn listAddNodeTail(list: *mut list, value: *mut libc::c_void) -> *mut list;
64 fn listDelNode(list: *mut list, node: *mut listNode);
65 fn zmalloc(size: size_t) -> *mut libc::c_void;
66 fn zcalloc(size: size_t) -> *mut libc::c_void;
67 fn zrealloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void;
68 fn zfree(ptr: *mut libc::c_void);
69 fn jemalloc_purge() -> libc::c_int;
70 fn intsetGet(is: *mut intset, pos: uint32_t, value: *mut int64_t) -> uint8_t;
71 fn stringmatchlen(
72 p: *const libc::c_char,
73 plen: libc::c_int,
74 s: *const libc::c_char,
75 slen: libc::c_int,
76 nocase: libc::c_int,
77 ) -> libc::c_int;
78 fn ll2string(
79 s: *mut libc::c_char,
80 len: size_t,
81 value: libc::c_longlong,
82 ) -> libc::c_int;
83 fn string2ll(
84 s: *const libc::c_char,
85 slen: size_t,
86 value: *mut libc::c_longlong,
87 ) -> libc::c_int;
88 fn latencyAddSample(event: *const libc::c_char, latency: mstime_t);
89 fn lpGet(
90 p: *mut libc::c_uchar,
91 count: *mut int64_t,
92 intbuf: *mut libc::c_uchar,
93 ) -> *mut libc::c_uchar;
94 fn lpFirst(lp: *mut libc::c_uchar) -> *mut libc::c_uchar;
95 fn lpNext(lp: *mut libc::c_uchar, p: *mut libc::c_uchar) -> *mut libc::c_uchar;
96 fn streamDup(o: *mut robj) -> *mut robj;
97 static mut server: redisServer;
98 static mut shared: sharedObjectsStruct;
99 static mut dbDictType: dictType;
100 static mut dbExpiresDictType: dictType;
101 fn moduleGetCommandKeysViaAPI(
102 cmd: *mut redisCommand,
103 argv: *mut *mut robj,
104 argc: libc::c_int,
105 result: *mut getKeysResult,
106 ) -> libc::c_int;
107 fn moduleGetCommandChannelsViaAPI(
108 cmd: *mut redisCommand,
109 argv: *mut *mut robj,
110 argc: libc::c_int,
111 result: *mut getKeysResult,
112 ) -> libc::c_int;
113 fn moduleFireServerEvent(eid: uint64_t, subid: libc::c_int, data: *mut libc::c_void);
114 fn moduleNotifyKeyUnlink(key: *mut robj, val: *mut robj, dbid: libc::c_int);
115 fn moduleTypeDupOrReply(
116 c: *mut client,
117 fromkey: *mut robj,
118 tokey: *mut robj,
119 todb: libc::c_int,
120 value: *mut robj,
121 ) -> *mut robj;
122 fn mstime() -> libc::c_longlong;
123 fn addReplyDeferredLen(c: *mut client) -> *mut libc::c_void;
124 fn setDeferredArrayLen(
125 c: *mut client,
126 node: *mut libc::c_void,
127 length: libc::c_long,
128 );
129 fn addReplyNull(c: *mut client);
130 fn addReplyBulk(c: *mut client, obj: *mut robj);
131 fn addReplyBulkLongLong(c: *mut client, ll: libc::c_longlong);
132 fn addReply(c: *mut client, obj: *mut robj);
133 fn addReplyErrorObject(c: *mut client, err: *mut robj);
134 fn addReplyOrErrorObject(c: *mut client, reply: *mut robj);
135 fn addReplyError(c: *mut client, err: *const libc::c_char);
136 fn addReplyStatus(c: *mut client, status: *const libc::c_char);
137 fn addReplyLongLong(c: *mut client, ll: libc::c_longlong);
138 fn addReplyArrayLen(c: *mut client, length: libc::c_long);
139 fn checkClientPauseTimeoutAndReturnIfPaused() -> libc::c_int;
140 fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
141 fn trackingInvalidateKey(c: *mut client, keyobj: *mut robj, bcast: libc::c_int);
142 fn trackingInvalidateKeysOnFlush(async_0: libc::c_int);
143 fn listTypeDup(o: *mut robj) -> *mut robj;
144 fn touchWatchedKey(db: *mut redisDb, key: *mut robj);
145 fn touchAllWatchedKeysInDb(emptied: *mut redisDb, replaced_with: *mut redisDb);
146 fn decrRefCount(o: *mut robj);
147 fn decrRefCountVoid(o: *mut libc::c_void);
148 fn incrRefCount(o: *mut robj);
149 fn createStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
150 fn createRawStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
151 fn dupStringObject(o: *const robj) -> *mut robj;
152 fn getDecodedObject(o: *mut robj) -> *mut robj;
153 fn createStringObjectFromLongLong(value: libc::c_longlong) -> *mut robj;
154 fn createStringObjectFromLongDouble(
155 value: f64,
156 humanfriendly: libc::c_int,
157 ) -> *mut robj;
158 fn getLongFromObjectOrReply(
159 c: *mut client,
160 o: *mut robj,
161 target: *mut libc::c_long,
162 msg: *const libc::c_char,
163 ) -> libc::c_int;
164 fn getIntFromObjectOrReply(
165 c: *mut client,
166 o: *mut robj,
167 target: *mut libc::c_int,
168 msg: *const libc::c_char,
169 ) -> libc::c_int;
170 fn rdbSave(
171 req: libc::c_int,
172 filename: *mut libc::c_char,
173 rsi: *mut rdbSaveInfo,
174 ) -> libc::c_int;
175 fn rdbPopulateSaveInfo(rsi: *mut rdbSaveInfo) -> *mut rdbSaveInfo;
176 fn killRDBChild();
177 fn hasActiveChildProcess() -> libc::c_int;
178 fn isInsideYieldingLongCommand() -> libc::c_int;
179 fn prepareForShutdown(flags: libc::c_int) -> libc::c_int;
180 fn abortShutdown() -> libc::c_int;
181 fn LRU_CLOCK() -> libc::c_uint;
182 fn setTypeDup(o: *mut robj) -> *mut robj;
183 fn hashTypeDup(o: *mut robj) -> *mut robj;
184 fn notifyKeyspaceEvent(
185 type_0: libc::c_int,
186 event: *mut libc::c_char,
187 key: *mut robj,
188 dbid: libc::c_int,
189 );
190 fn forceCommandPropagation(c: *mut client, flags: libc::c_int);
191 fn freeObjAsync(key: *mut robj, obj: *mut robj, dbid: libc::c_int);
192 fn alsoPropagate(
193 dbid: libc::c_int,
194 argv: *mut *mut robj,
195 argc: libc::c_int,
196 target: libc::c_int,
197 );
198 fn emptyDbAsync(db: *mut redisDb);
199 fn zsetDup(o: *mut robj) -> *mut robj;
200 fn signalKeyAsReady(db: *mut redisDb, key: *mut robj, type_0: libc::c_int);
201 fn rememberSlaveKeyWithExpire(db: *mut redisDb, key: *mut robj);
202 fn flushSlaveKeysWithExpireList();
203 fn LFULogIncr(value: uint8_t) -> uint8_t;
204 fn blockClient(c: *mut client, btype: libc::c_int);
205 fn LFUGetTimeInMinutes() -> libc::c_ulong;
206 fn LFUDecrAndReturn(o: *mut robj) -> libc::c_ulong;
207 fn subscribeCommand(c: *mut client);
208 fn ssubscribeCommand(c: *mut client);
209 fn unsubscribeCommand(c: *mut client);
210 fn sunsubscribeCommand(c: *mut client);
211 fn psubscribeCommand(c: *mut client);
212 fn punsubscribeCommand(c: *mut client);
213 fn publishCommand(c: *mut client);
214 fn spublishCommand(c: *mut client);
215 fn _serverAssert(
216 estr: *const libc::c_char,
217 file: *const libc::c_char,
218 line: libc::c_int,
219 );
220 fn _serverPanic(
221 file: *const libc::c_char,
222 line: libc::c_int,
223 msg: *const libc::c_char,
224 _: ...
225 );
226 fn _serverAssertWithInfo(
227 c: *const client,
228 o: *const robj,
229 estr: *const libc::c_char,
230 file: *const libc::c_char,
231 line: libc::c_int,
232 );
233 fn slotToKeyAddEntry(entry: *mut dictEntry, db: *mut redisDb);
234 fn slotToKeyDelEntry(entry: *mut dictEntry, db: *mut redisDb);
235 fn slotToKeyInit(db: *mut redisDb);
236 fn slotToKeyFlush(db: *mut redisDb);
237 fn slotToKeyDestroy(db: *mut redisDb);
238 fn scriptIsEval() -> libc::c_int;
239 fn scriptTimeSnapshot() -> mstime_t;
240 fn functionsLibCtxClearCurrent(async_0: libc::c_int);
241 fn __ctype_b_loc() -> *mut *const libc::c_ushort;
242}
243pub type __int8_t = libc::c_schar;
244pub type __uint8_t = libc::c_uchar;
245pub type __int16_t = libc::c_short;
246pub type __uint16_t = libc::c_ushort;
247pub type __int32_t = libc::c_int;
248pub type __uint32_t = libc::c_uint;
249pub type __int64_t = libc::c_long;
250pub type __uint64_t = libc::c_ulong;
251pub type __uint_least64_t = __uint64_t;
252pub type __mode_t = libc::c_uint;
253pub type __off_t = libc::c_long;
254pub type __off64_t = libc::c_long;
255pub type __pid_t = libc::c_int;
256pub type __time_t = libc::c_long;
257pub type __ssize_t = libc::c_long;
258pub type __sig_atomic_t = libc::c_int;
259pub type size_t = libc::c_ulong;
260#[derive(Copy, Clone)]
261#[repr(C)]
262pub struct iovec {
263 pub iov_base: *mut libc::c_void,
264 pub iov_len: size_t,
265}
266pub type mode_t = __mode_t;
267pub type off_t = __off64_t;
268pub type pid_t = __pid_t;
269pub type ssize_t = __ssize_t;
270pub type time_t = __time_t;
271pub type int8_t = __int8_t;
272pub type int16_t = __int16_t;
273pub type int32_t = __int32_t;
274pub type int64_t = __int64_t;
275pub type pthread_t = libc::c_ulong;
276#[derive(Copy, Clone)]
277#[repr(C)]
278pub struct _IO_FILE {
279 pub _flags: libc::c_int,
280 pub _IO_read_ptr: *mut libc::c_char,
281 pub _IO_read_end: *mut libc::c_char,
282 pub _IO_read_base: *mut libc::c_char,
283 pub _IO_write_base: *mut libc::c_char,
284 pub _IO_write_ptr: *mut libc::c_char,
285 pub _IO_write_end: *mut libc::c_char,
286 pub _IO_buf_base: *mut libc::c_char,
287 pub _IO_buf_end: *mut libc::c_char,
288 pub _IO_save_base: *mut libc::c_char,
289 pub _IO_backup_base: *mut libc::c_char,
290 pub _IO_save_end: *mut libc::c_char,
291 pub _markers: *mut _IO_marker,
292 pub _chain: *mut _IO_FILE,
293 pub _fileno: libc::c_int,
294 pub _flags2: libc::c_int,
295 pub _old_offset: __off_t,
296 pub _cur_column: libc::c_ushort,
297 pub _vtable_offset: libc::c_schar,
298 pub _shortbuf: [libc::c_char; 1],
299 pub _lock: *mut libc::c_void,
300 pub _offset: __off64_t,
301 pub _codecvt: *mut _IO_codecvt,
302 pub _wide_data: *mut _IO_wide_data,
303 pub _freeres_list: *mut _IO_FILE,
304 pub _freeres_buf: *mut libc::c_void,
305 pub __pad5: size_t,
306 pub _mode: libc::c_int,
307 pub _unused2: [libc::c_char; 20],
308}
309pub type _IO_lock_t = ();
310pub type FILE = _IO_FILE;
311pub type uint8_t = __uint8_t;
312pub type uint16_t = __uint16_t;
313pub type uint32_t = __uint32_t;
314pub type uint64_t = __uint64_t;
315pub type uint_least64_t = __uint_least64_t;
316pub type sds = *mut libc::c_char;
317#[derive(Copy, Clone)]
318#[repr(C, packed)]
319pub struct sdshdr8 {
320 pub len: uint8_t,
321 pub alloc: uint8_t,
322 pub flags: libc::c_uchar,
323 pub buf: [libc::c_char; 0],
324}
325#[derive(Copy, Clone)]
326#[repr(C, packed)]
327pub struct sdshdr16 {
328 pub len: uint16_t,
329 pub alloc: uint16_t,
330 pub flags: libc::c_uchar,
331 pub buf: [libc::c_char; 0],
332}
333#[derive(Copy, Clone)]
334#[repr(C, packed)]
335pub struct sdshdr32 {
336 pub len: uint32_t,
337 pub alloc: uint32_t,
338 pub flags: libc::c_uchar,
339 pub buf: [libc::c_char; 0],
340}
341#[derive(Copy, Clone)]
342#[repr(C, packed)]
343pub struct sdshdr64 {
344 pub len: uint64_t,
345 pub alloc: uint64_t,
346 pub flags: libc::c_uchar,
347 pub buf: [libc::c_char; 0],
348}
349#[derive(Copy, Clone)]
350#[repr(C)]
351pub struct aeEventLoop {
352 pub maxfd: libc::c_int,
353 pub setsize: libc::c_int,
354 pub timeEventNextId: libc::c_longlong,
355 pub events: *mut aeFileEvent,
356 pub fired: *mut aeFiredEvent,
357 pub timeEventHead: *mut aeTimeEvent,
358 pub stop: libc::c_int,
359 pub apidata: *mut libc::c_void,
360 pub beforesleep: Option::<aeBeforeSleepProc>,
361 pub aftersleep: Option::<aeBeforeSleepProc>,
362 pub flags: libc::c_int,
363}
364pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
365#[derive(Copy, Clone)]
366#[repr(C)]
367pub struct aeTimeEvent {
368 pub id: libc::c_longlong,
369 pub when: monotime,
370 pub timeProc: Option::<aeTimeProc>,
371 pub finalizerProc: Option::<aeEventFinalizerProc>,
372 pub clientData: *mut libc::c_void,
373 pub prev: *mut aeTimeEvent,
374 pub next: *mut aeTimeEvent,
375 pub refcount: libc::c_int,
376}
377pub type aeEventFinalizerProc = unsafe extern "C" fn(
378 *mut aeEventLoop,
379 *mut libc::c_void,
380) -> ();
381pub type aeTimeProc = unsafe extern "C" fn(
382 *mut aeEventLoop,
383 libc::c_longlong,
384 *mut libc::c_void,
385) -> libc::c_int;
386pub type monotime = uint64_t;
387#[derive(Copy, Clone)]
388#[repr(C)]
389pub struct aeFiredEvent {
390 pub fd: libc::c_int,
391 pub mask: libc::c_int,
392}
393#[derive(Copy, Clone)]
394#[repr(C)]
395pub struct aeFileEvent {
396 pub mask: libc::c_int,
397 pub rfileProc: Option::<aeFileProc>,
398 pub wfileProc: Option::<aeFileProc>,
399 pub clientData: *mut libc::c_void,
400}
401pub type aeFileProc = unsafe extern "C" fn(
402 *mut aeEventLoop,
403 libc::c_int,
404 *mut libc::c_void,
405 libc::c_int,
406) -> ();
407#[derive(Copy, Clone)]
408#[repr(C)]
409pub struct connection {
410 pub type_0: *mut ConnectionType,
411 pub state: ConnectionState,
412 pub flags: libc::c_short,
413 pub refs: libc::c_short,
414 pub last_errno: libc::c_int,
415 pub private_data: *mut libc::c_void,
416 pub conn_handler: ConnectionCallbackFunc,
417 pub write_handler: ConnectionCallbackFunc,
418 pub read_handler: ConnectionCallbackFunc,
419 pub fd: libc::c_int,
420}
421pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
422pub type ConnectionState = libc::c_uint;
423pub const CONN_STATE_ERROR: ConnectionState = 5;
424pub const CONN_STATE_CLOSED: ConnectionState = 4;
425pub const CONN_STATE_CONNECTED: ConnectionState = 3;
426pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
427pub const CONN_STATE_CONNECTING: ConnectionState = 1;
428pub const CONN_STATE_NONE: ConnectionState = 0;
429#[derive(Copy, Clone)]
430#[repr(C)]
431pub struct ConnectionType {
432 pub ae_handler: Option::<
433 unsafe extern "C" fn(
434 *mut aeEventLoop,
435 libc::c_int,
436 *mut libc::c_void,
437 libc::c_int,
438 ) -> (),
439 >,
440 pub connect: Option::<
441 unsafe extern "C" fn(
442 *mut connection,
443 *const libc::c_char,
444 libc::c_int,
445 *const libc::c_char,
446 ConnectionCallbackFunc,
447 ) -> libc::c_int,
448 >,
449 pub write: Option::<
450 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
451 >,
452 pub writev: Option::<
453 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
454 >,
455 pub read: Option::<
456 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
457 >,
458 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
459 pub accept: Option::<
460 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
461 >,
462 pub set_write_handler: Option::<
463 unsafe extern "C" fn(
464 *mut connection,
465 ConnectionCallbackFunc,
466 libc::c_int,
467 ) -> libc::c_int,
468 >,
469 pub set_read_handler: Option::<
470 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
471 >,
472 pub get_last_error: Option::<
473 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
474 >,
475 pub blocking_connect: Option::<
476 unsafe extern "C" fn(
477 *mut connection,
478 *const libc::c_char,
479 libc::c_int,
480 libc::c_longlong,
481 ) -> libc::c_int,
482 >,
483 pub sync_write: Option::<
484 unsafe extern "C" fn(
485 *mut connection,
486 *mut libc::c_char,
487 ssize_t,
488 libc::c_longlong,
489 ) -> ssize_t,
490 >,
491 pub sync_read: Option::<
492 unsafe extern "C" fn(
493 *mut connection,
494 *mut libc::c_char,
495 ssize_t,
496 libc::c_longlong,
497 ) -> ssize_t,
498 >,
499 pub sync_readline: Option::<
500 unsafe extern "C" fn(
501 *mut connection,
502 *mut libc::c_char,
503 ssize_t,
504 libc::c_longlong,
505 ) -> ssize_t,
506 >,
507 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
508}
509#[derive(Copy, Clone)]
510#[repr(C)]
511pub struct _rio {
512 pub read: Option::<
513 unsafe extern "C" fn(*mut _rio, *mut libc::c_void, size_t) -> size_t,
514 >,
515 pub write: Option::<
516 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> size_t,
517 >,
518 pub tell: Option::<unsafe extern "C" fn(*mut _rio) -> off_t>,
519 pub flush: Option::<unsafe extern "C" fn(*mut _rio) -> libc::c_int>,
520 pub update_cksum: Option::<
521 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> (),
522 >,
523 pub cksum: uint64_t,
524 pub flags: uint64_t,
525 pub processed_bytes: size_t,
526 pub max_processing_chunk: size_t,
527 pub io: C2RustUnnamed,
528}
529#[derive(Copy, Clone)]
530#[repr(C)]
531pub union C2RustUnnamed {
532 pub buffer: C2RustUnnamed_3,
533 pub file: C2RustUnnamed_2,
534 pub conn: C2RustUnnamed_1,
535 pub fd: C2RustUnnamed_0,
536}
537#[derive(Copy, Clone)]
538#[repr(C)]
539pub struct C2RustUnnamed_0 {
540 pub fd: libc::c_int,
541 pub pos: off_t,
542 pub buf: sds,
543}
544#[derive(Copy, Clone)]
545#[repr(C)]
546pub struct C2RustUnnamed_1 {
547 pub conn: *mut connection,
548 pub pos: off_t,
549 pub buf: sds,
550 pub read_limit: size_t,
551 pub read_so_far: size_t,
552}
553#[derive(Copy, Clone)]
554#[repr(C)]
555pub struct C2RustUnnamed_2 {
556 pub fp: *mut FILE,
557 pub buffered: off_t,
558 pub autosync: off_t,
559}
560#[derive(Copy, Clone)]
561#[repr(C)]
562pub struct C2RustUnnamed_3 {
563 pub ptr: sds,
564 pub pos: off_t,
565}
566pub type rio = _rio;
567#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
568#[repr(C)]
569pub struct redisObject {
570 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
571 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
572 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
573 pub type_0_encoding_lru: [u8; 4],
574 pub refcount: libc::c_int,
575 pub ptr: *mut libc::c_void,
576}
577pub type atomic_int = libc::c_int;
578pub type atomic_uint = libc::c_uint;
579pub type atomic_llong = libc::c_longlong;
580pub type sig_atomic_t = __sig_atomic_t;
581#[derive(Copy, Clone)]
582#[repr(C)]
583pub struct hdr_histogram {
584 pub lowest_discernible_value: int64_t,
585 pub highest_trackable_value: int64_t,
586 pub unit_magnitude: int32_t,
587 pub significant_figures: int32_t,
588 pub sub_bucket_half_count_magnitude: int32_t,
589 pub sub_bucket_half_count: int32_t,
590 pub sub_bucket_mask: int64_t,
591 pub sub_bucket_count: int32_t,
592 pub bucket_count: int32_t,
593 pub min_value: int64_t,
594 pub max_value: int64_t,
595 pub normalizing_index_offset: int32_t,
596 pub conversion_ratio: libc::c_double,
597 pub counts_len: int32_t,
598 pub total_count: int64_t,
599 pub counts: *mut int64_t,
600}
601pub type mstime_t = libc::c_longlong;
602pub type ustime_t = libc::c_longlong;
603#[derive(Copy, Clone)]
604#[repr(C)]
605pub struct dictEntry {
606 pub key: *mut libc::c_void,
607 pub v: C2RustUnnamed_4,
608 pub next: *mut dictEntry,
609 pub metadata: [*mut libc::c_void; 0],
610}
611#[derive(Copy, Clone)]
612#[repr(C)]
613pub union C2RustUnnamed_4 {
614 pub val: *mut libc::c_void,
615 pub u64_0: uint64_t,
616 pub s64: int64_t,
617 pub d: libc::c_double,
618}
619#[derive(Copy, Clone)]
620#[repr(C)]
621pub struct dict {
622 pub type_0: *mut dictType,
623 pub ht_table: [*mut *mut dictEntry; 2],
624 pub ht_used: [libc::c_ulong; 2],
625 pub rehashidx: libc::c_long,
626 pub pauserehash: int16_t,
627 pub ht_size_exp: [libc::c_schar; 2],
628}
629#[derive(Copy, Clone)]
630#[repr(C)]
631pub struct dictType {
632 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
633 pub keyDup: Option::<
634 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
635 >,
636 pub valDup: Option::<
637 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
638 >,
639 pub keyCompare: Option::<
640 unsafe extern "C" fn(
641 *mut dict,
642 *const libc::c_void,
643 *const libc::c_void,
644 ) -> libc::c_int,
645 >,
646 pub keyDestructor: Option::<
647 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
648 >,
649 pub valDestructor: Option::<
650 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
651 >,
652 pub expandAllowed: Option::<
653 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
654 >,
655 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
656}
657#[derive(Copy, Clone)]
658#[repr(C)]
659pub struct dictIterator {
660 pub d: *mut dict,
661 pub index: libc::c_long,
662 pub table: libc::c_int,
663 pub safe: libc::c_int,
664 pub entry: *mut dictEntry,
665 pub nextEntry: *mut dictEntry,
666 pub fingerprint: libc::c_ulonglong,
667}
668pub type dictScanFunction = unsafe extern "C" fn(
669 *mut libc::c_void,
670 *const dictEntry,
671) -> ();
672pub type dictScanBucketFunction = unsafe extern "C" fn(
673 *mut dict,
674 *mut *mut dictEntry,
675) -> ();
676#[derive(Copy, Clone)]
677#[repr(C)]
678pub struct listNode {
679 pub prev: *mut listNode,
680 pub next: *mut listNode,
681 pub value: *mut libc::c_void,
682}
683#[derive(Copy, Clone)]
684#[repr(C)]
685pub struct list {
686 pub head: *mut listNode,
687 pub tail: *mut listNode,
688 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
689 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
690 pub match_0: Option::<
691 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
692 >,
693 pub len: libc::c_ulong,
694}
695#[derive(Copy, Clone)]
696#[repr(C)]
697pub struct intset {
698 pub encoding: uint32_t,
699 pub length: uint32_t,
700 pub contents: [int8_t; 0],
701}
702#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
703#[repr(C)]
704pub struct raxNode {
705 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
706 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
707 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
708 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
709 pub iskey_isnull_iscompr_size: [u8; 4],
710 pub data: [libc::c_uchar; 0],
711}
712#[derive(Copy, Clone)]
713#[repr(C)]
714pub struct rax {
715 pub head: *mut raxNode,
716 pub numele: uint64_t,
717 pub numnodes: uint64_t,
718}
719#[derive(Copy, Clone)]
720#[repr(C)]
721pub struct RedisModuleFlushInfo {
722 pub version: uint64_t,
723 pub sync: int32_t,
724 pub dbnum: int32_t,
725}
726pub type RedisModuleFlushInfoV1 = RedisModuleFlushInfo;
727#[derive(Copy, Clone)]
728#[repr(C)]
729pub struct RedisModuleSwapDbInfo {
730 pub version: uint64_t,
731 pub dbnum_first: int32_t,
732 pub dbnum_second: int32_t,
733}
734pub type RedisModuleSwapDbInfoV1 = RedisModuleSwapDbInfo;
735pub type pause_type = libc::c_uint;
736pub const CLIENT_PAUSE_ALL: pause_type = 2;
737pub const CLIENT_PAUSE_WRITE: pause_type = 1;
738pub const CLIENT_PAUSE_OFF: pause_type = 0;
739#[derive(Copy, Clone)]
740#[repr(C)]
741pub struct pause_event {
742 pub type_0: pause_type,
743 pub end: mstime_t,
744}
745#[derive(Copy, Clone)]
746#[repr(C)]
747pub struct RedisModule {
748 pub handle: *mut libc::c_void,
749 pub name: *mut libc::c_char,
750 pub ver: libc::c_int,
751 pub apiver: libc::c_int,
752 pub types: *mut list,
753 pub usedby: *mut list,
754 pub using: *mut list,
755 pub filters: *mut list,
756 pub module_configs: *mut list,
757 pub configs_initialized: libc::c_int,
758 pub in_call: libc::c_int,
759 pub in_hook: libc::c_int,
760 pub options: libc::c_int,
761 pub blocked_clients: libc::c_int,
762 pub info_cb: RedisModuleInfoFunc,
763 pub defrag_cb: RedisModuleDefragFunc,
764 pub loadmod: *mut moduleLoadQueueEntry,
765}
766#[derive(Copy, Clone)]
767#[repr(C)]
768pub struct moduleLoadQueueEntry {
769 pub path: sds,
770 pub argc: libc::c_int,
771 pub argv: *mut *mut robj,
772}
773pub type robj = redisObject;
774pub type RedisModuleDefragFunc = Option::<
775 unsafe extern "C" fn(*mut RedisModuleDefragCtx) -> (),
776>;
777pub type RedisModuleInfoFunc = Option::<
778 unsafe extern "C" fn(*mut RedisModuleInfoCtx, libc::c_int) -> (),
779>;
780#[derive(Copy, Clone)]
781#[repr(C)]
782pub struct RedisModuleIO {
783 pub bytes: size_t,
784 pub rio: *mut rio,
785 pub type_0: *mut moduleType,
786 pub error: libc::c_int,
787 pub ver: libc::c_int,
788 pub ctx: *mut RedisModuleCtx,
789 pub key: *mut redisObject,
790 pub dbid: libc::c_int,
791}
792pub type moduleType = RedisModuleType;
793#[derive(Copy, Clone)]
794#[repr(C)]
795pub struct RedisModuleType {
796 pub id: uint64_t,
797 pub module: *mut RedisModule,
798 pub rdb_load: moduleTypeLoadFunc,
799 pub rdb_save: moduleTypeSaveFunc,
800 pub aof_rewrite: moduleTypeRewriteFunc,
801 pub mem_usage: moduleTypeMemUsageFunc,
802 pub digest: moduleTypeDigestFunc,
803 pub free: moduleTypeFreeFunc,
804 pub free_effort: moduleTypeFreeEffortFunc,
805 pub unlink: moduleTypeUnlinkFunc,
806 pub copy: moduleTypeCopyFunc,
807 pub defrag: moduleTypeDefragFunc,
808 pub aux_load: moduleTypeAuxLoadFunc,
809 pub aux_save: moduleTypeAuxSaveFunc,
810 pub mem_usage2: moduleTypeMemUsageFunc2,
811 pub free_effort2: moduleTypeFreeEffortFunc2,
812 pub unlink2: moduleTypeUnlinkFunc2,
813 pub copy2: moduleTypeCopyFunc2,
814 pub aux_save_triggers: libc::c_int,
815 pub name: [libc::c_char; 10],
816}
817pub type moduleTypeCopyFunc2 = Option::<
818 unsafe extern "C" fn(
819 *mut RedisModuleKeyOptCtx,
820 *const libc::c_void,
821 ) -> *mut libc::c_void,
822>;
823pub type moduleTypeUnlinkFunc2 = Option::<
824 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *mut libc::c_void) -> (),
825>;
826pub type moduleTypeFreeEffortFunc2 = Option::<
827 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *const libc::c_void) -> size_t,
828>;
829pub type moduleTypeMemUsageFunc2 = Option::<
830 unsafe extern "C" fn(
831 *mut RedisModuleKeyOptCtx,
832 *const libc::c_void,
833 size_t,
834 ) -> size_t,
835>;
836pub type moduleTypeAuxSaveFunc = Option::<
837 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> (),
838>;
839pub type moduleTypeAuxLoadFunc = Option::<
840 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int, libc::c_int) -> libc::c_int,
841>;
842pub type moduleTypeDefragFunc = Option::<
843 unsafe extern "C" fn(
844 *mut RedisModuleDefragCtx,
845 *mut redisObject,
846 *mut *mut libc::c_void,
847 ) -> libc::c_int,
848>;
849pub type moduleTypeCopyFunc = Option::<
850 unsafe extern "C" fn(
851 *mut redisObject,
852 *mut redisObject,
853 *const libc::c_void,
854 ) -> *mut libc::c_void,
855>;
856pub type moduleTypeUnlinkFunc = Option::<
857 unsafe extern "C" fn(*mut redisObject, *mut libc::c_void) -> (),
858>;
859pub type moduleTypeFreeEffortFunc = Option::<
860 unsafe extern "C" fn(*mut redisObject, *const libc::c_void) -> size_t,
861>;
862pub type moduleTypeFreeFunc = Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
863pub type moduleTypeDigestFunc = Option::<
864 unsafe extern "C" fn(*mut RedisModuleDigest, *mut libc::c_void) -> (),
865>;
866#[derive(Copy, Clone)]
867#[repr(C)]
868pub struct RedisModuleDigest {
869 pub o: [libc::c_uchar; 20],
870 pub x: [libc::c_uchar; 20],
871 pub key: *mut redisObject,
872 pub dbid: libc::c_int,
873}
874pub type moduleTypeMemUsageFunc = Option::<
875 unsafe extern "C" fn(*const libc::c_void) -> size_t,
876>;
877pub type moduleTypeRewriteFunc = Option::<
878 unsafe extern "C" fn(*mut RedisModuleIO, *mut redisObject, *mut libc::c_void) -> (),
879>;
880pub type moduleTypeSaveFunc = Option::<
881 unsafe extern "C" fn(*mut RedisModuleIO, *mut libc::c_void) -> (),
882>;
883pub type moduleTypeLoadFunc = Option::<
884 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> *mut libc::c_void,
885>;
886pub type RedisModuleUserChangedFunc = Option::<
887 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
888>;
889#[derive(Copy, Clone)]
890#[repr(C)]
891pub struct moduleValue {
892 pub type_0: *mut moduleType,
893 pub value: *mut libc::c_void,
894}
895#[derive(Copy, Clone)]
896#[repr(C)]
897pub struct clusterSlotToKeyMapping {
898 pub by_slot: [slotToKeys; 16384],
899}
900#[derive(Copy, Clone)]
901#[repr(C)]
902pub struct slotToKeys {
903 pub count: uint64_t,
904 pub head: *mut dictEntry,
905}
906#[derive(Copy, Clone)]
907#[repr(C)]
908pub struct redisDb {
909 pub dict: *mut dict,
910 pub expires: *mut dict,
911 pub blocking_keys: *mut dict,
912 pub ready_keys: *mut dict,
913 pub watched_keys: *mut dict,
914 pub id: libc::c_int,
915 pub avg_ttl: libc::c_longlong,
916 pub expires_cursor: libc::c_ulong,
917 pub defrag_later: *mut list,
918 pub slots_to_keys: *mut clusterSlotToKeyMapping,
919}
920#[derive(Copy, Clone)]
921#[repr(C)]
922pub struct multiCmd {
923 pub argv: *mut *mut robj,
924 pub argv_len: libc::c_int,
925 pub argc: libc::c_int,
926 pub cmd: *mut redisCommand,
927}
928#[derive(Copy, Clone)]
929#[repr(C)]
930pub struct redisCommand {
931 pub declared_name: *const libc::c_char,
932 pub summary: *const libc::c_char,
933 pub complexity: *const libc::c_char,
934 pub since: *const libc::c_char,
935 pub doc_flags: libc::c_int,
936 pub replaced_by: *const libc::c_char,
937 pub deprecated_since: *const libc::c_char,
938 pub group: redisCommandGroup,
939 pub history: *mut commandHistory,
940 pub tips: *mut *const libc::c_char,
941 pub proc_0: Option::<redisCommandProc>,
942 pub arity: libc::c_int,
943 pub flags: uint64_t,
944 pub acl_categories: uint64_t,
945 pub key_specs_static: [keySpec; 4],
946 pub getkeys_proc: Option::<redisGetKeysProc>,
947 pub subcommands: *mut redisCommand,
948 pub args: *mut redisCommandArg,
949 pub microseconds: libc::c_longlong,
950 pub calls: libc::c_longlong,
951 pub rejected_calls: libc::c_longlong,
952 pub failed_calls: libc::c_longlong,
953 pub id: libc::c_int,
954 pub fullname: sds,
955 pub latency_histogram: *mut hdr_histogram,
956 pub key_specs: *mut keySpec,
957 pub legacy_range_key_spec: keySpec,
958 pub num_args: libc::c_int,
959 pub num_history: libc::c_int,
960 pub num_tips: libc::c_int,
961 pub key_specs_num: libc::c_int,
962 pub key_specs_max: libc::c_int,
963 pub subcommands_dict: *mut dict,
964 pub parent: *mut redisCommand,
965 pub module_cmd: *mut RedisModuleCommand,
966}
967#[derive(Copy, Clone)]
968#[repr(C)]
969pub struct keySpec {
970 pub notes: *const libc::c_char,
971 pub flags: uint64_t,
972 pub begin_search_type: kspec_bs_type,
973 pub bs: C2RustUnnamed_8,
974 pub find_keys_type: kspec_fk_type,
975 pub fk: C2RustUnnamed_5,
976}
977#[derive(Copy, Clone)]
978#[repr(C)]
979pub union C2RustUnnamed_5 {
980 pub range: C2RustUnnamed_7,
981 pub keynum: C2RustUnnamed_6,
982}
983#[derive(Copy, Clone)]
984#[repr(C)]
985pub struct C2RustUnnamed_6 {
986 pub keynumidx: libc::c_int,
987 pub firstkey: libc::c_int,
988 pub keystep: libc::c_int,
989}
990#[derive(Copy, Clone)]
991#[repr(C)]
992pub struct C2RustUnnamed_7 {
993 pub lastkey: libc::c_int,
994 pub keystep: libc::c_int,
995 pub limit: libc::c_int,
996}
997pub type kspec_fk_type = libc::c_uint;
998pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
999pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
1000pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
1001pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
1002#[derive(Copy, Clone)]
1003#[repr(C)]
1004pub union C2RustUnnamed_8 {
1005 pub index: C2RustUnnamed_10,
1006 pub keyword: C2RustUnnamed_9,
1007}
1008#[derive(Copy, Clone)]
1009#[repr(C)]
1010pub struct C2RustUnnamed_9 {
1011 pub keyword: *const libc::c_char,
1012 pub startfrom: libc::c_int,
1013}
1014#[derive(Copy, Clone)]
1015#[repr(C)]
1016pub struct C2RustUnnamed_10 {
1017 pub pos: libc::c_int,
1018}
1019pub type kspec_bs_type = libc::c_uint;
1020pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
1021pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
1022pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
1023pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
1024#[derive(Copy, Clone)]
1025#[repr(C)]
1026pub struct redisCommandArg {
1027 pub name: *const libc::c_char,
1028 pub type_0: redisCommandArgType,
1029 pub key_spec_index: libc::c_int,
1030 pub token: *const libc::c_char,
1031 pub summary: *const libc::c_char,
1032 pub since: *const libc::c_char,
1033 pub flags: libc::c_int,
1034 pub deprecated_since: *const libc::c_char,
1035 pub subargs: *mut redisCommandArg,
1036 pub num_args: libc::c_int,
1037}
1038pub type redisCommandArgType = libc::c_uint;
1039pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
1040pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
1041pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
1042pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
1043pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
1044pub const ARG_TYPE_KEY: redisCommandArgType = 3;
1045pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
1046pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
1047pub const ARG_TYPE_STRING: redisCommandArgType = 0;
1048pub type redisGetKeysProc = unsafe extern "C" fn(
1049 *mut redisCommand,
1050 *mut *mut robj,
1051 libc::c_int,
1052 *mut getKeysResult,
1053) -> libc::c_int;
1054#[derive(Copy, Clone)]
1055#[repr(C)]
1056pub struct getKeysResult {
1057 pub keysbuf: [keyReference; 256],
1058 pub keys: *mut keyReference,
1059 pub numkeys: libc::c_int,
1060 pub size: libc::c_int,
1061}
1062#[derive(Copy, Clone)]
1063#[repr(C)]
1064pub struct keyReference {
1065 pub pos: libc::c_int,
1066 pub flags: libc::c_int,
1067}
1068pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
1069#[derive(Copy, Clone)]
1070#[repr(C)]
1071pub struct client {
1072 pub id: uint64_t,
1073 pub flags: uint64_t,
1074 pub conn: *mut connection,
1075 pub resp: libc::c_int,
1076 pub db: *mut redisDb,
1077 pub name: *mut robj,
1078 pub querybuf: sds,
1079 pub qb_pos: size_t,
1080 pub querybuf_peak: size_t,
1081 pub argc: libc::c_int,
1082 pub argv: *mut *mut robj,
1083 pub argv_len: libc::c_int,
1084 pub original_argc: libc::c_int,
1085 pub original_argv: *mut *mut robj,
1086 pub argv_len_sum: size_t,
1087 pub cmd: *mut redisCommand,
1088 pub lastcmd: *mut redisCommand,
1089 pub realcmd: *mut redisCommand,
1090 pub user: *mut user,
1091 pub reqtype: libc::c_int,
1092 pub multibulklen: libc::c_int,
1093 pub bulklen: libc::c_long,
1094 pub reply: *mut list,
1095 pub reply_bytes: libc::c_ulonglong,
1096 pub deferred_reply_errors: *mut list,
1097 pub sentlen: size_t,
1098 pub ctime: time_t,
1099 pub duration: libc::c_long,
1100 pub slot: libc::c_int,
1101 pub cur_script: *mut dictEntry,
1102 pub lastinteraction: time_t,
1103 pub obuf_soft_limit_reached_time: time_t,
1104 pub authenticated: libc::c_int,
1105 pub replstate: libc::c_int,
1106 pub repl_start_cmd_stream_on_ack: libc::c_int,
1107 pub repldbfd: libc::c_int,
1108 pub repldboff: off_t,
1109 pub repldbsize: off_t,
1110 pub replpreamble: sds,
1111 pub read_reploff: libc::c_longlong,
1112 pub reploff: libc::c_longlong,
1113 pub repl_applied: libc::c_longlong,
1114 pub repl_ack_off: libc::c_longlong,
1115 pub repl_ack_time: libc::c_longlong,
1116 pub repl_last_partial_write: libc::c_longlong,
1117 pub psync_initial_offset: libc::c_longlong,
1118 pub replid: [libc::c_char; 41],
1119 pub slave_listening_port: libc::c_int,
1120 pub slave_addr: *mut libc::c_char,
1121 pub slave_capa: libc::c_int,
1122 pub slave_req: libc::c_int,
1123 pub mstate: multiState,
1124 pub btype: libc::c_int,
1125 pub bpop: blockingState,
1126 pub woff: libc::c_longlong,
1127 pub watched_keys: *mut list,
1128 pub pubsub_channels: *mut dict,
1129 pub pubsub_patterns: *mut list,
1130 pub pubsubshard_channels: *mut dict,
1131 pub peerid: sds,
1132 pub sockname: sds,
1133 pub client_list_node: *mut listNode,
1134 pub postponed_list_node: *mut listNode,
1135 pub pending_read_list_node: *mut listNode,
1136 pub auth_callback: RedisModuleUserChangedFunc,
1137 pub auth_callback_privdata: *mut libc::c_void,
1138 pub auth_module: *mut libc::c_void,
1139 pub client_tracking_redirection: uint64_t,
1140 pub client_tracking_prefixes: *mut rax,
1141 pub last_memory_usage: size_t,
1142 pub last_memory_type: libc::c_int,
1143 pub mem_usage_bucket_node: *mut listNode,
1144 pub mem_usage_bucket: *mut clientMemUsageBucket,
1145 pub ref_repl_buf_node: *mut listNode,
1146 pub ref_block_pos: size_t,
1147 pub buf_peak: size_t,
1148 pub buf_peak_last_reset_time: mstime_t,
1149 pub bufpos: libc::c_int,
1150 pub buf_usable_size: size_t,
1151 pub buf: *mut libc::c_char,
1152}
1153#[derive(Copy, Clone)]
1154#[repr(C)]
1155pub struct clientMemUsageBucket {
1156 pub clients: *mut list,
1157 pub mem_usage_sum: size_t,
1158}
1159#[derive(Copy, Clone)]
1160#[repr(C)]
1161pub struct blockingState {
1162 pub count: libc::c_long,
1163 pub timeout: mstime_t,
1164 pub keys: *mut dict,
1165 pub target: *mut robj,
1166 pub blockpos: blockPos,
1167 pub xread_count: size_t,
1168 pub xread_group: *mut robj,
1169 pub xread_consumer: *mut robj,
1170 pub xread_group_noack: libc::c_int,
1171 pub numreplicas: libc::c_int,
1172 pub reploffset: libc::c_longlong,
1173 pub module_blocked_handle: *mut libc::c_void,
1174}
1175#[derive(Copy, Clone)]
1176#[repr(C)]
1177pub struct blockPos {
1178 pub wherefrom: libc::c_int,
1179 pub whereto: libc::c_int,
1180}
1181#[derive(Copy, Clone)]
1182#[repr(C)]
1183pub struct multiState {
1184 pub commands: *mut multiCmd,
1185 pub count: libc::c_int,
1186 pub cmd_flags: libc::c_int,
1187 pub cmd_inv_flags: libc::c_int,
1188 pub argv_len_sums: size_t,
1189 pub alloc_count: libc::c_int,
1190}
1191#[derive(Copy, Clone)]
1192#[repr(C)]
1193pub struct user {
1194 pub name: sds,
1195 pub flags: uint32_t,
1196 pub passwords: *mut list,
1197 pub selectors: *mut list,
1198 pub acl_string: *mut robj,
1199}
1200#[derive(Copy, Clone)]
1201#[repr(C)]
1202pub struct commandHistory {
1203 pub since: *const libc::c_char,
1204 pub changes: *const libc::c_char,
1205}
1206pub type redisCommandGroup = libc::c_uint;
1207pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
1208pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
1209pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
1210pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
1211pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
1212pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
1213pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
1214pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
1215pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
1216pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
1217pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
1218pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
1219pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
1220pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
1221pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
1222pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
1223pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
1224pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
1225#[derive(Copy, Clone)]
1226#[repr(C)]
1227pub struct replBacklog {
1228 pub ref_repl_buf_node: *mut listNode,
1229 pub unindexed_count: size_t,
1230 pub blocks_index: *mut rax,
1231 pub histlen: libc::c_longlong,
1232 pub offset: libc::c_longlong,
1233}
1234#[derive(Copy, Clone)]
1235#[repr(C)]
1236pub struct saveparam {
1237 pub seconds: time_t,
1238 pub changes: libc::c_int,
1239}
1240#[derive(Copy, Clone)]
1241#[repr(C)]
1242pub struct sentinelConfig {
1243 pub pre_monitor_cfg: *mut list,
1244 pub monitor_cfg: *mut list,
1245 pub post_monitor_cfg: *mut list,
1246}
1247#[derive(Copy, Clone)]
1248#[repr(C)]
1249pub struct sharedObjectsStruct {
1250 pub crlf: *mut robj,
1251 pub ok: *mut robj,
1252 pub err: *mut robj,
1253 pub emptybulk: *mut robj,
1254 pub czero: *mut robj,
1255 pub cone: *mut robj,
1256 pub pong: *mut robj,
1257 pub space: *mut robj,
1258 pub queued: *mut robj,
1259 pub null: [*mut robj; 4],
1260 pub nullarray: [*mut robj; 4],
1261 pub emptymap: [*mut robj; 4],
1262 pub emptyset: [*mut robj; 4],
1263 pub emptyarray: *mut robj,
1264 pub wrongtypeerr: *mut robj,
1265 pub nokeyerr: *mut robj,
1266 pub syntaxerr: *mut robj,
1267 pub sameobjecterr: *mut robj,
1268 pub outofrangeerr: *mut robj,
1269 pub noscripterr: *mut robj,
1270 pub loadingerr: *mut robj,
1271 pub slowevalerr: *mut robj,
1272 pub slowscripterr: *mut robj,
1273 pub slowmoduleerr: *mut robj,
1274 pub bgsaveerr: *mut robj,
1275 pub masterdownerr: *mut robj,
1276 pub roslaveerr: *mut robj,
1277 pub execaborterr: *mut robj,
1278 pub noautherr: *mut robj,
1279 pub noreplicaserr: *mut robj,
1280 pub busykeyerr: *mut robj,
1281 pub oomerr: *mut robj,
1282 pub plus: *mut robj,
1283 pub messagebulk: *mut robj,
1284 pub pmessagebulk: *mut robj,
1285 pub subscribebulk: *mut robj,
1286 pub unsubscribebulk: *mut robj,
1287 pub psubscribebulk: *mut robj,
1288 pub punsubscribebulk: *mut robj,
1289 pub del: *mut robj,
1290 pub unlink: *mut robj,
1291 pub rpop: *mut robj,
1292 pub lpop: *mut robj,
1293 pub lpush: *mut robj,
1294 pub rpoplpush: *mut robj,
1295 pub lmove: *mut robj,
1296 pub blmove: *mut robj,
1297 pub zpopmin: *mut robj,
1298 pub zpopmax: *mut robj,
1299 pub emptyscan: *mut robj,
1300 pub multi: *mut robj,
1301 pub exec: *mut robj,
1302 pub left: *mut robj,
1303 pub right: *mut robj,
1304 pub hset: *mut robj,
1305 pub srem: *mut robj,
1306 pub xgroup: *mut robj,
1307 pub xclaim: *mut robj,
1308 pub script: *mut robj,
1309 pub replconf: *mut robj,
1310 pub eval: *mut robj,
1311 pub persist: *mut robj,
1312 pub set: *mut robj,
1313 pub pexpireat: *mut robj,
1314 pub pexpire: *mut robj,
1315 pub time: *mut robj,
1316 pub pxat: *mut robj,
1317 pub absttl: *mut robj,
1318 pub retrycount: *mut robj,
1319 pub force: *mut robj,
1320 pub justid: *mut robj,
1321 pub entriesread: *mut robj,
1322 pub lastid: *mut robj,
1323 pub ping: *mut robj,
1324 pub setid: *mut robj,
1325 pub keepttl: *mut robj,
1326 pub load: *mut robj,
1327 pub createconsumer: *mut robj,
1328 pub getack: *mut robj,
1329 pub special_asterick: *mut robj,
1330 pub special_equals: *mut robj,
1331 pub default_username: *mut robj,
1332 pub redacted: *mut robj,
1333 pub ssubscribebulk: *mut robj,
1334 pub sunsubscribebulk: *mut robj,
1335 pub smessagebulk: *mut robj,
1336 pub select: [*mut robj; 10],
1337 pub integers: [*mut robj; 10000],
1338 pub mbulkhdr: [*mut robj; 32],
1339 pub bulkhdr: [*mut robj; 32],
1340 pub maphdr: [*mut robj; 32],
1341 pub sethdr: [*mut robj; 32],
1342 pub minstring: sds,
1343 pub maxstring: sds,
1344}
1345#[derive(Copy, Clone)]
1346#[repr(C)]
1347pub struct zskiplistNode {
1348 pub ele: sds,
1349 pub score: libc::c_double,
1350 pub backward: *mut zskiplistNode,
1351 pub level: [zskiplistLevel; 0],
1352}
1353#[derive(Copy, Clone)]
1354#[repr(C)]
1355pub struct zskiplistLevel {
1356 pub forward: *mut zskiplistNode,
1357 pub span: libc::c_ulong,
1358}
1359#[derive(Copy, Clone)]
1360#[repr(C)]
1361pub struct zskiplist {
1362 pub header: *mut zskiplistNode,
1363 pub tail: *mut zskiplistNode,
1364 pub length: libc::c_ulong,
1365 pub level: libc::c_int,
1366}
1367#[derive(Copy, Clone)]
1368#[repr(C)]
1369pub struct zset {
1370 pub dict: *mut dict,
1371 pub zsl: *mut zskiplist,
1372}
1373#[derive(Copy, Clone)]
1374#[repr(C)]
1375pub struct clientBufferLimitsConfig {
1376 pub hard_limit_bytes: libc::c_ulonglong,
1377 pub soft_limit_bytes: libc::c_ulonglong,
1378 pub soft_limit_seconds: time_t,
1379}
1380#[derive(Copy, Clone)]
1381#[repr(C)]
1382pub struct redisOp {
1383 pub argv: *mut *mut robj,
1384 pub argc: libc::c_int,
1385 pub dbid: libc::c_int,
1386 pub target: libc::c_int,
1387}
1388#[derive(Copy, Clone)]
1389#[repr(C)]
1390pub struct redisOpArray {
1391 pub ops: *mut redisOp,
1392 pub numops: libc::c_int,
1393 pub capacity: libc::c_int,
1394}
1395#[derive(Copy, Clone)]
1396#[repr(C)]
1397pub struct rdbSaveInfo {
1398 pub repl_stream_db: libc::c_int,
1399 pub repl_id_is_set: libc::c_int,
1400 pub repl_id: [libc::c_char; 41],
1401 pub repl_offset: libc::c_longlong,
1402}
1403#[derive(Copy, Clone)]
1404#[repr(C)]
1405pub struct malloc_stats {
1406 pub zmalloc_used: size_t,
1407 pub process_rss: size_t,
1408 pub allocator_allocated: size_t,
1409 pub allocator_active: size_t,
1410 pub allocator_resident: size_t,
1411}
1412#[derive(Copy, Clone)]
1413#[repr(C)]
1414pub struct socketFds {
1415 pub fd: [libc::c_int; 16],
1416 pub count: libc::c_int,
1417}
1418#[derive(Copy, Clone)]
1419#[repr(C)]
1420pub struct redisTLSContextConfig {
1421 pub cert_file: *mut libc::c_char,
1422 pub key_file: *mut libc::c_char,
1423 pub key_file_pass: *mut libc::c_char,
1424 pub client_cert_file: *mut libc::c_char,
1425 pub client_key_file: *mut libc::c_char,
1426 pub client_key_file_pass: *mut libc::c_char,
1427 pub dh_params_file: *mut libc::c_char,
1428 pub ca_cert_file: *mut libc::c_char,
1429 pub ca_cert_dir: *mut libc::c_char,
1430 pub protocols: *mut libc::c_char,
1431 pub ciphers: *mut libc::c_char,
1432 pub ciphersuites: *mut libc::c_char,
1433 pub prefer_server_ciphers: libc::c_int,
1434 pub session_caching: libc::c_int,
1435 pub session_cache_size: libc::c_int,
1436 pub session_cache_timeout: libc::c_int,
1437}
1438pub type aof_file_type = libc::c_uint;
1439pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
1440pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
1441pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
1442#[derive(Copy, Clone)]
1443#[repr(C)]
1444pub struct aofInfo {
1445 pub file_name: sds,
1446 pub file_seq: libc::c_longlong,
1447 pub file_type: aof_file_type,
1448}
1449#[derive(Copy, Clone)]
1450#[repr(C)]
1451pub struct aofManifest {
1452 pub base_aof_info: *mut aofInfo,
1453 pub incr_aof_list: *mut list,
1454 pub history_aof_list: *mut list,
1455 pub curr_base_file_seq: libc::c_longlong,
1456 pub curr_incr_file_seq: libc::c_longlong,
1457 pub dirty: libc::c_int,
1458}
1459#[derive(Copy, Clone)]
1460#[repr(C)]
1461pub struct redisServer {
1462 pub pid: pid_t,
1463 pub main_thread_id: pthread_t,
1464 pub configfile: *mut libc::c_char,
1465 pub executable: *mut libc::c_char,
1466 pub exec_argv: *mut *mut libc::c_char,
1467 pub dynamic_hz: libc::c_int,
1468 pub config_hz: libc::c_int,
1469 pub umask: mode_t,
1470 pub hz: libc::c_int,
1471 pub in_fork_child: libc::c_int,
1472 pub db: *mut redisDb,
1473 pub commands: *mut dict,
1474 pub orig_commands: *mut dict,
1475 pub el: *mut aeEventLoop,
1476 pub errors: *mut rax,
1477 pub lruclock: atomic_uint,
1478 pub shutdown_asap: sig_atomic_t,
1479 pub shutdown_mstime: mstime_t,
1480 pub last_sig_received: libc::c_int,
1481 pub shutdown_flags: libc::c_int,
1482 pub activerehashing: libc::c_int,
1483 pub active_defrag_running: libc::c_int,
1484 pub pidfile: *mut libc::c_char,
1485 pub arch_bits: libc::c_int,
1486 pub cronloops: libc::c_int,
1487 pub runid: [libc::c_char; 41],
1488 pub sentinel_mode: libc::c_int,
1489 pub initial_memory_usage: size_t,
1490 pub always_show_logo: libc::c_int,
1491 pub in_exec: libc::c_int,
1492 pub busy_module_yield_flags: libc::c_int,
1493 pub busy_module_yield_reply: *const libc::c_char,
1494 pub core_propagates: libc::c_int,
1495 pub propagate_no_multi: libc::c_int,
1496 pub module_ctx_nesting: libc::c_int,
1497 pub ignore_warnings: *mut libc::c_char,
1498 pub client_pause_in_transaction: libc::c_int,
1499 pub thp_enabled: libc::c_int,
1500 pub page_size: size_t,
1501 pub moduleapi: *mut dict,
1502 pub sharedapi: *mut dict,
1503 pub module_configs_queue: *mut dict,
1504 pub loadmodule_queue: *mut list,
1505 pub module_pipe: [libc::c_int; 2],
1506 pub child_pid: pid_t,
1507 pub child_type: libc::c_int,
1508 pub port: libc::c_int,
1509 pub tls_port: libc::c_int,
1510 pub tcp_backlog: libc::c_int,
1511 pub bindaddr: [*mut libc::c_char; 16],
1512 pub bindaddr_count: libc::c_int,
1513 pub bind_source_addr: *mut libc::c_char,
1514 pub unixsocket: *mut libc::c_char,
1515 pub unixsocketperm: libc::c_uint,
1516 pub ipfd: socketFds,
1517 pub tlsfd: socketFds,
1518 pub sofd: libc::c_int,
1519 pub socket_mark_id: uint32_t,
1520 pub cfd: socketFds,
1521 pub clients: *mut list,
1522 pub clients_to_close: *mut list,
1523 pub clients_pending_write: *mut list,
1524 pub clients_pending_read: *mut list,
1525 pub slaves: *mut list,
1526 pub monitors: *mut list,
1527 pub current_client: *mut client,
1528 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1529 pub clients_timeout_table: *mut rax,
1530 pub fixed_time_expire: libc::c_long,
1531 pub in_nested_call: libc::c_int,
1532 pub clients_index: *mut rax,
1533 pub client_pause_type: pause_type,
1534 pub postponed_clients: *mut list,
1535 pub client_pause_end_time: mstime_t,
1536 pub client_pause_per_purpose: [*mut pause_event; 3],
1537 pub neterr: [libc::c_char; 256],
1538 pub migrate_cached_sockets: *mut dict,
1539 pub next_client_id: uint_least64_t,
1540 pub protected_mode: libc::c_int,
1541 pub io_threads_num: libc::c_int,
1542 pub io_threads_do_reads: libc::c_int,
1543 pub io_threads_active: libc::c_int,
1544 pub events_processed_while_blocked: libc::c_longlong,
1545 pub enable_protected_configs: libc::c_int,
1546 pub enable_debug_cmd: libc::c_int,
1547 pub enable_module_cmd: libc::c_int,
1548 pub loading: sig_atomic_t,
1549 pub async_loading: sig_atomic_t,
1550 pub loading_total_bytes: off_t,
1551 pub loading_rdb_used_mem: off_t,
1552 pub loading_loaded_bytes: off_t,
1553 pub loading_start_time: time_t,
1554 pub loading_process_events_interval_bytes: off_t,
1555 pub stat_starttime: time_t,
1556 pub stat_numcommands: libc::c_longlong,
1557 pub stat_numconnections: libc::c_longlong,
1558 pub stat_expiredkeys: libc::c_longlong,
1559 pub stat_expired_stale_perc: libc::c_double,
1560 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1561 pub stat_expire_cycle_time_used: libc::c_longlong,
1562 pub stat_evictedkeys: libc::c_longlong,
1563 pub stat_evictedclients: libc::c_longlong,
1564 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1565 pub stat_last_eviction_exceeded_time: monotime,
1566 pub stat_keyspace_hits: libc::c_longlong,
1567 pub stat_keyspace_misses: libc::c_longlong,
1568 pub stat_active_defrag_hits: libc::c_longlong,
1569 pub stat_active_defrag_misses: libc::c_longlong,
1570 pub stat_active_defrag_key_hits: libc::c_longlong,
1571 pub stat_active_defrag_key_misses: libc::c_longlong,
1572 pub stat_active_defrag_scanned: libc::c_longlong,
1573 pub stat_total_active_defrag_time: libc::c_longlong,
1574 pub stat_last_active_defrag_time: monotime,
1575 pub stat_peak_memory: size_t,
1576 pub stat_aof_rewrites: libc::c_longlong,
1577 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1578 pub stat_rdb_saves: libc::c_longlong,
1579 pub stat_fork_time: libc::c_longlong,
1580 pub stat_fork_rate: libc::c_double,
1581 pub stat_total_forks: libc::c_longlong,
1582 pub stat_rejected_conn: libc::c_longlong,
1583 pub stat_sync_full: libc::c_longlong,
1584 pub stat_sync_partial_ok: libc::c_longlong,
1585 pub stat_sync_partial_err: libc::c_longlong,
1586 pub slowlog: *mut list,
1587 pub slowlog_entry_id: libc::c_longlong,
1588 pub slowlog_log_slower_than: libc::c_longlong,
1589 pub slowlog_max_len: libc::c_ulong,
1590 pub cron_malloc_stats: malloc_stats,
1591 pub stat_net_input_bytes: atomic_llong,
1592 pub stat_net_output_bytes: atomic_llong,
1593 pub stat_net_repl_input_bytes: atomic_llong,
1594 pub stat_net_repl_output_bytes: atomic_llong,
1595 pub stat_current_cow_peak: size_t,
1596 pub stat_current_cow_bytes: size_t,
1597 pub stat_current_cow_updated: monotime,
1598 pub stat_current_save_keys_processed: size_t,
1599 pub stat_current_save_keys_total: size_t,
1600 pub stat_rdb_cow_bytes: size_t,
1601 pub stat_aof_cow_bytes: size_t,
1602 pub stat_module_cow_bytes: size_t,
1603 pub stat_module_progress: libc::c_double,
1604 pub stat_clients_type_memory: [size_t; 4],
1605 pub stat_cluster_links_memory: size_t,
1606 pub stat_unexpected_error_replies: libc::c_longlong,
1607 pub stat_total_error_replies: libc::c_longlong,
1608 pub stat_dump_payload_sanitizations: libc::c_longlong,
1609 pub stat_io_reads_processed: libc::c_longlong,
1610 pub stat_io_writes_processed: libc::c_longlong,
1611 pub stat_total_reads_processed: atomic_llong,
1612 pub stat_total_writes_processed: atomic_llong,
1613 pub inst_metric: [C2RustUnnamed_11; 5],
1614 pub stat_reply_buffer_shrinks: libc::c_longlong,
1615 pub stat_reply_buffer_expands: libc::c_longlong,
1616 pub verbosity: libc::c_int,
1617 pub maxidletime: libc::c_int,
1618 pub tcpkeepalive: libc::c_int,
1619 pub active_expire_enabled: libc::c_int,
1620 pub active_expire_effort: libc::c_int,
1621 pub active_defrag_enabled: libc::c_int,
1622 pub sanitize_dump_payload: libc::c_int,
1623 pub skip_checksum_validation: libc::c_int,
1624 pub jemalloc_bg_thread: libc::c_int,
1625 pub active_defrag_ignore_bytes: size_t,
1626 pub active_defrag_threshold_lower: libc::c_int,
1627 pub active_defrag_threshold_upper: libc::c_int,
1628 pub active_defrag_cycle_min: libc::c_int,
1629 pub active_defrag_cycle_max: libc::c_int,
1630 pub active_defrag_max_scan_fields: libc::c_ulong,
1631 pub client_max_querybuf_len: size_t,
1632 pub dbnum: libc::c_int,
1633 pub supervised: libc::c_int,
1634 pub supervised_mode: libc::c_int,
1635 pub daemonize: libc::c_int,
1636 pub set_proc_title: libc::c_int,
1637 pub proc_title_template: *mut libc::c_char,
1638 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1639 pub pause_cron: libc::c_int,
1640 pub latency_tracking_enabled: libc::c_int,
1641 pub latency_tracking_info_percentiles: *mut libc::c_double,
1642 pub latency_tracking_info_percentiles_len: libc::c_int,
1643 pub aof_enabled: libc::c_int,
1644 pub aof_state: libc::c_int,
1645 pub aof_fsync: libc::c_int,
1646 pub aof_filename: *mut libc::c_char,
1647 pub aof_dirname: *mut libc::c_char,
1648 pub aof_no_fsync_on_rewrite: libc::c_int,
1649 pub aof_rewrite_perc: libc::c_int,
1650 pub aof_rewrite_min_size: off_t,
1651 pub aof_rewrite_base_size: off_t,
1652 pub aof_current_size: off_t,
1653 pub aof_last_incr_size: off_t,
1654 pub aof_fsync_offset: off_t,
1655 pub aof_flush_sleep: libc::c_int,
1656 pub aof_rewrite_scheduled: libc::c_int,
1657 pub aof_buf: sds,
1658 pub aof_fd: libc::c_int,
1659 pub aof_selected_db: libc::c_int,
1660 pub aof_flush_postponed_start: time_t,
1661 pub aof_last_fsync: time_t,
1662 pub aof_rewrite_time_last: time_t,
1663 pub aof_rewrite_time_start: time_t,
1664 pub aof_cur_timestamp: time_t,
1665 pub aof_timestamp_enabled: libc::c_int,
1666 pub aof_lastbgrewrite_status: libc::c_int,
1667 pub aof_delayed_fsync: libc::c_ulong,
1668 pub aof_rewrite_incremental_fsync: libc::c_int,
1669 pub rdb_save_incremental_fsync: libc::c_int,
1670 pub aof_last_write_status: libc::c_int,
1671 pub aof_last_write_errno: libc::c_int,
1672 pub aof_load_truncated: libc::c_int,
1673 pub aof_use_rdb_preamble: libc::c_int,
1674 pub aof_bio_fsync_status: atomic_int,
1675 pub aof_bio_fsync_errno: atomic_int,
1676 pub aof_manifest: *mut aofManifest,
1677 pub aof_disable_auto_gc: libc::c_int,
1678 pub dirty: libc::c_longlong,
1679 pub dirty_before_bgsave: libc::c_longlong,
1680 pub rdb_last_load_keys_expired: libc::c_longlong,
1681 pub rdb_last_load_keys_loaded: libc::c_longlong,
1682 pub saveparams: *mut saveparam,
1683 pub saveparamslen: libc::c_int,
1684 pub rdb_filename: *mut libc::c_char,
1685 pub rdb_compression: libc::c_int,
1686 pub rdb_checksum: libc::c_int,
1687 pub rdb_del_sync_files: libc::c_int,
1688 pub lastsave: time_t,
1689 pub lastbgsave_try: time_t,
1690 pub rdb_save_time_last: time_t,
1691 pub rdb_save_time_start: time_t,
1692 pub rdb_bgsave_scheduled: libc::c_int,
1693 pub rdb_child_type: libc::c_int,
1694 pub lastbgsave_status: libc::c_int,
1695 pub stop_writes_on_bgsave_err: libc::c_int,
1696 pub rdb_pipe_read: libc::c_int,
1697 pub rdb_child_exit_pipe: libc::c_int,
1698 pub rdb_pipe_conns: *mut *mut connection,
1699 pub rdb_pipe_numconns: libc::c_int,
1700 pub rdb_pipe_numconns_writing: libc::c_int,
1701 pub rdb_pipe_buff: *mut libc::c_char,
1702 pub rdb_pipe_bufflen: libc::c_int,
1703 pub rdb_key_save_delay: libc::c_int,
1704 pub key_load_delay: libc::c_int,
1705 pub child_info_pipe: [libc::c_int; 2],
1706 pub child_info_nread: libc::c_int,
1707 pub also_propagate: redisOpArray,
1708 pub replication_allowed: libc::c_int,
1709 pub logfile: *mut libc::c_char,
1710 pub syslog_enabled: libc::c_int,
1711 pub syslog_ident: *mut libc::c_char,
1712 pub syslog_facility: libc::c_int,
1713 pub crashlog_enabled: libc::c_int,
1714 pub memcheck_enabled: libc::c_int,
1715 pub use_exit_on_panic: libc::c_int,
1716 pub shutdown_timeout: libc::c_int,
1717 pub shutdown_on_sigint: libc::c_int,
1718 pub shutdown_on_sigterm: libc::c_int,
1719 pub replid: [libc::c_char; 41],
1720 pub replid2: [libc::c_char; 41],
1721 pub master_repl_offset: libc::c_longlong,
1722 pub second_replid_offset: libc::c_longlong,
1723 pub slaveseldb: libc::c_int,
1724 pub repl_ping_slave_period: libc::c_int,
1725 pub repl_backlog: *mut replBacklog,
1726 pub repl_backlog_size: libc::c_longlong,
1727 pub repl_backlog_time_limit: time_t,
1728 pub repl_no_slaves_since: time_t,
1729 pub repl_min_slaves_to_write: libc::c_int,
1730 pub repl_min_slaves_max_lag: libc::c_int,
1731 pub repl_good_slaves_count: libc::c_int,
1732 pub repl_diskless_sync: libc::c_int,
1733 pub repl_diskless_load: libc::c_int,
1734 pub repl_diskless_sync_delay: libc::c_int,
1735 pub repl_diskless_sync_max_replicas: libc::c_int,
1736 pub repl_buffer_mem: size_t,
1737 pub repl_buffer_blocks: *mut list,
1738 pub masteruser: *mut libc::c_char,
1739 pub masterauth: sds,
1740 pub masterhost: *mut libc::c_char,
1741 pub masterport: libc::c_int,
1742 pub repl_timeout: libc::c_int,
1743 pub master: *mut client,
1744 pub cached_master: *mut client,
1745 pub repl_syncio_timeout: libc::c_int,
1746 pub repl_state: libc::c_int,
1747 pub repl_transfer_size: off_t,
1748 pub repl_transfer_read: off_t,
1749 pub repl_transfer_last_fsync_off: off_t,
1750 pub repl_transfer_s: *mut connection,
1751 pub repl_transfer_fd: libc::c_int,
1752 pub repl_transfer_tmpfile: *mut libc::c_char,
1753 pub repl_transfer_lastio: time_t,
1754 pub repl_serve_stale_data: libc::c_int,
1755 pub repl_slave_ro: libc::c_int,
1756 pub repl_slave_ignore_maxmemory: libc::c_int,
1757 pub repl_down_since: time_t,
1758 pub repl_disable_tcp_nodelay: libc::c_int,
1759 pub slave_priority: libc::c_int,
1760 pub replica_announced: libc::c_int,
1761 pub slave_announce_port: libc::c_int,
1762 pub slave_announce_ip: *mut libc::c_char,
1763 pub propagation_error_behavior: libc::c_int,
1764 pub repl_ignore_disk_write_error: libc::c_int,
1765 pub master_replid: [libc::c_char; 41],
1766 pub master_initial_offset: libc::c_longlong,
1767 pub repl_slave_lazy_flush: libc::c_int,
1768 pub clients_waiting_acks: *mut list,
1769 pub get_ack_from_slaves: libc::c_int,
1770 pub maxclients: libc::c_uint,
1771 pub maxmemory: libc::c_ulonglong,
1772 pub maxmemory_clients: ssize_t,
1773 pub maxmemory_policy: libc::c_int,
1774 pub maxmemory_samples: libc::c_int,
1775 pub maxmemory_eviction_tenacity: libc::c_int,
1776 pub lfu_log_factor: libc::c_int,
1777 pub lfu_decay_time: libc::c_int,
1778 pub proto_max_bulk_len: libc::c_longlong,
1779 pub oom_score_adj_values: [libc::c_int; 3],
1780 pub oom_score_adj: libc::c_int,
1781 pub disable_thp: libc::c_int,
1782 pub blocked_clients: libc::c_uint,
1783 pub blocked_clients_by_type: [libc::c_uint; 8],
1784 pub unblocked_clients: *mut list,
1785 pub ready_keys: *mut list,
1786 pub tracking_clients: libc::c_uint,
1787 pub tracking_table_max_keys: size_t,
1788 pub tracking_pending_keys: *mut list,
1789 pub sort_desc: libc::c_int,
1790 pub sort_alpha: libc::c_int,
1791 pub sort_bypattern: libc::c_int,
1792 pub sort_store: libc::c_int,
1793 pub hash_max_listpack_entries: size_t,
1794 pub hash_max_listpack_value: size_t,
1795 pub set_max_intset_entries: size_t,
1796 pub zset_max_listpack_entries: size_t,
1797 pub zset_max_listpack_value: size_t,
1798 pub hll_sparse_max_bytes: size_t,
1799 pub stream_node_max_bytes: size_t,
1800 pub stream_node_max_entries: libc::c_longlong,
1801 pub list_max_listpack_size: libc::c_int,
1802 pub list_compress_depth: libc::c_int,
1803 pub unixtime: atomic_int,
1804 pub timezone: time_t,
1805 pub daylight_active: libc::c_int,
1806 pub mstime: mstime_t,
1807 pub ustime: ustime_t,
1808 pub blocking_op_nesting: size_t,
1809 pub blocked_last_cron: libc::c_longlong,
1810 pub pubsub_channels: *mut dict,
1811 pub pubsub_patterns: *mut dict,
1812 pub notify_keyspace_events: libc::c_int,
1813 pub pubsubshard_channels: *mut dict,
1814 pub cluster_enabled: libc::c_int,
1815 pub cluster_port: libc::c_int,
1816 pub cluster_node_timeout: mstime_t,
1817 pub cluster_configfile: *mut libc::c_char,
1818 pub cluster: *mut clusterState,
1819 pub cluster_migration_barrier: libc::c_int,
1820 pub cluster_allow_replica_migration: libc::c_int,
1821 pub cluster_slave_validity_factor: libc::c_int,
1822 pub cluster_require_full_coverage: libc::c_int,
1823 pub cluster_slave_no_failover: libc::c_int,
1824 pub cluster_announce_ip: *mut libc::c_char,
1825 pub cluster_announce_hostname: *mut libc::c_char,
1826 pub cluster_preferred_endpoint_type: libc::c_int,
1827 pub cluster_announce_port: libc::c_int,
1828 pub cluster_announce_tls_port: libc::c_int,
1829 pub cluster_announce_bus_port: libc::c_int,
1830 pub cluster_module_flags: libc::c_int,
1831 pub cluster_allow_reads_when_down: libc::c_int,
1832 pub cluster_config_file_lock_fd: libc::c_int,
1833 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1834 pub cluster_drop_packet_filter: libc::c_int,
1835 pub script_caller: *mut client,
1836 pub busy_reply_threshold: mstime_t,
1837 pub pre_command_oom_state: libc::c_int,
1838 pub script_disable_deny_script: libc::c_int,
1839 pub lazyfree_lazy_eviction: libc::c_int,
1840 pub lazyfree_lazy_expire: libc::c_int,
1841 pub lazyfree_lazy_server_del: libc::c_int,
1842 pub lazyfree_lazy_user_del: libc::c_int,
1843 pub lazyfree_lazy_user_flush: libc::c_int,
1844 pub latency_monitor_threshold: libc::c_longlong,
1845 pub latency_events: *mut dict,
1846 pub acl_filename: *mut libc::c_char,
1847 pub acllog_max_len: libc::c_ulong,
1848 pub requirepass: sds,
1849 pub acl_pubsub_default: libc::c_int,
1850 pub watchdog_period: libc::c_int,
1851 pub system_memory_size: size_t,
1852 pub tls_cluster: libc::c_int,
1853 pub tls_replication: libc::c_int,
1854 pub tls_auth_clients: libc::c_int,
1855 pub tls_ctx_config: redisTLSContextConfig,
1856 pub server_cpulist: *mut libc::c_char,
1857 pub bio_cpulist: *mut libc::c_char,
1858 pub aof_rewrite_cpulist: *mut libc::c_char,
1859 pub bgsave_cpulist: *mut libc::c_char,
1860 pub sentinel_config: *mut sentinelConfig,
1861 pub failover_end_time: mstime_t,
1862 pub force_failover: libc::c_int,
1863 pub target_replica_host: *mut libc::c_char,
1864 pub target_replica_port: libc::c_int,
1865 pub failover_state: libc::c_int,
1866 pub cluster_allow_pubsubshard_when_down: libc::c_int,
1867 pub reply_buffer_peak_reset_time: libc::c_long,
1868 pub reply_buffer_resizing_enabled: libc::c_int,
1869}
1870#[derive(Copy, Clone)]
1871#[repr(C)]
1872pub struct clusterState {
1873 pub myself: *mut clusterNode,
1874 pub currentEpoch: uint64_t,
1875 pub state: libc::c_int,
1876 pub size: libc::c_int,
1877 pub nodes: *mut dict,
1878 pub nodes_black_list: *mut dict,
1879 pub migrating_slots_to: [*mut clusterNode; 16384],
1880 pub importing_slots_from: [*mut clusterNode; 16384],
1881 pub slots: [*mut clusterNode; 16384],
1882 pub slots_to_channels: *mut rax,
1883 pub failover_auth_time: mstime_t,
1884 pub failover_auth_count: libc::c_int,
1885 pub failover_auth_sent: libc::c_int,
1886 pub failover_auth_rank: libc::c_int,
1887 pub failover_auth_epoch: uint64_t,
1888 pub cant_failover_reason: libc::c_int,
1889 pub mf_end: mstime_t,
1890 pub mf_slave: *mut clusterNode,
1891 pub mf_master_offset: libc::c_longlong,
1892 pub mf_can_start: libc::c_int,
1893 pub lastVoteEpoch: uint64_t,
1894 pub todo_before_sleep: libc::c_int,
1895 pub stats_bus_messages_sent: [libc::c_longlong; 11],
1896 pub stats_bus_messages_received: [libc::c_longlong; 11],
1897 pub stats_pfail_nodes: libc::c_longlong,
1898 pub stat_cluster_links_buffer_limit_exceeded: libc::c_ulonglong,
1899}
1900#[derive(Copy, Clone)]
1901#[repr(C)]
1902pub struct clusterNode {
1903 pub ctime: mstime_t,
1904 pub name: [libc::c_char; 40],
1905 pub flags: libc::c_int,
1906 pub configEpoch: uint64_t,
1907 pub slots: [libc::c_uchar; 2048],
1908 pub slot_info_pairs: *mut uint16_t,
1909 pub slot_info_pairs_count: libc::c_int,
1910 pub numslots: libc::c_int,
1911 pub numslaves: libc::c_int,
1912 pub slaves: *mut *mut clusterNode,
1913 pub slaveof: *mut clusterNode,
1914 pub last_in_ping_gossip: libc::c_ulonglong,
1915 pub ping_sent: mstime_t,
1916 pub pong_received: mstime_t,
1917 pub data_received: mstime_t,
1918 pub fail_time: mstime_t,
1919 pub voted_time: mstime_t,
1920 pub repl_offset_time: mstime_t,
1921 pub orphaned_time: mstime_t,
1922 pub repl_offset: libc::c_longlong,
1923 pub ip: [libc::c_char; 46],
1924 pub hostname: sds,
1925 pub port: libc::c_int,
1926 pub pport: libc::c_int,
1927 pub cport: libc::c_int,
1928 pub link: *mut clusterLink,
1929 pub inbound_link: *mut clusterLink,
1930 pub fail_reports: *mut list,
1931}
1932#[derive(Copy, Clone)]
1933#[repr(C)]
1934pub struct clusterLink {
1935 pub ctime: mstime_t,
1936 pub conn: *mut connection,
1937 pub sndbuf: sds,
1938 pub rcvbuf: *mut libc::c_char,
1939 pub rcvbuf_len: size_t,
1940 pub rcvbuf_alloc: size_t,
1941 pub node: *mut clusterNode,
1942 pub inbound: libc::c_int,
1943}
1944#[derive(Copy, Clone)]
1945#[repr(C)]
1946pub struct C2RustUnnamed_11 {
1947 pub last_sample_time: libc::c_longlong,
1948 pub last_sample_count: libc::c_longlong,
1949 pub samples: [libc::c_longlong; 16],
1950 pub idx: libc::c_int,
1951}
1952pub const _ISspace: C2RustUnnamed_14 = 8192;
1953#[derive(Copy, Clone)]
1954#[repr(C)]
1955pub struct ChannelSpecs {
1956 pub proc_0: Option::<redisCommandProc>,
1957 pub flags: uint64_t,
1958 pub start: libc::c_int,
1959 pub count: libc::c_int,
1960}
1961#[derive(Copy, Clone)]
1962#[repr(C)]
1963pub struct C2RustUnnamed_12 {
1964 pub name: *mut libc::c_char,
1965 pub skip: libc::c_int,
1966}
1967#[derive(Copy, Clone)]
1968#[repr(C)]
1969pub struct C2RustUnnamed_13 {
1970 pub name: *mut libc::c_char,
1971 pub skip: libc::c_int,
1972}
1973pub type C2RustUnnamed_14 = libc::c_uint;
1974pub const _ISalnum: C2RustUnnamed_14 = 8;
1975pub const _ISpunct: C2RustUnnamed_14 = 4;
1976pub const _IScntrl: C2RustUnnamed_14 = 2;
1977pub const _ISblank: C2RustUnnamed_14 = 1;
1978pub const _ISgraph: C2RustUnnamed_14 = 32768;
1979pub const _ISprint: C2RustUnnamed_14 = 16384;
1980pub const _ISxdigit: C2RustUnnamed_14 = 4096;
1981pub const _ISdigit: C2RustUnnamed_14 = 2048;
1982pub const _ISalpha: C2RustUnnamed_14 = 1024;
1983pub const _ISlower: C2RustUnnamed_14 = 512;
1984pub const _ISupper: C2RustUnnamed_14 = 256;
1985#[inline]
1986unsafe extern "C" fn sdslen(s: sds) -> size_t {
1987 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1988 as libc::c_uchar;
1989 match flags as libc::c_int & 7 as libc::c_int {
1990 0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
1991 1 => {
1992 return (*(s
1993 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1994 as *mut sdshdr8))
1995 .len as size_t;
1996 }
1997 2 => {
1998 return (*(s
1999 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
2000 as *mut sdshdr16))
2001 .len as size_t;
2002 }
2003 3 => {
2004 return (*(s
2005 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
2006 as *mut sdshdr32))
2007 .len as size_t;
2008 }
2009 4 => {
2010 return (*(s
2011 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
2012 as *mut sdshdr64))
2013 .len;
2014 }
2015 _ => {}
2016 }
2017 return 0 as libc::c_int as size_t;
2018}
2019#[inline]
2020unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int {
2021 return strtol(
2022 __nptr,
2023 0 as *mut libc::c_void as *mut *mut libc::c_char,
2024 10 as libc::c_int,
2025 ) as libc::c_int;
2026}
2027#[no_mangle]
2028pub unsafe extern "C" fn updateLFU(mut val: *mut robj) {
2029 let mut counter: libc::c_ulong = LFUDecrAndReturn(val);
2030 counter = LFULogIncr(counter as uint8_t) as libc::c_ulong;
2031 (*val)
2032 .set_lru((LFUGetTimeInMinutes() << 8 as libc::c_int | counter) as libc::c_uint);
2033}
2034#[no_mangle]
2035pub unsafe extern "C" fn lookupKey(
2036 mut db: *mut redisDb,
2037 mut key: *mut robj,
2038 mut flags: libc::c_int,
2039) -> *mut robj {
2040 let mut de: *mut dictEntry = dictFind((*db).dict, (*key).ptr);
2041 let mut val: *mut robj = 0 as *mut robj;
2042 if !de.is_null() {
2043 val = (*de).v.val as *mut robj;
2044 let mut is_ro_replica: libc::c_int = (!(server.masterhost).is_null()
2045 && server.repl_slave_ro != 0) as libc::c_int;
2046 let mut expire_flags: libc::c_int = 0 as libc::c_int;
2047 if flags & (1 as libc::c_int) << 3 as libc::c_int != 0 && is_ro_replica == 0 {
2048 expire_flags |= 1 as libc::c_int;
2049 }
2050 if flags & (1 as libc::c_int) << 4 as libc::c_int != 0 {
2051 expire_flags |= 2 as libc::c_int;
2052 }
2053 if expireIfNeeded(db, key, expire_flags) != 0 {
2054 val = 0 as *mut robj;
2055 }
2056 }
2057 if !val.is_null() {
2058 if hasActiveChildProcess() == 0
2059 && flags & (1 as libc::c_int) << 0 as libc::c_int == 0
2060 {
2061 if server.maxmemory_policy & (1 as libc::c_int) << 1 as libc::c_int != 0 {
2062 updateLFU(val);
2063 } else {
2064 (*val).set_lru(LRU_CLOCK());
2065 }
2066 }
2067 if flags
2068 & ((1 as libc::c_int) << 2 as libc::c_int
2069 | (1 as libc::c_int) << 3 as libc::c_int) == 0
2070 {
2071 server.stat_keyspace_hits += 1;
2072 }
2073 } else {
2074 if flags
2075 & ((1 as libc::c_int) << 1 as libc::c_int
2076 | (1 as libc::c_int) << 3 as libc::c_int) == 0
2077 {
2078 notifyKeyspaceEvent(
2079 (1 as libc::c_int) << 11 as libc::c_int,
2080 b"keymiss\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2081 key,
2082 (*db).id,
2083 );
2084 }
2085 if flags
2086 & ((1 as libc::c_int) << 2 as libc::c_int
2087 | (1 as libc::c_int) << 3 as libc::c_int) == 0
2088 {
2089 server.stat_keyspace_misses += 1;
2090 }
2091 }
2092 return val;
2093}
2094#[no_mangle]
2095pub unsafe extern "C" fn lookupKeyReadWithFlags(
2096 mut db: *mut redisDb,
2097 mut key: *mut robj,
2098 mut flags: libc::c_int,
2099) -> *mut robj {
2100 if flags & (1 as libc::c_int) << 3 as libc::c_int == 0 {} else {
2101 _serverAssert(
2102 b"!(flags & LOOKUP_WRITE)\0" as *const u8 as *const libc::c_char,
2103 b"db.c\0" as *const u8 as *const libc::c_char,
2104 148 as libc::c_int,
2105 );
2106 unreachable!();
2107 };
2108 return lookupKey(db, key, flags);
2109}
2110#[no_mangle]
2111pub unsafe extern "C" fn lookupKeyRead(
2112 mut db: *mut redisDb,
2113 mut key: *mut robj,
2114) -> *mut robj {
2115 return lookupKeyReadWithFlags(db, key, 0 as libc::c_int);
2116}
2117#[no_mangle]
2118pub unsafe extern "C" fn lookupKeyWriteWithFlags(
2119 mut db: *mut redisDb,
2120 mut key: *mut robj,
2121 mut flags: libc::c_int,
2122) -> *mut robj {
2123 return lookupKey(db, key, flags | (1 as libc::c_int) << 3 as libc::c_int);
2124}
2125#[no_mangle]
2126pub unsafe extern "C" fn lookupKeyWrite(
2127 mut db: *mut redisDb,
2128 mut key: *mut robj,
2129) -> *mut robj {
2130 return lookupKeyWriteWithFlags(db, key, 0 as libc::c_int);
2131}
2132#[no_mangle]
2133pub unsafe extern "C" fn lookupKeyReadOrReply(
2134 mut c: *mut client,
2135 mut key: *mut robj,
2136 mut reply: *mut robj,
2137) -> *mut robj {
2138 let mut o: *mut robj = lookupKeyRead((*c).db, key);
2139 if o.is_null() {
2140 addReplyOrErrorObject(c, reply);
2141 }
2142 return o;
2143}
2144#[no_mangle]
2145pub unsafe extern "C" fn lookupKeyWriteOrReply(
2146 mut c: *mut client,
2147 mut key: *mut robj,
2148 mut reply: *mut robj,
2149) -> *mut robj {
2150 let mut o: *mut robj = lookupKeyWrite((*c).db, key);
2151 if o.is_null() {
2152 addReplyOrErrorObject(c, reply);
2153 }
2154 return o;
2155}
2156#[no_mangle]
2157pub unsafe extern "C" fn dbAdd(
2158 mut db: *mut redisDb,
2159 mut key: *mut robj,
2160 mut val: *mut robj,
2161) {
2162 let mut copy: sds = sdsdup((*key).ptr as sds);
2163 let mut de: *mut dictEntry = dictAddRaw(
2164 (*db).dict,
2165 copy as *mut libc::c_void,
2166 0 as *mut *mut dictEntry,
2167 );
2168 if !de.is_null() {} else {
2169 _serverAssertWithInfo(
2170 0 as *const client,
2171 key,
2172 b"de != NULL\0" as *const u8 as *const libc::c_char,
2173 b"db.c\0" as *const u8 as *const libc::c_char,
2174 191 as libc::c_int,
2175 );
2176 unreachable!();
2177 };
2178 if ((*(*(*db).dict).type_0).valDup).is_some() {
2179 (*de)
2180 .v
2181 .val = ((*(*(*db).dict).type_0).valDup)
2182 .expect("non-null function pointer")((*db).dict, val as *const libc::c_void);
2183 } else {
2184 (*de).v.val = val as *mut libc::c_void;
2185 }
2186 signalKeyAsReady(db, key, (*val).type_0() as libc::c_int);
2187 if server.cluster_enabled != 0 {
2188 slotToKeyAddEntry(de, db);
2189 }
2190 notifyKeyspaceEvent(
2191 (1 as libc::c_int) << 14 as libc::c_int,
2192 b"new\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2193 key,
2194 (*db).id,
2195 );
2196}
2197#[no_mangle]
2198pub unsafe extern "C" fn dbAddRDBLoad(
2199 mut db: *mut redisDb,
2200 mut key: sds,
2201 mut val: *mut robj,
2202) -> libc::c_int {
2203 let mut de: *mut dictEntry = dictAddRaw(
2204 (*db).dict,
2205 key as *mut libc::c_void,
2206 0 as *mut *mut dictEntry,
2207 );
2208 if de.is_null() {
2209 return 0 as libc::c_int;
2210 }
2211 if ((*(*(*db).dict).type_0).valDup).is_some() {
2212 (*de)
2213 .v
2214 .val = ((*(*(*db).dict).type_0).valDup)
2215 .expect("non-null function pointer")((*db).dict, val as *const libc::c_void);
2216 } else {
2217 (*de).v.val = val as *mut libc::c_void;
2218 }
2219 if server.cluster_enabled != 0 {
2220 slotToKeyAddEntry(de, db);
2221 }
2222 return 1 as libc::c_int;
2223}
2224#[no_mangle]
2225pub unsafe extern "C" fn dbOverwrite(
2226 mut db: *mut redisDb,
2227 mut key: *mut robj,
2228 mut val: *mut robj,
2229) {
2230 let mut de: *mut dictEntry = dictFind((*db).dict, (*key).ptr);
2231 if !de.is_null() {} else {
2232 _serverAssertWithInfo(
2233 0 as *const client,
2234 key,
2235 b"de != NULL\0" as *const u8 as *const libc::c_char,
2236 b"db.c\0" as *const u8 as *const libc::c_char,
2237 225 as libc::c_int,
2238 );
2239 unreachable!();
2240 };
2241 let mut auxentry: dictEntry = *de;
2242 let mut old: *mut robj = (*de).v.val as *mut robj;
2243 if server.maxmemory_policy & (1 as libc::c_int) << 1 as libc::c_int != 0 {
2244 (*val).set_lru((*old).lru());
2245 }
2246 moduleNotifyKeyUnlink(key, old, (*db).id);
2247 if (*old).type_0() as libc::c_int == 6 as libc::c_int {
2248 signalKeyAsReady(db, key, (*old).type_0() as libc::c_int);
2249 }
2250 if ((*(*(*db).dict).type_0).valDup).is_some() {
2251 (*de)
2252 .v
2253 .val = ((*(*(*db).dict).type_0).valDup)
2254 .expect("non-null function pointer")((*db).dict, val as *const libc::c_void);
2255 } else {
2256 (*de).v.val = val as *mut libc::c_void;
2257 }
2258 if server.lazyfree_lazy_server_del != 0 {
2259 freeObjAsync(key, old, (*db).id);
2260 if ((*(*(*db).dict).type_0).valDup).is_some() {
2261 auxentry
2262 .v
2263 .val = ((*(*(*db).dict).type_0).valDup)
2264 .expect(
2265 "non-null function pointer",
2266 )((*db).dict, 0 as *const libc::c_void);
2267 } else {
2268 auxentry.v.val = 0 as *mut libc::c_void;
2269 }
2270 }
2271 if ((*(*(*db).dict).type_0).valDestructor).is_some() {
2272 ((*(*(*db).dict).type_0).valDestructor)
2273 .expect("non-null function pointer")((*db).dict, auxentry.v.val);
2274 }
2275}
2276#[no_mangle]
2277pub unsafe extern "C" fn setKey(
2278 mut c: *mut client,
2279 mut db: *mut redisDb,
2280 mut key: *mut robj,
2281 mut val: *mut robj,
2282 mut flags: libc::c_int,
2283) {
2284 let mut keyfound: libc::c_int = 0 as libc::c_int;
2285 if flags & 4 as libc::c_int != 0 {
2286 keyfound = 1 as libc::c_int;
2287 } else if flags & 8 as libc::c_int == 0 {
2288 keyfound = (lookupKeyWrite(db, key) != 0 as *mut libc::c_void as *mut robj)
2289 as libc::c_int;
2290 }
2291 if keyfound == 0 {
2292 dbAdd(db, key, val);
2293 } else {
2294 dbOverwrite(db, key, val);
2295 }
2296 incrRefCount(val);
2297 if flags & 1 as libc::c_int == 0 {
2298 removeExpire(db, key);
2299 }
2300 if flags & 2 as libc::c_int == 0 {
2301 signalModifiedKey(c, db, key);
2302 }
2303}
2304#[no_mangle]
2305pub unsafe extern "C" fn dbRandomKey(mut db: *mut redisDb) -> *mut robj {
2306 let mut de: *mut dictEntry = 0 as *mut dictEntry;
2307 let mut maxtries: libc::c_int = 100 as libc::c_int;
2308 let mut allvolatile: libc::c_int = (((*(*db).dict)
2309 .ht_used[0 as libc::c_int as usize])
2310 .wrapping_add((*(*db).dict).ht_used[1 as libc::c_int as usize])
2311 == ((*(*db).expires).ht_used[0 as libc::c_int as usize])
2312 .wrapping_add((*(*db).expires).ht_used[1 as libc::c_int as usize]))
2313 as libc::c_int;
2314 loop {
2315 let mut key: sds = 0 as *mut libc::c_char;
2316 let mut keyobj: *mut robj = 0 as *mut robj;
2317 de = dictGetFairRandomKey((*db).dict);
2318 if de.is_null() {
2319 return 0 as *mut robj;
2320 }
2321 key = (*de).key as sds;
2322 keyobj = createStringObject(key as *const libc::c_char, sdslen(key));
2323 if !(dictFind((*db).expires, key as *const libc::c_void)).is_null() {
2324 if allvolatile != 0 && !(server.masterhost).is_null()
2325 && {
2326 maxtries -= 1;
2327 maxtries == 0 as libc::c_int
2328 }
2329 {
2330 return keyobj;
2331 }
2332 if expireIfNeeded(db, keyobj, 0 as libc::c_int) != 0 {
2333 decrRefCount(keyobj);
2334 continue;
2335 }
2336 }
2337 return keyobj;
2338 };
2339}
2340unsafe extern "C" fn dbGenericDelete(
2341 mut db: *mut redisDb,
2342 mut key: *mut robj,
2343 mut async_0: libc::c_int,
2344) -> libc::c_int {
2345 if ((*(*db).expires).ht_used[0 as libc::c_int as usize])
2346 .wrapping_add((*(*db).expires).ht_used[1 as libc::c_int as usize])
2347 > 0 as libc::c_int as libc::c_ulong
2348 {
2349 dictDelete((*db).expires, (*key).ptr);
2350 }
2351 let mut de: *mut dictEntry = dictUnlink((*db).dict, (*key).ptr);
2352 if !de.is_null() {
2353 let mut val: *mut robj = (*de).v.val as *mut robj;
2354 moduleNotifyKeyUnlink(key, val, (*db).id);
2355 if (*val).type_0() as libc::c_int == 6 as libc::c_int {
2356 signalKeyAsReady(db, key, (*val).type_0() as libc::c_int);
2357 }
2358 if async_0 != 0 {
2359 freeObjAsync(key, val, (*db).id);
2360 if ((*(*(*db).dict).type_0).valDup).is_some() {
2361 (*de)
2362 .v
2363 .val = ((*(*(*db).dict).type_0).valDup)
2364 .expect(
2365 "non-null function pointer",
2366 )((*db).dict, 0 as *const libc::c_void);
2367 } else {
2368 (*de).v.val = 0 as *mut libc::c_void;
2369 }
2370 }
2371 if server.cluster_enabled != 0 {
2372 slotToKeyDelEntry(de, db);
2373 }
2374 dictFreeUnlinkedEntry((*db).dict, de);
2375 return 1 as libc::c_int;
2376 } else {
2377 return 0 as libc::c_int
2378 };
2379}
2380#[no_mangle]
2381pub unsafe extern "C" fn dbSyncDelete(
2382 mut db: *mut redisDb,
2383 mut key: *mut robj,
2384) -> libc::c_int {
2385 return dbGenericDelete(db, key, 0 as libc::c_int);
2386}
2387#[no_mangle]
2388pub unsafe extern "C" fn dbAsyncDelete(
2389 mut db: *mut redisDb,
2390 mut key: *mut robj,
2391) -> libc::c_int {
2392 return dbGenericDelete(db, key, 1 as libc::c_int);
2393}
2394#[no_mangle]
2395pub unsafe extern "C" fn dbDelete(
2396 mut db: *mut redisDb,
2397 mut key: *mut robj,
2398) -> libc::c_int {
2399 return dbGenericDelete(db, key, server.lazyfree_lazy_server_del);
2400}
2401#[no_mangle]
2402pub unsafe extern "C" fn dbUnshareStringValue(
2403 mut db: *mut redisDb,
2404 mut key: *mut robj,
2405 mut o: *mut robj,
2406) -> *mut robj {
2407 if (*o).type_0() as libc::c_int == 0 as libc::c_int {} else {
2408 _serverAssert(
2409 b"o->type == OBJ_STRING\0" as *const u8 as *const libc::c_char,
2410 b"db.c\0" as *const u8 as *const libc::c_char,
2411 388 as libc::c_int,
2412 );
2413 unreachable!();
2414 };
2415 if (*o).refcount != 1 as libc::c_int
2416 || (*o).encoding() as libc::c_int != 0 as libc::c_int
2417 {
2418 let mut decoded: *mut robj = getDecodedObject(o);
2419 o = createRawStringObject(
2420 (*decoded).ptr as *const libc::c_char,
2421 sdslen((*decoded).ptr as sds),
2422 );
2423 decrRefCount(decoded);
2424 dbOverwrite(db, key, o);
2425 }
2426 return o;
2427}
2428#[no_mangle]
2429pub unsafe extern "C" fn emptyDbStructure(
2430 mut dbarray: *mut redisDb,
2431 mut dbnum: libc::c_int,
2432 mut async_0: libc::c_int,
2433 mut callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
2434) -> libc::c_longlong {
2435 let mut removed: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2436 let mut startdb: libc::c_int = 0;
2437 let mut enddb: libc::c_int = 0;
2438 if dbnum == -(1 as libc::c_int) {
2439 startdb = 0 as libc::c_int;
2440 enddb = server.dbnum - 1 as libc::c_int;
2441 } else {
2442 enddb = dbnum;
2443 startdb = enddb;
2444 }
2445 let mut j: libc::c_int = startdb;
2446 while j <= enddb {
2447 removed = (removed as libc::c_ulonglong)
2448 .wrapping_add(
2449 ((*(*dbarray.offset(j as isize)).dict)
2450 .ht_used[0 as libc::c_int as usize])
2451 .wrapping_add(
2452 (*(*dbarray.offset(j as isize)).dict)
2453 .ht_used[1 as libc::c_int as usize],
2454 ) as libc::c_ulonglong,
2455 ) as libc::c_longlong as libc::c_longlong;
2456 if async_0 != 0 {
2457 emptyDbAsync(&mut *dbarray.offset(j as isize));
2458 } else {
2459 dictEmpty((*dbarray.offset(j as isize)).dict, callback);
2460 dictEmpty((*dbarray.offset(j as isize)).expires, callback);
2461 }
2462 (*dbarray.offset(j as isize)).avg_ttl = 0 as libc::c_int as libc::c_longlong;
2463 (*dbarray.offset(j as isize)).expires_cursor = 0 as libc::c_int as libc::c_ulong;
2464 j += 1;
2465 }
2466 return removed;
2467}
2468#[no_mangle]
2469pub unsafe extern "C" fn emptyData(
2470 mut dbnum: libc::c_int,
2471 mut flags: libc::c_int,
2472 mut callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
2473) -> libc::c_longlong {
2474 let mut async_0: libc::c_int = flags & (1 as libc::c_int) << 0 as libc::c_int;
2475 let mut with_functions: libc::c_int = (flags & (1 as libc::c_int) << 1 as libc::c_int
2476 == 0) as libc::c_int;
2477 let mut fi: RedisModuleFlushInfoV1 = {
2478 let mut init = RedisModuleFlushInfo {
2479 version: 1 as libc::c_int as uint64_t,
2480 sync: (async_0 == 0) as libc::c_int,
2481 dbnum: dbnum,
2482 };
2483 init
2484 };
2485 let mut removed: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2486 if dbnum < -(1 as libc::c_int) || dbnum >= server.dbnum {
2487 *__errno_location() = 22 as libc::c_int;
2488 return -(1 as libc::c_int) as libc::c_longlong;
2489 }
2490 moduleFireServerEvent(
2491 2 as libc::c_int as uint64_t,
2492 0 as libc::c_int,
2493 &mut fi as *mut RedisModuleFlushInfoV1 as *mut libc::c_void,
2494 );
2495 signalFlushedDb(dbnum, async_0);
2496 removed = emptyDbStructure(server.db, dbnum, async_0, callback);
2497 if server.cluster_enabled != 0 {
2498 slotToKeyFlush(server.db);
2499 }
2500 if dbnum == -(1 as libc::c_int) {
2501 flushSlaveKeysWithExpireList();
2502 }
2503 if with_functions != 0 {
2504 if dbnum == -(1 as libc::c_int) {} else {
2505 _serverAssert(
2506 b"dbnum == -1\0" as *const u8 as *const libc::c_char,
2507 b"db.c\0" as *const u8 as *const libc::c_char,
2508 480 as libc::c_int,
2509 );
2510 unreachable!();
2511 };
2512 functionsLibCtxClearCurrent(async_0);
2513 }
2514 moduleFireServerEvent(
2515 2 as libc::c_int as uint64_t,
2516 1 as libc::c_int,
2517 &mut fi as *mut RedisModuleFlushInfoV1 as *mut libc::c_void,
2518 );
2519 return removed;
2520}
2521#[no_mangle]
2522pub unsafe extern "C" fn initTempDb() -> *mut redisDb {
2523 let mut tempDb: *mut redisDb = zcalloc(
2524 (core::mem::size_of::<redisDb>() as libc::c_ulong)
2525 .wrapping_mul(server.dbnum as libc::c_ulong),
2526 ) as *mut redisDb;
2527 let mut i: libc::c_int = 0 as libc::c_int;
2528 while i < server.dbnum {
2529 let ref mut fresh0 = (*tempDb.offset(i as isize)).dict;
2530 *fresh0 = dictCreate(&mut dbDictType);
2531 let ref mut fresh1 = (*tempDb.offset(i as isize)).expires;
2532 *fresh1 = dictCreate(&mut dbExpiresDictType);
2533 let ref mut fresh2 = (*tempDb.offset(i as isize)).slots_to_keys;
2534 *fresh2 = 0 as *mut clusterSlotToKeyMapping;
2535 i += 1;
2536 }
2537 if server.cluster_enabled != 0 {
2538 slotToKeyInit(tempDb);
2539 }
2540 return tempDb;
2541}
2542#[no_mangle]
2543pub unsafe extern "C" fn discardTempDb(
2544 mut tempDb: *mut redisDb,
2545 mut callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
2546) {
2547 let mut async_0: libc::c_int = 1 as libc::c_int;
2548 emptyDbStructure(tempDb, -(1 as libc::c_int), async_0, callback);
2549 let mut i: libc::c_int = 0 as libc::c_int;
2550 while i < server.dbnum {
2551 dictRelease((*tempDb.offset(i as isize)).dict);
2552 dictRelease((*tempDb.offset(i as isize)).expires);
2553 i += 1;
2554 }
2555 if server.cluster_enabled != 0 {
2556 slotToKeyDestroy(tempDb);
2557 }
2558 zfree(tempDb as *mut libc::c_void);
2559}
2560#[no_mangle]
2561pub unsafe extern "C" fn selectDb(
2562 mut c: *mut client,
2563 mut id: libc::c_int,
2564) -> libc::c_int {
2565 if id < 0 as libc::c_int || id >= server.dbnum {
2566 return -(1 as libc::c_int);
2567 }
2568 (*c).db = &mut *(server.db).offset(id as isize) as *mut redisDb;
2569 return 0 as libc::c_int;
2570}
2571#[no_mangle]
2572pub unsafe extern "C" fn dbTotalServerKeyCount() -> libc::c_longlong {
2573 let mut total: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2574 let mut j: libc::c_int = 0;
2575 j = 0 as libc::c_int;
2576 while j < server.dbnum {
2577 total = (total as libc::c_ulonglong)
2578 .wrapping_add(
2579 ((*(*(server.db).offset(j as isize)).dict)
2580 .ht_used[0 as libc::c_int as usize])
2581 .wrapping_add(
2582 (*(*(server.db).offset(j as isize)).dict)
2583 .ht_used[1 as libc::c_int as usize],
2584 ) as libc::c_ulonglong,
2585 ) as libc::c_longlong as libc::c_longlong;
2586 j += 1;
2587 }
2588 return total;
2589}
2590#[no_mangle]
2591pub unsafe extern "C" fn signalModifiedKey(
2592 mut c: *mut client,
2593 mut db: *mut redisDb,
2594 mut key: *mut robj,
2595) {
2596 touchWatchedKey(db, key);
2597 trackingInvalidateKey(c, key, 1 as libc::c_int);
2598}
2599#[no_mangle]
2600pub unsafe extern "C" fn signalFlushedDb(
2601 mut dbid: libc::c_int,
2602 mut async_0: libc::c_int,
2603) {
2604 let mut startdb: libc::c_int = 0;
2605 let mut enddb: libc::c_int = 0;
2606 if dbid == -(1 as libc::c_int) {
2607 startdb = 0 as libc::c_int;
2608 enddb = server.dbnum - 1 as libc::c_int;
2609 } else {
2610 enddb = dbid;
2611 startdb = enddb;
2612 }
2613 let mut j: libc::c_int = startdb;
2614 while j <= enddb {
2615 scanDatabaseForDeletedStreams(
2616 &mut *(server.db).offset(j as isize),
2617 0 as *mut redisDb,
2618 );
2619 touchAllWatchedKeysInDb(&mut *(server.db).offset(j as isize), 0 as *mut redisDb);
2620 j += 1;
2621 }
2622 trackingInvalidateKeysOnFlush(async_0);
2623}
2624#[no_mangle]
2625pub unsafe extern "C" fn getFlushCommandFlags(
2626 mut c: *mut client,
2627 mut flags: *mut libc::c_int,
2628) -> libc::c_int {
2629 if (*c).argc == 2 as libc::c_int
2630 && strcasecmp(
2631 (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2632 b"sync\0" as *const u8 as *const libc::c_char,
2633 ) == 0
2634 {
2635 *flags = 0 as libc::c_int;
2636 } else if (*c).argc == 2 as libc::c_int
2637 && strcasecmp(
2638 (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2639 b"async\0" as *const u8 as *const libc::c_char,
2640 ) == 0
2641 {
2642 *flags = (1 as libc::c_int) << 0 as libc::c_int;
2643 } else if (*c).argc == 1 as libc::c_int {
2644 *flags = if server.lazyfree_lazy_user_flush != 0 {
2645 (1 as libc::c_int) << 0 as libc::c_int
2646 } else {
2647 0 as libc::c_int
2648 };
2649 } else {
2650 addReplyErrorObject(c, shared.syntaxerr);
2651 return -(1 as libc::c_int);
2652 }
2653 return 0 as libc::c_int;
2654}
2655#[no_mangle]
2656pub unsafe extern "C" fn flushAllDataAndResetRDB(mut flags: libc::c_int) {
2657 server.dirty += emptyData(-(1 as libc::c_int), flags, None);
2658 if server.child_type == 1 as libc::c_int {
2659 killRDBChild();
2660 }
2661 if server.saveparamslen > 0 as libc::c_int {
2662 let mut rsi: rdbSaveInfo = rdbSaveInfo {
2663 repl_stream_db: 0,
2664 repl_id_is_set: 0,
2665 repl_id: [0; 41],
2666 repl_offset: 0,
2667 };
2668 let mut rsiptr: *mut rdbSaveInfo = 0 as *mut rdbSaveInfo;
2669 rsiptr = rdbPopulateSaveInfo(&mut rsi);
2670 rdbSave(0 as libc::c_int, server.rdb_filename, rsiptr);
2671 }
2672 if flags & (1 as libc::c_int) << 0 as libc::c_int == 0 {
2673 jemalloc_purge();
2674 }
2675}
2676#[no_mangle]
2677pub unsafe extern "C" fn flushdbCommand(mut c: *mut client) {
2678 let mut flags: libc::c_int = 0;
2679 if getFlushCommandFlags(c, &mut flags) == -(1 as libc::c_int) {
2680 return;
2681 }
2682 server.dirty
2683 += emptyData(
2684 (*(*c).db).id,
2685 flags | (1 as libc::c_int) << 1 as libc::c_int,
2686 None,
2687 );
2688 forceCommandPropagation(c, 2 as libc::c_int | 1 as libc::c_int);
2689 addReply(c, shared.ok);
2690 if flags & (1 as libc::c_int) << 0 as libc::c_int == 0 {
2691 jemalloc_purge();
2692 }
2693}
2694#[no_mangle]
2695pub unsafe extern "C" fn flushallCommand(mut c: *mut client) {
2696 let mut flags: libc::c_int = 0;
2697 if getFlushCommandFlags(c, &mut flags) == -(1 as libc::c_int) {
2698 return;
2699 }
2700 flushAllDataAndResetRDB(flags | (1 as libc::c_int) << 1 as libc::c_int);
2701 forceCommandPropagation(c, 2 as libc::c_int | 1 as libc::c_int);
2702 addReply(c, shared.ok);
2703}
2704#[no_mangle]
2705pub unsafe extern "C" fn delGenericCommand(mut c: *mut client, mut lazy: libc::c_int) {
2706 let mut numdel: libc::c_int = 0 as libc::c_int;
2707 let mut j: libc::c_int = 0;
2708 j = 1 as libc::c_int;
2709 while j < (*c).argc {
2710 expireIfNeeded((*c).db, *((*c).argv).offset(j as isize), 0 as libc::c_int);
2711 let mut deleted: libc::c_int = if lazy != 0 {
2712 dbAsyncDelete((*c).db, *((*c).argv).offset(j as isize))
2713 } else {
2714 dbSyncDelete((*c).db, *((*c).argv).offset(j as isize))
2715 };
2716 if deleted != 0 {
2717 signalModifiedKey(c, (*c).db, *((*c).argv).offset(j as isize));
2718 notifyKeyspaceEvent(
2719 (1 as libc::c_int) << 2 as libc::c_int,
2720 b"del\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2721 *((*c).argv).offset(j as isize),
2722 (*(*c).db).id,
2723 );
2724 server.dirty += 1;
2725 numdel += 1;
2726 }
2727 j += 1;
2728 }
2729 addReplyLongLong(c, numdel as libc::c_longlong);
2730}
2731#[no_mangle]
2732pub unsafe extern "C" fn delCommand(mut c: *mut client) {
2733 delGenericCommand(c, server.lazyfree_lazy_user_del);
2734}
2735#[no_mangle]
2736pub unsafe extern "C" fn unlinkCommand(mut c: *mut client) {
2737 delGenericCommand(c, 1 as libc::c_int);
2738}
2739#[no_mangle]
2740pub unsafe extern "C" fn existsCommand(mut c: *mut client) {
2741 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2742 let mut j: libc::c_int = 0;
2743 j = 1 as libc::c_int;
2744 while j < (*c).argc {
2745 if !(lookupKeyReadWithFlags(
2746 (*c).db,
2747 *((*c).argv).offset(j as isize),
2748 (1 as libc::c_int) << 0 as libc::c_int,
2749 ))
2750 .is_null()
2751 {
2752 count += 1;
2753 }
2754 j += 1;
2755 }
2756 addReplyLongLong(c, count);
2757}
2758#[no_mangle]
2759pub unsafe extern "C" fn selectCommand(mut c: *mut client) {
2760 let mut id: libc::c_int = 0;
2761 if getIntFromObjectOrReply(
2762 c,
2763 *((*c).argv).offset(1 as libc::c_int as isize),
2764 &mut id,
2765 0 as *const libc::c_char,
2766 ) != 0 as libc::c_int
2767 {
2768 return;
2769 }
2770 if server.cluster_enabled != 0 && id != 0 as libc::c_int {
2771 addReplyError(
2772 c,
2773 b"SELECT is not allowed in cluster mode\0" as *const u8
2774 as *const libc::c_char,
2775 );
2776 return;
2777 }
2778 if selectDb(c, id) == -(1 as libc::c_int) {
2779 addReplyError(
2780 c,
2781 b"DB index is out of range\0" as *const u8 as *const libc::c_char,
2782 );
2783 } else {
2784 addReply(c, shared.ok);
2785 };
2786}
2787#[no_mangle]
2788pub unsafe extern "C" fn randomkeyCommand(mut c: *mut client) {
2789 let mut key: *mut robj = 0 as *mut robj;
2790 key = dbRandomKey((*c).db);
2791 if key.is_null() {
2792 addReplyNull(c);
2793 return;
2794 }
2795 addReplyBulk(c, key);
2796 decrRefCount(key);
2797}
2798#[no_mangle]
2799pub unsafe extern "C" fn keysCommand(mut c: *mut client) {
2800 let mut di: *mut dictIterator = 0 as *mut dictIterator;
2801 let mut de: *mut dictEntry = 0 as *mut dictEntry;
2802 let mut pattern: sds = (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds;
2803 let mut plen: libc::c_int = sdslen(pattern) as libc::c_int;
2804 let mut allkeys: libc::c_int = 0;
2805 let mut numkeys: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
2806 let mut replylen: *mut libc::c_void = addReplyDeferredLen(c);
2807 di = dictGetSafeIterator((*(*c).db).dict);
2808 allkeys = (*pattern.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32
2809 && plen == 1 as libc::c_int) as libc::c_int;
2810 loop {
2811 de = dictNext(di);
2812 if de.is_null() {
2813 break;
2814 }
2815 let mut key: sds = (*de).key as sds;
2816 let mut keyobj: *mut robj = 0 as *mut robj;
2817 if allkeys != 0
2818 || stringmatchlen(
2819 pattern as *const libc::c_char,
2820 plen,
2821 key as *const libc::c_char,
2822 sdslen(key) as libc::c_int,
2823 0 as libc::c_int,
2824 ) != 0
2825 {
2826 keyobj = createStringObject(key as *const libc::c_char, sdslen(key));
2827 if keyIsExpired((*c).db, keyobj) == 0 {
2828 addReplyBulk(c, keyobj);
2829 numkeys = numkeys.wrapping_add(1);
2830 }
2831 decrRefCount(keyobj);
2832 }
2833 if (*c).flags & ((1 as libc::c_int) << 10 as libc::c_int) as libc::c_ulong != 0 {
2834 break;
2835 }
2836 }
2837 dictReleaseIterator(di);
2838 setDeferredArrayLen(c, replylen, numkeys as libc::c_long);
2839}
2840#[no_mangle]
2841pub unsafe extern "C" fn scanCallback(
2842 mut privdata: *mut libc::c_void,
2843 mut de: *const dictEntry,
2844) {
2845 let mut pd: *mut *mut libc::c_void = privdata as *mut *mut libc::c_void;
2846 let mut keys: *mut list = *pd.offset(0 as libc::c_int as isize) as *mut list;
2847 let mut o: *mut robj = *pd.offset(1 as libc::c_int as isize) as *mut robj;
2848 let mut key: *mut robj = 0 as *mut robj;
2849 let mut val: *mut robj = 0 as *mut robj;
2850 if o.is_null() {
2851 let mut sdskey: sds = (*de).key as sds;
2852 key = createStringObject(sdskey as *const libc::c_char, sdslen(sdskey));
2853 } else if (*o).type_0() as libc::c_int == 2 as libc::c_int {
2854 let mut keysds: sds = (*de).key as sds;
2855 key = createStringObject(keysds as *const libc::c_char, sdslen(keysds));
2856 } else if (*o).type_0() as libc::c_int == 4 as libc::c_int {
2857 let mut sdskey_0: sds = (*de).key as sds;
2858 let mut sdsval: sds = (*de).v.val as sds;
2859 key = createStringObject(sdskey_0 as *const libc::c_char, sdslen(sdskey_0));
2860 val = createStringObject(sdsval as *const libc::c_char, sdslen(sdsval));
2861 } else if (*o).type_0() as libc::c_int == 3 as libc::c_int {
2862 let mut sdskey_1: sds = (*de).key as sds;
2863 key = createStringObject(sdskey_1 as *const libc::c_char, sdslen(sdskey_1));
2864 let c_double_ptr = (*de).v.val as *mut libc::c_double;
2865 let new_f64_value = *c_double_ptr as f64;
2866 val = createStringObjectFromLongDouble(
2867 new_f64_value,
2868 0 as libc::c_int,
2869 );
2870 } else {
2871 _serverPanic(
2872 b"db.c\0" as *const u8 as *const libc::c_char,
2873 791 as libc::c_int,
2874 b"Type not handled in SCAN callback.\0" as *const u8 as *const libc::c_char,
2875 );
2876 unreachable!();
2877 }
2878 listAddNodeTail(keys, key as *mut libc::c_void);
2879 if !val.is_null() {
2880 listAddNodeTail(keys, val as *mut libc::c_void);
2881 }
2882}
2883#[no_mangle]
2884pub unsafe extern "C" fn parseScanCursorOrReply(
2885 mut c: *mut client,
2886 mut o: *mut robj,
2887 mut cursor: *mut libc::c_ulong,
2888) -> libc::c_int {
2889 let mut eptr: *mut libc::c_char = 0 as *mut libc::c_char;
2890 *__errno_location() = 0 as libc::c_int;
2891 *cursor = strtoul((*o).ptr as *const libc::c_char, &mut eptr, 10 as libc::c_int);
2892 if *(*__ctype_b_loc())
2893 .offset(
2894 *((*o).ptr as *mut libc::c_char).offset(0 as libc::c_int as isize)
2895 as libc::c_int as isize,
2896 ) as libc::c_int & _ISspace as libc::c_int as libc::c_ushort as libc::c_int != 0
2897 || *eptr.offset(0 as libc::c_int as isize) as libc::c_int != '\0' as i32
2898 || *__errno_location() == 34 as libc::c_int
2899 {
2900 addReplyError(c, b"invalid cursor\0" as *const u8 as *const libc::c_char);
2901 return -(1 as libc::c_int);
2902 }
2903 return 0 as libc::c_int;
2904}
2905#[no_mangle]
2906pub unsafe extern "C" fn scanGenericCommand(
2907 mut c: *mut client,
2908 mut o: *mut robj,
2909 mut cursor: libc::c_ulong,
2910) {
2911 let mut current_block: u64;
2912 let mut i: libc::c_int = 0;
2913 let mut j: libc::c_int = 0;
2914 let mut keys: *mut list = listCreate();
2915 let mut node: *mut listNode = 0 as *mut listNode;
2916 let mut nextnode: *mut listNode = 0 as *mut listNode;
2917 let mut count: libc::c_long = 10 as libc::c_int as libc::c_long;
2918 let mut pat: sds = 0 as sds;
2919 let mut typename: sds = 0 as sds;
2920 let mut patlen: libc::c_int = 0 as libc::c_int;
2921 let mut use_pattern: libc::c_int = 0 as libc::c_int;
2922 let mut ht: *mut dict = 0 as *mut dict;
2923 if o.is_null() || (*o).type_0() as libc::c_int == 2 as libc::c_int
2924 || (*o).type_0() as libc::c_int == 4 as libc::c_int
2925 || (*o).type_0() as libc::c_int == 3 as libc::c_int
2926 {} else {
2927 _serverAssert(
2928 b"o == NULL || o->type == OBJ_SET || o->type == OBJ_HASH || o->type == OBJ_ZSET\0"
2929 as *const u8 as *const libc::c_char,
2930 b"db.c\0" as *const u8 as *const libc::c_char,
2931 841 as libc::c_int,
2932 );
2933 unreachable!();
2934 };
2935 i = if o.is_null() { 2 as libc::c_int } else { 3 as libc::c_int };
2936 loop {
2937 if !(i < (*c).argc) {
2938 current_block = 26972500619410423;
2939 break;
2940 }
2941 j = (*c).argc - i;
2942 if strcasecmp(
2943 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
2944 b"count\0" as *const u8 as *const libc::c_char,
2945 ) == 0 && j >= 2 as libc::c_int
2946 {
2947 if getLongFromObjectOrReply(
2948 c,
2949 *((*c).argv).offset((i + 1 as libc::c_int) as isize),
2950 &mut count,
2951 0 as *const libc::c_char,
2952 ) != 0 as libc::c_int
2953 {
2954 current_block = 12433311124224288381;
2955 break;
2956 }
2957 if count < 1 as libc::c_int as libc::c_long {
2958 addReplyErrorObject(c, shared.syntaxerr);
2959 current_block = 12433311124224288381;
2960 break;
2961 } else {
2962 i += 2 as libc::c_int;
2963 }
2964 } else if strcasecmp(
2965 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
2966 b"match\0" as *const u8 as *const libc::c_char,
2967 ) == 0 && j >= 2 as libc::c_int
2968 {
2969 pat = (**((*c).argv).offset((i + 1 as libc::c_int) as isize)).ptr as sds;
2970 patlen = sdslen(pat) as libc::c_int;
2971 use_pattern = !(patlen == 1 as libc::c_int
2972 && *pat.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32)
2973 as libc::c_int;
2974 i += 2 as libc::c_int;
2975 } else if strcasecmp(
2976 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
2977 b"type\0" as *const u8 as *const libc::c_char,
2978 ) == 0 && o.is_null() && j >= 2 as libc::c_int
2979 {
2980 typename = (**((*c).argv).offset((i + 1 as libc::c_int) as isize)).ptr
2981 as sds;
2982 i += 2 as libc::c_int;
2983 } else {
2984 addReplyErrorObject(c, shared.syntaxerr);
2985 current_block = 12433311124224288381;
2986 break;
2987 }
2988 }
2989 match current_block {
2990 26972500619410423 => {
2991 ht = 0 as *mut dict;
2992 if o.is_null() {
2993 ht = (*(*c).db).dict;
2994 } else if (*o).type_0() as libc::c_int == 2 as libc::c_int
2995 && (*o).encoding() as libc::c_int == 2 as libc::c_int
2996 {
2997 ht = (*o).ptr as *mut dict;
2998 } else if (*o).type_0() as libc::c_int == 4 as libc::c_int
2999 && (*o).encoding() as libc::c_int == 2 as libc::c_int
3000 {
3001 ht = (*o).ptr as *mut dict;
3002 count *= 2 as libc::c_int as libc::c_long;
3003 } else if (*o).type_0() as libc::c_int == 3 as libc::c_int
3004 && (*o).encoding() as libc::c_int == 7 as libc::c_int
3005 {
3006 let mut zs: *mut zset = (*o).ptr as *mut zset;
3007 ht = (*zs).dict;
3008 count *= 2 as libc::c_int as libc::c_long;
3009 }
3010 if !ht.is_null() {
3011 let mut privdata: [*mut libc::c_void; 2] = [0 as *mut libc::c_void; 2];
3012 let mut maxiterations: libc::c_long = count
3013 * 10 as libc::c_int as libc::c_long;
3014 privdata[0 as libc::c_int as usize] = keys as *mut libc::c_void;
3015 privdata[1 as libc::c_int as usize] = o as *mut libc::c_void;
3016 loop {
3017 cursor = dictScan(
3018 ht,
3019 cursor,
3020 Some(
3021 scanCallback
3022 as unsafe extern "C" fn(
3023 *mut libc::c_void,
3024 *const dictEntry,
3025 ) -> (),
3026 ),
3027 None,
3028 privdata.as_mut_ptr() as *mut libc::c_void,
3029 );
3030 if !(cursor != 0
3031 && {
3032 let fresh3 = maxiterations;
3033 maxiterations = maxiterations - 1;
3034 fresh3 != 0
3035 } && (*keys).len < count as libc::c_ulong)
3036 {
3037 break;
3038 }
3039 }
3040 } else if (*o).type_0() as libc::c_int == 2 as libc::c_int {
3041 let mut pos: libc::c_int = 0 as libc::c_int;
3042 let mut ll: int64_t = 0;
3043 loop {
3044 let fresh4 = pos;
3045 pos = pos + 1;
3046 if !(intsetGet((*o).ptr as *mut intset, fresh4 as uint32_t, &mut ll)
3047 != 0)
3048 {
3049 break;
3050 }
3051 listAddNodeTail(
3052 keys,
3053 createStringObjectFromLongLong(ll as libc::c_longlong)
3054 as *mut libc::c_void,
3055 );
3056 }
3057 cursor = 0 as libc::c_int as libc::c_ulong;
3058 } else if (*o).type_0() as libc::c_int == 4 as libc::c_int
3059 || (*o).type_0() as libc::c_int == 3 as libc::c_int
3060 {
3061 let mut p: *mut libc::c_uchar = lpFirst((*o).ptr as *mut libc::c_uchar);
3062 let mut vstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
3063 let mut vlen: int64_t = 0;
3064 let mut intbuf: [libc::c_uchar; 21] = [0; 21];
3065 while !p.is_null() {
3066 vstr = lpGet(p, &mut vlen, intbuf.as_mut_ptr());
3067 listAddNodeTail(
3068 keys,
3069 createStringObject(vstr as *mut libc::c_char, vlen as size_t)
3070 as *mut libc::c_void,
3071 );
3072 p = lpNext((*o).ptr as *mut libc::c_uchar, p);
3073 }
3074 cursor = 0 as libc::c_int as libc::c_ulong;
3075 } else {
3076 _serverPanic(
3077 b"db.c\0" as *const u8 as *const libc::c_char,
3078 942 as libc::c_int,
3079 b"Not handled encoding in SCAN.\0" as *const u8
3080 as *const libc::c_char,
3081 );
3082 unreachable!();
3083 }
3084 node = (*keys).head;
3085 while !node.is_null() {
3086 let mut kobj: *mut robj = (*node).value as *mut robj;
3087 nextnode = (*node).next;
3088 let mut filter: libc::c_int = 0 as libc::c_int;
3089 if use_pattern != 0 {
3090 if (*kobj).encoding() as libc::c_int == 0 as libc::c_int
3091 || (*kobj).encoding() as libc::c_int == 8 as libc::c_int
3092 {
3093 if stringmatchlen(
3094 pat as *const libc::c_char,
3095 patlen,
3096 (*kobj).ptr as *const libc::c_char,
3097 sdslen((*kobj).ptr as sds) as libc::c_int,
3098 0 as libc::c_int,
3099 ) == 0
3100 {
3101 filter = 1 as libc::c_int;
3102 }
3103 } else {
3104 let mut buf: [libc::c_char; 21] = [0; 21];
3105 let mut len: libc::c_int = 0;
3106 if (*kobj).encoding() as libc::c_int == 1 as libc::c_int
3107 {} else {
3108 _serverAssert(
3109 b"kobj->encoding == OBJ_ENCODING_INT\0" as *const u8
3110 as *const libc::c_char,
3111 b"db.c\0" as *const u8 as *const libc::c_char,
3112 961 as libc::c_int,
3113 );
3114 unreachable!();
3115 };
3116 len = ll2string(
3117 buf.as_mut_ptr(),
3118 core::mem::size_of::<[libc::c_char; 21]>()
3119 as libc::c_ulong,
3120 (*kobj).ptr as libc::c_long as libc::c_longlong,
3121 );
3122 if stringmatchlen(
3123 pat as *const libc::c_char,
3124 patlen,
3125 buf.as_mut_ptr(),
3126 len,
3127 0 as libc::c_int,
3128 ) == 0
3129 {
3130 filter = 1 as libc::c_int;
3131 }
3132 }
3133 }
3134 if filter == 0 && o.is_null() && !typename.is_null() {
3135 let mut typecheck: *mut robj = lookupKeyReadWithFlags(
3136 (*c).db,
3137 kobj,
3138 (1 as libc::c_int) << 0 as libc::c_int,
3139 );
3140 let mut type_0: *mut libc::c_char = getObjectTypeName(typecheck);
3141 if strcasecmp(typename, type_0) != 0 {
3142 filter = 1 as libc::c_int;
3143 }
3144 }
3145 if filter == 0 && o.is_null()
3146 && expireIfNeeded((*c).db, kobj, 0 as libc::c_int) != 0
3147 {
3148 filter = 1 as libc::c_int;
3149 }
3150 if filter != 0 {
3151 decrRefCount(kobj);
3152 listDelNode(keys, node);
3153 }
3154 if !o.is_null()
3155 && ((*o).type_0() as libc::c_int == 3 as libc::c_int
3156 || (*o).type_0() as libc::c_int == 4 as libc::c_int)
3157 {
3158 node = nextnode;
3159 if !node.is_null() {} else {
3160 _serverAssert(
3161 b"node\0" as *const u8 as *const libc::c_char,
3162 b"db.c\0" as *const u8 as *const libc::c_char,
3163 988 as libc::c_int,
3164 );
3165 unreachable!();
3166 };
3167 nextnode = (*node).next;
3168 if filter != 0 {
3169 kobj = (*node).value as *mut robj;
3170 decrRefCount(kobj);
3171 listDelNode(keys, node);
3172 }
3173 }
3174 node = nextnode;
3175 }
3176 addReplyArrayLen(c, 2 as libc::c_int as libc::c_long);
3177 addReplyBulkLongLong(c, cursor as libc::c_longlong);
3178 addReplyArrayLen(c, (*keys).len as libc::c_long);
3179 loop {
3180 node = (*keys).head;
3181 if node.is_null() {
3182 break;
3183 }
3184 let mut kobj_0: *mut robj = (*node).value as *mut robj;
3185 addReplyBulk(c, kobj_0);
3186 decrRefCount(kobj_0);
3187 listDelNode(keys, node);
3188 }
3189 }
3190 _ => {}
3191 }
3192 (*keys)
3193 .free = Some(decrRefCountVoid as unsafe extern "C" fn(*mut libc::c_void) -> ());
3194 listRelease(keys);
3195}
3196#[no_mangle]
3197pub unsafe extern "C" fn scanCommand(mut c: *mut client) {
3198 let mut cursor: libc::c_ulong = 0;
3199 if parseScanCursorOrReply(
3200 c,
3201 *((*c).argv).offset(1 as libc::c_int as isize),
3202 &mut cursor,
3203 ) == -(1 as libc::c_int)
3204 {
3205 return;
3206 }
3207 scanGenericCommand(c, 0 as *mut robj, cursor);
3208}
3209#[no_mangle]
3210pub unsafe extern "C" fn dbsizeCommand(mut c: *mut client) {
3211 addReplyLongLong(
3212 c,
3213 ((*(*(*c).db).dict).ht_used[0 as libc::c_int as usize])
3214 .wrapping_add((*(*(*c).db).dict).ht_used[1 as libc::c_int as usize])
3215 as libc::c_longlong,
3216 );
3217}
3218#[no_mangle]
3219pub unsafe extern "C" fn lastsaveCommand(mut c: *mut client) {
3220 addReplyLongLong(c, server.lastsave as libc::c_longlong);
3221}
3222#[no_mangle]
3223pub unsafe extern "C" fn getObjectTypeName(mut o: *mut robj) -> *mut libc::c_char {
3224 let mut type_0: *mut libc::c_char = 0 as *mut libc::c_char;
3225 if o.is_null() {
3226 type_0 = b"none\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
3227 } else {
3228 match (*o).type_0() as libc::c_int {
3229 0 => {
3230 type_0 = b"string\0" as *const u8 as *const libc::c_char
3231 as *mut libc::c_char;
3232 }
3233 1 => {
3234 type_0 = b"list\0" as *const u8 as *const libc::c_char
3235 as *mut libc::c_char;
3236 }
3237 2 => {
3238 type_0 = b"set\0" as *const u8 as *const libc::c_char
3239 as *mut libc::c_char;
3240 }
3241 3 => {
3242 type_0 = b"zset\0" as *const u8 as *const libc::c_char
3243 as *mut libc::c_char;
3244 }
3245 4 => {
3246 type_0 = b"hash\0" as *const u8 as *const libc::c_char
3247 as *mut libc::c_char;
3248 }
3249 6 => {
3250 type_0 = b"stream\0" as *const u8 as *const libc::c_char
3251 as *mut libc::c_char;
3252 }
3253 5 => {
3254 let mut mv: *mut moduleValue = (*o).ptr as *mut moduleValue;
3255 type_0 = ((*(*mv).type_0).name).as_mut_ptr();
3256 }
3257 _ => {
3258 type_0 = b"unknown\0" as *const u8 as *const libc::c_char
3259 as *mut libc::c_char;
3260 }
3261 }
3262 }
3263 return type_0;
3264}
3265#[no_mangle]
3266pub unsafe extern "C" fn typeCommand(mut c: *mut client) {
3267 let mut o: *mut robj = 0 as *mut robj;
3268 o = lookupKeyReadWithFlags(
3269 (*c).db,
3270 *((*c).argv).offset(1 as libc::c_int as isize),
3271 (1 as libc::c_int) << 0 as libc::c_int,
3272 );
3273 addReplyStatus(c, getObjectTypeName(o));
3274}
3275#[no_mangle]
3276pub unsafe extern "C" fn shutdownCommand(mut c: *mut client) {
3277 let mut flags: libc::c_int = 0 as libc::c_int;
3278 let mut abort: libc::c_int = 0 as libc::c_int;
3279 let mut i: libc::c_int = 1 as libc::c_int;
3280 while i < (*c).argc {
3281 if strcasecmp(
3282 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
3283 b"nosave\0" as *const u8 as *const libc::c_char,
3284 ) == 0
3285 {
3286 flags |= 2 as libc::c_int;
3287 } else if strcasecmp(
3288 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
3289 b"save\0" as *const u8 as *const libc::c_char,
3290 ) == 0
3291 {
3292 flags |= 1 as libc::c_int;
3293 } else if strcasecmp(
3294 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
3295 b"now\0" as *const u8 as *const libc::c_char,
3296 ) == 0
3297 {
3298 flags |= 4 as libc::c_int;
3299 } else if strcasecmp(
3300 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
3301 b"force\0" as *const u8 as *const libc::c_char,
3302 ) == 0
3303 {
3304 flags |= 8 as libc::c_int;
3305 } else if strcasecmp(
3306 (**((*c).argv).offset(i as isize)).ptr as *const libc::c_char,
3307 b"abort\0" as *const u8 as *const libc::c_char,
3308 ) == 0
3309 {
3310 abort = 1 as libc::c_int;
3311 } else {
3312 addReplyErrorObject(c, shared.syntaxerr);
3313 return;
3314 }
3315 i += 1;
3316 }
3317 if abort != 0 && flags != 0 as libc::c_int
3318 || flags & 2 as libc::c_int != 0 && flags & 1 as libc::c_int != 0
3319 {
3320 addReplyErrorObject(c, shared.syntaxerr);
3321 return;
3322 }
3323 if abort != 0 {
3324 if abortShutdown() == 0 as libc::c_int {
3325 addReply(c, shared.ok);
3326 } else {
3327 addReplyError(
3328 c,
3329 b"No shutdown in progress.\0" as *const u8 as *const libc::c_char,
3330 );
3331 }
3332 return;
3333 }
3334 if flags & 4 as libc::c_int == 0
3335 && (*c).flags as libc::c_ulonglong
3336 & (1 as libc::c_ulonglong) << 41 as libc::c_int != 0
3337 {
3338 addReplyError(
3339 c,
3340 b"SHUTDOWN without NOW or ABORT isn't allowed for DENY BLOCKING client\0"
3341 as *const u8 as *const libc::c_char,
3342 );
3343 return;
3344 }
3345 if flags & 2 as libc::c_int == 0 && isInsideYieldingLongCommand() != 0 {
3346 if server.busy_module_yield_flags != 0
3347 && !(server.busy_module_yield_reply).is_null()
3348 {
3349 addReplyErrorFormat(
3350 c,
3351 b"-BUSY %s\0" as *const u8 as *const libc::c_char,
3352 server.busy_module_yield_reply,
3353 );
3354 } else if server.busy_module_yield_flags != 0 {
3355 addReplyErrorObject(c, shared.slowmoduleerr);
3356 } else if scriptIsEval() != 0 {
3357 addReplyErrorObject(c, shared.slowevalerr);
3358 } else {
3359 addReplyErrorObject(c, shared.slowscripterr);
3360 }
3361 return;
3362 }
3363 blockClient(c, 7 as libc::c_int);
3364 if prepareForShutdown(flags) == 0 as libc::c_int {
3365 exit(0 as libc::c_int);
3366 }
3367}
3368#[no_mangle]
3369pub unsafe extern "C" fn renameGenericCommand(mut c: *mut client, mut nx: libc::c_int) {
3370 let mut o: *mut robj = 0 as *mut robj;
3371 let mut expire: libc::c_longlong = 0;
3372 let mut samekey: libc::c_int = 0 as libc::c_int;
3373 if sdscmp(
3374 (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds,
3375 (**((*c).argv).offset(2 as libc::c_int as isize)).ptr as sds,
3376 ) == 0 as libc::c_int
3377 {
3378 samekey = 1 as libc::c_int;
3379 }
3380 o = lookupKeyWriteOrReply(
3381 c,
3382 *((*c).argv).offset(1 as libc::c_int as isize),
3383 shared.nokeyerr,
3384 );
3385 if o.is_null() {
3386 return;
3387 }
3388 if samekey != 0 {
3389 addReply(c, if nx != 0 { shared.czero } else { shared.ok });
3390 return;
3391 }
3392 incrRefCount(o);
3393 expire = getExpire((*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
3394 if !(lookupKeyWrite((*c).db, *((*c).argv).offset(2 as libc::c_int as isize)))
3395 .is_null()
3396 {
3397 if nx != 0 {
3398 decrRefCount(o);
3399 addReply(c, shared.czero);
3400 return;
3401 }
3402 dbDelete((*c).db, *((*c).argv).offset(2 as libc::c_int as isize));
3403 }
3404 dbAdd((*c).db, *((*c).argv).offset(2 as libc::c_int as isize), o);
3405 if expire != -(1 as libc::c_int) as libc::c_longlong {
3406 setExpire(c, (*c).db, *((*c).argv).offset(2 as libc::c_int as isize), expire);
3407 }
3408 dbDelete((*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
3409 signalModifiedKey(c, (*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
3410 signalModifiedKey(c, (*c).db, *((*c).argv).offset(2 as libc::c_int as isize));
3411 notifyKeyspaceEvent(
3412 (1 as libc::c_int) << 2 as libc::c_int,
3413 b"rename_from\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3414 *((*c).argv).offset(1 as libc::c_int as isize),
3415 (*(*c).db).id,
3416 );
3417 notifyKeyspaceEvent(
3418 (1 as libc::c_int) << 2 as libc::c_int,
3419 b"rename_to\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3420 *((*c).argv).offset(2 as libc::c_int as isize),
3421 (*(*c).db).id,
3422 );
3423 server.dirty += 1;
3424 addReply(c, if nx != 0 { shared.cone } else { shared.ok });
3425}
3426#[no_mangle]
3427pub unsafe extern "C" fn renameCommand(mut c: *mut client) {
3428 renameGenericCommand(c, 0 as libc::c_int);
3429}
3430#[no_mangle]
3431pub unsafe extern "C" fn renamenxCommand(mut c: *mut client) {
3432 renameGenericCommand(c, 1 as libc::c_int);
3433}
3434#[no_mangle]
3435pub unsafe extern "C" fn moveCommand(mut c: *mut client) {
3436 let mut o: *mut robj = 0 as *mut robj;
3437 let mut src: *mut redisDb = 0 as *mut redisDb;
3438 let mut dst: *mut redisDb = 0 as *mut redisDb;
3439 let mut srcid: libc::c_int = 0;
3440 let mut dbid: libc::c_int = 0;
3441 let mut expire: libc::c_longlong = 0;
3442 if server.cluster_enabled != 0 {
3443 addReplyError(
3444 c,
3445 b"MOVE is not allowed in cluster mode\0" as *const u8 as *const libc::c_char,
3446 );
3447 return;
3448 }
3449 src = (*c).db;
3450 srcid = (*(*c).db).id;
3451 if getIntFromObjectOrReply(
3452 c,
3453 *((*c).argv).offset(2 as libc::c_int as isize),
3454 &mut dbid,
3455 0 as *const libc::c_char,
3456 ) != 0 as libc::c_int
3457 {
3458 return;
3459 }
3460 if selectDb(c, dbid) == -(1 as libc::c_int) {
3461 addReplyError(
3462 c,
3463 b"DB index is out of range\0" as *const u8 as *const libc::c_char,
3464 );
3465 return;
3466 }
3467 dst = (*c).db;
3468 selectDb(c, srcid);
3469 if src == dst {
3470 addReplyErrorObject(c, shared.sameobjecterr);
3471 return;
3472 }
3473 o = lookupKeyWrite((*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
3474 if o.is_null() {
3475 addReply(c, shared.czero);
3476 return;
3477 }
3478 expire = getExpire((*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
3479 if !(lookupKeyWrite(dst, *((*c).argv).offset(1 as libc::c_int as isize))).is_null() {
3480 addReply(c, shared.czero);
3481 return;
3482 }
3483 dbAdd(dst, *((*c).argv).offset(1 as libc::c_int as isize), o);
3484 if expire != -(1 as libc::c_int) as libc::c_longlong {
3485 setExpire(c, dst, *((*c).argv).offset(1 as libc::c_int as isize), expire);
3486 }
3487 incrRefCount(o);
3488 dbDelete(src, *((*c).argv).offset(1 as libc::c_int as isize));
3489 signalModifiedKey(c, src, *((*c).argv).offset(1 as libc::c_int as isize));
3490 signalModifiedKey(c, dst, *((*c).argv).offset(1 as libc::c_int as isize));
3491 notifyKeyspaceEvent(
3492 (1 as libc::c_int) << 2 as libc::c_int,
3493 b"move_from\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3494 *((*c).argv).offset(1 as libc::c_int as isize),
3495 (*src).id,
3496 );
3497 notifyKeyspaceEvent(
3498 (1 as libc::c_int) << 2 as libc::c_int,
3499 b"move_to\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3500 *((*c).argv).offset(1 as libc::c_int as isize),
3501 (*dst).id,
3502 );
3503 server.dirty += 1;
3504 addReply(c, shared.cone);
3505}
3506#[no_mangle]
3507pub unsafe extern "C" fn copyCommand(mut c: *mut client) {
3508 let mut o: *mut robj = 0 as *mut robj;
3509 let mut src: *mut redisDb = 0 as *mut redisDb;
3510 let mut dst: *mut redisDb = 0 as *mut redisDb;
3511 let mut srcid: libc::c_int = 0;
3512 let mut dbid: libc::c_int = 0;
3513 let mut expire: libc::c_longlong = 0;
3514 let mut j: libc::c_int = 0;
3515 let mut replace: libc::c_int = 0 as libc::c_int;
3516 let mut delete: libc::c_int = 0 as libc::c_int;
3517 src = (*c).db;
3518 dst = (*c).db;
3519 srcid = (*(*c).db).id;
3520 dbid = (*(*c).db).id;
3521 j = 3 as libc::c_int;
3522 while j < (*c).argc {
3523 let mut additional: libc::c_int = (*c).argc - j - 1 as libc::c_int;
3524 if strcasecmp(
3525 (**((*c).argv).offset(j as isize)).ptr as *const libc::c_char,
3526 b"replace\0" as *const u8 as *const libc::c_char,
3527 ) == 0
3528 {
3529 replace = 1 as libc::c_int;
3530 } else if strcasecmp(
3531 (**((*c).argv).offset(j as isize)).ptr as *const libc::c_char,
3532 b"db\0" as *const u8 as *const libc::c_char,
3533 ) == 0 && additional >= 1 as libc::c_int
3534 {
3535 if getIntFromObjectOrReply(
3536 c,
3537 *((*c).argv).offset((j + 1 as libc::c_int) as isize),
3538 &mut dbid,
3539 0 as *const libc::c_char,
3540 ) != 0 as libc::c_int
3541 {
3542 return;
3543 }
3544 if selectDb(c, dbid) == -(1 as libc::c_int) {
3545 addReplyError(
3546 c,
3547 b"DB index is out of range\0" as *const u8 as *const libc::c_char,
3548 );
3549 return;
3550 }
3551 dst = (*c).db;
3552 selectDb(c, srcid);
3553 j += 1;
3554 } else {
3555 addReplyErrorObject(c, shared.syntaxerr);
3556 return;
3557 }
3558 j += 1;
3559 }
3560 if server.cluster_enabled == 1 as libc::c_int
3561 && (srcid != 0 as libc::c_int || dbid != 0 as libc::c_int)
3562 {
3563 addReplyError(
3564 c,
3565 b"Copying to another database is not allowed in cluster mode\0" as *const u8
3566 as *const libc::c_char,
3567 );
3568 return;
3569 }
3570 let mut key: *mut robj = *((*c).argv).offset(1 as libc::c_int as isize);
3571 let mut newkey: *mut robj = *((*c).argv).offset(2 as libc::c_int as isize);
3572 if src == dst && sdscmp((*key).ptr as sds, (*newkey).ptr as sds) == 0 as libc::c_int
3573 {
3574 addReplyErrorObject(c, shared.sameobjecterr);
3575 return;
3576 }
3577 o = lookupKeyRead((*c).db, key);
3578 if o.is_null() {
3579 addReply(c, shared.czero);
3580 return;
3581 }
3582 expire = getExpire((*c).db, key);
3583 if !(lookupKeyWrite(dst, newkey)).is_null() {
3584 if replace != 0 {
3585 delete = 1 as libc::c_int;
3586 } else {
3587 addReply(c, shared.czero);
3588 return;
3589 }
3590 }
3591 let mut newobj: *mut robj = 0 as *mut robj;
3592 match (*o).type_0() as libc::c_int {
3593 0 => {
3594 newobj = dupStringObject(o);
3595 }
3596 1 => {
3597 newobj = listTypeDup(o);
3598 }
3599 2 => {
3600 newobj = setTypeDup(o);
3601 }
3602 3 => {
3603 newobj = zsetDup(o);
3604 }
3605 4 => {
3606 newobj = hashTypeDup(o);
3607 }
3608 6 => {
3609 newobj = streamDup(o);
3610 }
3611 5 => {
3612 newobj = moduleTypeDupOrReply(c, key, newkey, (*dst).id, o);
3613 if newobj.is_null() {
3614 return;
3615 }
3616 }
3617 _ => {
3618 addReplyError(
3619 c,
3620 b"unknown type object\0" as *const u8 as *const libc::c_char,
3621 );
3622 return;
3623 }
3624 }
3625 if delete != 0 {
3626 dbDelete(dst, newkey);
3627 }
3628 dbAdd(dst, newkey, newobj);
3629 if expire != -(1 as libc::c_int) as libc::c_longlong {
3630 setExpire(c, dst, newkey, expire);
3631 }
3632 signalModifiedKey(c, dst, *((*c).argv).offset(2 as libc::c_int as isize));
3633 notifyKeyspaceEvent(
3634 (1 as libc::c_int) << 2 as libc::c_int,
3635 b"copy_to\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3636 *((*c).argv).offset(2 as libc::c_int as isize),
3637 (*dst).id,
3638 );
3639 server.dirty += 1;
3640 addReply(c, shared.cone);
3641}
3642#[no_mangle]
3643pub unsafe extern "C" fn scanDatabaseForReadyKeys(mut db: *mut redisDb) {
3644 let mut de: *mut dictEntry = 0 as *mut dictEntry;
3645 let mut di: *mut dictIterator = dictGetSafeIterator((*db).blocking_keys);
3646 loop {
3647 de = dictNext(di);
3648 if de.is_null() {
3649 break;
3650 }
3651 let mut key: *mut robj = (*de).key as *mut robj;
3652 let mut kde: *mut dictEntry = dictFind((*db).dict, (*key).ptr);
3653 if !kde.is_null() {
3654 let mut value: *mut robj = (*kde).v.val as *mut robj;
3655 signalKeyAsReady(db, key, (*value).type_0() as libc::c_int);
3656 }
3657 }
3658 dictReleaseIterator(di);
3659}
3660#[no_mangle]
3661pub unsafe extern "C" fn scanDatabaseForDeletedStreams(
3662 mut emptied: *mut redisDb,
3663 mut replaced_with: *mut redisDb,
3664) {
3665 if server.blocked_clients_by_type[4 as libc::c_int as usize] == 0 {
3666 return;
3667 }
3668 let mut de: *mut dictEntry = 0 as *mut dictEntry;
3669 let mut di: *mut dictIterator = dictGetSafeIterator((*emptied).blocking_keys);
3670 loop {
3671 de = dictNext(di);
3672 if de.is_null() {
3673 break;
3674 }
3675 let mut key: *mut robj = (*de).key as *mut robj;
3676 let mut was_stream: libc::c_int = 0 as libc::c_int;
3677 let mut is_stream: libc::c_int = 0 as libc::c_int;
3678 let mut kde: *mut dictEntry = dictFind((*emptied).dict, (*key).ptr);
3679 if !kde.is_null() {
3680 let mut value: *mut robj = (*kde).v.val as *mut robj;
3681 was_stream = ((*value).type_0() as libc::c_int == 6 as libc::c_int)
3682 as libc::c_int;
3683 }
3684 if !replaced_with.is_null() {
3685 let mut kde_0: *mut dictEntry = dictFind((*replaced_with).dict, (*key).ptr);
3686 if !kde_0.is_null() {
3687 let mut value_0: *mut robj = (*kde_0).v.val as *mut robj;
3688 is_stream = ((*value_0).type_0() as libc::c_int == 6 as libc::c_int)
3689 as libc::c_int;
3690 }
3691 }
3692 if was_stream != 0 && is_stream == 0 {
3693 signalKeyAsReady(emptied, key, 6 as libc::c_int);
3694 }
3695 }
3696 dictReleaseIterator(di);
3697}
3698#[no_mangle]
3699pub unsafe extern "C" fn dbSwapDatabases(
3700 mut id1: libc::c_int,
3701 mut id2: libc::c_int,
3702) -> libc::c_int {
3703 if id1 < 0 as libc::c_int || id1 >= server.dbnum || id2 < 0 as libc::c_int
3704 || id2 >= server.dbnum
3705 {
3706 return -(1 as libc::c_int);
3707 }
3708 if id1 == id2 {
3709 return 0 as libc::c_int;
3710 }
3711 let mut aux: redisDb = *(server.db).offset(id1 as isize);
3712 let mut db1: *mut redisDb = &mut *(server.db).offset(id1 as isize) as *mut redisDb;
3713 let mut db2: *mut redisDb = &mut *(server.db).offset(id2 as isize) as *mut redisDb;
3714 touchAllWatchedKeysInDb(db1, db2);
3715 touchAllWatchedKeysInDb(db2, db1);
3716 scanDatabaseForDeletedStreams(db1, db2);
3717 scanDatabaseForDeletedStreams(db2, db1);
3718 (*db1).dict = (*db2).dict;
3719 (*db1).expires = (*db2).expires;
3720 (*db1).avg_ttl = (*db2).avg_ttl;
3721 (*db1).expires_cursor = (*db2).expires_cursor;
3722 (*db2).dict = aux.dict;
3723 (*db2).expires = aux.expires;
3724 (*db2).avg_ttl = aux.avg_ttl;
3725 (*db2).expires_cursor = aux.expires_cursor;
3726 scanDatabaseForReadyKeys(db1);
3727 scanDatabaseForReadyKeys(db2);
3728 return 0 as libc::c_int;
3729}
3730#[no_mangle]
3731pub unsafe extern "C" fn swapMainDbWithTempDb(mut tempDb: *mut redisDb) {
3732 if server.cluster_enabled != 0 {
3733 let mut aux: *mut clusterSlotToKeyMapping = (*server.db).slots_to_keys;
3734 (*server.db).slots_to_keys = (*tempDb).slots_to_keys;
3735 (*tempDb).slots_to_keys = aux;
3736 }
3737 let mut i: libc::c_int = 0 as libc::c_int;
3738 while i < server.dbnum {
3739 let mut aux_0: redisDb = *(server.db).offset(i as isize);
3740 let mut activedb: *mut redisDb = &mut *(server.db).offset(i as isize)
3741 as *mut redisDb;
3742 let mut newdb: *mut redisDb = &mut *tempDb.offset(i as isize) as *mut redisDb;
3743 touchAllWatchedKeysInDb(activedb, newdb);
3744 scanDatabaseForDeletedStreams(activedb, newdb);
3745 (*activedb).dict = (*newdb).dict;
3746 (*activedb).expires = (*newdb).expires;
3747 (*activedb).avg_ttl = (*newdb).avg_ttl;
3748 (*activedb).expires_cursor = (*newdb).expires_cursor;
3749 (*newdb).dict = aux_0.dict;
3750 (*newdb).expires = aux_0.expires;
3751 (*newdb).avg_ttl = aux_0.avg_ttl;
3752 (*newdb).expires_cursor = aux_0.expires_cursor;
3753 scanDatabaseForReadyKeys(activedb);
3754 i += 1;
3755 }
3756 trackingInvalidateKeysOnFlush(1 as libc::c_int);
3757 flushSlaveKeysWithExpireList();
3758}
3759#[no_mangle]
3760pub unsafe extern "C" fn swapdbCommand(mut c: *mut client) {
3761 let mut id1: libc::c_int = 0;
3762 let mut id2: libc::c_int = 0;
3763 if server.cluster_enabled != 0 {
3764 addReplyError(
3765 c,
3766 b"SWAPDB is not allowed in cluster mode\0" as *const u8
3767 as *const libc::c_char,
3768 );
3769 return;
3770 }
3771 if getIntFromObjectOrReply(
3772 c,
3773 *((*c).argv).offset(1 as libc::c_int as isize),
3774 &mut id1,
3775 b"invalid first DB index\0" as *const u8 as *const libc::c_char,
3776 ) != 0 as libc::c_int
3777 {
3778 return;
3779 }
3780 if getIntFromObjectOrReply(
3781 c,
3782 *((*c).argv).offset(2 as libc::c_int as isize),
3783 &mut id2,
3784 b"invalid second DB index\0" as *const u8 as *const libc::c_char,
3785 ) != 0 as libc::c_int
3786 {
3787 return;
3788 }
3789 if dbSwapDatabases(id1, id2) == -(1 as libc::c_int) {
3790 addReplyError(
3791 c,
3792 b"DB index is out of range\0" as *const u8 as *const libc::c_char,
3793 );
3794 return;
3795 } else {
3796 let mut si: RedisModuleSwapDbInfoV1 = {
3797 let mut init = RedisModuleSwapDbInfo {
3798 version: 1 as libc::c_int as uint64_t,
3799 dbnum_first: id1,
3800 dbnum_second: id2,
3801 };
3802 init
3803 };
3804 moduleFireServerEvent(
3805 11 as libc::c_int as uint64_t,
3806 0 as libc::c_int,
3807 &mut si as *mut RedisModuleSwapDbInfoV1 as *mut libc::c_void,
3808 );
3809 server.dirty += 1;
3810 addReply(c, shared.ok);
3811 };
3812}
3813#[no_mangle]
3814pub unsafe extern "C" fn removeExpire(
3815 mut db: *mut redisDb,
3816 mut key: *mut robj,
3817) -> libc::c_int {
3818 if !(dictFind((*db).dict, (*key).ptr)).is_null() {} else {
3819 _serverAssertWithInfo(
3820 0 as *const client,
3821 key,
3822 b"dictFind(db->dict,key->ptr) != NULL\0" as *const u8 as *const libc::c_char,
3823 b"db.c\0" as *const u8 as *const libc::c_char,
3824 1525 as libc::c_int,
3825 );
3826 unreachable!();
3827 };
3828 return (dictDelete((*db).expires, (*key).ptr) == 0 as libc::c_int) as libc::c_int;
3829}
3830#[no_mangle]
3831pub unsafe extern "C" fn setExpire(
3832 mut c: *mut client,
3833 mut db: *mut redisDb,
3834 mut key: *mut robj,
3835 mut when: libc::c_longlong,
3836) {
3837 let mut kde: *mut dictEntry = 0 as *mut dictEntry;
3838 let mut de: *mut dictEntry = 0 as *mut dictEntry;
3839 kde = dictFind((*db).dict, (*key).ptr);
3840 if !kde.is_null() {} else {
3841 _serverAssertWithInfo(
3842 0 as *const client,
3843 key,
3844 b"kde != NULL\0" as *const u8 as *const libc::c_char,
3845 b"db.c\0" as *const u8 as *const libc::c_char,
3846 1538 as libc::c_int,
3847 );
3848 unreachable!();
3849 };
3850 de = dictAddOrFind((*db).expires, (*kde).key);
3851 (*de).v.s64 = when as int64_t;
3852 let mut writable_slave: libc::c_int = (!(server.masterhost).is_null()
3853 && server.repl_slave_ro == 0 as libc::c_int) as libc::c_int;
3854 if !c.is_null() && writable_slave != 0
3855 && (*c).flags & ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong == 0
3856 {
3857 rememberSlaveKeyWithExpire(db, key);
3858 }
3859}
3860#[no_mangle]
3861pub unsafe extern "C" fn getExpire(
3862 mut db: *mut redisDb,
3863 mut key: *mut robj,
3864) -> libc::c_longlong {
3865 let mut de: *mut dictEntry = 0 as *mut dictEntry;
3866 if ((*(*db).expires).ht_used[0 as libc::c_int as usize])
3867 .wrapping_add((*(*db).expires).ht_used[1 as libc::c_int as usize])
3868 == 0 as libc::c_int as libc::c_ulong
3869 || {
3870 de = dictFind((*db).expires, (*key).ptr);
3871 de.is_null()
3872 }
3873 {
3874 return -(1 as libc::c_int) as libc::c_longlong;
3875 }
3876 if !(dictFind((*db).dict, (*key).ptr)).is_null() {} else {
3877 _serverAssertWithInfo(
3878 0 as *const client,
3879 key,
3880 b"dictFind(db->dict,key->ptr) != NULL\0" as *const u8 as *const libc::c_char,
3881 b"db.c\0" as *const u8 as *const libc::c_char,
3882 1558 as libc::c_int,
3883 );
3884 unreachable!();
3885 };
3886 return (*de).v.s64 as libc::c_longlong;
3887}
3888#[no_mangle]
3889pub unsafe extern "C" fn deleteExpiredKeyAndPropagate(
3890 mut db: *mut redisDb,
3891 mut keyobj: *mut robj,
3892) {
3893 let mut expire_latency: mstime_t = 0;
3894 if server.latency_monitor_threshold != 0 {
3895 expire_latency = mstime();
3896 } else {
3897 expire_latency = 0 as libc::c_int as mstime_t;
3898 }
3899 if server.lazyfree_lazy_expire != 0 {
3900 dbAsyncDelete(db, keyobj);
3901 } else {
3902 dbSyncDelete(db, keyobj);
3903 }
3904 if server.latency_monitor_threshold != 0 {
3905 expire_latency = mstime() - expire_latency;
3906 }
3907 if server.latency_monitor_threshold != 0
3908 && expire_latency >= server.latency_monitor_threshold
3909 {
3910 latencyAddSample(
3911 b"expire-del\0" as *const u8 as *const libc::c_char,
3912 expire_latency,
3913 );
3914 }
3915 notifyKeyspaceEvent(
3916 (1 as libc::c_int) << 8 as libc::c_int,
3917 b"expired\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3918 keyobj,
3919 (*db).id,
3920 );
3921 signalModifiedKey(0 as *mut client, db, keyobj);
3922 propagateDeletion(db, keyobj, server.lazyfree_lazy_expire);
3923 server.stat_expiredkeys += 1;
3924}
3925#[no_mangle]
3926pub unsafe extern "C" fn propagateDeletion(
3927 mut db: *mut redisDb,
3928 mut key: *mut robj,
3929 mut lazy: libc::c_int,
3930) {
3931 let mut argv: [*mut robj; 2] = [0 as *mut robj; 2];
3932 argv[0 as libc::c_int as usize] = if lazy != 0 { shared.unlink } else { shared.del };
3933 argv[1 as libc::c_int as usize] = key;
3934 incrRefCount(argv[0 as libc::c_int as usize]);
3935 incrRefCount(argv[1 as libc::c_int as usize]);
3936 let mut prev_replication_allowed: libc::c_int = server.replication_allowed;
3937 server.replication_allowed = 1 as libc::c_int;
3938 alsoPropagate(
3939 (*db).id,
3940 argv.as_mut_ptr(),
3941 2 as libc::c_int,
3942 1 as libc::c_int | 2 as libc::c_int,
3943 );
3944 server.replication_allowed = prev_replication_allowed;
3945 decrRefCount(argv[0 as libc::c_int as usize]);
3946 decrRefCount(argv[1 as libc::c_int as usize]);
3947}
3948#[no_mangle]
3949pub unsafe extern "C" fn keyIsExpired(
3950 mut db: *mut redisDb,
3951 mut key: *mut robj,
3952) -> libc::c_int {
3953 let mut when: mstime_t = getExpire(db, key);
3954 let mut now: mstime_t = 0;
3955 if when < 0 as libc::c_int as libc::c_longlong {
3956 return 0 as libc::c_int;
3957 }
3958 if server.loading != 0 {
3959 return 0 as libc::c_int;
3960 }
3961 if !(server.script_caller).is_null() {
3962 now = scriptTimeSnapshot();
3963 } else if server.fixed_time_expire > 0 as libc::c_int as libc::c_long {
3964 now = server.mstime;
3965 } else {
3966 now = mstime();
3967 }
3968 return (now > when) as libc::c_int;
3969}
3970#[no_mangle]
3971pub unsafe extern "C" fn expireIfNeeded(
3972 mut db: *mut redisDb,
3973 mut key: *mut robj,
3974 mut flags: libc::c_int,
3975) -> libc::c_int {
3976 if keyIsExpired(db, key) == 0 {
3977 return 0 as libc::c_int;
3978 }
3979 if !(server.masterhost).is_null() {
3980 if server.current_client == server.master {
3981 return 0 as libc::c_int;
3982 }
3983 if flags & 1 as libc::c_int == 0 {
3984 return 1 as libc::c_int;
3985 }
3986 }
3987 if flags & 2 as libc::c_int != 0 {
3988 return 1 as libc::c_int;
3989 }
3990 if checkClientPauseTimeoutAndReturnIfPaused() != 0 {
3991 return 1 as libc::c_int;
3992 }
3993 deleteExpiredKeyAndPropagate(db, key);
3994 return 1 as libc::c_int;
3995}
3996#[no_mangle]
3997pub unsafe extern "C" fn getKeysPrepareResult(
3998 mut result: *mut getKeysResult,
3999 mut numkeys: libc::c_int,
4000) -> *mut keyReference {
4001 if ((*result).keys).is_null() {
4002 if (*result).numkeys == 0 {} else {
4003 _serverAssert(
4004 b"!result->numkeys\0" as *const u8 as *const libc::c_char,
4005 b"db.c\0" as *const u8 as *const libc::c_char,
4006 1733 as libc::c_int,
4007 );
4008 unreachable!();
4009 };
4010 (*result).keys = ((*result).keysbuf).as_mut_ptr();
4011 }
4012 if numkeys > (*result).size {
4013 if (*result).keys != ((*result).keysbuf).as_mut_ptr() {
4014 (*result)
4015 .keys = zrealloc(
4016 (*result).keys as *mut libc::c_void,
4017 (numkeys as libc::c_ulong)
4018 .wrapping_mul(
4019 core::mem::size_of::<keyReference>() as libc::c_ulong,
4020 ),
4021 ) as *mut keyReference;
4022 } else {
4023 (*result)
4024 .keys = zmalloc(
4025 (numkeys as libc::c_ulong)
4026 .wrapping_mul(
4027 core::mem::size_of::<keyReference>() as libc::c_ulong,
4028 ),
4029 ) as *mut keyReference;
4030 if (*result).numkeys != 0 {
4031 memcpy(
4032 (*result).keys as *mut libc::c_void,
4033 ((*result).keysbuf).as_mut_ptr() as *const libc::c_void,
4034 ((*result).numkeys as libc::c_ulong)
4035 .wrapping_mul(
4036 core::mem::size_of::<keyReference>() as libc::c_ulong,
4037 ),
4038 );
4039 }
4040 }
4041 (*result).size = numkeys;
4042 }
4043 return (*result).keys;
4044}
4045#[no_mangle]
4046pub unsafe extern "C" fn getAllKeySpecsFlags(
4047 mut cmd: *mut redisCommand,
4048 mut inv: libc::c_int,
4049) -> int64_t {
4050 let mut flags: int64_t = 0 as libc::c_int as int64_t;
4051 let mut j: libc::c_int = 0 as libc::c_int;
4052 while j < (*cmd).key_specs_num {
4053 let mut spec: *mut keySpec = ((*cmd).key_specs).offset(j as isize);
4054 flags = (flags as libc::c_ulong
4055 | if inv != 0 { !(*spec).flags } else { (*spec).flags }) as int64_t;
4056 j += 1;
4057 }
4058 return flags;
4059}
4060#[no_mangle]
4061pub unsafe extern "C" fn getKeysUsingKeySpecs(
4062 mut cmd: *mut redisCommand,
4063 mut argv: *mut *mut robj,
4064 mut argc: libc::c_int,
4065 mut search_flags: libc::c_int,
4066 mut result: *mut getKeysResult,
4067) -> libc::c_int {
4068 let mut count: libc::c_int = 0;
4069 let mut current_block: u64;
4070 let mut j: libc::c_int = 0;
4071 let mut i: libc::c_int = 0;
4072 let mut k: libc::c_int = 0 as libc::c_int;
4073 let mut last: libc::c_int = 0;
4074 let mut first: libc::c_int = 0;
4075 let mut step: libc::c_int = 0;
4076 let mut keys: *mut keyReference = 0 as *mut keyReference;
4077 j = 0 as libc::c_int;
4078 while j < (*cmd).key_specs_num {
4079 let mut spec: *mut keySpec = ((*cmd).key_specs).offset(j as isize);
4080 if (*spec).begin_search_type as libc::c_uint
4081 != KSPEC_BS_INVALID as libc::c_int as libc::c_uint
4082 {} else {
4083 _serverAssert(
4084 b"spec->begin_search_type != KSPEC_BS_INVALID\0" as *const u8
4085 as *const libc::c_char,
4086 b"db.c\0" as *const u8 as *const libc::c_char,
4087 1778 as libc::c_int,
4088 );
4089 unreachable!();
4090 };
4091 if !((*spec).flags as libc::c_ulonglong
4092 & (1 as libc::c_ulonglong) << 8 as libc::c_int != 0
4093 && search_flags & (1 as libc::c_int) << 0 as libc::c_int == 0)
4094 {
4095 first = 0 as libc::c_int;
4096 if (*spec).begin_search_type as libc::c_uint
4097 == KSPEC_BS_INDEX as libc::c_int as libc::c_uint
4098 {
4099 first = (*spec).bs.index.pos;
4100 current_block = 6009453772311597924;
4101 } else if (*spec).begin_search_type as libc::c_uint
4102 == KSPEC_BS_KEYWORD as libc::c_int as libc::c_uint
4103 {
4104 let mut start_index: libc::c_int = if (*spec).bs.keyword.startfrom
4105 > 0 as libc::c_int
4106 {
4107 (*spec).bs.keyword.startfrom
4108 } else {
4109 argc + (*spec).bs.keyword.startfrom
4110 };
4111 let mut end_index: libc::c_int = if (*spec).bs.keyword.startfrom
4112 > 0 as libc::c_int
4113 {
4114 argc - 1 as libc::c_int
4115 } else {
4116 1 as libc::c_int
4117 };
4118 i = start_index;
4119 while i != end_index {
4120 if i >= argc || i < 1 as libc::c_int {
4121 break;
4122 }
4123 if strcasecmp(
4124 (**argv.offset(i as isize)).ptr as *mut libc::c_char,
4125 (*spec).bs.keyword.keyword,
4126 ) == 0
4127 {
4128 first = i + 1 as libc::c_int;
4129 break;
4130 } else {
4131 i = if start_index <= end_index {
4132 i + 1 as libc::c_int
4133 } else {
4134 i - 1 as libc::c_int
4135 };
4136 }
4137 }
4138 if first == 0 {
4139 current_block = 16668937799742929182;
4140 } else {
4141 current_block = 6009453772311597924;
4142 }
4143 } else {
4144 current_block = 6370670150452288782;
4145 }
4146 match current_block {
4147 16668937799742929182 => {}
4148 _ => {
4149 match current_block {
4150 6009453772311597924 => {
4151 if (*spec).find_keys_type as libc::c_uint
4152 == KSPEC_FK_RANGE as libc::c_int as libc::c_uint
4153 {
4154 step = (*spec).fk.range.keystep;
4155 if (*spec).fk.range.lastkey >= 0 as libc::c_int {
4156 last = first + (*spec).fk.range.lastkey;
4157 } else if (*spec).fk.range.limit == 0 {
4158 last = argc + (*spec).fk.range.lastkey;
4159 } else {
4160 if (*spec).fk.range.lastkey == -(1 as libc::c_int) {} else {
4161 _serverAssert(
4162 b"spec->fk.range.lastkey == -1\0" as *const u8
4163 as *const libc::c_char,
4164 b"db.c\0" as *const u8 as *const libc::c_char,
4165 1815 as libc::c_int,
4166 );
4167 unreachable!();
4168 };
4169 last = first
4170 + ((argc - first) / (*spec).fk.range.limit
4171 + (*spec).fk.range.lastkey);
4172 }
4173 current_block = 7828949454673616476;
4174 } else if (*spec).find_keys_type as libc::c_uint
4175 == KSPEC_FK_KEYNUM as libc::c_int as libc::c_uint
4176 {
4177 step = (*spec).fk.keynum.keystep;
4178 let mut numkeys: libc::c_longlong = 0;
4179 if (*spec).fk.keynum.keynumidx >= argc {
4180 current_block = 6370670150452288782;
4181 } else {
4182 let mut keynum_str: sds = (**argv
4183 .offset((first + (*spec).fk.keynum.keynumidx) as isize))
4184 .ptr as sds;
4185 if string2ll(
4186 keynum_str as *const libc::c_char,
4187 sdslen(keynum_str),
4188 &mut numkeys,
4189 ) == 0 || numkeys < 0 as libc::c_int as libc::c_longlong
4190 {
4191 current_block = 6370670150452288782;
4192 } else {
4193 first += (*spec).fk.keynum.firstkey;
4194 last = first + numkeys as libc::c_int - 1 as libc::c_int;
4195 current_block = 7828949454673616476;
4196 }
4197 }
4198 } else {
4199 current_block = 6370670150452288782;
4200 }
4201 match current_block {
4202 6370670150452288782 => {}
4203 _ => {
4204 count = last - first + 1 as libc::c_int;
4205 keys = getKeysPrepareResult(result, count);
4206 if last >= argc || last < first || first >= argc {
4207 current_block = 6370670150452288782;
4208 } else {
4209 let mut current_block_28: u64;
4210 i = first;
4211 while i <= last {
4212 if i >= argc || i < first {
4213 if (*cmd).flags as libc::c_ulonglong
4214 & (1 as libc::c_ulonglong) << 3 as libc::c_int != 0
4215 || (*cmd).arity < 0 as libc::c_int
4216 {
4217 current_block_28 = 7746103178988627676;
4218 } else {
4219 _serverPanic(
4220 b"db.c\0" as *const u8 as *const libc::c_char,
4221 1857 as libc::c_int,
4222 b"Redis built-in command declared keys positions not matching the arity requirements.\0"
4223 as *const u8 as *const libc::c_char,
4224 );
4225 unreachable!();
4226 current_block_28 = 3938820862080741272;
4227 }
4228 } else {
4229 current_block_28 = 3938820862080741272;
4230 }
4231 match current_block_28 {
4232 3938820862080741272 => {
4233 (*keys.offset(k as isize)).pos = i;
4234 let fresh5 = k;
4235 k = k + 1;
4236 (*keys.offset(fresh5 as isize))
4237 .flags = (*spec).flags as libc::c_int;
4238 }
4239 _ => {}
4240 }
4241 i += step;
4242 }
4243 if (*spec).flags as libc::c_ulonglong
4244 & (1 as libc::c_ulonglong) << 9 as libc::c_int != 0
4245 {
4246 current_block = 6370670150452288782;
4247 } else {
4248 current_block = 16668937799742929182;
4249 }
4250 }
4251 }
4252 }
4253 }
4254 _ => {}
4255 }
4256 match current_block {
4257 16668937799742929182 => {}
4258 _ => {
4259 if !(search_flags & (1 as libc::c_int) << 1 as libc::c_int
4260 != 0)
4261 {
4262 (*result).numkeys = 0 as libc::c_int;
4263 return -(1 as libc::c_int);
4264 }
4265 }
4266 }
4267 }
4268 }
4269 }
4270 j += 1;
4271 }
4272 (*result).numkeys = k;
4273 return k;
4274}
4275#[no_mangle]
4276pub unsafe extern "C" fn getKeysFromCommandWithSpecs(
4277 mut cmd: *mut redisCommand,
4278 mut argv: *mut *mut robj,
4279 mut argc: libc::c_int,
4280 mut search_flags: libc::c_int,
4281 mut result: *mut getKeysResult,
4282) -> libc::c_int {
4283 let mut has_keyspec: libc::c_int = (getAllKeySpecsFlags(cmd, 1 as libc::c_int)
4284 as libc::c_ulonglong & (1 as libc::c_ulonglong) << 8 as libc::c_int)
4285 as libc::c_int;
4286 let mut has_varflags: libc::c_int = (getAllKeySpecsFlags(cmd, 0 as libc::c_int)
4287 as libc::c_ulonglong & (1 as libc::c_ulonglong) << 10 as libc::c_int)
4288 as libc::c_int;
4289 if has_keyspec != 0 && has_varflags == 0 {
4290 let mut ret: libc::c_int = getKeysUsingKeySpecs(
4291 cmd,
4292 argv,
4293 argc,
4294 search_flags,
4295 result,
4296 );
4297 if ret >= 0 as libc::c_int {
4298 return ret;
4299 }
4300 }
4301 if (*cmd).flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 21 as libc::c_int
4302 != 0
4303 {
4304 return moduleGetCommandKeysViaAPI(cmd, argv, argc, result);
4305 }
4306 if ((*cmd).getkeys_proc).is_some() {
4307 return ((*cmd).getkeys_proc)
4308 .expect("non-null function pointer")(cmd, argv, argc, result);
4309 }
4310 return 0 as libc::c_int;
4311}
4312#[no_mangle]
4313pub unsafe extern "C" fn doesCommandHaveKeys(mut cmd: *mut redisCommand) -> libc::c_int {
4314 return (((*cmd).getkeys_proc).is_some()
4315 || (*cmd).flags as libc::c_ulonglong
4316 & (1 as libc::c_ulonglong) << 21 as libc::c_int != 0
4317 || getAllKeySpecsFlags(cmd, 1 as libc::c_int) as libc::c_ulonglong
4318 & (1 as libc::c_ulonglong) << 8 as libc::c_int != 0) as libc::c_int;
4319}
4320#[no_mangle]
4321pub static mut commands_with_channels: [ChannelSpecs; 9] = unsafe {
4322 [
4323 {
4324 let mut init = ChannelSpecs {
4325 proc_0: Some(
4326 subscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4327 ),
4328 flags: ((1 as libc::c_ulonglong) << 12 as libc::c_int) as uint64_t,
4329 start: 1 as libc::c_int,
4330 count: -(1 as libc::c_int),
4331 };
4332 init
4333 },
4334 {
4335 let mut init = ChannelSpecs {
4336 proc_0: Some(
4337 ssubscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4338 ),
4339 flags: ((1 as libc::c_ulonglong) << 12 as libc::c_int) as uint64_t,
4340 start: 1 as libc::c_int,
4341 count: -(1 as libc::c_int),
4342 };
4343 init
4344 },
4345 {
4346 let mut init = ChannelSpecs {
4347 proc_0: Some(
4348 unsubscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4349 ),
4350 flags: ((1 as libc::c_ulonglong) << 13 as libc::c_int) as uint64_t,
4351 start: 1 as libc::c_int,
4352 count: -(1 as libc::c_int),
4353 };
4354 init
4355 },
4356 {
4357 let mut init = ChannelSpecs {
4358 proc_0: Some(
4359 sunsubscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4360 ),
4361 flags: ((1 as libc::c_ulonglong) << 13 as libc::c_int) as uint64_t,
4362 start: 1 as libc::c_int,
4363 count: -(1 as libc::c_int),
4364 };
4365 init
4366 },
4367 {
4368 let mut init = ChannelSpecs {
4369 proc_0: Some(
4370 psubscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4371 ),
4372 flags: ((1 as libc::c_ulonglong) << 11 as libc::c_int
4373 | (1 as libc::c_ulonglong) << 12 as libc::c_int) as uint64_t,
4374 start: 1 as libc::c_int,
4375 count: -(1 as libc::c_int),
4376 };
4377 init
4378 },
4379 {
4380 let mut init = ChannelSpecs {
4381 proc_0: Some(
4382 punsubscribeCommand as unsafe extern "C" fn(*mut client) -> (),
4383 ),
4384 flags: ((1 as libc::c_ulonglong) << 11 as libc::c_int
4385 | (1 as libc::c_ulonglong) << 13 as libc::c_int) as uint64_t,
4386 start: 1 as libc::c_int,
4387 count: -(1 as libc::c_int),
4388 };
4389 init
4390 },
4391 {
4392 let mut init = ChannelSpecs {
4393 proc_0: Some(publishCommand as unsafe extern "C" fn(*mut client) -> ()),
4394 flags: ((1 as libc::c_ulonglong) << 14 as libc::c_int) as uint64_t,
4395 start: 1 as libc::c_int,
4396 count: 1 as libc::c_int,
4397 };
4398 init
4399 },
4400 {
4401 let mut init = ChannelSpecs {
4402 proc_0: Some(spublishCommand as unsafe extern "C" fn(*mut client) -> ()),
4403 flags: ((1 as libc::c_ulonglong) << 14 as libc::c_int) as uint64_t,
4404 start: 1 as libc::c_int,
4405 count: 1 as libc::c_int,
4406 };
4407 init
4408 },
4409 {
4410 let mut init = ChannelSpecs {
4411 proc_0: None,
4412 flags: 0 as libc::c_int as uint64_t,
4413 start: 0,
4414 count: 0,
4415 };
4416 init
4417 },
4418 ]
4419};
4420#[no_mangle]
4421pub unsafe extern "C" fn doesCommandHaveChannelsWithFlags(
4422 mut cmd: *mut redisCommand,
4423 mut flags: libc::c_int,
4424) -> libc::c_int {
4425 if (*cmd).flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 27 as libc::c_int
4426 != 0
4427 {
4428 return 1 as libc::c_int;
4429 }
4430 let mut spec: *mut ChannelSpecs = commands_with_channels.as_mut_ptr();
4431 while ((*spec).proc_0).is_some() {
4432 if (*cmd).proc_0 == (*spec).proc_0 {
4433 return ((*spec).flags & flags as libc::c_ulong != 0) as libc::c_int;
4434 }
4435 spec = spec.offset(1 as libc::c_int as isize);
4436 }
4437 return 0 as libc::c_int;
4438}
4439#[no_mangle]
4440pub unsafe extern "C" fn getChannelsFromCommand(
4441 mut cmd: *mut redisCommand,
4442 mut argv: *mut *mut robj,
4443 mut argc: libc::c_int,
4444 mut result: *mut getKeysResult,
4445) -> libc::c_int {
4446 let mut keys: *mut keyReference = 0 as *mut keyReference;
4447 if (*cmd).flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 27 as libc::c_int
4448 != 0
4449 {
4450 return moduleGetCommandChannelsViaAPI(cmd, argv, argc, result);
4451 }
4452 let mut spec: *mut ChannelSpecs = commands_with_channels.as_mut_ptr();
4453 while !spec.is_null() {
4454 if (*cmd).proc_0 == (*spec).proc_0 {
4455 let mut start: libc::c_int = (*spec).start;
4456 let mut stop: libc::c_int = if (*spec).count == -(1 as libc::c_int) {
4457 argc
4458 } else {
4459 start + (*spec).count
4460 };
4461 if stop > argc {
4462 stop = argc;
4463 }
4464 let mut count: libc::c_int = 0 as libc::c_int;
4465 keys = getKeysPrepareResult(result, stop - start);
4466 let mut i: libc::c_int = start;
4467 while i < stop {
4468 (*keys.offset(count as isize)).pos = i;
4469 let fresh6 = count;
4470 count = count + 1;
4471 (*keys.offset(fresh6 as isize)).flags = (*spec).flags as libc::c_int;
4472 i += 1;
4473 }
4474 (*result).numkeys = count;
4475 return count;
4476 }
4477 spec = spec.offset(1 as libc::c_int as isize);
4478 }
4479 return 0 as libc::c_int;
4480}
4481#[no_mangle]
4482pub unsafe extern "C" fn getKeysUsingLegacyRangeSpec(
4483 mut cmd: *mut redisCommand,
4484 mut argv: *mut *mut robj,
4485 mut argc: libc::c_int,
4486 mut result: *mut getKeysResult,
4487) -> libc::c_int {
4488 let mut j: libc::c_int = 0;
4489 let mut i: libc::c_int = 0 as libc::c_int;
4490 let mut last: libc::c_int = 0;
4491 let mut first: libc::c_int = 0;
4492 let mut step: libc::c_int = 0;
4493 let mut keys: *mut keyReference = 0 as *mut keyReference;
4494 if (*cmd).legacy_range_key_spec.begin_search_type as libc::c_uint
4495 == KSPEC_BS_INVALID as libc::c_int as libc::c_uint
4496 {
4497 (*result).numkeys = 0 as libc::c_int;
4498 return 0 as libc::c_int;
4499 }
4500 first = (*cmd).legacy_range_key_spec.bs.index.pos;
4501 last = (*cmd).legacy_range_key_spec.fk.range.lastkey;
4502 if last >= 0 as libc::c_int {
4503 last += first;
4504 }
4505 step = (*cmd).legacy_range_key_spec.fk.range.keystep;
4506 if last < 0 as libc::c_int {
4507 last = argc + last;
4508 }
4509 let mut count: libc::c_int = last - first + 1 as libc::c_int;
4510 keys = getKeysPrepareResult(result, count);
4511 j = first;
4512 while j <= last {
4513 if j >= argc || j < first {
4514 if (*cmd).flags as libc::c_ulonglong
4515 & (1 as libc::c_ulonglong) << 3 as libc::c_int != 0
4516 || (*cmd).arity < 0 as libc::c_int
4517 {
4518 (*result).numkeys = 0 as libc::c_int;
4519 return 0 as libc::c_int;
4520 } else {
4521 _serverPanic(
4522 b"db.c\0" as *const u8 as *const libc::c_char,
4523 2050 as libc::c_int,
4524 b"Redis built-in command declared keys positions not matching the arity requirements.\0"
4525 as *const u8 as *const libc::c_char,
4526 );
4527 unreachable!();
4528 }
4529 }
4530 (*keys.offset(i as isize)).pos = j;
4531 let fresh7 = i;
4532 i = i + 1;
4533 (*keys.offset(fresh7 as isize)).flags = 0 as libc::c_int;
4534 j += step;
4535 }
4536 (*result).numkeys = i;
4537 return i;
4538}
4539#[no_mangle]
4540pub unsafe extern "C" fn getKeysFromCommand(
4541 mut cmd: *mut redisCommand,
4542 mut argv: *mut *mut robj,
4543 mut argc: libc::c_int,
4544 mut result: *mut getKeysResult,
4545) -> libc::c_int {
4546 if (*cmd).flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 21 as libc::c_int
4547 != 0
4548 {
4549 return moduleGetCommandKeysViaAPI(cmd, argv, argc, result)
4550 } else if ((*cmd).getkeys_proc).is_some() {
4551 return ((*cmd).getkeys_proc)
4552 .expect("non-null function pointer")(cmd, argv, argc, result)
4553 } else {
4554 return getKeysUsingLegacyRangeSpec(cmd, argv, argc, result)
4555 };
4556}
4557#[no_mangle]
4558pub unsafe extern "C" fn getKeysFreeResult(mut result: *mut getKeysResult) {
4559 if !result.is_null() && (*result).keys != ((*result).keysbuf).as_mut_ptr() {
4560 zfree((*result).keys as *mut libc::c_void);
4561 }
4562}
4563#[no_mangle]
4564pub unsafe extern "C" fn genericGetKeys(
4565 mut storeKeyOfs: libc::c_int,
4566 mut keyCountOfs: libc::c_int,
4567 mut firstKeyOfs: libc::c_int,
4568 mut keyStep: libc::c_int,
4569 mut argv: *mut *mut robj,
4570 mut argc: libc::c_int,
4571 mut result: *mut getKeysResult,
4572) -> libc::c_int {
4573 let mut i: libc::c_int = 0;
4574 let mut num: libc::c_int = 0;
4575 let mut keys: *mut keyReference = 0 as *mut keyReference;
4576 num = atoi((**argv.offset(keyCountOfs as isize)).ptr as *const libc::c_char);
4577 if num < 1 as libc::c_int || num > (argc - firstKeyOfs) / keyStep {
4578 (*result).numkeys = 0 as libc::c_int;
4579 return 0 as libc::c_int;
4580 }
4581 let mut numkeys: libc::c_int = if storeKeyOfs != 0 {
4582 num + 1 as libc::c_int
4583 } else {
4584 num
4585 };
4586 keys = getKeysPrepareResult(result, numkeys);
4587 (*result).numkeys = numkeys;
4588 i = 0 as libc::c_int;
4589 while i < num {
4590 (*keys.offset(i as isize)).pos = firstKeyOfs + i * keyStep;
4591 (*keys.offset(i as isize)).flags = 0 as libc::c_int;
4592 i += 1;
4593 }
4594 if storeKeyOfs != 0 {
4595 (*keys.offset(num as isize)).pos = storeKeyOfs;
4596 (*keys.offset(num as isize)).flags = 0 as libc::c_int;
4597 }
4598 return (*result).numkeys;
4599}
4600#[no_mangle]
4601pub unsafe extern "C" fn sintercardGetKeys(
4602 mut cmd: *mut redisCommand,
4603 mut argv: *mut *mut robj,
4604 mut argc: libc::c_int,
4605 mut result: *mut getKeysResult,
4606) -> libc::c_int {
4607 return genericGetKeys(
4608 0 as libc::c_int,
4609 1 as libc::c_int,
4610 2 as libc::c_int,
4611 1 as libc::c_int,
4612 argv,
4613 argc,
4614 result,
4615 );
4616}
4617#[no_mangle]
4618pub unsafe extern "C" fn zunionInterDiffStoreGetKeys(
4619 mut cmd: *mut redisCommand,
4620 mut argv: *mut *mut robj,
4621 mut argc: libc::c_int,
4622 mut result: *mut getKeysResult,
4623) -> libc::c_int {
4624 return genericGetKeys(
4625 1 as libc::c_int,
4626 2 as libc::c_int,
4627 3 as libc::c_int,
4628 1 as libc::c_int,
4629 argv,
4630 argc,
4631 result,
4632 );
4633}
4634#[no_mangle]
4635pub unsafe extern "C" fn zunionInterDiffGetKeys(
4636 mut cmd: *mut redisCommand,
4637 mut argv: *mut *mut robj,
4638 mut argc: libc::c_int,
4639 mut result: *mut getKeysResult,
4640) -> libc::c_int {
4641 return genericGetKeys(
4642 0 as libc::c_int,
4643 1 as libc::c_int,
4644 2 as libc::c_int,
4645 1 as libc::c_int,
4646 argv,
4647 argc,
4648 result,
4649 );
4650}
4651#[no_mangle]
4652pub unsafe extern "C" fn evalGetKeys(
4653 mut cmd: *mut redisCommand,
4654 mut argv: *mut *mut robj,
4655 mut argc: libc::c_int,
4656 mut result: *mut getKeysResult,
4657) -> libc::c_int {
4658 return genericGetKeys(
4659 0 as libc::c_int,
4660 2 as libc::c_int,
4661 3 as libc::c_int,
4662 1 as libc::c_int,
4663 argv,
4664 argc,
4665 result,
4666 );
4667}
4668#[no_mangle]
4669pub unsafe extern "C" fn functionGetKeys(
4670 mut cmd: *mut redisCommand,
4671 mut argv: *mut *mut robj,
4672 mut argc: libc::c_int,
4673 mut result: *mut getKeysResult,
4674) -> libc::c_int {
4675 return genericGetKeys(
4676 0 as libc::c_int,
4677 2 as libc::c_int,
4678 3 as libc::c_int,
4679 1 as libc::c_int,
4680 argv,
4681 argc,
4682 result,
4683 );
4684}
4685#[no_mangle]
4686pub unsafe extern "C" fn lmpopGetKeys(
4687 mut cmd: *mut redisCommand,
4688 mut argv: *mut *mut robj,
4689 mut argc: libc::c_int,
4690 mut result: *mut getKeysResult,
4691) -> libc::c_int {
4692 return genericGetKeys(
4693 0 as libc::c_int,
4694 1 as libc::c_int,
4695 2 as libc::c_int,
4696 1 as libc::c_int,
4697 argv,
4698 argc,
4699 result,
4700 );
4701}
4702#[no_mangle]
4703pub unsafe extern "C" fn blmpopGetKeys(
4704 mut cmd: *mut redisCommand,
4705 mut argv: *mut *mut robj,
4706 mut argc: libc::c_int,
4707 mut result: *mut getKeysResult,
4708) -> libc::c_int {
4709 return genericGetKeys(
4710 0 as libc::c_int,
4711 2 as libc::c_int,
4712 3 as libc::c_int,
4713 1 as libc::c_int,
4714 argv,
4715 argc,
4716 result,
4717 );
4718}
4719#[no_mangle]
4720pub unsafe extern "C" fn zmpopGetKeys(
4721 mut cmd: *mut redisCommand,
4722 mut argv: *mut *mut robj,
4723 mut argc: libc::c_int,
4724 mut result: *mut getKeysResult,
4725) -> libc::c_int {
4726 return genericGetKeys(
4727 0 as libc::c_int,
4728 1 as libc::c_int,
4729 2 as libc::c_int,
4730 1 as libc::c_int,
4731 argv,
4732 argc,
4733 result,
4734 );
4735}
4736#[no_mangle]
4737pub unsafe extern "C" fn bzmpopGetKeys(
4738 mut cmd: *mut redisCommand,
4739 mut argv: *mut *mut robj,
4740 mut argc: libc::c_int,
4741 mut result: *mut getKeysResult,
4742) -> libc::c_int {
4743 return genericGetKeys(
4744 0 as libc::c_int,
4745 2 as libc::c_int,
4746 3 as libc::c_int,
4747 1 as libc::c_int,
4748 argv,
4749 argc,
4750 result,
4751 );
4752}
4753#[no_mangle]
4754pub unsafe extern "C" fn sortROGetKeys(
4755 mut cmd: *mut redisCommand,
4756 mut argv: *mut *mut robj,
4757 mut argc: libc::c_int,
4758 mut result: *mut getKeysResult,
4759) -> libc::c_int {
4760 let mut keys: *mut keyReference = 0 as *mut keyReference;
4761 keys = getKeysPrepareResult(result, 1 as libc::c_int);
4762 (*keys.offset(0 as libc::c_int as isize)).pos = 1 as libc::c_int;
4763 (*keys.offset(0 as libc::c_int as isize))
4764 .flags = ((1 as libc::c_ulonglong) << 0 as libc::c_int
4765 | (1 as libc::c_ulonglong) << 4 as libc::c_int) as libc::c_int;
4766 return 1 as libc::c_int;
4767}
4768#[no_mangle]
4769pub unsafe extern "C" fn sortGetKeys(
4770 mut cmd: *mut redisCommand,
4771 mut argv: *mut *mut robj,
4772 mut argc: libc::c_int,
4773 mut result: *mut getKeysResult,
4774) -> libc::c_int {
4775 let mut i: libc::c_int = 0;
4776 let mut j: libc::c_int = 0;
4777 let mut num: libc::c_int = 0;
4778 let mut found_store: libc::c_int = 0 as libc::c_int;
4779 let mut keys: *mut keyReference = 0 as *mut keyReference;
4780 num = 0 as libc::c_int;
4781 keys = getKeysPrepareResult(result, 2 as libc::c_int);
4782 (*keys.offset(num as isize)).pos = 1 as libc::c_int;
4783 let fresh8 = num;
4784 num = num + 1;
4785 (*keys.offset(fresh8 as isize))
4786 .flags = ((1 as libc::c_ulonglong) << 0 as libc::c_int
4787 | (1 as libc::c_ulonglong) << 4 as libc::c_int) as libc::c_int;
4788 let mut skiplist: [C2RustUnnamed_12; 4] = [
4789 {
4790 let mut init = C2RustUnnamed_12 {
4791 name: b"limit\0" as *const u8 as *const libc::c_char
4792 as *mut libc::c_char,
4793 skip: 2 as libc::c_int,
4794 };
4795 init
4796 },
4797 {
4798 let mut init = C2RustUnnamed_12 {
4799 name: b"get\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4800 skip: 1 as libc::c_int,
4801 };
4802 init
4803 },
4804 {
4805 let mut init = C2RustUnnamed_12 {
4806 name: b"by\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4807 skip: 1 as libc::c_int,
4808 };
4809 init
4810 },
4811 {
4812 let mut init = C2RustUnnamed_12 {
4813 name: 0 as *mut libc::c_char,
4814 skip: 0 as libc::c_int,
4815 };
4816 init
4817 },
4818 ];
4819 i = 2 as libc::c_int;
4820 while i < argc {
4821 j = 0 as libc::c_int;
4822 while !(skiplist[j as usize].name).is_null() {
4823 if strcasecmp(
4824 (**argv.offset(i as isize)).ptr as *const libc::c_char,
4825 skiplist[j as usize].name,
4826 ) == 0
4827 {
4828 i += skiplist[j as usize].skip;
4829 break;
4830 } else if strcasecmp(
4831 (**argv.offset(i as isize)).ptr as *const libc::c_char,
4832 b"store\0" as *const u8 as *const libc::c_char,
4833 ) == 0 && (i + 1 as libc::c_int) < argc
4834 {
4835 found_store = 1 as libc::c_int;
4836 (*keys.offset(num as isize)).pos = i + 1 as libc::c_int;
4837 (*keys.offset(num as isize))
4838 .flags = ((1 as libc::c_ulonglong) << 2 as libc::c_int
4839 | (1 as libc::c_ulonglong) << 5 as libc::c_int) as libc::c_int;
4840 break;
4841 } else {
4842 j += 1;
4843 }
4844 }
4845 i += 1;
4846 }
4847 (*result).numkeys = num + found_store;
4848 return (*result).numkeys;
4849}
4850#[no_mangle]
4851pub unsafe extern "C" fn migrateGetKeys(
4852 mut cmd: *mut redisCommand,
4853 mut argv: *mut *mut robj,
4854 mut argc: libc::c_int,
4855 mut result: *mut getKeysResult,
4856) -> libc::c_int {
4857 let mut i: libc::c_int = 0;
4858 let mut j: libc::c_int = 0;
4859 let mut num: libc::c_int = 0;
4860 let mut first: libc::c_int = 0;
4861 let mut keys: *mut keyReference = 0 as *mut keyReference;
4862 first = 3 as libc::c_int;
4863 num = 1 as libc::c_int;
4864 let mut skip_keywords: [C2RustUnnamed_13; 5] = [
4865 {
4866 let mut init = C2RustUnnamed_13 {
4867 name: b"copy\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4868 skip: 0 as libc::c_int,
4869 };
4870 init
4871 },
4872 {
4873 let mut init = C2RustUnnamed_13 {
4874 name: b"replace\0" as *const u8 as *const libc::c_char
4875 as *mut libc::c_char,
4876 skip: 0 as libc::c_int,
4877 };
4878 init
4879 },
4880 {
4881 let mut init = C2RustUnnamed_13 {
4882 name: b"auth\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4883 skip: 1 as libc::c_int,
4884 };
4885 init
4886 },
4887 {
4888 let mut init = C2RustUnnamed_13 {
4889 name: b"auth2\0" as *const u8 as *const libc::c_char
4890 as *mut libc::c_char,
4891 skip: 2 as libc::c_int,
4892 };
4893 init
4894 },
4895 {
4896 let mut init = C2RustUnnamed_13 {
4897 name: 0 as *mut libc::c_char,
4898 skip: 0 as libc::c_int,
4899 };
4900 init
4901 },
4902 ];
4903 if argc > 6 as libc::c_int {
4904 i = 6 as libc::c_int;
4905 while i < argc {
4906 if strcasecmp(
4907 (**argv.offset(i as isize)).ptr as *const libc::c_char,
4908 b"keys\0" as *const u8 as *const libc::c_char,
4909 ) == 0
4910 {
4911 if sdslen((**argv.offset(3 as libc::c_int as isize)).ptr as sds)
4912 > 0 as libc::c_int as libc::c_ulong
4913 {
4914 num = 0 as libc::c_int;
4915 } else {
4916 first = i + 1 as libc::c_int;
4917 num = argc - first;
4918 }
4919 break;
4920 } else {
4921 j = 0 as libc::c_int;
4922 while !(skip_keywords[j as usize].name).is_null() {
4923 if strcasecmp(
4924 (**argv.offset(i as isize)).ptr as *const libc::c_char,
4925 skip_keywords[j as usize].name,
4926 ) == 0
4927 {
4928 i += skip_keywords[j as usize].skip;
4929 break;
4930 } else {
4931 j += 1;
4932 }
4933 }
4934 i += 1;
4935 }
4936 }
4937 }
4938 keys = getKeysPrepareResult(result, num);
4939 i = 0 as libc::c_int;
4940 while i < num {
4941 (*keys.offset(i as isize)).pos = first + i;
4942 (*keys.offset(i as isize))
4943 .flags = ((1 as libc::c_ulonglong) << 1 as libc::c_int
4944 | (1 as libc::c_ulonglong) << 4 as libc::c_int
4945 | (1 as libc::c_ulonglong) << 7 as libc::c_int) as libc::c_int;
4946 i += 1;
4947 }
4948 (*result).numkeys = num;
4949 return num;
4950}
4951#[no_mangle]
4952pub unsafe extern "C" fn georadiusGetKeys(
4953 mut cmd: *mut redisCommand,
4954 mut argv: *mut *mut robj,
4955 mut argc: libc::c_int,
4956 mut result: *mut getKeysResult,
4957) -> libc::c_int {
4958 let mut i: libc::c_int = 0;
4959 let mut num: libc::c_int = 0;
4960 let mut keys: *mut keyReference = 0 as *mut keyReference;
4961 let mut stored_key: libc::c_int = -(1 as libc::c_int);
4962 i = 5 as libc::c_int;
4963 while i < argc {
4964 let mut arg: *mut libc::c_char = (**argv.offset(i as isize)).ptr
4965 as *mut libc::c_char;
4966 if (strcasecmp(arg, b"store\0" as *const u8 as *const libc::c_char) == 0
4967 || strcasecmp(arg, b"storedist\0" as *const u8 as *const libc::c_char) == 0)
4968 && (i + 1 as libc::c_int) < argc
4969 {
4970 stored_key = i + 1 as libc::c_int;
4971 i += 1;
4972 }
4973 i += 1;
4974 }
4975 num = 1 as libc::c_int
4976 + (if stored_key == -(1 as libc::c_int) {
4977 0 as libc::c_int
4978 } else {
4979 1 as libc::c_int
4980 });
4981 keys = getKeysPrepareResult(result, num);
4982 (*keys.offset(0 as libc::c_int as isize)).pos = 1 as libc::c_int;
4983 (*keys.offset(0 as libc::c_int as isize)).flags = 0 as libc::c_int;
4984 if num > 1 as libc::c_int {
4985 (*keys.offset(1 as libc::c_int as isize)).pos = stored_key;
4986 (*keys.offset(1 as libc::c_int as isize)).flags = 0 as libc::c_int;
4987 }
4988 (*result).numkeys = num;
4989 return num;
4990}
4991#[no_mangle]
4992pub unsafe extern "C" fn xreadGetKeys(
4993 mut cmd: *mut redisCommand,
4994 mut argv: *mut *mut robj,
4995 mut argc: libc::c_int,
4996 mut result: *mut getKeysResult,
4997) -> libc::c_int {
4998 let mut i: libc::c_int = 0;
4999 let mut num: libc::c_int = 0 as libc::c_int;
5000 let mut keys: *mut keyReference = 0 as *mut keyReference;
5001 let mut streams_pos: libc::c_int = -(1 as libc::c_int);
5002 i = 1 as libc::c_int;
5003 while i < argc {
5004 let mut arg: *mut libc::c_char = (**argv.offset(i as isize)).ptr
5005 as *mut libc::c_char;
5006 if strcasecmp(arg, b"block\0" as *const u8 as *const libc::c_char) == 0 {
5007 i += 1;
5008 } else if strcasecmp(arg, b"count\0" as *const u8 as *const libc::c_char) == 0 {
5009 i += 1;
5010 } else if strcasecmp(arg, b"group\0" as *const u8 as *const libc::c_char) == 0 {
5011 i += 2 as libc::c_int;
5012 } else if !(strcasecmp(arg, b"noack\0" as *const u8 as *const libc::c_char) == 0)
5013 {
5014 if !(strcasecmp(arg, b"streams\0" as *const u8 as *const libc::c_char) == 0)
5015 {
5016 break;
5017 }
5018 streams_pos = i;
5019 break;
5020 }
5021 i += 1;
5022 }
5023 if streams_pos != -(1 as libc::c_int) {
5024 num = argc - streams_pos - 1 as libc::c_int;
5025 }
5026 if streams_pos == -(1 as libc::c_int) || num == 0 as libc::c_int
5027 || num % 2 as libc::c_int != 0 as libc::c_int
5028 {
5029 (*result).numkeys = 0 as libc::c_int;
5030 return 0 as libc::c_int;
5031 }
5032 num /= 2 as libc::c_int;
5033 keys = getKeysPrepareResult(result, num);
5034 i = streams_pos + 1 as libc::c_int;
5035 while i < argc - num {
5036 (*keys.offset((i - streams_pos - 1 as libc::c_int) as isize)).pos = i;
5037 (*keys.offset((i - streams_pos - 1 as libc::c_int) as isize))
5038 .flags = 0 as libc::c_int;
5039 i += 1;
5040 }
5041 (*result).numkeys = num;
5042 return num;
5043}
5044#[no_mangle]
5045pub unsafe extern "C" fn setGetKeys(
5046 mut cmd: *mut redisCommand,
5047 mut argv: *mut *mut robj,
5048 mut argc: libc::c_int,
5049 mut result: *mut getKeysResult,
5050) -> libc::c_int {
5051 let mut keys: *mut keyReference = 0 as *mut keyReference;
5052 keys = getKeysPrepareResult(result, 1 as libc::c_int);
5053 (*keys.offset(0 as libc::c_int as isize)).pos = 1 as libc::c_int;
5054 (*result).numkeys = 1 as libc::c_int;
5055 let mut i: libc::c_int = 3 as libc::c_int;
5056 while i < argc {
5057 let mut arg: *mut libc::c_char = (**argv.offset(i as isize)).ptr
5058 as *mut libc::c_char;
5059 if (*arg.offset(0 as libc::c_int as isize) as libc::c_int == 'g' as i32
5060 || *arg.offset(0 as libc::c_int as isize) as libc::c_int == 'G' as i32)
5061 && (*arg.offset(1 as libc::c_int as isize) as libc::c_int == 'e' as i32
5062 || *arg.offset(1 as libc::c_int as isize) as libc::c_int == 'E' as i32)
5063 && (*arg.offset(2 as libc::c_int as isize) as libc::c_int == 't' as i32
5064 || *arg.offset(2 as libc::c_int as isize) as libc::c_int == 'T' as i32)
5065 && *arg.offset(3 as libc::c_int as isize) as libc::c_int == '\0' as i32
5066 {
5067 (*keys.offset(0 as libc::c_int as isize))
5068 .flags = ((1 as libc::c_ulonglong) << 1 as libc::c_int
5069 | (1 as libc::c_ulonglong) << 4 as libc::c_int
5070 | (1 as libc::c_ulonglong) << 5 as libc::c_int) as libc::c_int;
5071 return 1 as libc::c_int;
5072 }
5073 i += 1;
5074 }
5075 (*keys.offset(0 as libc::c_int as isize))
5076 .flags = ((1 as libc::c_ulonglong) << 2 as libc::c_int
5077 | (1 as libc::c_ulonglong) << 5 as libc::c_int) as libc::c_int;
5078 return 1 as libc::c_int;
5079}
5080#[no_mangle]
5081pub unsafe extern "C" fn bitfieldGetKeys(
5082 mut cmd: *mut redisCommand,
5083 mut argv: *mut *mut robj,
5084 mut argc: libc::c_int,
5085 mut result: *mut getKeysResult,
5086) -> libc::c_int {
5087 let mut keys: *mut keyReference = 0 as *mut keyReference;
5088 let mut readonly: libc::c_int = 1 as libc::c_int;
5089 keys = getKeysPrepareResult(result, 1 as libc::c_int);
5090 (*keys.offset(0 as libc::c_int as isize)).pos = 1 as libc::c_int;
5091 (*result).numkeys = 1 as libc::c_int;
5092 let mut i: libc::c_int = 2 as libc::c_int;
5093 while i < argc {
5094 let mut remargs: libc::c_int = argc - i - 1 as libc::c_int;
5095 let mut arg: *mut libc::c_char = (**argv.offset(i as isize)).ptr
5096 as *mut libc::c_char;
5097 if strcasecmp(arg, b"get\0" as *const u8 as *const libc::c_char) == 0
5098 && remargs >= 2 as libc::c_int
5099 {
5100 i += 2 as libc::c_int;
5101 } else if (strcasecmp(arg, b"set\0" as *const u8 as *const libc::c_char) == 0
5102 || strcasecmp(arg, b"incrby\0" as *const u8 as *const libc::c_char) == 0)
5103 && remargs >= 3 as libc::c_int
5104 {
5105 readonly = 0 as libc::c_int;
5106 i += 3 as libc::c_int;
5107 break;
5108 } else if strcasecmp(arg, b"overflow\0" as *const u8 as *const libc::c_char) == 0
5109 && remargs >= 1 as libc::c_int
5110 {
5111 i += 1 as libc::c_int;
5112 } else {
5113 readonly = 0 as libc::c_int;
5114 break;
5115 }
5116 i += 1;
5117 }
5118 if readonly != 0 {
5119 (*keys.offset(0 as libc::c_int as isize))
5120 .flags = ((1 as libc::c_ulonglong) << 0 as libc::c_int
5121 | (1 as libc::c_ulonglong) << 4 as libc::c_int) as libc::c_int;
5122 } else {
5123 (*keys.offset(0 as libc::c_int as isize))
5124 .flags = ((1 as libc::c_ulonglong) << 1 as libc::c_int
5125 | (1 as libc::c_ulonglong) << 4 as libc::c_int
5126 | (1 as libc::c_ulonglong) << 5 as libc::c_int) as libc::c_int;
5127 }
5128 return 1 as libc::c_int;
5129}