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