redrust/
eval.rs

1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4extern "C" {
5    pub type lua_State;
6    pub type RedisModuleCommand;
7    static mut server: redisServer;
8    static mut shared: sharedObjectsStruct;
9    fn mstime() -> libc::c_longlong;
10    fn exitFromChild(retcode: libc::c_int);
11    fn createClient(conn: *mut connection) -> *mut client;
12    fn freeClientAsync(c: *mut client);
13    fn addReplyBulkCBuffer(c: *mut client, p: *const libc::c_void, len: size_t);
14    fn addReply(c: *mut client, obj: *mut robj);
15    fn addReplyErrorObject(c: *mut client, err: *mut robj);
16    fn addReplyErrorSds(c: *mut client, err: sds);
17    fn addReplyError(c: *mut client, err: *const libc::c_char);
18    fn addReplyArrayLen(c: *mut client, length: libc::c_long);
19    fn addReplyHelp(c: *mut client, help: *mut *const libc::c_char);
20    fn addReplySubcommandSyntaxError(c: *mut client);
21    fn sdsZmallocSize(s: sds) -> size_t;
22    fn getStringObjectSdsUsedMemory(o: *mut robj) -> size_t;
23    fn clientHasPendingReplies(c: *mut client) -> libc::c_int;
24    fn writeToClient(c: *mut client, handler_installed: libc::c_int) -> libc::c_int;
25    fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
26    fn decrRefCount(o: *mut robj);
27    fn incrRefCount(o: *mut robj);
28    fn sdscatprintf(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
29    fn sdscatfmt(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
30    fn sdsrange(s: sds, start: ssize_t, end: ssize_t);
31    fn sdssplitlen(
32        s: *const libc::c_char,
33        len: ssize_t,
34        sep: *const libc::c_char,
35        seplen: libc::c_int,
36        count: *mut libc::c_int,
37    ) -> *mut sds;
38    fn sdsfreesplitres(tokens: *mut sds, count: libc::c_int);
39    fn sdscatrepr(s: sds, p: *const libc::c_char, len: size_t) -> sds;
40    fn sdssplitargs(line: *const libc::c_char, argc: *mut libc::c_int) -> *mut sds;
41    fn sdsmapchars(
42        s: sds,
43        from: *const libc::c_char,
44        to: *const libc::c_char,
45        setlen: size_t,
46    ) -> sds;
47    fn sdsjoinsds(
48        argv: *mut sds,
49        argc: libc::c_int,
50        sep: *const libc::c_char,
51        seplen: size_t,
52    ) -> sds;
53    fn __errno_location() -> *mut libc::c_int;
54    fn connBlock(conn: *mut connection) -> libc::c_int;
55    fn connNonBlock(conn: *mut connection) -> libc::c_int;
56    fn connSendTimeout(conn: *mut connection, ms: libc::c_longlong) -> libc::c_int;
57    fn sdscatsds(s: sds, t: sds) -> sds;
58    fn strtol(
59        _: *const libc::c_char,
60        _: *mut *mut libc::c_char,
61        _: libc::c_int,
62    ) -> libc::c_long;
63    fn abs(_: libc::c_int) -> libc::c_int;
64    fn memcpy(
65        _: *mut libc::c_void,
66        _: *const libc::c_void,
67        _: libc::c_ulong,
68    ) -> *mut libc::c_void;
69    fn memmove(
70        _: *mut libc::c_void,
71        _: *const libc::c_void,
72        _: libc::c_ulong,
73    ) -> *mut libc::c_void;
74    fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
75    fn strncmp(
76        _: *const libc::c_char,
77        _: *const libc::c_char,
78        _: libc::c_ulong,
79    ) -> libc::c_int;
80    fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
81    fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
82    fn strlen(_: *const libc::c_char) -> libc::c_ulong;
83    fn strerror(_: libc::c_int) -> *mut libc::c_char;
84    fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
85    fn lua_close(L: *mut lua_State);
86    fn lua_gettop(L: *mut lua_State) -> libc::c_int;
87    fn lua_settop(L: *mut lua_State, idx: libc::c_int);
88    fn lua_pushvalue(L: *mut lua_State, idx: libc::c_int);
89    fn lua_checkstack(L: *mut lua_State, sz: libc::c_int) -> libc::c_int;
90    fn lua_type(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
91    fn lua_tonumber(L: *mut lua_State, idx: libc::c_int) -> lua_Number;
92    fn lua_toboolean(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
93    fn lua_tolstring(
94        L: *mut lua_State,
95        idx: libc::c_int,
96        len: *mut size_t,
97    ) -> *const libc::c_char;
98    fn lua_topointer(L: *mut lua_State, idx: libc::c_int) -> *const libc::c_void;
99    fn lua_pushnil(L: *mut lua_State);
100    fn lua_pushlstring(L: *mut lua_State, s: *const libc::c_char, l: size_t);
101    fn lua_pushstring(L: *mut lua_State, s: *const libc::c_char);
102    fn lua_pushcclosure(L: *mut lua_State, fn_0: lua_CFunction, n: libc::c_int);
103    fn lua_pushboolean(L: *mut lua_State, b: libc::c_int);
104    fn lua_gettable(L: *mut lua_State, idx: libc::c_int);
105    fn lua_getfield(L: *mut lua_State, idx: libc::c_int, k: *const libc::c_char);
106    fn lua_settable(L: *mut lua_State, idx: libc::c_int);
107    fn lua_setfield(L: *mut lua_State, idx: libc::c_int, k: *const libc::c_char);
108    fn lua_pcall(
109        L: *mut lua_State,
110        nargs: libc::c_int,
111        nresults: libc::c_int,
112        errfunc: libc::c_int,
113    ) -> libc::c_int;
114    fn lua_next(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
115    fn lua_getstack(
116        L: *mut lua_State,
117        level: libc::c_int,
118        ar: *mut lua_Debug,
119    ) -> libc::c_int;
120    fn lua_getinfo(
121        L: *mut lua_State,
122        what: *const libc::c_char,
123        ar: *mut lua_Debug,
124    ) -> libc::c_int;
125    fn lua_getlocal(
126        L: *mut lua_State,
127        ar: *const lua_Debug,
128        n: libc::c_int,
129    ) -> *const libc::c_char;
130    fn kill(__pid: __pid_t, __sig: libc::c_int) -> libc::c_int;
131    fn sigemptyset(__set: *mut sigset_t) -> libc::c_int;
132    fn sigaction(
133        __sig: libc::c_int,
134        __act: *const sigaction,
135        __oact: *mut sigaction,
136    ) -> libc::c_int;
137    fn sdscatlen(s: sds, t: *const libc::c_void, len: size_t) -> sds;
138    fn sdscat(s: sds, t: *const libc::c_char) -> sds;
139    static mut getMonotonicUs: Option::<unsafe extern "C" fn() -> monotime>;
140    fn dictCreate(type_0: *mut dictType) -> *mut dict;
141    fn dictAdd(
142        d: *mut dict,
143        key: *mut libc::c_void,
144        val: *mut libc::c_void,
145    ) -> libc::c_int;
146    fn dictRelease(d: *mut dict);
147    fn dictFind(d: *mut dict, key: *const libc::c_void) -> *mut dictEntry;
148    fn dictGenCaseHashFunction(buf: *const libc::c_uchar, len: size_t) -> uint64_t;
149    fn listCreate() -> *mut list;
150    fn listRelease(list: *mut list);
151    fn listAddNodeTail(list: *mut list, value: *mut libc::c_void) -> *mut list;
152    fn listDelNode(list: *mut list, node: *mut listNode);
153    fn listNext(iter: *mut listIter) -> *mut listNode;
154    fn listSearchKey(list: *mut list, key: *mut libc::c_void) -> *mut listNode;
155    fn listRewind(list: *mut list, li: *mut listIter);
156    fn zmalloc(size: size_t) -> *mut libc::c_void;
157    fn zcalloc(size: size_t) -> *mut libc::c_void;
158    fn zfree(ptr: *mut libc::c_void);
159    fn string2ll(
160        s: *const libc::c_char,
161        slen: size_t,
162        value: *mut libc::c_longlong,
163    ) -> libc::c_int;
164    fn string2l(
165        s: *const libc::c_char,
166        slen: size_t,
167        value: *mut libc::c_long,
168    ) -> libc::c_int;
169    fn SHA1Init(context: *mut SHA1_CTX);
170    fn SHA1Update(context: *mut SHA1_CTX, data: *const libc::c_uchar, len: uint32_t);
171    fn SHA1Final(digest: *mut libc::c_uchar, context: *mut SHA1_CTX);
172    fn sdsfree(s: sds);
173    fn sdsdup(s: sds) -> sds;
174    fn sdsempty() -> sds;
175    fn sdsnew(init: *const libc::c_char) -> sds;
176    fn sdsnewlen(init: *const libc::c_void, initlen: size_t) -> sds;
177    fn getLongLongFromObjectOrReply(
178        c: *mut client,
179        o: *mut robj,
180        target: *mut libc::c_longlong,
181        msg: *const libc::c_char,
182    ) -> libc::c_int;
183    fn replicationFeedMonitors(
184        c: *mut client,
185        monitors: *mut list,
186        dictid: libc::c_int,
187        argv: *mut *mut robj,
188        argc: libc::c_int,
189    );
190    fn redisFork(purpose: libc::c_int) -> libc::c_int;
191    fn _serverLog(level: libc::c_int, fmt: *const libc::c_char, _: ...);
192    fn selectDb(c: *mut client, id: libc::c_int) -> libc::c_int;
193    fn dictSdsDestructor(d: *mut dict, val: *mut libc::c_void);
194    fn dictSdsKeyCaseCompare(
195        d: *mut dict,
196        key1: *const libc::c_void,
197        key2: *const libc::c_void,
198    ) -> libc::c_int;
199    fn _serverAssertWithInfo(
200        c: *const client,
201        o: *const robj,
202        estr: *const libc::c_char,
203        file: *const libc::c_char,
204        line: libc::c_int,
205    );
206    fn _serverAssert(
207        estr: *const libc::c_char,
208        file: *const libc::c_char,
209        line: libc::c_int,
210    );
211    fn freeLuaScriptsAsync(lua_scripts: *mut dict);
212    fn scriptPrepareForRun(
213        r_ctx: *mut scriptRunCtx,
214        engine_client: *mut client,
215        caller: *mut client,
216        funcname: *const libc::c_char,
217        script_flags: uint64_t,
218        ro: libc::c_int,
219    ) -> libc::c_int;
220    fn luaPushError(lua: *mut lua_State, error: *const libc::c_char);
221    fn luaError(lua: *mut lua_State) -> libc::c_int;
222    fn luaGetFromRegistry(
223        lua: *mut lua_State,
224        name: *const libc::c_char,
225    ) -> *mut libc::c_void;
226    static mut scripts_flags_def: [scriptFlag; 0];
227    fn luaCallFunction(
228        r_ctx: *mut scriptRunCtx,
229        lua: *mut lua_State,
230        keys: *mut *mut robj,
231        nkeys: size_t,
232        args: *mut *mut robj,
233        nargs: size_t,
234        debug_enabled: libc::c_int,
235    );
236    fn luaRegisterRedisAPI(lua: *mut lua_State);
237    fn scriptResetRun(r_ctx: *mut scriptRunCtx);
238    fn scriptFlagsToCmdFlags(cmd_flags: uint64_t, script_flags: uint64_t) -> uint64_t;
239    fn scriptKill(c: *mut client, is_eval: libc::c_int);
240    fn luaSetTableProtectionRecursively(lua: *mut lua_State);
241    fn luaMemory(lua: *mut lua_State) -> libc::c_ulong;
242    fn luaSetErrorMetatable(lua: *mut lua_State);
243    fn luaL_newstate() -> *mut lua_State;
244    fn luaL_loadbuffer(
245        L: *mut lua_State,
246        buff: *const libc::c_char,
247        sz: size_t,
248        name: *const libc::c_char,
249    ) -> libc::c_int;
250}
251pub type __uint8_t = libc::c_uchar;
252pub type __int16_t = libc::c_short;
253pub type __uint16_t = libc::c_ushort;
254pub type __int32_t = libc::c_int;
255pub type __uint32_t = libc::c_uint;
256pub type __int64_t = libc::c_long;
257pub type __uint64_t = libc::c_ulong;
258pub type __uint_least64_t = __uint64_t;
259pub type __uid_t = libc::c_uint;
260pub type __mode_t = libc::c_uint;
261pub type __off64_t = libc::c_long;
262pub type __pid_t = libc::c_int;
263pub type __clock_t = libc::c_long;
264pub type __time_t = libc::c_long;
265pub type __ssize_t = libc::c_long;
266pub type __sig_atomic_t = libc::c_int;
267pub type size_t = libc::c_ulong;
268#[derive(Copy, Clone)]
269#[repr(C)]
270pub struct iovec {
271    pub iov_base: *mut libc::c_void,
272    pub iov_len: size_t,
273}
274pub type mode_t = __mode_t;
275pub type off_t = __off64_t;
276pub type pid_t = __pid_t;
277pub type ssize_t = __ssize_t;
278pub type time_t = __time_t;
279pub type int16_t = __int16_t;
280pub type int32_t = __int32_t;
281pub type int64_t = __int64_t;
282#[derive(Copy, Clone)]
283#[repr(C)]
284pub struct __sigset_t {
285    pub __val: [libc::c_ulong; 16],
286}
287pub type sigset_t = __sigset_t;
288pub type pthread_t = libc::c_ulong;
289pub type uint8_t = __uint8_t;
290pub type uint16_t = __uint16_t;
291pub type uint32_t = __uint32_t;
292pub type uint64_t = __uint64_t;
293pub type uint_least64_t = __uint_least64_t;
294pub type sds = *mut libc::c_char;
295#[derive(Copy, Clone)]
296#[repr(C, packed)]
297pub struct sdshdr8 {
298    pub len: uint8_t,
299    pub alloc: uint8_t,
300    pub flags: libc::c_uchar,
301    pub buf: [libc::c_char; 0],
302}
303#[derive(Copy, Clone)]
304#[repr(C, packed)]
305pub struct sdshdr16 {
306    pub len: uint16_t,
307    pub alloc: uint16_t,
308    pub flags: libc::c_uchar,
309    pub buf: [libc::c_char; 0],
310}
311#[derive(Copy, Clone)]
312#[repr(C, packed)]
313pub struct sdshdr32 {
314    pub len: uint32_t,
315    pub alloc: uint32_t,
316    pub flags: libc::c_uchar,
317    pub buf: [libc::c_char; 0],
318}
319#[derive(Copy, Clone)]
320#[repr(C, packed)]
321pub struct sdshdr64 {
322    pub len: uint64_t,
323    pub alloc: uint64_t,
324    pub flags: libc::c_uchar,
325    pub buf: [libc::c_char; 0],
326}
327#[derive(Copy, Clone)]
328#[repr(C)]
329pub struct aeEventLoop {
330    pub maxfd: libc::c_int,
331    pub setsize: libc::c_int,
332    pub timeEventNextId: libc::c_longlong,
333    pub events: *mut aeFileEvent,
334    pub fired: *mut aeFiredEvent,
335    pub timeEventHead: *mut aeTimeEvent,
336    pub stop: libc::c_int,
337    pub apidata: *mut libc::c_void,
338    pub beforesleep: Option::<aeBeforeSleepProc>,
339    pub aftersleep: Option::<aeBeforeSleepProc>,
340    pub flags: libc::c_int,
341}
342pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
343#[derive(Copy, Clone)]
344#[repr(C)]
345pub struct aeTimeEvent {
346    pub id: libc::c_longlong,
347    pub when: monotime,
348    pub timeProc: Option::<aeTimeProc>,
349    pub finalizerProc: Option::<aeEventFinalizerProc>,
350    pub clientData: *mut libc::c_void,
351    pub prev: *mut aeTimeEvent,
352    pub next: *mut aeTimeEvent,
353    pub refcount: libc::c_int,
354}
355pub type aeEventFinalizerProc = unsafe extern "C" fn(
356    *mut aeEventLoop,
357    *mut libc::c_void,
358) -> ();
359pub type aeTimeProc = unsafe extern "C" fn(
360    *mut aeEventLoop,
361    libc::c_longlong,
362    *mut libc::c_void,
363) -> libc::c_int;
364pub type monotime = uint64_t;
365#[derive(Copy, Clone)]
366#[repr(C)]
367pub struct aeFiredEvent {
368    pub fd: libc::c_int,
369    pub mask: libc::c_int,
370}
371#[derive(Copy, Clone)]
372#[repr(C)]
373pub struct aeFileEvent {
374    pub mask: libc::c_int,
375    pub rfileProc: Option::<aeFileProc>,
376    pub wfileProc: Option::<aeFileProc>,
377    pub clientData: *mut libc::c_void,
378}
379pub type aeFileProc = unsafe extern "C" fn(
380    *mut aeEventLoop,
381    libc::c_int,
382    *mut libc::c_void,
383    libc::c_int,
384) -> ();
385#[derive(Copy, Clone)]
386#[repr(C)]
387pub struct connection {
388    pub type_0: *mut ConnectionType,
389    pub state: ConnectionState,
390    pub flags: libc::c_short,
391    pub refs: libc::c_short,
392    pub last_errno: libc::c_int,
393    pub private_data: *mut libc::c_void,
394    pub conn_handler: ConnectionCallbackFunc,
395    pub write_handler: ConnectionCallbackFunc,
396    pub read_handler: ConnectionCallbackFunc,
397    pub fd: libc::c_int,
398}
399pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
400pub type ConnectionState = libc::c_uint;
401pub const CONN_STATE_ERROR: ConnectionState = 5;
402pub const CONN_STATE_CLOSED: ConnectionState = 4;
403pub const CONN_STATE_CONNECTED: ConnectionState = 3;
404pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
405pub const CONN_STATE_CONNECTING: ConnectionState = 1;
406pub const CONN_STATE_NONE: ConnectionState = 0;
407#[derive(Copy, Clone)]
408#[repr(C)]
409pub struct ConnectionType {
410    pub ae_handler: Option::<
411        unsafe extern "C" fn(
412            *mut aeEventLoop,
413            libc::c_int,
414            *mut libc::c_void,
415            libc::c_int,
416        ) -> (),
417    >,
418    pub connect: Option::<
419        unsafe extern "C" fn(
420            *mut connection,
421            *const libc::c_char,
422            libc::c_int,
423            *const libc::c_char,
424            ConnectionCallbackFunc,
425        ) -> libc::c_int,
426    >,
427    pub write: Option::<
428        unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
429    >,
430    pub writev: Option::<
431        unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
432    >,
433    pub read: Option::<
434        unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
435    >,
436    pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
437    pub accept: Option::<
438        unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
439    >,
440    pub set_write_handler: Option::<
441        unsafe extern "C" fn(
442            *mut connection,
443            ConnectionCallbackFunc,
444            libc::c_int,
445        ) -> libc::c_int,
446    >,
447    pub set_read_handler: Option::<
448        unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
449    >,
450    pub get_last_error: Option::<
451        unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
452    >,
453    pub blocking_connect: Option::<
454        unsafe extern "C" fn(
455            *mut connection,
456            *const libc::c_char,
457            libc::c_int,
458            libc::c_longlong,
459        ) -> libc::c_int,
460    >,
461    pub sync_write: Option::<
462        unsafe extern "C" fn(
463            *mut connection,
464            *mut libc::c_char,
465            ssize_t,
466            libc::c_longlong,
467        ) -> ssize_t,
468    >,
469    pub sync_read: Option::<
470        unsafe extern "C" fn(
471            *mut connection,
472            *mut libc::c_char,
473            ssize_t,
474            libc::c_longlong,
475        ) -> ssize_t,
476    >,
477    pub sync_readline: Option::<
478        unsafe extern "C" fn(
479            *mut connection,
480            *mut libc::c_char,
481            ssize_t,
482            libc::c_longlong,
483        ) -> ssize_t,
484    >,
485    pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
486}
487#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
488#[repr(C)]
489pub struct redisObject {
490    #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
491    #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
492    #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
493    pub type_0_encoding_lru: [u8; 4],
494    pub refcount: libc::c_int,
495    pub ptr: *mut libc::c_void,
496}
497pub type __sigval_t = sigval;
498#[derive(Copy, Clone)]
499#[repr(C)]
500pub union sigval {
501    pub sival_int: libc::c_int,
502    pub sival_ptr: *mut libc::c_void,
503}
504pub type atomic_int = libc::c_int;
505pub type atomic_uint = libc::c_uint;
506pub type atomic_llong = libc::c_longlong;
507pub type lua_CFunction = Option::<unsafe extern "C" fn(*mut lua_State) -> libc::c_int>;
508pub type lua_Number = libc::c_double;
509#[derive(Copy, Clone)]
510#[repr(C)]
511pub struct lua_Debug {
512    pub event: libc::c_int,
513    pub name: *const libc::c_char,
514    pub namewhat: *const libc::c_char,
515    pub what: *const libc::c_char,
516    pub source: *const libc::c_char,
517    pub currentline: libc::c_int,
518    pub nups: libc::c_int,
519    pub linedefined: libc::c_int,
520    pub lastlinedefined: libc::c_int,
521    pub short_src: [libc::c_char; 60],
522    pub i_ci: libc::c_int,
523}
524pub type sig_atomic_t = __sig_atomic_t;
525#[derive(Copy, Clone)]
526#[repr(C)]
527pub struct siginfo_t {
528    pub si_signo: libc::c_int,
529    pub si_errno: libc::c_int,
530    pub si_code: libc::c_int,
531    pub __pad0: libc::c_int,
532    pub _sifields: C2RustUnnamed,
533}
534#[derive(Copy, Clone)]
535#[repr(C)]
536pub union C2RustUnnamed {
537    pub _pad: [libc::c_int; 28],
538    pub _kill: C2RustUnnamed_8,
539    pub _timer: C2RustUnnamed_7,
540    pub _rt: C2RustUnnamed_6,
541    pub _sigchld: C2RustUnnamed_5,
542    pub _sigfault: C2RustUnnamed_2,
543    pub _sigpoll: C2RustUnnamed_1,
544    pub _sigsys: C2RustUnnamed_0,
545}
546#[derive(Copy, Clone)]
547#[repr(C)]
548pub struct C2RustUnnamed_0 {
549    pub _call_addr: *mut libc::c_void,
550    pub _syscall: libc::c_int,
551    pub _arch: libc::c_uint,
552}
553#[derive(Copy, Clone)]
554#[repr(C)]
555pub struct C2RustUnnamed_1 {
556    pub si_band: libc::c_long,
557    pub si_fd: libc::c_int,
558}
559#[derive(Copy, Clone)]
560#[repr(C)]
561pub struct C2RustUnnamed_2 {
562    pub si_addr: *mut libc::c_void,
563    pub si_addr_lsb: libc::c_short,
564    pub _bounds: C2RustUnnamed_3,
565}
566#[derive(Copy, Clone)]
567#[repr(C)]
568pub union C2RustUnnamed_3 {
569    pub _addr_bnd: C2RustUnnamed_4,
570    pub _pkey: __uint32_t,
571}
572#[derive(Copy, Clone)]
573#[repr(C)]
574pub struct C2RustUnnamed_4 {
575    pub _lower: *mut libc::c_void,
576    pub _upper: *mut libc::c_void,
577}
578#[derive(Copy, Clone)]
579#[repr(C)]
580pub struct C2RustUnnamed_5 {
581    pub si_pid: __pid_t,
582    pub si_uid: __uid_t,
583    pub si_status: libc::c_int,
584    pub si_utime: __clock_t,
585    pub si_stime: __clock_t,
586}
587#[derive(Copy, Clone)]
588#[repr(C)]
589pub struct C2RustUnnamed_6 {
590    pub si_pid: __pid_t,
591    pub si_uid: __uid_t,
592    pub si_sigval: __sigval_t,
593}
594#[derive(Copy, Clone)]
595#[repr(C)]
596pub struct C2RustUnnamed_7 {
597    pub si_tid: libc::c_int,
598    pub si_overrun: libc::c_int,
599    pub si_sigval: __sigval_t,
600}
601#[derive(Copy, Clone)]
602#[repr(C)]
603pub struct C2RustUnnamed_8 {
604    pub si_pid: __pid_t,
605    pub si_uid: __uid_t,
606}
607pub type __sighandler_t = Option::<unsafe extern "C" fn(libc::c_int) -> ()>;
608#[derive(Copy, Clone)]
609#[repr(C)]
610pub struct sigaction {
611    pub __sigaction_handler: C2RustUnnamed_9,
612    pub sa_mask: __sigset_t,
613    pub sa_flags: libc::c_int,
614    pub sa_restorer: Option::<unsafe extern "C" fn() -> ()>,
615}
616#[derive(Copy, Clone)]
617#[repr(C)]
618pub union C2RustUnnamed_9 {
619    pub sa_handler: __sighandler_t,
620    pub sa_sigaction: Option::<
621        unsafe extern "C" fn(libc::c_int, *mut siginfo_t, *mut libc::c_void) -> (),
622    >,
623}
624#[derive(Copy, Clone)]
625#[repr(C)]
626pub struct hdr_histogram {
627    pub lowest_discernible_value: int64_t,
628    pub highest_trackable_value: int64_t,
629    pub unit_magnitude: int32_t,
630    pub significant_figures: int32_t,
631    pub sub_bucket_half_count_magnitude: int32_t,
632    pub sub_bucket_half_count: int32_t,
633    pub sub_bucket_mask: int64_t,
634    pub sub_bucket_count: int32_t,
635    pub bucket_count: int32_t,
636    pub min_value: int64_t,
637    pub max_value: int64_t,
638    pub normalizing_index_offset: int32_t,
639    pub conversion_ratio: libc::c_double,
640    pub counts_len: int32_t,
641    pub total_count: int64_t,
642    pub counts: *mut int64_t,
643}
644pub type mstime_t = libc::c_longlong;
645pub type ustime_t = libc::c_longlong;
646#[derive(Copy, Clone)]
647#[repr(C)]
648pub struct dictEntry {
649    pub key: *mut libc::c_void,
650    pub v: C2RustUnnamed_10,
651    pub next: *mut dictEntry,
652    pub metadata: [*mut libc::c_void; 0],
653}
654#[derive(Copy, Clone)]
655#[repr(C)]
656pub union C2RustUnnamed_10 {
657    pub val: *mut libc::c_void,
658    pub u64_0: uint64_t,
659    pub s64: int64_t,
660    pub d: libc::c_double,
661}
662#[derive(Copy, Clone)]
663#[repr(C)]
664pub struct dict {
665    pub type_0: *mut dictType,
666    pub ht_table: [*mut *mut dictEntry; 2],
667    pub ht_used: [libc::c_ulong; 2],
668    pub rehashidx: libc::c_long,
669    pub pauserehash: int16_t,
670    pub ht_size_exp: [libc::c_schar; 2],
671}
672#[derive(Copy, Clone)]
673#[repr(C)]
674pub struct dictType {
675    pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
676    pub keyDup: Option::<
677        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
678    >,
679    pub valDup: Option::<
680        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
681    >,
682    pub keyCompare: Option::<
683        unsafe extern "C" fn(
684            *mut dict,
685            *const libc::c_void,
686            *const libc::c_void,
687        ) -> libc::c_int,
688    >,
689    pub keyDestructor: Option::<
690        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
691    >,
692    pub valDestructor: Option::<
693        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
694    >,
695    pub expandAllowed: Option::<
696        unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
697    >,
698    pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
699}
700#[derive(Copy, Clone)]
701#[repr(C)]
702pub struct listNode {
703    pub prev: *mut listNode,
704    pub next: *mut listNode,
705    pub value: *mut libc::c_void,
706}
707#[derive(Copy, Clone)]
708#[repr(C)]
709pub struct listIter {
710    pub next: *mut listNode,
711    pub direction: libc::c_int,
712}
713#[derive(Copy, Clone)]
714#[repr(C)]
715pub struct list {
716    pub head: *mut listNode,
717    pub tail: *mut listNode,
718    pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
719    pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
720    pub match_0: Option::<
721        unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
722    >,
723    pub len: libc::c_ulong,
724}
725#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
726#[repr(C)]
727pub struct raxNode {
728    #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
729    #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
730    #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
731    #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
732    pub iskey_isnull_iscompr_size: [u8; 4],
733    pub data: [libc::c_uchar; 0],
734}
735#[derive(Copy, Clone)]
736#[repr(C)]
737pub struct rax {
738    pub head: *mut raxNode,
739    pub numele: uint64_t,
740    pub numnodes: uint64_t,
741}
742#[derive(Copy, Clone)]
743#[repr(C)]
744pub struct SHA1_CTX {
745    pub state: [uint32_t; 5],
746    pub count: [uint32_t; 2],
747    pub buffer: [libc::c_uchar; 64],
748}
749pub type pause_type = libc::c_uint;
750pub const CLIENT_PAUSE_ALL: pause_type = 2;
751pub const CLIENT_PAUSE_WRITE: pause_type = 1;
752pub const CLIENT_PAUSE_OFF: pause_type = 0;
753#[derive(Copy, Clone)]
754#[repr(C)]
755pub struct pause_event {
756    pub type_0: pause_type,
757    pub end: mstime_t,
758}
759pub type robj = redisObject;
760pub type RedisModuleUserChangedFunc = Option::<
761    unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
762>;
763#[derive(Copy, Clone)]
764#[repr(C)]
765pub struct clusterSlotToKeyMapping {
766    pub by_slot: [slotToKeys; 16384],
767}
768#[derive(Copy, Clone)]
769#[repr(C)]
770pub struct slotToKeys {
771    pub count: uint64_t,
772    pub head: *mut dictEntry,
773}
774#[derive(Copy, Clone)]
775#[repr(C)]
776pub struct redisDb {
777    pub dict: *mut dict,
778    pub expires: *mut dict,
779    pub blocking_keys: *mut dict,
780    pub ready_keys: *mut dict,
781    pub watched_keys: *mut dict,
782    pub id: libc::c_int,
783    pub avg_ttl: libc::c_longlong,
784    pub expires_cursor: libc::c_ulong,
785    pub defrag_later: *mut list,
786    pub slots_to_keys: *mut clusterSlotToKeyMapping,
787}
788#[derive(Copy, Clone)]
789#[repr(C)]
790pub struct multiCmd {
791    pub argv: *mut *mut robj,
792    pub argv_len: libc::c_int,
793    pub argc: libc::c_int,
794    pub cmd: *mut redisCommand,
795}
796#[derive(Copy, Clone)]
797#[repr(C)]
798pub struct redisCommand {
799    pub declared_name: *const libc::c_char,
800    pub summary: *const libc::c_char,
801    pub complexity: *const libc::c_char,
802    pub since: *const libc::c_char,
803    pub doc_flags: libc::c_int,
804    pub replaced_by: *const libc::c_char,
805    pub deprecated_since: *const libc::c_char,
806    pub group: redisCommandGroup,
807    pub history: *mut commandHistory,
808    pub tips: *mut *const libc::c_char,
809    pub proc_0: Option::<redisCommandProc>,
810    pub arity: libc::c_int,
811    pub flags: uint64_t,
812    pub acl_categories: uint64_t,
813    pub key_specs_static: [keySpec; 4],
814    pub getkeys_proc: Option::<redisGetKeysProc>,
815    pub subcommands: *mut redisCommand,
816    pub args: *mut redisCommandArg,
817    pub microseconds: libc::c_longlong,
818    pub calls: libc::c_longlong,
819    pub rejected_calls: libc::c_longlong,
820    pub failed_calls: libc::c_longlong,
821    pub id: libc::c_int,
822    pub fullname: sds,
823    pub latency_histogram: *mut hdr_histogram,
824    pub key_specs: *mut keySpec,
825    pub legacy_range_key_spec: keySpec,
826    pub num_args: libc::c_int,
827    pub num_history: libc::c_int,
828    pub num_tips: libc::c_int,
829    pub key_specs_num: libc::c_int,
830    pub key_specs_max: libc::c_int,
831    pub subcommands_dict: *mut dict,
832    pub parent: *mut redisCommand,
833    pub module_cmd: *mut RedisModuleCommand,
834}
835#[derive(Copy, Clone)]
836#[repr(C)]
837pub struct keySpec {
838    pub notes: *const libc::c_char,
839    pub flags: uint64_t,
840    pub begin_search_type: kspec_bs_type,
841    pub bs: C2RustUnnamed_14,
842    pub find_keys_type: kspec_fk_type,
843    pub fk: C2RustUnnamed_11,
844}
845#[derive(Copy, Clone)]
846#[repr(C)]
847pub union C2RustUnnamed_11 {
848    pub range: C2RustUnnamed_13,
849    pub keynum: C2RustUnnamed_12,
850}
851#[derive(Copy, Clone)]
852#[repr(C)]
853pub struct C2RustUnnamed_12 {
854    pub keynumidx: libc::c_int,
855    pub firstkey: libc::c_int,
856    pub keystep: libc::c_int,
857}
858#[derive(Copy, Clone)]
859#[repr(C)]
860pub struct C2RustUnnamed_13 {
861    pub lastkey: libc::c_int,
862    pub keystep: libc::c_int,
863    pub limit: libc::c_int,
864}
865pub type kspec_fk_type = libc::c_uint;
866pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
867pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
868pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
869pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
870#[derive(Copy, Clone)]
871#[repr(C)]
872pub union C2RustUnnamed_14 {
873    pub index: C2RustUnnamed_16,
874    pub keyword: C2RustUnnamed_15,
875}
876#[derive(Copy, Clone)]
877#[repr(C)]
878pub struct C2RustUnnamed_15 {
879    pub keyword: *const libc::c_char,
880    pub startfrom: libc::c_int,
881}
882#[derive(Copy, Clone)]
883#[repr(C)]
884pub struct C2RustUnnamed_16 {
885    pub pos: libc::c_int,
886}
887pub type kspec_bs_type = libc::c_uint;
888pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
889pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
890pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
891pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
892#[derive(Copy, Clone)]
893#[repr(C)]
894pub struct redisCommandArg {
895    pub name: *const libc::c_char,
896    pub type_0: redisCommandArgType,
897    pub key_spec_index: libc::c_int,
898    pub token: *const libc::c_char,
899    pub summary: *const libc::c_char,
900    pub since: *const libc::c_char,
901    pub flags: libc::c_int,
902    pub deprecated_since: *const libc::c_char,
903    pub subargs: *mut redisCommandArg,
904    pub num_args: libc::c_int,
905}
906pub type redisCommandArgType = libc::c_uint;
907pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
908pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
909pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
910pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
911pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
912pub const ARG_TYPE_KEY: redisCommandArgType = 3;
913pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
914pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
915pub const ARG_TYPE_STRING: redisCommandArgType = 0;
916pub type redisGetKeysProc = unsafe extern "C" fn(
917    *mut redisCommand,
918    *mut *mut robj,
919    libc::c_int,
920    *mut getKeysResult,
921) -> libc::c_int;
922#[derive(Copy, Clone)]
923#[repr(C)]
924pub struct getKeysResult {
925    pub keysbuf: [keyReference; 256],
926    pub keys: *mut keyReference,
927    pub numkeys: libc::c_int,
928    pub size: libc::c_int,
929}
930#[derive(Copy, Clone)]
931#[repr(C)]
932pub struct keyReference {
933    pub pos: libc::c_int,
934    pub flags: libc::c_int,
935}
936pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
937#[derive(Copy, Clone)]
938#[repr(C)]
939pub struct client {
940    pub id: uint64_t,
941    pub flags: uint64_t,
942    pub conn: *mut connection,
943    pub resp: libc::c_int,
944    pub db: *mut redisDb,
945    pub name: *mut robj,
946    pub querybuf: sds,
947    pub qb_pos: size_t,
948    pub querybuf_peak: size_t,
949    pub argc: libc::c_int,
950    pub argv: *mut *mut robj,
951    pub argv_len: libc::c_int,
952    pub original_argc: libc::c_int,
953    pub original_argv: *mut *mut robj,
954    pub argv_len_sum: size_t,
955    pub cmd: *mut redisCommand,
956    pub lastcmd: *mut redisCommand,
957    pub realcmd: *mut redisCommand,
958    pub user: *mut user,
959    pub reqtype: libc::c_int,
960    pub multibulklen: libc::c_int,
961    pub bulklen: libc::c_long,
962    pub reply: *mut list,
963    pub reply_bytes: libc::c_ulonglong,
964    pub deferred_reply_errors: *mut list,
965    pub sentlen: size_t,
966    pub ctime: time_t,
967    pub duration: libc::c_long,
968    pub slot: libc::c_int,
969    pub cur_script: *mut dictEntry,
970    pub lastinteraction: time_t,
971    pub obuf_soft_limit_reached_time: time_t,
972    pub authenticated: libc::c_int,
973    pub replstate: libc::c_int,
974    pub repl_start_cmd_stream_on_ack: libc::c_int,
975    pub repldbfd: libc::c_int,
976    pub repldboff: off_t,
977    pub repldbsize: off_t,
978    pub replpreamble: sds,
979    pub read_reploff: libc::c_longlong,
980    pub reploff: libc::c_longlong,
981    pub repl_applied: libc::c_longlong,
982    pub repl_ack_off: libc::c_longlong,
983    pub repl_ack_time: libc::c_longlong,
984    pub repl_last_partial_write: libc::c_longlong,
985    pub psync_initial_offset: libc::c_longlong,
986    pub replid: [libc::c_char; 41],
987    pub slave_listening_port: libc::c_int,
988    pub slave_addr: *mut libc::c_char,
989    pub slave_capa: libc::c_int,
990    pub slave_req: libc::c_int,
991    pub mstate: multiState,
992    pub btype: libc::c_int,
993    pub bpop: blockingState,
994    pub woff: libc::c_longlong,
995    pub watched_keys: *mut list,
996    pub pubsub_channels: *mut dict,
997    pub pubsub_patterns: *mut list,
998    pub pubsubshard_channels: *mut dict,
999    pub peerid: sds,
1000    pub sockname: sds,
1001    pub client_list_node: *mut listNode,
1002    pub postponed_list_node: *mut listNode,
1003    pub pending_read_list_node: *mut listNode,
1004    pub auth_callback: RedisModuleUserChangedFunc,
1005    pub auth_callback_privdata: *mut libc::c_void,
1006    pub auth_module: *mut libc::c_void,
1007    pub client_tracking_redirection: uint64_t,
1008    pub client_tracking_prefixes: *mut rax,
1009    pub last_memory_usage: size_t,
1010    pub last_memory_type: libc::c_int,
1011    pub mem_usage_bucket_node: *mut listNode,
1012    pub mem_usage_bucket: *mut clientMemUsageBucket,
1013    pub ref_repl_buf_node: *mut listNode,
1014    pub ref_block_pos: size_t,
1015    pub buf_peak: size_t,
1016    pub buf_peak_last_reset_time: mstime_t,
1017    pub bufpos: libc::c_int,
1018    pub buf_usable_size: size_t,
1019    pub buf: *mut libc::c_char,
1020}
1021#[derive(Copy, Clone)]
1022#[repr(C)]
1023pub struct clientMemUsageBucket {
1024    pub clients: *mut list,
1025    pub mem_usage_sum: size_t,
1026}
1027#[derive(Copy, Clone)]
1028#[repr(C)]
1029pub struct blockingState {
1030    pub count: libc::c_long,
1031    pub timeout: mstime_t,
1032    pub keys: *mut dict,
1033    pub target: *mut robj,
1034    pub blockpos: blockPos,
1035    pub xread_count: size_t,
1036    pub xread_group: *mut robj,
1037    pub xread_consumer: *mut robj,
1038    pub xread_group_noack: libc::c_int,
1039    pub numreplicas: libc::c_int,
1040    pub reploffset: libc::c_longlong,
1041    pub module_blocked_handle: *mut libc::c_void,
1042}
1043#[derive(Copy, Clone)]
1044#[repr(C)]
1045pub struct blockPos {
1046    pub wherefrom: libc::c_int,
1047    pub whereto: libc::c_int,
1048}
1049#[derive(Copy, Clone)]
1050#[repr(C)]
1051pub struct multiState {
1052    pub commands: *mut multiCmd,
1053    pub count: libc::c_int,
1054    pub cmd_flags: libc::c_int,
1055    pub cmd_inv_flags: libc::c_int,
1056    pub argv_len_sums: size_t,
1057    pub alloc_count: libc::c_int,
1058}
1059#[derive(Copy, Clone)]
1060#[repr(C)]
1061pub struct user {
1062    pub name: sds,
1063    pub flags: uint32_t,
1064    pub passwords: *mut list,
1065    pub selectors: *mut list,
1066    pub acl_string: *mut robj,
1067}
1068#[derive(Copy, Clone)]
1069#[repr(C)]
1070pub struct commandHistory {
1071    pub since: *const libc::c_char,
1072    pub changes: *const libc::c_char,
1073}
1074pub type redisCommandGroup = libc::c_uint;
1075pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
1076pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
1077pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
1078pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
1079pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
1080pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
1081pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
1082pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
1083pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
1084pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
1085pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
1086pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
1087pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
1088pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
1089pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
1090pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
1091pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
1092pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
1093#[derive(Copy, Clone)]
1094#[repr(C)]
1095pub struct replBacklog {
1096    pub ref_repl_buf_node: *mut listNode,
1097    pub unindexed_count: size_t,
1098    pub blocks_index: *mut rax,
1099    pub histlen: libc::c_longlong,
1100    pub offset: libc::c_longlong,
1101}
1102#[derive(Copy, Clone)]
1103#[repr(C)]
1104pub struct saveparam {
1105    pub seconds: time_t,
1106    pub changes: libc::c_int,
1107}
1108#[derive(Copy, Clone)]
1109#[repr(C)]
1110pub struct sentinelConfig {
1111    pub pre_monitor_cfg: *mut list,
1112    pub monitor_cfg: *mut list,
1113    pub post_monitor_cfg: *mut list,
1114}
1115#[derive(Copy, Clone)]
1116#[repr(C)]
1117pub struct sharedObjectsStruct {
1118    pub crlf: *mut robj,
1119    pub ok: *mut robj,
1120    pub err: *mut robj,
1121    pub emptybulk: *mut robj,
1122    pub czero: *mut robj,
1123    pub cone: *mut robj,
1124    pub pong: *mut robj,
1125    pub space: *mut robj,
1126    pub queued: *mut robj,
1127    pub null: [*mut robj; 4],
1128    pub nullarray: [*mut robj; 4],
1129    pub emptymap: [*mut robj; 4],
1130    pub emptyset: [*mut robj; 4],
1131    pub emptyarray: *mut robj,
1132    pub wrongtypeerr: *mut robj,
1133    pub nokeyerr: *mut robj,
1134    pub syntaxerr: *mut robj,
1135    pub sameobjecterr: *mut robj,
1136    pub outofrangeerr: *mut robj,
1137    pub noscripterr: *mut robj,
1138    pub loadingerr: *mut robj,
1139    pub slowevalerr: *mut robj,
1140    pub slowscripterr: *mut robj,
1141    pub slowmoduleerr: *mut robj,
1142    pub bgsaveerr: *mut robj,
1143    pub masterdownerr: *mut robj,
1144    pub roslaveerr: *mut robj,
1145    pub execaborterr: *mut robj,
1146    pub noautherr: *mut robj,
1147    pub noreplicaserr: *mut robj,
1148    pub busykeyerr: *mut robj,
1149    pub oomerr: *mut robj,
1150    pub plus: *mut robj,
1151    pub messagebulk: *mut robj,
1152    pub pmessagebulk: *mut robj,
1153    pub subscribebulk: *mut robj,
1154    pub unsubscribebulk: *mut robj,
1155    pub psubscribebulk: *mut robj,
1156    pub punsubscribebulk: *mut robj,
1157    pub del: *mut robj,
1158    pub unlink: *mut robj,
1159    pub rpop: *mut robj,
1160    pub lpop: *mut robj,
1161    pub lpush: *mut robj,
1162    pub rpoplpush: *mut robj,
1163    pub lmove: *mut robj,
1164    pub blmove: *mut robj,
1165    pub zpopmin: *mut robj,
1166    pub zpopmax: *mut robj,
1167    pub emptyscan: *mut robj,
1168    pub multi: *mut robj,
1169    pub exec: *mut robj,
1170    pub left: *mut robj,
1171    pub right: *mut robj,
1172    pub hset: *mut robj,
1173    pub srem: *mut robj,
1174    pub xgroup: *mut robj,
1175    pub xclaim: *mut robj,
1176    pub script: *mut robj,
1177    pub replconf: *mut robj,
1178    pub eval: *mut robj,
1179    pub persist: *mut robj,
1180    pub set: *mut robj,
1181    pub pexpireat: *mut robj,
1182    pub pexpire: *mut robj,
1183    pub time: *mut robj,
1184    pub pxat: *mut robj,
1185    pub absttl: *mut robj,
1186    pub retrycount: *mut robj,
1187    pub force: *mut robj,
1188    pub justid: *mut robj,
1189    pub entriesread: *mut robj,
1190    pub lastid: *mut robj,
1191    pub ping: *mut robj,
1192    pub setid: *mut robj,
1193    pub keepttl: *mut robj,
1194    pub load: *mut robj,
1195    pub createconsumer: *mut robj,
1196    pub getack: *mut robj,
1197    pub special_asterick: *mut robj,
1198    pub special_equals: *mut robj,
1199    pub default_username: *mut robj,
1200    pub redacted: *mut robj,
1201    pub ssubscribebulk: *mut robj,
1202    pub sunsubscribebulk: *mut robj,
1203    pub smessagebulk: *mut robj,
1204    pub select: [*mut robj; 10],
1205    pub integers: [*mut robj; 10000],
1206    pub mbulkhdr: [*mut robj; 32],
1207    pub bulkhdr: [*mut robj; 32],
1208    pub maphdr: [*mut robj; 32],
1209    pub sethdr: [*mut robj; 32],
1210    pub minstring: sds,
1211    pub maxstring: sds,
1212}
1213#[derive(Copy, Clone)]
1214#[repr(C)]
1215pub struct clientBufferLimitsConfig {
1216    pub hard_limit_bytes: libc::c_ulonglong,
1217    pub soft_limit_bytes: libc::c_ulonglong,
1218    pub soft_limit_seconds: time_t,
1219}
1220#[derive(Copy, Clone)]
1221#[repr(C)]
1222pub struct redisOp {
1223    pub argv: *mut *mut robj,
1224    pub argc: libc::c_int,
1225    pub dbid: libc::c_int,
1226    pub target: libc::c_int,
1227}
1228#[derive(Copy, Clone)]
1229#[repr(C)]
1230pub struct redisOpArray {
1231    pub ops: *mut redisOp,
1232    pub numops: libc::c_int,
1233    pub capacity: libc::c_int,
1234}
1235#[derive(Copy, Clone)]
1236#[repr(C)]
1237pub struct malloc_stats {
1238    pub zmalloc_used: size_t,
1239    pub process_rss: size_t,
1240    pub allocator_allocated: size_t,
1241    pub allocator_active: size_t,
1242    pub allocator_resident: size_t,
1243}
1244#[derive(Copy, Clone)]
1245#[repr(C)]
1246pub struct socketFds {
1247    pub fd: [libc::c_int; 16],
1248    pub count: libc::c_int,
1249}
1250#[derive(Copy, Clone)]
1251#[repr(C)]
1252pub struct redisTLSContextConfig {
1253    pub cert_file: *mut libc::c_char,
1254    pub key_file: *mut libc::c_char,
1255    pub key_file_pass: *mut libc::c_char,
1256    pub client_cert_file: *mut libc::c_char,
1257    pub client_key_file: *mut libc::c_char,
1258    pub client_key_file_pass: *mut libc::c_char,
1259    pub dh_params_file: *mut libc::c_char,
1260    pub ca_cert_file: *mut libc::c_char,
1261    pub ca_cert_dir: *mut libc::c_char,
1262    pub protocols: *mut libc::c_char,
1263    pub ciphers: *mut libc::c_char,
1264    pub ciphersuites: *mut libc::c_char,
1265    pub prefer_server_ciphers: libc::c_int,
1266    pub session_caching: libc::c_int,
1267    pub session_cache_size: libc::c_int,
1268    pub session_cache_timeout: libc::c_int,
1269}
1270pub type aof_file_type = libc::c_uint;
1271pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
1272pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
1273pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
1274#[derive(Copy, Clone)]
1275#[repr(C)]
1276pub struct aofInfo {
1277    pub file_name: sds,
1278    pub file_seq: libc::c_longlong,
1279    pub file_type: aof_file_type,
1280}
1281#[derive(Copy, Clone)]
1282#[repr(C)]
1283pub struct aofManifest {
1284    pub base_aof_info: *mut aofInfo,
1285    pub incr_aof_list: *mut list,
1286    pub history_aof_list: *mut list,
1287    pub curr_base_file_seq: libc::c_longlong,
1288    pub curr_incr_file_seq: libc::c_longlong,
1289    pub dirty: libc::c_int,
1290}
1291#[derive(Copy, Clone)]
1292#[repr(C)]
1293pub struct redisServer {
1294    pub pid: pid_t,
1295    pub main_thread_id: pthread_t,
1296    pub configfile: *mut libc::c_char,
1297    pub executable: *mut libc::c_char,
1298    pub exec_argv: *mut *mut libc::c_char,
1299    pub dynamic_hz: libc::c_int,
1300    pub config_hz: libc::c_int,
1301    pub umask: mode_t,
1302    pub hz: libc::c_int,
1303    pub in_fork_child: libc::c_int,
1304    pub db: *mut redisDb,
1305    pub commands: *mut dict,
1306    pub orig_commands: *mut dict,
1307    pub el: *mut aeEventLoop,
1308    pub errors: *mut rax,
1309    pub lruclock: atomic_uint,
1310    pub shutdown_asap: sig_atomic_t,
1311    pub shutdown_mstime: mstime_t,
1312    pub last_sig_received: libc::c_int,
1313    pub shutdown_flags: libc::c_int,
1314    pub activerehashing: libc::c_int,
1315    pub active_defrag_running: libc::c_int,
1316    pub pidfile: *mut libc::c_char,
1317    pub arch_bits: libc::c_int,
1318    pub cronloops: libc::c_int,
1319    pub runid: [libc::c_char; 41],
1320    pub sentinel_mode: libc::c_int,
1321    pub initial_memory_usage: size_t,
1322    pub always_show_logo: libc::c_int,
1323    pub in_exec: libc::c_int,
1324    pub busy_module_yield_flags: libc::c_int,
1325    pub busy_module_yield_reply: *const libc::c_char,
1326    pub core_propagates: libc::c_int,
1327    pub propagate_no_multi: libc::c_int,
1328    pub module_ctx_nesting: libc::c_int,
1329    pub ignore_warnings: *mut libc::c_char,
1330    pub client_pause_in_transaction: libc::c_int,
1331    pub thp_enabled: libc::c_int,
1332    pub page_size: size_t,
1333    pub moduleapi: *mut dict,
1334    pub sharedapi: *mut dict,
1335    pub module_configs_queue: *mut dict,
1336    pub loadmodule_queue: *mut list,
1337    pub module_pipe: [libc::c_int; 2],
1338    pub child_pid: pid_t,
1339    pub child_type: libc::c_int,
1340    pub port: libc::c_int,
1341    pub tls_port: libc::c_int,
1342    pub tcp_backlog: libc::c_int,
1343    pub bindaddr: [*mut libc::c_char; 16],
1344    pub bindaddr_count: libc::c_int,
1345    pub bind_source_addr: *mut libc::c_char,
1346    pub unixsocket: *mut libc::c_char,
1347    pub unixsocketperm: libc::c_uint,
1348    pub ipfd: socketFds,
1349    pub tlsfd: socketFds,
1350    pub sofd: libc::c_int,
1351    pub socket_mark_id: uint32_t,
1352    pub cfd: socketFds,
1353    pub clients: *mut list,
1354    pub clients_to_close: *mut list,
1355    pub clients_pending_write: *mut list,
1356    pub clients_pending_read: *mut list,
1357    pub slaves: *mut list,
1358    pub monitors: *mut list,
1359    pub current_client: *mut client,
1360    pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1361    pub clients_timeout_table: *mut rax,
1362    pub fixed_time_expire: libc::c_long,
1363    pub in_nested_call: libc::c_int,
1364    pub clients_index: *mut rax,
1365    pub client_pause_type: pause_type,
1366    pub postponed_clients: *mut list,
1367    pub client_pause_end_time: mstime_t,
1368    pub client_pause_per_purpose: [*mut pause_event; 3],
1369    pub neterr: [libc::c_char; 256],
1370    pub migrate_cached_sockets: *mut dict,
1371    pub next_client_id: uint_least64_t,
1372    pub protected_mode: libc::c_int,
1373    pub io_threads_num: libc::c_int,
1374    pub io_threads_do_reads: libc::c_int,
1375    pub io_threads_active: libc::c_int,
1376    pub events_processed_while_blocked: libc::c_longlong,
1377    pub enable_protected_configs: libc::c_int,
1378    pub enable_debug_cmd: libc::c_int,
1379    pub enable_module_cmd: libc::c_int,
1380    pub loading: sig_atomic_t,
1381    pub async_loading: sig_atomic_t,
1382    pub loading_total_bytes: off_t,
1383    pub loading_rdb_used_mem: off_t,
1384    pub loading_loaded_bytes: off_t,
1385    pub loading_start_time: time_t,
1386    pub loading_process_events_interval_bytes: off_t,
1387    pub stat_starttime: time_t,
1388    pub stat_numcommands: libc::c_longlong,
1389    pub stat_numconnections: libc::c_longlong,
1390    pub stat_expiredkeys: libc::c_longlong,
1391    pub stat_expired_stale_perc: libc::c_double,
1392    pub stat_expired_time_cap_reached_count: libc::c_longlong,
1393    pub stat_expire_cycle_time_used: libc::c_longlong,
1394    pub stat_evictedkeys: libc::c_longlong,
1395    pub stat_evictedclients: libc::c_longlong,
1396    pub stat_total_eviction_exceeded_time: libc::c_longlong,
1397    pub stat_last_eviction_exceeded_time: monotime,
1398    pub stat_keyspace_hits: libc::c_longlong,
1399    pub stat_keyspace_misses: libc::c_longlong,
1400    pub stat_active_defrag_hits: libc::c_longlong,
1401    pub stat_active_defrag_misses: libc::c_longlong,
1402    pub stat_active_defrag_key_hits: libc::c_longlong,
1403    pub stat_active_defrag_key_misses: libc::c_longlong,
1404    pub stat_active_defrag_scanned: libc::c_longlong,
1405    pub stat_total_active_defrag_time: libc::c_longlong,
1406    pub stat_last_active_defrag_time: monotime,
1407    pub stat_peak_memory: size_t,
1408    pub stat_aof_rewrites: libc::c_longlong,
1409    pub stat_aofrw_consecutive_failures: libc::c_longlong,
1410    pub stat_rdb_saves: libc::c_longlong,
1411    pub stat_fork_time: libc::c_longlong,
1412    pub stat_fork_rate: libc::c_double,
1413    pub stat_total_forks: libc::c_longlong,
1414    pub stat_rejected_conn: libc::c_longlong,
1415    pub stat_sync_full: libc::c_longlong,
1416    pub stat_sync_partial_ok: libc::c_longlong,
1417    pub stat_sync_partial_err: libc::c_longlong,
1418    pub slowlog: *mut list,
1419    pub slowlog_entry_id: libc::c_longlong,
1420    pub slowlog_log_slower_than: libc::c_longlong,
1421    pub slowlog_max_len: libc::c_ulong,
1422    pub cron_malloc_stats: malloc_stats,
1423    pub stat_net_input_bytes: atomic_llong,
1424    pub stat_net_output_bytes: atomic_llong,
1425    pub stat_net_repl_input_bytes: atomic_llong,
1426    pub stat_net_repl_output_bytes: atomic_llong,
1427    pub stat_current_cow_peak: size_t,
1428    pub stat_current_cow_bytes: size_t,
1429    pub stat_current_cow_updated: monotime,
1430    pub stat_current_save_keys_processed: size_t,
1431    pub stat_current_save_keys_total: size_t,
1432    pub stat_rdb_cow_bytes: size_t,
1433    pub stat_aof_cow_bytes: size_t,
1434    pub stat_module_cow_bytes: size_t,
1435    pub stat_module_progress: libc::c_double,
1436    pub stat_clients_type_memory: [size_t; 4],
1437    pub stat_cluster_links_memory: size_t,
1438    pub stat_unexpected_error_replies: libc::c_longlong,
1439    pub stat_total_error_replies: libc::c_longlong,
1440    pub stat_dump_payload_sanitizations: libc::c_longlong,
1441    pub stat_io_reads_processed: libc::c_longlong,
1442    pub stat_io_writes_processed: libc::c_longlong,
1443    pub stat_total_reads_processed: atomic_llong,
1444    pub stat_total_writes_processed: atomic_llong,
1445    pub inst_metric: [C2RustUnnamed_17; 5],
1446    pub stat_reply_buffer_shrinks: libc::c_longlong,
1447    pub stat_reply_buffer_expands: libc::c_longlong,
1448    pub verbosity: libc::c_int,
1449    pub maxidletime: libc::c_int,
1450    pub tcpkeepalive: libc::c_int,
1451    pub active_expire_enabled: libc::c_int,
1452    pub active_expire_effort: libc::c_int,
1453    pub active_defrag_enabled: libc::c_int,
1454    pub sanitize_dump_payload: libc::c_int,
1455    pub skip_checksum_validation: libc::c_int,
1456    pub jemalloc_bg_thread: libc::c_int,
1457    pub active_defrag_ignore_bytes: size_t,
1458    pub active_defrag_threshold_lower: libc::c_int,
1459    pub active_defrag_threshold_upper: libc::c_int,
1460    pub active_defrag_cycle_min: libc::c_int,
1461    pub active_defrag_cycle_max: libc::c_int,
1462    pub active_defrag_max_scan_fields: libc::c_ulong,
1463    pub client_max_querybuf_len: size_t,
1464    pub dbnum: libc::c_int,
1465    pub supervised: libc::c_int,
1466    pub supervised_mode: libc::c_int,
1467    pub daemonize: libc::c_int,
1468    pub set_proc_title: libc::c_int,
1469    pub proc_title_template: *mut libc::c_char,
1470    pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1471    pub pause_cron: libc::c_int,
1472    pub latency_tracking_enabled: libc::c_int,
1473    pub latency_tracking_info_percentiles: *mut libc::c_double,
1474    pub latency_tracking_info_percentiles_len: libc::c_int,
1475    pub aof_enabled: libc::c_int,
1476    pub aof_state: libc::c_int,
1477    pub aof_fsync: libc::c_int,
1478    pub aof_filename: *mut libc::c_char,
1479    pub aof_dirname: *mut libc::c_char,
1480    pub aof_no_fsync_on_rewrite: libc::c_int,
1481    pub aof_rewrite_perc: libc::c_int,
1482    pub aof_rewrite_min_size: off_t,
1483    pub aof_rewrite_base_size: off_t,
1484    pub aof_current_size: off_t,
1485    pub aof_last_incr_size: off_t,
1486    pub aof_fsync_offset: off_t,
1487    pub aof_flush_sleep: libc::c_int,
1488    pub aof_rewrite_scheduled: libc::c_int,
1489    pub aof_buf: sds,
1490    pub aof_fd: libc::c_int,
1491    pub aof_selected_db: libc::c_int,
1492    pub aof_flush_postponed_start: time_t,
1493    pub aof_last_fsync: time_t,
1494    pub aof_rewrite_time_last: time_t,
1495    pub aof_rewrite_time_start: time_t,
1496    pub aof_cur_timestamp: time_t,
1497    pub aof_timestamp_enabled: libc::c_int,
1498    pub aof_lastbgrewrite_status: libc::c_int,
1499    pub aof_delayed_fsync: libc::c_ulong,
1500    pub aof_rewrite_incremental_fsync: libc::c_int,
1501    pub rdb_save_incremental_fsync: libc::c_int,
1502    pub aof_last_write_status: libc::c_int,
1503    pub aof_last_write_errno: libc::c_int,
1504    pub aof_load_truncated: libc::c_int,
1505    pub aof_use_rdb_preamble: libc::c_int,
1506    pub aof_bio_fsync_status: atomic_int,
1507    pub aof_bio_fsync_errno: atomic_int,
1508    pub aof_manifest: *mut aofManifest,
1509    pub aof_disable_auto_gc: libc::c_int,
1510    pub dirty: libc::c_longlong,
1511    pub dirty_before_bgsave: libc::c_longlong,
1512    pub rdb_last_load_keys_expired: libc::c_longlong,
1513    pub rdb_last_load_keys_loaded: libc::c_longlong,
1514    pub saveparams: *mut saveparam,
1515    pub saveparamslen: libc::c_int,
1516    pub rdb_filename: *mut libc::c_char,
1517    pub rdb_compression: libc::c_int,
1518    pub rdb_checksum: libc::c_int,
1519    pub rdb_del_sync_files: libc::c_int,
1520    pub lastsave: time_t,
1521    pub lastbgsave_try: time_t,
1522    pub rdb_save_time_last: time_t,
1523    pub rdb_save_time_start: time_t,
1524    pub rdb_bgsave_scheduled: libc::c_int,
1525    pub rdb_child_type: libc::c_int,
1526    pub lastbgsave_status: libc::c_int,
1527    pub stop_writes_on_bgsave_err: libc::c_int,
1528    pub rdb_pipe_read: libc::c_int,
1529    pub rdb_child_exit_pipe: libc::c_int,
1530    pub rdb_pipe_conns: *mut *mut connection,
1531    pub rdb_pipe_numconns: libc::c_int,
1532    pub rdb_pipe_numconns_writing: libc::c_int,
1533    pub rdb_pipe_buff: *mut libc::c_char,
1534    pub rdb_pipe_bufflen: libc::c_int,
1535    pub rdb_key_save_delay: libc::c_int,
1536    pub key_load_delay: libc::c_int,
1537    pub child_info_pipe: [libc::c_int; 2],
1538    pub child_info_nread: libc::c_int,
1539    pub also_propagate: redisOpArray,
1540    pub replication_allowed: libc::c_int,
1541    pub logfile: *mut libc::c_char,
1542    pub syslog_enabled: libc::c_int,
1543    pub syslog_ident: *mut libc::c_char,
1544    pub syslog_facility: libc::c_int,
1545    pub crashlog_enabled: libc::c_int,
1546    pub memcheck_enabled: libc::c_int,
1547    pub use_exit_on_panic: libc::c_int,
1548    pub shutdown_timeout: libc::c_int,
1549    pub shutdown_on_sigint: libc::c_int,
1550    pub shutdown_on_sigterm: libc::c_int,
1551    pub replid: [libc::c_char; 41],
1552    pub replid2: [libc::c_char; 41],
1553    pub master_repl_offset: libc::c_longlong,
1554    pub second_replid_offset: libc::c_longlong,
1555    pub slaveseldb: libc::c_int,
1556    pub repl_ping_slave_period: libc::c_int,
1557    pub repl_backlog: *mut replBacklog,
1558    pub repl_backlog_size: libc::c_longlong,
1559    pub repl_backlog_time_limit: time_t,
1560    pub repl_no_slaves_since: time_t,
1561    pub repl_min_slaves_to_write: libc::c_int,
1562    pub repl_min_slaves_max_lag: libc::c_int,
1563    pub repl_good_slaves_count: libc::c_int,
1564    pub repl_diskless_sync: libc::c_int,
1565    pub repl_diskless_load: libc::c_int,
1566    pub repl_diskless_sync_delay: libc::c_int,
1567    pub repl_diskless_sync_max_replicas: libc::c_int,
1568    pub repl_buffer_mem: size_t,
1569    pub repl_buffer_blocks: *mut list,
1570    pub masteruser: *mut libc::c_char,
1571    pub masterauth: sds,
1572    pub masterhost: *mut libc::c_char,
1573    pub masterport: libc::c_int,
1574    pub repl_timeout: libc::c_int,
1575    pub master: *mut client,
1576    pub cached_master: *mut client,
1577    pub repl_syncio_timeout: libc::c_int,
1578    pub repl_state: libc::c_int,
1579    pub repl_transfer_size: off_t,
1580    pub repl_transfer_read: off_t,
1581    pub repl_transfer_last_fsync_off: off_t,
1582    pub repl_transfer_s: *mut connection,
1583    pub repl_transfer_fd: libc::c_int,
1584    pub repl_transfer_tmpfile: *mut libc::c_char,
1585    pub repl_transfer_lastio: time_t,
1586    pub repl_serve_stale_data: libc::c_int,
1587    pub repl_slave_ro: libc::c_int,
1588    pub repl_slave_ignore_maxmemory: libc::c_int,
1589    pub repl_down_since: time_t,
1590    pub repl_disable_tcp_nodelay: libc::c_int,
1591    pub slave_priority: libc::c_int,
1592    pub replica_announced: libc::c_int,
1593    pub slave_announce_port: libc::c_int,
1594    pub slave_announce_ip: *mut libc::c_char,
1595    pub propagation_error_behavior: libc::c_int,
1596    pub repl_ignore_disk_write_error: libc::c_int,
1597    pub master_replid: [libc::c_char; 41],
1598    pub master_initial_offset: libc::c_longlong,
1599    pub repl_slave_lazy_flush: libc::c_int,
1600    pub clients_waiting_acks: *mut list,
1601    pub get_ack_from_slaves: libc::c_int,
1602    pub maxclients: libc::c_uint,
1603    pub maxmemory: libc::c_ulonglong,
1604    pub maxmemory_clients: ssize_t,
1605    pub maxmemory_policy: libc::c_int,
1606    pub maxmemory_samples: libc::c_int,
1607    pub maxmemory_eviction_tenacity: libc::c_int,
1608    pub lfu_log_factor: libc::c_int,
1609    pub lfu_decay_time: libc::c_int,
1610    pub proto_max_bulk_len: libc::c_longlong,
1611    pub oom_score_adj_values: [libc::c_int; 3],
1612    pub oom_score_adj: libc::c_int,
1613    pub disable_thp: libc::c_int,
1614    pub blocked_clients: libc::c_uint,
1615    pub blocked_clients_by_type: [libc::c_uint; 8],
1616    pub unblocked_clients: *mut list,
1617    pub ready_keys: *mut list,
1618    pub tracking_clients: libc::c_uint,
1619    pub tracking_table_max_keys: size_t,
1620    pub tracking_pending_keys: *mut list,
1621    pub sort_desc: libc::c_int,
1622    pub sort_alpha: libc::c_int,
1623    pub sort_bypattern: libc::c_int,
1624    pub sort_store: libc::c_int,
1625    pub hash_max_listpack_entries: size_t,
1626    pub hash_max_listpack_value: size_t,
1627    pub set_max_intset_entries: size_t,
1628    pub zset_max_listpack_entries: size_t,
1629    pub zset_max_listpack_value: size_t,
1630    pub hll_sparse_max_bytes: size_t,
1631    pub stream_node_max_bytes: size_t,
1632    pub stream_node_max_entries: libc::c_longlong,
1633    pub list_max_listpack_size: libc::c_int,
1634    pub list_compress_depth: libc::c_int,
1635    pub unixtime: atomic_int,
1636    pub timezone: time_t,
1637    pub daylight_active: libc::c_int,
1638    pub mstime: mstime_t,
1639    pub ustime: ustime_t,
1640    pub blocking_op_nesting: size_t,
1641    pub blocked_last_cron: libc::c_longlong,
1642    pub pubsub_channels: *mut dict,
1643    pub pubsub_patterns: *mut dict,
1644    pub notify_keyspace_events: libc::c_int,
1645    pub pubsubshard_channels: *mut dict,
1646    pub cluster_enabled: libc::c_int,
1647    pub cluster_port: libc::c_int,
1648    pub cluster_node_timeout: mstime_t,
1649    pub cluster_configfile: *mut libc::c_char,
1650    pub cluster: *mut clusterState,
1651    pub cluster_migration_barrier: libc::c_int,
1652    pub cluster_allow_replica_migration: libc::c_int,
1653    pub cluster_slave_validity_factor: libc::c_int,
1654    pub cluster_require_full_coverage: libc::c_int,
1655    pub cluster_slave_no_failover: libc::c_int,
1656    pub cluster_announce_ip: *mut libc::c_char,
1657    pub cluster_announce_hostname: *mut libc::c_char,
1658    pub cluster_preferred_endpoint_type: libc::c_int,
1659    pub cluster_announce_port: libc::c_int,
1660    pub cluster_announce_tls_port: libc::c_int,
1661    pub cluster_announce_bus_port: libc::c_int,
1662    pub cluster_module_flags: libc::c_int,
1663    pub cluster_allow_reads_when_down: libc::c_int,
1664    pub cluster_config_file_lock_fd: libc::c_int,
1665    pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1666    pub cluster_drop_packet_filter: libc::c_int,
1667    pub script_caller: *mut client,
1668    pub busy_reply_threshold: mstime_t,
1669    pub pre_command_oom_state: libc::c_int,
1670    pub script_disable_deny_script: libc::c_int,
1671    pub lazyfree_lazy_eviction: libc::c_int,
1672    pub lazyfree_lazy_expire: libc::c_int,
1673    pub lazyfree_lazy_server_del: libc::c_int,
1674    pub lazyfree_lazy_user_del: libc::c_int,
1675    pub lazyfree_lazy_user_flush: libc::c_int,
1676    pub latency_monitor_threshold: libc::c_longlong,
1677    pub latency_events: *mut dict,
1678    pub acl_filename: *mut libc::c_char,
1679    pub acllog_max_len: libc::c_ulong,
1680    pub requirepass: sds,
1681    pub acl_pubsub_default: libc::c_int,
1682    pub watchdog_period: libc::c_int,
1683    pub system_memory_size: size_t,
1684    pub tls_cluster: libc::c_int,
1685    pub tls_replication: libc::c_int,
1686    pub tls_auth_clients: libc::c_int,
1687    pub tls_ctx_config: redisTLSContextConfig,
1688    pub server_cpulist: *mut libc::c_char,
1689    pub bio_cpulist: *mut libc::c_char,
1690    pub aof_rewrite_cpulist: *mut libc::c_char,
1691    pub bgsave_cpulist: *mut libc::c_char,
1692    pub sentinel_config: *mut sentinelConfig,
1693    pub failover_end_time: mstime_t,
1694    pub force_failover: libc::c_int,
1695    pub target_replica_host: *mut libc::c_char,
1696    pub target_replica_port: libc::c_int,
1697    pub failover_state: libc::c_int,
1698    pub cluster_allow_pubsubshard_when_down: libc::c_int,
1699    pub reply_buffer_peak_reset_time: libc::c_long,
1700    pub reply_buffer_resizing_enabled: libc::c_int,
1701}
1702#[derive(Copy, Clone)]
1703#[repr(C)]
1704pub struct clusterState {
1705    pub myself: *mut clusterNode,
1706    pub currentEpoch: uint64_t,
1707    pub state: libc::c_int,
1708    pub size: libc::c_int,
1709    pub nodes: *mut dict,
1710    pub nodes_black_list: *mut dict,
1711    pub migrating_slots_to: [*mut clusterNode; 16384],
1712    pub importing_slots_from: [*mut clusterNode; 16384],
1713    pub slots: [*mut clusterNode; 16384],
1714    pub slots_to_channels: *mut rax,
1715    pub failover_auth_time: mstime_t,
1716    pub failover_auth_count: libc::c_int,
1717    pub failover_auth_sent: libc::c_int,
1718    pub failover_auth_rank: libc::c_int,
1719    pub failover_auth_epoch: uint64_t,
1720    pub cant_failover_reason: libc::c_int,
1721    pub mf_end: mstime_t,
1722    pub mf_slave: *mut clusterNode,
1723    pub mf_master_offset: libc::c_longlong,
1724    pub mf_can_start: libc::c_int,
1725    pub lastVoteEpoch: uint64_t,
1726    pub todo_before_sleep: libc::c_int,
1727    pub stats_bus_messages_sent: [libc::c_longlong; 11],
1728    pub stats_bus_messages_received: [libc::c_longlong; 11],
1729    pub stats_pfail_nodes: libc::c_longlong,
1730    pub stat_cluster_links_buffer_limit_exceeded: libc::c_ulonglong,
1731}
1732#[derive(Copy, Clone)]
1733#[repr(C)]
1734pub struct clusterNode {
1735    pub ctime: mstime_t,
1736    pub name: [libc::c_char; 40],
1737    pub flags: libc::c_int,
1738    pub configEpoch: uint64_t,
1739    pub slots: [libc::c_uchar; 2048],
1740    pub slot_info_pairs: *mut uint16_t,
1741    pub slot_info_pairs_count: libc::c_int,
1742    pub numslots: libc::c_int,
1743    pub numslaves: libc::c_int,
1744    pub slaves: *mut *mut clusterNode,
1745    pub slaveof: *mut clusterNode,
1746    pub last_in_ping_gossip: libc::c_ulonglong,
1747    pub ping_sent: mstime_t,
1748    pub pong_received: mstime_t,
1749    pub data_received: mstime_t,
1750    pub fail_time: mstime_t,
1751    pub voted_time: mstime_t,
1752    pub repl_offset_time: mstime_t,
1753    pub orphaned_time: mstime_t,
1754    pub repl_offset: libc::c_longlong,
1755    pub ip: [libc::c_char; 46],
1756    pub hostname: sds,
1757    pub port: libc::c_int,
1758    pub pport: libc::c_int,
1759    pub cport: libc::c_int,
1760    pub link: *mut clusterLink,
1761    pub inbound_link: *mut clusterLink,
1762    pub fail_reports: *mut list,
1763}
1764#[derive(Copy, Clone)]
1765#[repr(C)]
1766pub struct clusterLink {
1767    pub ctime: mstime_t,
1768    pub conn: *mut connection,
1769    pub sndbuf: sds,
1770    pub rcvbuf: *mut libc::c_char,
1771    pub rcvbuf_len: size_t,
1772    pub rcvbuf_alloc: size_t,
1773    pub node: *mut clusterNode,
1774    pub inbound: libc::c_int,
1775}
1776#[derive(Copy, Clone)]
1777#[repr(C)]
1778pub struct C2RustUnnamed_17 {
1779    pub last_sample_time: libc::c_longlong,
1780    pub last_sample_count: libc::c_longlong,
1781    pub samples: [libc::c_longlong; 16],
1782    pub idx: libc::c_int,
1783}
1784#[derive(Copy, Clone)]
1785#[repr(C)]
1786pub struct luaCtx {
1787    pub lua: *mut lua_State,
1788    pub lua_client: *mut client,
1789    pub lua_scripts: *mut dict,
1790    pub lua_scripts_mem: libc::c_ulonglong,
1791}
1792#[derive(Copy, Clone)]
1793#[repr(C)]
1794pub struct ldbState {
1795    pub conn: *mut connection,
1796    pub active: libc::c_int,
1797    pub forked: libc::c_int,
1798    pub logs: *mut list,
1799    pub traces: *mut list,
1800    pub children: *mut list,
1801    pub bp: [libc::c_int; 64],
1802    pub bpcount: libc::c_int,
1803    pub step: libc::c_int,
1804    pub luabp: libc::c_int,
1805    pub src: *mut sds,
1806    pub lines: libc::c_int,
1807    pub currentline: libc::c_int,
1808    pub cbuf: sds,
1809    pub maxlen: size_t,
1810    pub maxlen_hint_sent: libc::c_int,
1811}
1812#[derive(Copy, Clone)]
1813#[repr(C)]
1814pub struct luaScript {
1815    pub flags: uint64_t,
1816    pub body: *mut robj,
1817}
1818#[derive(Copy, Clone)]
1819#[repr(C)]
1820pub struct scriptFlag {
1821    pub flag: uint64_t,
1822    pub str_0: *const libc::c_char,
1823}
1824#[derive(Copy, Clone)]
1825#[repr(C)]
1826pub struct scriptRunCtx {
1827    pub funcname: *const libc::c_char,
1828    pub c: *mut client,
1829    pub original_client: *mut client,
1830    pub flags: libc::c_int,
1831    pub repl_flags: libc::c_int,
1832    pub start_time: monotime,
1833    pub snapshot_time: mstime_t,
1834}
1835#[inline]
1836unsafe extern "C" fn connWrite(
1837    mut conn: *mut connection,
1838    mut data: *const libc::c_void,
1839    mut data_len: size_t,
1840) -> libc::c_int {
1841    return ((*(*conn).type_0).write)
1842        .expect("non-null function pointer")(conn, data, data_len);
1843}
1844#[inline]
1845unsafe extern "C" fn connRead(
1846    mut conn: *mut connection,
1847    mut buf: *mut libc::c_void,
1848    mut buf_len: size_t,
1849) -> libc::c_int {
1850    let mut ret: libc::c_int = ((*(*conn).type_0).read)
1851        .expect("non-null function pointer")(conn, buf, buf_len);
1852    return ret;
1853}
1854#[inline]
1855unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int {
1856    return strtol(
1857        __nptr,
1858        0 as *mut libc::c_void as *mut *mut libc::c_char,
1859        10 as libc::c_int,
1860    ) as libc::c_int;
1861}
1862#[inline]
1863unsafe extern "C" fn elapsedUs(mut start_time: monotime) -> uint64_t {
1864    return (getMonotonicUs.expect("non-null function pointer")())
1865        .wrapping_sub(start_time);
1866}
1867#[inline]
1868unsafe extern "C" fn elapsedMs(mut start_time: monotime) -> uint64_t {
1869    return (elapsedUs(start_time)).wrapping_div(1000 as libc::c_int as libc::c_ulong);
1870}
1871#[inline]
1872unsafe extern "C" fn sdssetlen(mut s: sds, mut newlen: size_t) {
1873    let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1874        as libc::c_uchar;
1875    match flags as libc::c_int & 7 as libc::c_int {
1876        0 => {
1877            let mut fp: *mut libc::c_uchar = (s as *mut libc::c_uchar)
1878                .offset(-(1 as libc::c_int as isize));
1879            *fp = (0 as libc::c_int as libc::c_ulong | newlen << 3 as libc::c_int)
1880                as libc::c_uchar;
1881        }
1882        1 => {
1883            (*(s.offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1884                as *mut sdshdr8))
1885                .len = newlen as uint8_t;
1886        }
1887        2 => {
1888            (*(s.offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
1889                as *mut sdshdr16))
1890                .len = newlen as uint16_t;
1891        }
1892        3 => {
1893            (*(s.offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
1894                as *mut sdshdr32))
1895                .len = newlen as uint32_t;
1896        }
1897        4 => {
1898            (*(s.offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
1899                as *mut sdshdr64))
1900                .len = newlen;
1901        }
1902        _ => {}
1903    };
1904}
1905#[inline]
1906unsafe extern "C" fn sdslen(s: sds) -> size_t {
1907    let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1908        as libc::c_uchar;
1909    match flags as libc::c_int & 7 as libc::c_int {
1910        0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
1911        1 => {
1912            return (*(s
1913                .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1914                as *mut sdshdr8))
1915                .len as size_t;
1916        }
1917        2 => {
1918            return (*(s
1919                .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
1920                as *mut sdshdr16))
1921                .len as size_t;
1922        }
1923        3 => {
1924            return (*(s
1925                .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
1926                as *mut sdshdr32))
1927                .len as size_t;
1928        }
1929        4 => {
1930            return (*(s
1931                .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
1932                as *mut sdshdr64))
1933                .len;
1934        }
1935        _ => {}
1936    }
1937    return 0 as libc::c_int as size_t;
1938}
1939unsafe extern "C" fn dictLuaScriptDestructor(
1940    mut d: *mut dict,
1941    mut val: *mut libc::c_void,
1942) {
1943    if val.is_null() {
1944        return;
1945    }
1946    decrRefCount((*(val as *mut luaScript)).body);
1947    zfree(val);
1948}
1949unsafe extern "C" fn dictStrCaseHash(mut key: *const libc::c_void) -> uint64_t {
1950    return dictGenCaseHashFunction(
1951        key as *mut libc::c_uchar,
1952        strlen(key as *mut libc::c_char),
1953    );
1954}
1955#[no_mangle]
1956pub static mut shaScriptObjectDictType: dictType = unsafe {
1957    {
1958        let mut init = dictType {
1959            hashFunction: Some(
1960                dictStrCaseHash as unsafe extern "C" fn(*const libc::c_void) -> uint64_t,
1961            ),
1962            keyDup: None,
1963            valDup: None,
1964            keyCompare: Some(
1965                dictSdsKeyCaseCompare
1966                    as unsafe extern "C" fn(
1967                        *mut dict,
1968                        *const libc::c_void,
1969                        *const libc::c_void,
1970                    ) -> libc::c_int,
1971            ),
1972            keyDestructor: Some(
1973                dictSdsDestructor
1974                    as unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
1975            ),
1976            valDestructor: Some(
1977                dictLuaScriptDestructor
1978                    as unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
1979            ),
1980            expandAllowed: None,
1981            dictEntryMetadataBytes: None,
1982        };
1983        init
1984    }
1985};
1986#[no_mangle]
1987pub static mut lctx: luaCtx = luaCtx {
1988    lua: 0 as *const lua_State as *mut lua_State,
1989    lua_client: 0 as *const client as *mut client,
1990    lua_scripts: 0 as *const dict as *mut dict,
1991    lua_scripts_mem: 0,
1992};
1993#[no_mangle]
1994pub static mut ldb: ldbState = ldbState {
1995    conn: 0 as *const connection as *mut connection,
1996    active: 0,
1997    forked: 0,
1998    logs: 0 as *const list as *mut list,
1999    traces: 0 as *const list as *mut list,
2000    children: 0 as *const list as *mut list,
2001    bp: [0; 64],
2002    bpcount: 0,
2003    step: 0,
2004    luabp: 0,
2005    src: 0 as *const sds as *mut sds,
2006    lines: 0,
2007    currentline: 0,
2008    cbuf: 0 as *const libc::c_char as *mut libc::c_char,
2009    maxlen: 0,
2010    maxlen_hint_sent: 0,
2011};
2012#[no_mangle]
2013pub unsafe extern "C" fn sha1hex(
2014    mut digest: *mut libc::c_char,
2015    mut script: *mut libc::c_char,
2016    mut len: size_t,
2017) {
2018    let mut ctx: SHA1_CTX = SHA1_CTX {
2019        state: [0; 5],
2020        count: [0; 2],
2021        buffer: [0; 64],
2022    };
2023    let mut hash: [libc::c_uchar; 20] = [0; 20];
2024    let mut cset: *mut libc::c_char = b"0123456789abcdef\0" as *const u8
2025        as *const libc::c_char as *mut libc::c_char;
2026    let mut j: libc::c_int = 0;
2027    SHA1Init(&mut ctx);
2028    SHA1Update(&mut ctx, script as *mut libc::c_uchar, len as uint32_t);
2029    SHA1Final(hash.as_mut_ptr(), &mut ctx);
2030    j = 0 as libc::c_int;
2031    while j < 20 as libc::c_int {
2032        *digest
2033            .offset(
2034                (j * 2 as libc::c_int) as isize,
2035            ) = *cset
2036            .offset(
2037                ((hash[j as usize] as libc::c_int & 0xf0 as libc::c_int)
2038                    >> 4 as libc::c_int) as isize,
2039            );
2040        *digest
2041            .offset(
2042                (j * 2 as libc::c_int + 1 as libc::c_int) as isize,
2043            ) = *cset
2044            .offset((hash[j as usize] as libc::c_int & 0xf as libc::c_int) as isize);
2045        j += 1;
2046    }
2047    *digest.offset(40 as libc::c_int as isize) = '\0' as i32 as libc::c_char;
2048}
2049#[no_mangle]
2050pub unsafe extern "C" fn luaRedisBreakpointCommand(
2051    mut lua: *mut lua_State,
2052) -> libc::c_int {
2053    if ldb.active != 0 {
2054        ldb.luabp = 1 as libc::c_int;
2055        lua_pushboolean(lua, 1 as libc::c_int);
2056    } else {
2057        lua_pushboolean(lua, 0 as libc::c_int);
2058    }
2059    return 1 as libc::c_int;
2060}
2061#[no_mangle]
2062pub unsafe extern "C" fn luaRedisDebugCommand(mut lua: *mut lua_State) -> libc::c_int {
2063    if ldb.active == 0 {
2064        return 0 as libc::c_int;
2065    }
2066    let mut argc: libc::c_int = lua_gettop(lua);
2067    let mut log: sds = sdscatprintf(
2068        sdsempty(),
2069        b"<debug> line %d: \0" as *const u8 as *const libc::c_char,
2070        ldb.currentline,
2071    );
2072    loop {
2073        let fresh0 = argc;
2074        argc = argc - 1;
2075        if !(fresh0 != 0) {
2076            break;
2077        }
2078        log = ldbCatStackValue(log, lua, -(1 as libc::c_int) - argc);
2079        if argc != 0 as libc::c_int {
2080            log = sdscatlen(
2081                log,
2082                b", \0" as *const u8 as *const libc::c_char as *const libc::c_void,
2083                2 as libc::c_int as size_t,
2084            );
2085        }
2086    }
2087    ldbLog(log);
2088    return 0 as libc::c_int;
2089}
2090#[no_mangle]
2091pub unsafe extern "C" fn luaRedisReplicateCommandsCommand(
2092    mut lua: *mut lua_State,
2093) -> libc::c_int {
2094    lua_pushboolean(lua, 1 as libc::c_int);
2095    return 1 as libc::c_int;
2096}
2097#[no_mangle]
2098pub unsafe extern "C" fn scriptingInit(mut setup: libc::c_int) {
2099    let mut lua: *mut lua_State = luaL_newstate();
2100    if setup != 0 {
2101        lctx.lua_client = 0 as *mut client;
2102        server.script_caller = 0 as *mut client;
2103        server.script_disable_deny_script = 0 as libc::c_int;
2104        ldbInit();
2105    }
2106    lctx.lua_scripts = dictCreate(&mut shaScriptObjectDictType);
2107    lctx.lua_scripts_mem = 0 as libc::c_int as libc::c_ulonglong;
2108    luaRegisterRedisAPI(lua);
2109    lua_getfield(
2110        lua,
2111        -(10002 as libc::c_int),
2112        b"redis\0" as *const u8 as *const libc::c_char,
2113    );
2114    lua_pushstring(lua, b"breakpoint\0" as *const u8 as *const libc::c_char);
2115    lua_pushcclosure(
2116        lua,
2117        Some(
2118            luaRedisBreakpointCommand
2119                as unsafe extern "C" fn(*mut lua_State) -> libc::c_int,
2120        ),
2121        0 as libc::c_int,
2122    );
2123    lua_settable(lua, -(3 as libc::c_int));
2124    lua_pushstring(lua, b"debug\0" as *const u8 as *const libc::c_char);
2125    lua_pushcclosure(
2126        lua,
2127        Some(
2128            luaRedisDebugCommand as unsafe extern "C" fn(*mut lua_State) -> libc::c_int,
2129        ),
2130        0 as libc::c_int,
2131    );
2132    lua_settable(lua, -(3 as libc::c_int));
2133    lua_pushstring(lua, b"replicate_commands\0" as *const u8 as *const libc::c_char);
2134    lua_pushcclosure(
2135        lua,
2136        Some(
2137            luaRedisReplicateCommandsCommand
2138                as unsafe extern "C" fn(*mut lua_State) -> libc::c_int,
2139        ),
2140        0 as libc::c_int,
2141    );
2142    lua_settable(lua, -(3 as libc::c_int));
2143    lua_setfield(
2144        lua,
2145        -(10002 as libc::c_int),
2146        b"redis\0" as *const u8 as *const libc::c_char,
2147    );
2148    let mut errh_func: *mut libc::c_char = b"local dbg = debug\ndebug = nil\nfunction __redis__err__handler(err)\n  local i = dbg.getinfo(2,'nSl')\n  if i and i.what == 'C' then\n    i = dbg.getinfo(3,'nSl')\n  end\n  if type(err) ~= 'table' then\n    err = {err='ERR ' .. tostring(err)}  end  if i then\n    err['source'] = i.source\n    err['line'] = i.currentline\n  end  return err\nend\n\0"
2149        as *const u8 as *const libc::c_char as *mut libc::c_char;
2150    luaL_loadbuffer(
2151        lua,
2152        errh_func,
2153        strlen(errh_func),
2154        b"@err_handler_def\0" as *const u8 as *const libc::c_char,
2155    );
2156    lua_pcall(lua, 0 as libc::c_int, 0 as libc::c_int, 0 as libc::c_int);
2157    if (lctx.lua_client).is_null() {
2158        lctx.lua_client = createClient(0 as *mut connection);
2159        (*lctx.lua_client).flags
2160            |= ((1 as libc::c_int) << 8 as libc::c_int) as libc::c_ulong;
2161        (*lctx.lua_client)
2162            .flags = ((*lctx.lua_client).flags as libc::c_ulonglong
2163            | (1 as libc::c_ulonglong) << 41 as libc::c_int) as uint64_t;
2164    }
2165    lua_pushvalue(lua, -(10002 as libc::c_int));
2166    luaSetErrorMetatable(lua);
2167    luaSetTableProtectionRecursively(lua);
2168    lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
2169    lctx.lua = lua;
2170}
2171#[no_mangle]
2172pub unsafe extern "C" fn scriptingRelease(mut async_0: libc::c_int) {
2173    if async_0 != 0 {
2174        freeLuaScriptsAsync(lctx.lua_scripts);
2175    } else {
2176        dictRelease(lctx.lua_scripts);
2177    }
2178    lctx.lua_scripts_mem = 0 as libc::c_int as libc::c_ulonglong;
2179    lua_close(lctx.lua);
2180}
2181#[no_mangle]
2182pub unsafe extern "C" fn scriptingReset(mut async_0: libc::c_int) {
2183    scriptingRelease(async_0);
2184    scriptingInit(0 as libc::c_int);
2185}
2186unsafe extern "C" fn evalCalcFunctionName(
2187    mut evalsha: libc::c_int,
2188    mut script: sds,
2189    mut out_funcname: *mut libc::c_char,
2190) {
2191    *out_funcname.offset(0 as libc::c_int as isize) = 'f' as i32 as libc::c_char;
2192    *out_funcname.offset(1 as libc::c_int as isize) = '_' as i32 as libc::c_char;
2193    if evalsha == 0 {
2194        sha1hex(out_funcname.offset(2 as libc::c_int as isize), script, sdslen(script));
2195    } else {
2196        let mut j: libc::c_int = 0;
2197        let mut sha: *mut libc::c_char = script;
2198        j = 0 as libc::c_int;
2199        while j < 40 as libc::c_int {
2200            *out_funcname
2201                .offset(
2202                    (j + 2 as libc::c_int) as isize,
2203                ) = (if *sha.offset(j as isize) as libc::c_int >= 'A' as i32
2204                && *sha.offset(j as isize) as libc::c_int <= 'Z' as i32
2205            {
2206                *sha.offset(j as isize) as libc::c_int + ('a' as i32 - 'A' as i32)
2207            } else {
2208                *sha.offset(j as isize) as libc::c_int
2209            }) as libc::c_char;
2210            j += 1;
2211        }
2212        *out_funcname.offset(42 as libc::c_int as isize) = '\0' as i32 as libc::c_char;
2213    };
2214}
2215#[no_mangle]
2216pub unsafe extern "C" fn evalExtractShebangFlags(
2217    mut body: sds,
2218    mut out_flags: *mut uint64_t,
2219    mut out_shebang_len: *mut ssize_t,
2220    mut err: *mut sds,
2221) -> libc::c_int {
2222    let mut shebang_len: ssize_t = 0 as libc::c_int as ssize_t;
2223    let mut script_flags: uint64_t = ((1 as libc::c_ulonglong) << 4 as libc::c_int)
2224        as uint64_t;
2225    if strncmp(
2226        body as *const libc::c_char,
2227        b"#!\0" as *const u8 as *const libc::c_char,
2228        2 as libc::c_int as libc::c_ulong,
2229    ) == 0
2230    {
2231        let mut numparts: libc::c_int = 0;
2232        let mut j: libc::c_int = 0;
2233        let mut shebang_end: *mut libc::c_char = strchr(
2234            body as *const libc::c_char,
2235            '\n' as i32,
2236        );
2237        if shebang_end.is_null() {
2238            if !err.is_null() {
2239                *err = sdsnew(
2240                    b"Invalid script shebang\0" as *const u8 as *const libc::c_char,
2241                );
2242            }
2243            return -(1 as libc::c_int);
2244        }
2245        shebang_len = shebang_end.offset_from(body) as libc::c_long;
2246        let mut shebang: sds = sdsnewlen(
2247            body as *const libc::c_void,
2248            shebang_len as size_t,
2249        );
2250        let mut parts: *mut sds = sdssplitargs(
2251            shebang as *const libc::c_char,
2252            &mut numparts,
2253        );
2254        sdsfree(shebang);
2255        if parts.is_null() || numparts == 0 as libc::c_int {
2256            if !err.is_null() {
2257                *err = sdsnew(
2258                    b"Invalid engine in script shebang\0" as *const u8
2259                        as *const libc::c_char,
2260                );
2261            }
2262            sdsfreesplitres(parts, numparts);
2263            return -(1 as libc::c_int);
2264        }
2265        if strcmp(
2266            *parts.offset(0 as libc::c_int as isize) as *const libc::c_char,
2267            b"#!lua\0" as *const u8 as *const libc::c_char,
2268        ) != 0
2269        {
2270            if !err.is_null() {
2271                *err = sdscatfmt(
2272                    sdsempty(),
2273                    b"Unexpected engine in script shebang: %s\0" as *const u8
2274                        as *const libc::c_char,
2275                    *parts.offset(0 as libc::c_int as isize),
2276                );
2277            }
2278            sdsfreesplitres(parts, numparts);
2279            return -(1 as libc::c_int);
2280        }
2281        script_flags = (script_flags as libc::c_ulonglong
2282            & !((1 as libc::c_ulonglong) << 4 as libc::c_int)) as uint64_t;
2283        j = 1 as libc::c_int;
2284        while j < numparts {
2285            if strncmp(
2286                *parts.offset(j as isize) as *const libc::c_char,
2287                b"flags=\0" as *const u8 as *const libc::c_char,
2288                6 as libc::c_int as libc::c_ulong,
2289            ) == 0
2290            {
2291                sdsrange(
2292                    *parts.offset(j as isize),
2293                    6 as libc::c_int as ssize_t,
2294                    -(1 as libc::c_int) as ssize_t,
2295                );
2296                let mut numflags: libc::c_int = 0;
2297                let mut jj: libc::c_int = 0;
2298                let mut flags: *mut sds = sdssplitlen(
2299                    *parts.offset(j as isize) as *const libc::c_char,
2300                    sdslen(*parts.offset(j as isize)) as ssize_t,
2301                    b",\0" as *const u8 as *const libc::c_char,
2302                    1 as libc::c_int,
2303                    &mut numflags,
2304                );
2305                jj = 0 as libc::c_int;
2306                while jj < numflags {
2307                    let mut sf: *mut scriptFlag = 0 as *mut scriptFlag;
2308                    sf = scripts_flags_def.as_mut_ptr();
2309                    while (*sf).flag != 0 {
2310                        if strcmp(
2311                            *flags.offset(jj as isize) as *const libc::c_char,
2312                            (*sf).str_0,
2313                        ) == 0
2314                        {
2315                            break;
2316                        }
2317                        sf = sf.offset(1);
2318                    }
2319                    if (*sf).flag == 0 {
2320                        if !err.is_null() {
2321                            *err = sdscatfmt(
2322                                sdsempty(),
2323                                b"Unexpected flag in script shebang: %s\0" as *const u8
2324                                    as *const libc::c_char,
2325                                *flags.offset(jj as isize),
2326                            );
2327                        }
2328                        sdsfreesplitres(flags, numflags);
2329                        sdsfreesplitres(parts, numparts);
2330                        return -(1 as libc::c_int);
2331                    }
2332                    script_flags |= (*sf).flag;
2333                    jj += 1;
2334                }
2335                sdsfreesplitres(flags, numflags);
2336            } else {
2337                if !err.is_null() {
2338                    *err = sdscatfmt(
2339                        sdsempty(),
2340                        b"Unknown lua shebang option: %s\0" as *const u8
2341                            as *const libc::c_char,
2342                        *parts.offset(j as isize),
2343                    );
2344                }
2345                sdsfreesplitres(parts, numparts);
2346                return -(1 as libc::c_int);
2347            }
2348            j += 1;
2349        }
2350        sdsfreesplitres(parts, numparts);
2351    }
2352    if !out_shebang_len.is_null() {
2353        *out_shebang_len = shebang_len;
2354    }
2355    *out_flags = script_flags;
2356    return 0 as libc::c_int;
2357}
2358#[no_mangle]
2359pub unsafe extern "C" fn evalGetCommandFlags(
2360    mut c: *mut client,
2361    mut cmd_flags: uint64_t,
2362) -> uint64_t {
2363    let mut funcname: [libc::c_char; 43] = [0; 43];
2364    let mut evalsha: libc::c_int = ((*(*c).cmd).proc_0
2365        == Some(evalShaCommand as unsafe extern "C" fn(*mut client) -> ())
2366        || (*(*c).cmd).proc_0
2367            == Some(evalShaRoCommand as unsafe extern "C" fn(*mut client) -> ()))
2368        as libc::c_int;
2369    if evalsha != 0
2370        && sdslen((**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds)
2371            != 40 as libc::c_int as libc::c_ulong
2372    {
2373        return cmd_flags;
2374    }
2375    let mut script_flags: uint64_t = 0;
2376    evalCalcFunctionName(
2377        evalsha,
2378        (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds,
2379        funcname.as_mut_ptr(),
2380    );
2381    let mut lua_cur_script: *mut libc::c_char = funcname
2382        .as_mut_ptr()
2383        .offset(2 as libc::c_int as isize);
2384    (*c).cur_script = dictFind(lctx.lua_scripts, lua_cur_script as *const libc::c_void);
2385    if ((*c).cur_script).is_null() {
2386        if evalsha != 0 {
2387            return cmd_flags;
2388        }
2389        if evalExtractShebangFlags(
2390            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds,
2391            &mut script_flags,
2392            0 as *mut ssize_t,
2393            0 as *mut sds,
2394        ) == -(1 as libc::c_int)
2395        {
2396            return cmd_flags;
2397        }
2398    } else {
2399        let mut l: *mut luaScript = (*(*c).cur_script).v.val as *mut luaScript;
2400        script_flags = (*l).flags;
2401    }
2402    if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 4 as libc::c_int
2403        != 0
2404    {
2405        return cmd_flags;
2406    }
2407    return scriptFlagsToCmdFlags(cmd_flags, script_flags);
2408}
2409#[no_mangle]
2410pub unsafe extern "C" fn luaCreateFunction(
2411    mut c: *mut client,
2412    mut body: *mut robj,
2413) -> sds {
2414    let mut funcname: [libc::c_char; 43] = [0; 43];
2415    let mut de: *mut dictEntry = 0 as *mut dictEntry;
2416    let mut script_flags: uint64_t = 0;
2417    funcname[0 as libc::c_int as usize] = 'f' as i32 as libc::c_char;
2418    funcname[1 as libc::c_int as usize] = '_' as i32 as libc::c_char;
2419    sha1hex(
2420        funcname.as_mut_ptr().offset(2 as libc::c_int as isize),
2421        (*body).ptr as *mut libc::c_char,
2422        sdslen((*body).ptr as sds),
2423    );
2424    de = dictFind(
2425        lctx.lua_scripts,
2426        funcname.as_mut_ptr().offset(2 as libc::c_int as isize) as *const libc::c_void,
2427    );
2428    if !de.is_null() {
2429        return (*de).key as sds;
2430    }
2431    let mut shebang_len: ssize_t = 0 as libc::c_int as ssize_t;
2432    let mut err: sds = 0 as sds;
2433    if evalExtractShebangFlags(
2434        (*body).ptr as sds,
2435        &mut script_flags,
2436        &mut shebang_len,
2437        &mut err,
2438    ) == -(1 as libc::c_int)
2439    {
2440        addReplyErrorSds(c, err);
2441        return 0 as sds;
2442    }
2443    if luaL_loadbuffer(
2444        lctx.lua,
2445        ((*body).ptr as *mut libc::c_char).offset(shebang_len as isize),
2446        (sdslen((*body).ptr as sds)).wrapping_sub(shebang_len as libc::c_ulong),
2447        b"@user_script\0" as *const u8 as *const libc::c_char,
2448    ) != 0
2449    {
2450        if !c.is_null() {
2451            addReplyErrorFormat(
2452                c,
2453                b"Error compiling script (new function): %s\0" as *const u8
2454                    as *const libc::c_char,
2455                lua_tolstring(lctx.lua, -(1 as libc::c_int), 0 as *mut size_t),
2456            );
2457        }
2458        lua_settop(lctx.lua, -(1 as libc::c_int) - 1 as libc::c_int);
2459        return 0 as sds;
2460    }
2461    if lua_type(lctx.lua, -(1 as libc::c_int)) == 6 as libc::c_int {} else {
2462        _serverAssert(
2463            b"lua_isfunction(lctx.lua, -1)\0" as *const u8 as *const libc::c_char,
2464            b"eval.c\0" as *const u8 as *const libc::c_char,
2465            455 as libc::c_int,
2466        );
2467        unreachable!();
2468    };
2469    lua_setfield(lctx.lua, -(10000 as libc::c_int), funcname.as_mut_ptr());
2470    let mut l: *mut luaScript = zcalloc(
2471        core::mem::size_of::<luaScript>() as libc::c_ulong,
2472    ) as *mut luaScript;
2473    (*l).body = body;
2474    (*l).flags = script_flags;
2475    let mut sha: sds = sdsnewlen(
2476        funcname.as_mut_ptr().offset(2 as libc::c_int as isize) as *const libc::c_void,
2477        40 as libc::c_int as size_t,
2478    );
2479    let mut retval: libc::c_int = dictAdd(
2480        lctx.lua_scripts,
2481        sha as *mut libc::c_void,
2482        l as *mut libc::c_void,
2483    );
2484    if retval == 0 as libc::c_int {} else {
2485        _serverAssertWithInfo(
2486            (if !c.is_null() { c } else { lctx.lua_client }),
2487            0 as *const robj,
2488            b"retval == DICT_OK\0" as *const u8 as *const libc::c_char,
2489            b"eval.c\0" as *const u8 as *const libc::c_char,
2490            467 as libc::c_int,
2491        );
2492        unreachable!();
2493    };
2494    lctx
2495        .lua_scripts_mem = (lctx.lua_scripts_mem)
2496        .wrapping_add(
2497            (sdsZmallocSize(sha)).wrapping_add(getStringObjectSdsUsedMemory(body))
2498                as libc::c_ulonglong,
2499        );
2500    incrRefCount(body);
2501    return sha;
2502}
2503#[no_mangle]
2504pub unsafe extern "C" fn prepareLuaClient() {
2505    selectDb(lctx.lua_client, (*(*server.script_caller).db).id);
2506    (*lctx.lua_client).resp = 2 as libc::c_int;
2507    if (*server.script_caller).flags
2508        & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong != 0
2509    {
2510        (*lctx.lua_client).flags
2511            |= ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong;
2512    }
2513}
2514#[no_mangle]
2515pub unsafe extern "C" fn resetLuaClient() {
2516    (*lctx.lua_client).flags
2517        &= !((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong;
2518}
2519#[no_mangle]
2520pub unsafe extern "C" fn evalGenericCommand(
2521    mut c: *mut client,
2522    mut evalsha: libc::c_int,
2523) {
2524    let mut lua: *mut lua_State = lctx.lua;
2525    let mut funcname: [libc::c_char; 43] = [0; 43];
2526    let mut numkeys: libc::c_longlong = 0;
2527    if getLongLongFromObjectOrReply(
2528        c,
2529        *((*c).argv).offset(2 as libc::c_int as isize),
2530        &mut numkeys,
2531        0 as *const libc::c_char,
2532    ) != 0 as libc::c_int
2533    {
2534        return;
2535    }
2536    if numkeys > ((*c).argc - 3 as libc::c_int) as libc::c_longlong {
2537        addReplyError(
2538            c,
2539            b"Number of keys can't be greater than number of args\0" as *const u8
2540                as *const libc::c_char,
2541        );
2542        return;
2543    } else {
2544        if numkeys < 0 as libc::c_int as libc::c_longlong {
2545            addReplyError(
2546                c,
2547                b"Number of keys can't be negative\0" as *const u8 as *const libc::c_char,
2548            );
2549            return;
2550        }
2551    }
2552    if !((*c).cur_script).is_null() {
2553        funcname[0 as libc::c_int as usize] = 'f' as i32 as libc::c_char;
2554        funcname[1 as libc::c_int as usize] = '_' as i32 as libc::c_char;
2555        memcpy(
2556            funcname.as_mut_ptr().offset(2 as libc::c_int as isize) as *mut libc::c_void,
2557            (*(*c).cur_script).key,
2558            40 as libc::c_int as libc::c_ulong,
2559        );
2560        funcname[42 as libc::c_int as usize] = '\0' as i32 as libc::c_char;
2561    } else {
2562        evalCalcFunctionName(
2563            evalsha,
2564            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds,
2565            funcname.as_mut_ptr(),
2566        );
2567    }
2568    lua_getfield(
2569        lua,
2570        -(10002 as libc::c_int),
2571        b"__redis__err__handler\0" as *const u8 as *const libc::c_char,
2572    );
2573    lua_getfield(lua, -(10000 as libc::c_int), funcname.as_mut_ptr());
2574    if lua_type(lua, -(1 as libc::c_int)) == 0 as libc::c_int {
2575        lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
2576        if evalsha != 0 {
2577            lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
2578            addReplyErrorObject(c, shared.noscripterr);
2579            return;
2580        }
2581        if (luaCreateFunction(c, *((*c).argv).offset(1 as libc::c_int as isize)))
2582            .is_null()
2583        {
2584            lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
2585            return;
2586        }
2587        lua_getfield(lua, -(10000 as libc::c_int), funcname.as_mut_ptr());
2588        if !(lua_type(lua, -(1 as libc::c_int)) == 0 as libc::c_int) {} else {
2589            _serverAssert(
2590                b"!lua_isnil(lua,-1)\0" as *const u8 as *const libc::c_char,
2591                b"eval.c\0" as *const u8 as *const libc::c_char,
2592                535 as libc::c_int,
2593            );
2594            unreachable!();
2595        };
2596    }
2597    let mut lua_cur_script: *mut libc::c_char = funcname
2598        .as_mut_ptr()
2599        .offset(2 as libc::c_int as isize);
2600    let mut de: *mut dictEntry = (*c).cur_script;
2601    if de.is_null() {
2602        de = dictFind(lctx.lua_scripts, lua_cur_script as *const libc::c_void);
2603    }
2604    let mut l: *mut luaScript = (*de).v.val as *mut luaScript;
2605    let mut ro: libc::c_int = ((*(*c).cmd).proc_0
2606        == Some(evalRoCommand as unsafe extern "C" fn(*mut client) -> ())
2607        || (*(*c).cmd).proc_0
2608            == Some(evalShaRoCommand as unsafe extern "C" fn(*mut client) -> ()))
2609        as libc::c_int;
2610    let mut rctx: scriptRunCtx = scriptRunCtx {
2611        funcname: 0 as *const libc::c_char,
2612        c: 0 as *mut client,
2613        original_client: 0 as *mut client,
2614        flags: 0,
2615        repl_flags: 0,
2616        start_time: 0,
2617        snapshot_time: 0,
2618    };
2619    if scriptPrepareForRun(&mut rctx, lctx.lua_client, c, lua_cur_script, (*l).flags, ro)
2620        != 0 as libc::c_int
2621    {
2622        lua_settop(lua, -(2 as libc::c_int) - 1 as libc::c_int);
2623        return;
2624    }
2625    rctx
2626        .flags = (rctx.flags as libc::c_ulonglong
2627        | (1 as libc::c_ulonglong) << 7 as libc::c_int) as libc::c_int;
2628    luaCallFunction(
2629        &mut rctx,
2630        lua,
2631        ((*c).argv).offset(3 as libc::c_int as isize),
2632        numkeys as size_t,
2633        ((*c).argv).offset(3 as libc::c_int as isize).offset(numkeys as isize),
2634        (((*c).argc - 3 as libc::c_int) as libc::c_longlong - numkeys) as size_t,
2635        ldb.active,
2636    );
2637    lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
2638    scriptResetRun(&mut rctx);
2639}
2640#[no_mangle]
2641pub unsafe extern "C" fn evalCommand(mut c: *mut client) {
2642    replicationFeedMonitors(c, server.monitors, (*(*c).db).id, (*c).argv, (*c).argc);
2643    if (*c).flags & ((1 as libc::c_int) << 25 as libc::c_int) as libc::c_ulong == 0 {
2644        evalGenericCommand(c, 0 as libc::c_int);
2645    } else {
2646        evalGenericCommandWithDebugging(c, 0 as libc::c_int);
2647    };
2648}
2649#[no_mangle]
2650pub unsafe extern "C" fn evalRoCommand(mut c: *mut client) {
2651    evalCommand(c);
2652}
2653#[no_mangle]
2654pub unsafe extern "C" fn evalShaCommand(mut c: *mut client) {
2655    replicationFeedMonitors(c, server.monitors, (*(*c).db).id, (*c).argv, (*c).argc);
2656    if sdslen((**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds)
2657        != 40 as libc::c_int as libc::c_ulong
2658    {
2659        addReplyErrorObject(c, shared.noscripterr);
2660        return;
2661    }
2662    if (*c).flags & ((1 as libc::c_int) << 25 as libc::c_int) as libc::c_ulong == 0 {
2663        evalGenericCommand(c, 1 as libc::c_int);
2664    } else {
2665        addReplyError(
2666            c,
2667            b"Please use EVAL instead of EVALSHA for debugging\0" as *const u8
2668                as *const libc::c_char,
2669        );
2670        return;
2671    };
2672}
2673#[no_mangle]
2674pub unsafe extern "C" fn evalShaRoCommand(mut c: *mut client) {
2675    evalShaCommand(c);
2676}
2677#[no_mangle]
2678pub unsafe extern "C" fn scriptCommand(mut c: *mut client) {
2679    if (*c).argc == 2 as libc::c_int
2680        && strcasecmp(
2681            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2682            b"help\0" as *const u8 as *const libc::c_char,
2683        ) == 0
2684    {
2685        let mut help: [*const libc::c_char; 15] = [
2686            b"DEBUG (YES|SYNC|NO)\0" as *const u8 as *const libc::c_char,
2687            b"    Set the debug mode for subsequent scripts executed.\0" as *const u8
2688                as *const libc::c_char,
2689            b"EXISTS <sha1> [<sha1> ...]\0" as *const u8 as *const libc::c_char,
2690            b"    Return information about the existence of the scripts in the script cache.\0"
2691                as *const u8 as *const libc::c_char,
2692            b"FLUSH [ASYNC|SYNC]\0" as *const u8 as *const libc::c_char,
2693            b"    Flush the Lua scripts cache. Very dangerous on replicas.\0"
2694                as *const u8 as *const libc::c_char,
2695            b"    When called without the optional mode argument, the behavior is determined by the\0"
2696                as *const u8 as *const libc::c_char,
2697            b"    lazyfree-lazy-user-flush configuration directive. Valid modes are:\0"
2698                as *const u8 as *const libc::c_char,
2699            b"    * ASYNC: Asynchronously flush the scripts cache.\0" as *const u8
2700                as *const libc::c_char,
2701            b"    * SYNC: Synchronously flush the scripts cache.\0" as *const u8
2702                as *const libc::c_char,
2703            b"KILL\0" as *const u8 as *const libc::c_char,
2704            b"    Kill the currently executing Lua script.\0" as *const u8
2705                as *const libc::c_char,
2706            b"LOAD <script>\0" as *const u8 as *const libc::c_char,
2707            b"    Load a script into the scripts cache without executing it.\0"
2708                as *const u8 as *const libc::c_char,
2709            0 as *const libc::c_char,
2710        ];
2711        addReplyHelp(c, help.as_mut_ptr());
2712    } else if (*c).argc >= 2 as libc::c_int
2713        && strcasecmp(
2714            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2715            b"flush\0" as *const u8 as *const libc::c_char,
2716        ) == 0
2717    {
2718        let mut async_0: libc::c_int = 0 as libc::c_int;
2719        if (*c).argc == 3 as libc::c_int
2720            && strcasecmp(
2721                (**((*c).argv).offset(2 as libc::c_int as isize)).ptr
2722                    as *const libc::c_char,
2723                b"sync\0" as *const u8 as *const libc::c_char,
2724            ) == 0
2725        {
2726            async_0 = 0 as libc::c_int;
2727        } else if (*c).argc == 3 as libc::c_int
2728            && strcasecmp(
2729                (**((*c).argv).offset(2 as libc::c_int as isize)).ptr
2730                    as *const libc::c_char,
2731                b"async\0" as *const u8 as *const libc::c_char,
2732            ) == 0
2733        {
2734            async_0 = 1 as libc::c_int;
2735        } else if (*c).argc == 2 as libc::c_int {
2736            async_0 = if server.lazyfree_lazy_user_flush != 0 {
2737                1 as libc::c_int
2738            } else {
2739                0 as libc::c_int
2740            };
2741        } else {
2742            addReplyError(
2743                c,
2744                b"SCRIPT FLUSH only support SYNC|ASYNC option\0" as *const u8
2745                    as *const libc::c_char,
2746            );
2747            return;
2748        }
2749        scriptingReset(async_0);
2750        addReply(c, shared.ok);
2751    } else if (*c).argc >= 2 as libc::c_int
2752        && strcasecmp(
2753            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2754            b"exists\0" as *const u8 as *const libc::c_char,
2755        ) == 0
2756    {
2757        let mut j: libc::c_int = 0;
2758        addReplyArrayLen(c, ((*c).argc - 2 as libc::c_int) as libc::c_long);
2759        j = 2 as libc::c_int;
2760        while j < (*c).argc {
2761            if !(dictFind(lctx.lua_scripts, (**((*c).argv).offset(j as isize)).ptr))
2762                .is_null()
2763            {
2764                addReply(c, shared.cone);
2765            } else {
2766                addReply(c, shared.czero);
2767            }
2768            j += 1;
2769        }
2770    } else if (*c).argc == 3 as libc::c_int
2771        && strcasecmp(
2772            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2773            b"load\0" as *const u8 as *const libc::c_char,
2774        ) == 0
2775    {
2776        let mut sha: sds = luaCreateFunction(
2777            c,
2778            *((*c).argv).offset(2 as libc::c_int as isize),
2779        );
2780        if sha.is_null() {
2781            return;
2782        }
2783        addReplyBulkCBuffer(c, sha as *const libc::c_void, 40 as libc::c_int as size_t);
2784    } else if (*c).argc == 2 as libc::c_int
2785        && strcasecmp(
2786            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2787            b"kill\0" as *const u8 as *const libc::c_char,
2788        ) == 0
2789    {
2790        scriptKill(c, 1 as libc::c_int);
2791    } else if (*c).argc == 3 as libc::c_int
2792        && strcasecmp(
2793            (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as *const libc::c_char,
2794            b"debug\0" as *const u8 as *const libc::c_char,
2795        ) == 0
2796    {
2797        if clientHasPendingReplies(c) != 0 {
2798            addReplyError(
2799                c,
2800                b"SCRIPT DEBUG must be called outside a pipeline\0" as *const u8
2801                    as *const libc::c_char,
2802            );
2803            return;
2804        }
2805        if strcasecmp(
2806            (**((*c).argv).offset(2 as libc::c_int as isize)).ptr as *const libc::c_char,
2807            b"no\0" as *const u8 as *const libc::c_char,
2808        ) == 0
2809        {
2810            ldbDisable(c);
2811            addReply(c, shared.ok);
2812        } else if strcasecmp(
2813            (**((*c).argv).offset(2 as libc::c_int as isize)).ptr as *const libc::c_char,
2814            b"yes\0" as *const u8 as *const libc::c_char,
2815        ) == 0
2816        {
2817            ldbEnable(c);
2818            addReply(c, shared.ok);
2819        } else if strcasecmp(
2820            (**((*c).argv).offset(2 as libc::c_int as isize)).ptr as *const libc::c_char,
2821            b"sync\0" as *const u8 as *const libc::c_char,
2822        ) == 0
2823        {
2824            ldbEnable(c);
2825            addReply(c, shared.ok);
2826            (*c).flags |= ((1 as libc::c_int) << 26 as libc::c_int) as libc::c_ulong;
2827        } else {
2828            addReplyError(
2829                c,
2830                b"Use SCRIPT DEBUG YES/SYNC/NO\0" as *const u8 as *const libc::c_char,
2831            );
2832            return;
2833        }
2834    } else {
2835        addReplySubcommandSyntaxError(c);
2836    };
2837}
2838#[no_mangle]
2839pub unsafe extern "C" fn evalMemory() -> libc::c_ulong {
2840    return luaMemory(lctx.lua);
2841}
2842#[no_mangle]
2843pub unsafe extern "C" fn evalScriptsDict() -> *mut dict {
2844    return lctx.lua_scripts;
2845}
2846#[no_mangle]
2847pub unsafe extern "C" fn evalScriptsMemory() -> libc::c_ulong {
2848    return (lctx.lua_scripts_mem)
2849        .wrapping_add(
2850            ((*lctx.lua_scripts).ht_used[0 as libc::c_int as usize])
2851                .wrapping_add((*lctx.lua_scripts).ht_used[1 as libc::c_int as usize])
2852                .wrapping_mul(
2853                    (core::mem::size_of::<dictEntry>() as libc::c_ulong)
2854                        .wrapping_add(
2855                            core::mem::size_of::<luaScript>() as libc::c_ulong,
2856                        ),
2857                ) as libc::c_ulonglong,
2858        )
2859        .wrapping_add(
2860            (if (*lctx.lua_scripts).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
2861                == -(1 as libc::c_int)
2862            {
2863                0 as libc::c_int as libc::c_ulong
2864            } else {
2865                (1 as libc::c_int as libc::c_ulong)
2866                    << (*lctx.lua_scripts).ht_size_exp[0 as libc::c_int as usize]
2867                        as libc::c_int
2868            })
2869                .wrapping_add(
2870                    (if (*lctx.lua_scripts).ht_size_exp[1 as libc::c_int as usize]
2871                        as libc::c_int == -(1 as libc::c_int)
2872                    {
2873                        0 as libc::c_int as libc::c_ulong
2874                    } else {
2875                        (1 as libc::c_int as libc::c_ulong)
2876                            << (*lctx.lua_scripts).ht_size_exp[1 as libc::c_int as usize]
2877                                as libc::c_int
2878                    }),
2879                )
2880                .wrapping_mul(core::mem::size_of::<*mut dictEntry>() as libc::c_ulong)
2881                as libc::c_ulonglong,
2882        ) as libc::c_ulong;
2883}
2884#[no_mangle]
2885pub unsafe extern "C" fn ldbInit() {
2886    ldb.conn = 0 as *mut connection;
2887    ldb.active = 0 as libc::c_int;
2888    ldb.logs = listCreate();
2889    (*ldb.logs)
2890        .free = core::mem::transmute::<
2891        Option::<unsafe extern "C" fn(sds) -> ()>,
2892        Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
2893    >(Some(sdsfree as unsafe extern "C" fn(sds) -> ()));
2894    ldb.children = listCreate();
2895    ldb.src = 0 as *mut sds;
2896    ldb.lines = 0 as libc::c_int;
2897    ldb.cbuf = sdsempty();
2898}
2899#[no_mangle]
2900pub unsafe extern "C" fn ldbFlushLog(mut log: *mut list) {
2901    let mut ln: *mut listNode = 0 as *mut listNode;
2902    loop {
2903        ln = (*log).head;
2904        if ln.is_null() {
2905            break;
2906        }
2907        listDelNode(log, ln);
2908    };
2909}
2910#[no_mangle]
2911pub unsafe extern "C" fn ldbIsEnabled() -> libc::c_int {
2912    return (ldb.active != 0 && ldb.step != 0) as libc::c_int;
2913}
2914#[no_mangle]
2915pub unsafe extern "C" fn ldbEnable(mut c: *mut client) {
2916    (*c).flags |= ((1 as libc::c_int) << 25 as libc::c_int) as libc::c_ulong;
2917    ldbFlushLog(ldb.logs);
2918    ldb.conn = (*c).conn;
2919    ldb.step = 1 as libc::c_int;
2920    ldb.bpcount = 0 as libc::c_int;
2921    ldb.luabp = 0 as libc::c_int;
2922    sdsfree(ldb.cbuf);
2923    ldb.cbuf = sdsempty();
2924    ldb.maxlen = 256 as libc::c_int as size_t;
2925    ldb.maxlen_hint_sent = 0 as libc::c_int;
2926}
2927#[no_mangle]
2928pub unsafe extern "C" fn ldbDisable(mut c: *mut client) {
2929    (*c).flags
2930        &= !((1 as libc::c_int) << 25 as libc::c_int
2931            | (1 as libc::c_int) << 26 as libc::c_int) as libc::c_ulong;
2932}
2933#[no_mangle]
2934pub unsafe extern "C" fn ldbLog(mut entry: sds) {
2935    listAddNodeTail(ldb.logs, entry as *mut libc::c_void);
2936}
2937#[no_mangle]
2938pub unsafe extern "C" fn ldbLogWithMaxLen(mut entry: sds) {
2939    let mut trimmed: libc::c_int = 0 as libc::c_int;
2940    if ldb.maxlen != 0 && sdslen(entry) > ldb.maxlen {
2941        sdsrange(
2942            entry,
2943            0 as libc::c_int as ssize_t,
2944            (ldb.maxlen).wrapping_sub(1 as libc::c_int as libc::c_ulong) as ssize_t,
2945        );
2946        entry = sdscatlen(
2947            entry,
2948            b" ...\0" as *const u8 as *const libc::c_char as *const libc::c_void,
2949            4 as libc::c_int as size_t,
2950        );
2951        trimmed = 1 as libc::c_int;
2952    }
2953    ldbLog(entry);
2954    if trimmed != 0 && ldb.maxlen_hint_sent == 0 as libc::c_int {
2955        ldb.maxlen_hint_sent = 1 as libc::c_int;
2956        ldbLog(
2957            sdsnew(
2958                b"<hint> The above reply was trimmed. Use 'maxlen 0' to disable trimming.\0"
2959                    as *const u8 as *const libc::c_char,
2960            ),
2961        );
2962    }
2963}
2964#[no_mangle]
2965pub unsafe extern "C" fn ldbSendLogs() {
2966    let mut proto: sds = sdsempty();
2967    proto = sdscatfmt(
2968        proto,
2969        b"*%i\r\n\0" as *const u8 as *const libc::c_char,
2970        (*ldb.logs).len as libc::c_int,
2971    );
2972    while (*ldb.logs).len != 0 {
2973        let mut ln: *mut listNode = (*ldb.logs).head;
2974        proto = sdscatlen(
2975            proto,
2976            b"+\0" as *const u8 as *const libc::c_char as *const libc::c_void,
2977            1 as libc::c_int as size_t,
2978        );
2979        sdsmapchars(
2980            (*ln).value as sds,
2981            b"\r\n\0" as *const u8 as *const libc::c_char,
2982            b"  \0" as *const u8 as *const libc::c_char,
2983            2 as libc::c_int as size_t,
2984        );
2985        proto = sdscatsds(proto, (*ln).value as sds);
2986        proto = sdscatlen(
2987            proto,
2988            b"\r\n\0" as *const u8 as *const libc::c_char as *const libc::c_void,
2989            2 as libc::c_int as size_t,
2990        );
2991        listDelNode(ldb.logs, ln);
2992    }
2993    connWrite(ldb.conn, proto as *const libc::c_void, sdslen(proto))
2994        == -(1 as libc::c_int);
2995    sdsfree(proto);
2996}
2997#[no_mangle]
2998pub unsafe extern "C" fn ldbStartSession(mut c: *mut client) -> libc::c_int {
2999    ldb
3000        .forked = ((*c).flags
3001        & ((1 as libc::c_int) << 26 as libc::c_int) as libc::c_ulong
3002        == 0 as libc::c_int as libc::c_ulong) as libc::c_int;
3003    if ldb.forked != 0 {
3004        let mut cp: pid_t = redisFork(3 as libc::c_int);
3005        if cp == -(1 as libc::c_int) {
3006            addReplyErrorFormat(
3007                c,
3008                b"Fork() failed: can't run EVAL in debugging mode: %s\0" as *const u8
3009                    as *const libc::c_char,
3010                strerror(*__errno_location()),
3011            );
3012            return 0 as libc::c_int;
3013        } else {
3014            if cp == 0 as libc::c_int {
3015                let mut act: sigaction = sigaction {
3016                    __sigaction_handler: C2RustUnnamed_9 {
3017                        sa_handler: None,
3018                    },
3019                    sa_mask: __sigset_t { __val: [0; 16] },
3020                    sa_flags: 0,
3021                    sa_restorer: None,
3022                };
3023                sigemptyset(&mut act.sa_mask);
3024                act.sa_flags = 0 as libc::c_int;
3025                act
3026                    .__sigaction_handler
3027                    .sa_handler = core::mem::transmute::<
3028                    libc::intptr_t,
3029                    __sighandler_t,
3030                >(1 as libc::c_int as libc::intptr_t);
3031                sigaction(15 as libc::c_int, &mut act, 0 as *mut sigaction);
3032                sigaction(2 as libc::c_int, &mut act, 0 as *mut sigaction);
3033                if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3034                    _serverLog(
3035                        3 as libc::c_int,
3036                        b"Redis forked for debugging eval\0" as *const u8
3037                            as *const libc::c_char,
3038                    );
3039                }
3040            } else {
3041                listAddNodeTail(ldb.children, cp as libc::c_ulong as *mut libc::c_void);
3042                freeClientAsync(c);
3043                return 0 as libc::c_int;
3044            }
3045        }
3046    } else if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3047        _serverLog(
3048            3 as libc::c_int,
3049            b"Redis synchronous debugging eval session started\0" as *const u8
3050                as *const libc::c_char,
3051        );
3052    }
3053    connBlock(ldb.conn);
3054    connSendTimeout(ldb.conn, 5000 as libc::c_int as libc::c_longlong);
3055    ldb.active = 1 as libc::c_int;
3056    let mut srcstring: sds = sdsdup(
3057        (**((*c).argv).offset(1 as libc::c_int as isize)).ptr as sds,
3058    );
3059    let mut srclen: size_t = sdslen(srcstring);
3060    while srclen != 0
3061        && (*srcstring
3062            .offset(srclen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize)
3063            as libc::c_int == '\n' as i32
3064            || *srcstring
3065                .offset(srclen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize)
3066                as libc::c_int == '\r' as i32)
3067    {
3068        srclen = srclen.wrapping_sub(1);
3069        *srcstring.offset(srclen as isize) = '\0' as i32 as libc::c_char;
3070    }
3071    sdssetlen(srcstring, srclen);
3072    ldb
3073        .src = sdssplitlen(
3074        srcstring as *const libc::c_char,
3075        sdslen(srcstring) as ssize_t,
3076        b"\n\0" as *const u8 as *const libc::c_char,
3077        1 as libc::c_int,
3078        &mut ldb.lines,
3079    );
3080    sdsfree(srcstring);
3081    return 1 as libc::c_int;
3082}
3083#[no_mangle]
3084pub unsafe extern "C" fn ldbEndSession(mut c: *mut client) {
3085    ldbLog(sdsnew(b"<endsession>\0" as *const u8 as *const libc::c_char));
3086    ldbSendLogs();
3087    if ldb.forked != 0 {
3088        writeToClient(c, 0 as libc::c_int);
3089        if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3090            _serverLog(
3091                3 as libc::c_int,
3092                b"Lua debugging session child exiting\0" as *const u8
3093                    as *const libc::c_char,
3094            );
3095        }
3096        exitFromChild(0 as libc::c_int);
3097    } else if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3098        _serverLog(
3099            3 as libc::c_int,
3100            b"Redis synchronous debugging eval session ended\0" as *const u8
3101                as *const libc::c_char,
3102        );
3103    }
3104    connNonBlock(ldb.conn);
3105    connSendTimeout(ldb.conn, 0 as libc::c_int as libc::c_longlong);
3106    (*c).flags |= ((1 as libc::c_int) << 6 as libc::c_int) as libc::c_ulong;
3107    sdsfreesplitres(ldb.src, ldb.lines);
3108    ldb.lines = 0 as libc::c_int;
3109    ldb.active = 0 as libc::c_int;
3110}
3111#[no_mangle]
3112pub unsafe extern "C" fn ldbRemoveChild(mut pid: pid_t) -> libc::c_int {
3113    let mut ln: *mut listNode = listSearchKey(
3114        ldb.children,
3115        pid as libc::c_ulong as *mut libc::c_void,
3116    );
3117    if !ln.is_null() {
3118        listDelNode(ldb.children, ln);
3119        return 1 as libc::c_int;
3120    }
3121    return 0 as libc::c_int;
3122}
3123#[no_mangle]
3124pub unsafe extern "C" fn ldbPendingChildren() -> libc::c_int {
3125    return (*ldb.children).len as libc::c_int;
3126}
3127#[no_mangle]
3128pub unsafe extern "C" fn ldbKillForkedSessions() {
3129    let mut li: listIter = listIter {
3130        next: 0 as *mut listNode,
3131        direction: 0,
3132    };
3133    let mut ln: *mut listNode = 0 as *mut listNode;
3134    listRewind(ldb.children, &mut li);
3135    loop {
3136        ln = listNext(&mut li);
3137        if ln.is_null() {
3138            break;
3139        }
3140        let mut pid: pid_t = (*ln).value as libc::c_ulong as pid_t;
3141        if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3142            _serverLog(
3143                3 as libc::c_int,
3144                b"Killing debugging session %ld\0" as *const u8 as *const libc::c_char,
3145                pid as libc::c_long,
3146            );
3147        }
3148        kill(pid, 9 as libc::c_int);
3149    }
3150    listRelease(ldb.children);
3151    ldb.children = listCreate();
3152}
3153#[no_mangle]
3154pub unsafe extern "C" fn evalGenericCommandWithDebugging(
3155    mut c: *mut client,
3156    mut evalsha: libc::c_int,
3157) {
3158    if ldbStartSession(c) != 0 {
3159        evalGenericCommand(c, evalsha);
3160        ldbEndSession(c);
3161    } else {
3162        ldbDisable(c);
3163    };
3164}
3165#[no_mangle]
3166pub unsafe extern "C" fn ldbGetSourceLine(mut line: libc::c_int) -> *mut libc::c_char {
3167    let mut idx: libc::c_int = line - 1 as libc::c_int;
3168    if idx < 0 as libc::c_int || idx >= ldb.lines {
3169        return b"<out of range source code line>\0" as *const u8 as *const libc::c_char
3170            as *mut libc::c_char;
3171    }
3172    return *(ldb.src).offset(idx as isize);
3173}
3174#[no_mangle]
3175pub unsafe extern "C" fn ldbIsBreakpoint(mut line: libc::c_int) -> libc::c_int {
3176    let mut j: libc::c_int = 0;
3177    j = 0 as libc::c_int;
3178    while j < ldb.bpcount {
3179        if ldb.bp[j as usize] == line {
3180            return 1 as libc::c_int;
3181        }
3182        j += 1;
3183    }
3184    return 0 as libc::c_int;
3185}
3186#[no_mangle]
3187pub unsafe extern "C" fn ldbAddBreakpoint(mut line: libc::c_int) -> libc::c_int {
3188    if line <= 0 as libc::c_int || line > ldb.lines {
3189        return 0 as libc::c_int;
3190    }
3191    if ldbIsBreakpoint(line) == 0 && ldb.bpcount != 64 as libc::c_int {
3192        let fresh1 = ldb.bpcount;
3193        ldb.bpcount = ldb.bpcount + 1;
3194        ldb.bp[fresh1 as usize] = line;
3195        return 1 as libc::c_int;
3196    }
3197    return 0 as libc::c_int;
3198}
3199#[no_mangle]
3200pub unsafe extern "C" fn ldbDelBreakpoint(mut line: libc::c_int) -> libc::c_int {
3201    let mut j: libc::c_int = 0;
3202    j = 0 as libc::c_int;
3203    while j < ldb.bpcount {
3204        if ldb.bp[j as usize] == line {
3205            ldb.bpcount -= 1;
3206            memmove(
3207                (ldb.bp).as_mut_ptr().offset(j as isize) as *mut libc::c_void,
3208                (ldb.bp)
3209                    .as_mut_ptr()
3210                    .offset(j as isize)
3211                    .offset(1 as libc::c_int as isize) as *const libc::c_void,
3212                (ldb.bpcount - j) as libc::c_ulong,
3213            );
3214            return 1 as libc::c_int;
3215        }
3216        j += 1;
3217    }
3218    return 0 as libc::c_int;
3219}
3220#[no_mangle]
3221pub unsafe extern "C" fn ldbReplParseCommand(
3222    mut argcp: *mut libc::c_int,
3223    mut err: *mut *mut libc::c_char,
3224) -> *mut sds {
3225    let mut plen: *mut libc::c_char = 0 as *mut libc::c_char;
3226    let mut current_block: u64;
3227    static mut protocol_error: *mut libc::c_char = b"protocol error\0" as *const u8
3228        as *const libc::c_char as *mut libc::c_char;
3229    let mut argv: *mut sds = 0 as *mut sds;
3230    let mut argc: libc::c_int = 0 as libc::c_int;
3231    if sdslen(ldb.cbuf) == 0 as libc::c_int as libc::c_ulong {
3232        return 0 as *mut sds;
3233    }
3234    let mut copy: sds = sdsdup(ldb.cbuf);
3235    let mut p: *mut libc::c_char = copy;
3236    p = strchr(p, '*' as i32);
3237    if p.is_null() {
3238        current_block = 2611887017218276167;
3239    } else {
3240        plen = p.offset(1 as libc::c_int as isize);
3241        p = strstr(p, b"\r\n\0" as *const u8 as *const libc::c_char);
3242        if p.is_null() {
3243            current_block = 979901658470254302;
3244        } else {
3245            *p = '\0' as i32 as libc::c_char;
3246            p = p.offset(2 as libc::c_int as isize);
3247            *argcp = atoi(plen);
3248            if *argcp <= 0 as libc::c_int || *argcp > 1024 as libc::c_int {
3249                current_block = 2611887017218276167;
3250            } else {
3251                argv = zmalloc(
3252                    (core::mem::size_of::<sds>() as libc::c_ulong)
3253                        .wrapping_mul(*argcp as libc::c_ulong),
3254                ) as *mut sds;
3255                argc = 0 as libc::c_int;
3256                loop {
3257                    if !(argc < *argcp) {
3258                        current_block = 14401909646449704462;
3259                        break;
3260                    }
3261                    if *p as libc::c_int == '\0' as i32 {
3262                        current_block = 979901658470254302;
3263                        break;
3264                    }
3265                    if *p as libc::c_int != '$' as i32 {
3266                        current_block = 2611887017218276167;
3267                        break;
3268                    }
3269                    plen = p.offset(1 as libc::c_int as isize);
3270                    p = strstr(p, b"\r\n\0" as *const u8 as *const libc::c_char);
3271                    if p.is_null() {
3272                        current_block = 979901658470254302;
3273                        break;
3274                    }
3275                    *p = '\0' as i32 as libc::c_char;
3276                    p = p.offset(2 as libc::c_int as isize);
3277                    let mut slen: libc::c_int = atoi(plen);
3278                    if slen <= 0 as libc::c_int || slen > 1024 as libc::c_int {
3279                        current_block = 2611887017218276167;
3280                        break;
3281                    }
3282                    if p
3283                        .offset(slen as isize)
3284                        .offset(2 as libc::c_int as isize)
3285                        .offset_from(copy) as libc::c_long as size_t > sdslen(copy)
3286                    {
3287                        current_block = 979901658470254302;
3288                        break;
3289                    }
3290                    let fresh2 = argc;
3291                    argc = argc + 1;
3292                    let ref mut fresh3 = *argv.offset(fresh2 as isize);
3293                    *fresh3 = sdsnewlen(p as *const libc::c_void, slen as size_t);
3294                    p = p.offset(slen as isize);
3295                    if *p.offset(0 as libc::c_int as isize) as libc::c_int != '\r' as i32
3296                        || *p.offset(1 as libc::c_int as isize) as libc::c_int
3297                            != '\n' as i32
3298                    {
3299                        current_block = 2611887017218276167;
3300                        break;
3301                    }
3302                    p = p.offset(2 as libc::c_int as isize);
3303                }
3304                match current_block {
3305                    2611887017218276167 => {}
3306                    979901658470254302 => {}
3307                    _ => {
3308                        sdsfree(copy);
3309                        return argv;
3310                    }
3311                }
3312            }
3313        }
3314    }
3315    match current_block {
3316        2611887017218276167 => {
3317            *err = protocol_error;
3318        }
3319        _ => {}
3320    }
3321    sdsfreesplitres(argv, argc);
3322    sdsfree(copy);
3323    return 0 as *mut sds;
3324}
3325#[no_mangle]
3326pub unsafe extern "C" fn ldbLogSourceLine(mut lnum: libc::c_int) {
3327    let mut line: *mut libc::c_char = ldbGetSourceLine(lnum);
3328    let mut prefix: *mut libc::c_char = 0 as *mut libc::c_char;
3329    let mut bp: libc::c_int = ldbIsBreakpoint(lnum);
3330    let mut current: libc::c_int = (ldb.currentline == lnum) as libc::c_int;
3331    if current != 0 && bp != 0 {
3332        prefix = b"->#\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
3333    } else if current != 0 {
3334        prefix = b"-> \0" as *const u8 as *const libc::c_char as *mut libc::c_char;
3335    } else if bp != 0 {
3336        prefix = b"  #\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
3337    } else {
3338        prefix = b"   \0" as *const u8 as *const libc::c_char as *mut libc::c_char;
3339    }
3340    let mut thisline: sds = sdscatprintf(
3341        sdsempty(),
3342        b"%s%-3d %s\0" as *const u8 as *const libc::c_char,
3343        prefix,
3344        lnum,
3345        line,
3346    );
3347    ldbLog(thisline);
3348}
3349#[no_mangle]
3350pub unsafe extern "C" fn ldbList(mut around: libc::c_int, mut context: libc::c_int) {
3351    let mut j: libc::c_int = 0;
3352    j = 1 as libc::c_int;
3353    while j <= ldb.lines {
3354        if !(around != 0 as libc::c_int && abs(around - j) > context) {
3355            ldbLogSourceLine(j);
3356        }
3357        j += 1;
3358    }
3359}
3360#[no_mangle]
3361pub unsafe extern "C" fn ldbCatStackValueRec(
3362    mut s: sds,
3363    mut lua: *mut lua_State,
3364    mut idx: libc::c_int,
3365    mut level: libc::c_int,
3366) -> sds {
3367    let mut t: libc::c_int = lua_type(lua, idx);
3368    let fresh4 = level;
3369    level = level + 1;
3370    if fresh4 == 20 as libc::c_int / 2 as libc::c_int {
3371        return sdscat(
3372            s,
3373            b"<max recursion level reached! Nested table?>\0" as *const u8
3374                as *const libc::c_char,
3375        );
3376    }
3377    match t {
3378        4 => {
3379            let mut strl: size_t = 0;
3380            let mut strp: *mut libc::c_char = lua_tolstring(lua, idx, &mut strl)
3381                as *mut libc::c_char;
3382            s = sdscatrepr(s, strp, strl);
3383        }
3384        1 => {
3385            s = sdscat(
3386                s,
3387                if lua_toboolean(lua, idx) != 0 {
3388                    b"true\0" as *const u8 as *const libc::c_char
3389                } else {
3390                    b"false\0" as *const u8 as *const libc::c_char
3391                },
3392            );
3393        }
3394        3 => {
3395            s = sdscatprintf(
3396                s,
3397                b"%g\0" as *const u8 as *const libc::c_char,
3398                lua_tonumber(lua, idx),
3399            );
3400        }
3401        0 => {
3402            s = sdscatlen(
3403                s,
3404                b"nil\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3405                3 as libc::c_int as size_t,
3406            );
3407        }
3408        5 => {
3409            let mut expected_index: libc::c_int = 1 as libc::c_int;
3410            let mut is_array: libc::c_int = 1 as libc::c_int;
3411            let mut repr1: sds = sdsempty();
3412            let mut repr2: sds = sdsempty();
3413            lua_pushnil(lua);
3414            while lua_next(lua, idx - 1 as libc::c_int) != 0 {
3415                if is_array != 0
3416                    && (lua_type(lua, -(2 as libc::c_int)) != 3 as libc::c_int
3417                        || lua_tonumber(lua, -(2 as libc::c_int))
3418                            != expected_index as libc::c_double)
3419                {
3420                    is_array = 0 as libc::c_int;
3421                }
3422                repr1 = ldbCatStackValueRec(repr1, lua, -(1 as libc::c_int), level);
3423                repr1 = sdscatlen(
3424                    repr1,
3425                    b"; \0" as *const u8 as *const libc::c_char as *const libc::c_void,
3426                    2 as libc::c_int as size_t,
3427                );
3428                repr2 = sdscatlen(
3429                    repr2,
3430                    b"[\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3431                    1 as libc::c_int as size_t,
3432                );
3433                repr2 = ldbCatStackValueRec(repr2, lua, -(2 as libc::c_int), level);
3434                repr2 = sdscatlen(
3435                    repr2,
3436                    b"]=\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3437                    2 as libc::c_int as size_t,
3438                );
3439                repr2 = ldbCatStackValueRec(repr2, lua, -(1 as libc::c_int), level);
3440                repr2 = sdscatlen(
3441                    repr2,
3442                    b"; \0" as *const u8 as *const libc::c_char as *const libc::c_void,
3443                    2 as libc::c_int as size_t,
3444                );
3445                lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
3446                expected_index += 1;
3447            }
3448            if sdslen(repr1) != 0 {
3449                sdsrange(
3450                    repr1,
3451                    0 as libc::c_int as ssize_t,
3452                    -(3 as libc::c_int) as ssize_t,
3453                );
3454            }
3455            if sdslen(repr2) != 0 {
3456                sdsrange(
3457                    repr2,
3458                    0 as libc::c_int as ssize_t,
3459                    -(3 as libc::c_int) as ssize_t,
3460                );
3461            }
3462            s = sdscatlen(
3463                s,
3464                b"{\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3465                1 as libc::c_int as size_t,
3466            );
3467            s = sdscatsds(s, if is_array != 0 { repr1 } else { repr2 });
3468            s = sdscatlen(
3469                s,
3470                b"}\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3471                1 as libc::c_int as size_t,
3472            );
3473            sdsfree(repr1);
3474            sdsfree(repr2);
3475        }
3476        6 | 7 | 8 | 2 => {
3477            let mut p: *const libc::c_void = lua_topointer(lua, idx);
3478            let mut typename: *mut libc::c_char = b"unknown\0" as *const u8
3479                as *const libc::c_char as *mut libc::c_char;
3480            if t == 6 as libc::c_int {
3481                typename = b"function\0" as *const u8 as *const libc::c_char
3482                    as *mut libc::c_char;
3483            } else if t == 7 as libc::c_int {
3484                typename = b"userdata\0" as *const u8 as *const libc::c_char
3485                    as *mut libc::c_char;
3486            } else if t == 8 as libc::c_int {
3487                typename = b"thread\0" as *const u8 as *const libc::c_char
3488                    as *mut libc::c_char;
3489            } else if t == 2 as libc::c_int {
3490                typename = b"light-userdata\0" as *const u8 as *const libc::c_char
3491                    as *mut libc::c_char;
3492            }
3493            s = sdscatprintf(
3494                s,
3495                b"\"%s@%p\"\0" as *const u8 as *const libc::c_char,
3496                typename,
3497                p,
3498            );
3499        }
3500        _ => {
3501            s = sdscat(
3502                s,
3503                b"\"<unknown-lua-type>\"\0" as *const u8 as *const libc::c_char,
3504            );
3505        }
3506    }
3507    return s;
3508}
3509#[no_mangle]
3510pub unsafe extern "C" fn ldbCatStackValue(
3511    mut s: sds,
3512    mut lua: *mut lua_State,
3513    mut idx: libc::c_int,
3514) -> sds {
3515    return ldbCatStackValueRec(s, lua, idx, 0 as libc::c_int);
3516}
3517#[no_mangle]
3518pub unsafe extern "C" fn ldbLogStackValue(
3519    mut lua: *mut lua_State,
3520    mut prefix: *mut libc::c_char,
3521) {
3522    let mut s: sds = sdsnew(prefix);
3523    s = ldbCatStackValue(s, lua, -(1 as libc::c_int));
3524    ldbLogWithMaxLen(s);
3525}
3526#[no_mangle]
3527pub unsafe extern "C" fn ldbRedisProtocolToHuman(
3528    mut o: *mut sds,
3529    mut reply: *mut libc::c_char,
3530) -> *mut libc::c_char {
3531    let mut p: *mut libc::c_char = reply;
3532    match *p as libc::c_int {
3533        58 => {
3534            p = ldbRedisProtocolToHuman_Int(o, reply);
3535        }
3536        36 => {
3537            p = ldbRedisProtocolToHuman_Bulk(o, reply);
3538        }
3539        43 => {
3540            p = ldbRedisProtocolToHuman_Status(o, reply);
3541        }
3542        45 => {
3543            p = ldbRedisProtocolToHuman_Status(o, reply);
3544        }
3545        42 => {
3546            p = ldbRedisProtocolToHuman_MultiBulk(o, reply);
3547        }
3548        126 => {
3549            p = ldbRedisProtocolToHuman_Set(o, reply);
3550        }
3551        37 => {
3552            p = ldbRedisProtocolToHuman_Map(o, reply);
3553        }
3554        95 => {
3555            p = ldbRedisProtocolToHuman_Null(o, reply);
3556        }
3557        35 => {
3558            p = ldbRedisProtocolToHuman_Bool(o, reply);
3559        }
3560        44 => {
3561            p = ldbRedisProtocolToHuman_Double(o, reply);
3562        }
3563        _ => {}
3564    }
3565    return p;
3566}
3567#[no_mangle]
3568pub unsafe extern "C" fn ldbRedisProtocolToHuman_Int(
3569    mut o: *mut sds,
3570    mut reply: *mut libc::c_char,
3571) -> *mut libc::c_char {
3572    let mut p: *mut libc::c_char = strchr(
3573        reply.offset(1 as libc::c_int as isize),
3574        '\r' as i32,
3575    );
3576    *o = sdscatlen(
3577        *o,
3578        reply.offset(1 as libc::c_int as isize) as *const libc::c_void,
3579        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3580            as size_t,
3581    );
3582    return p.offset(2 as libc::c_int as isize);
3583}
3584#[no_mangle]
3585pub unsafe extern "C" fn ldbRedisProtocolToHuman_Bulk(
3586    mut o: *mut sds,
3587    mut reply: *mut libc::c_char,
3588) -> *mut libc::c_char {
3589    let mut p: *mut libc::c_char = strchr(
3590        reply.offset(1 as libc::c_int as isize),
3591        '\r' as i32,
3592    );
3593    let mut bulklen: libc::c_longlong = 0;
3594    string2ll(
3595        reply.offset(1 as libc::c_int as isize),
3596        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3597            as size_t,
3598        &mut bulklen,
3599    );
3600    if bulklen == -(1 as libc::c_int) as libc::c_longlong {
3601        *o = sdscatlen(
3602            *o,
3603            b"NULL\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3604            4 as libc::c_int as size_t,
3605        );
3606        return p.offset(2 as libc::c_int as isize);
3607    } else {
3608        *o = sdscatrepr(*o, p.offset(2 as libc::c_int as isize), bulklen as size_t);
3609        return p
3610            .offset(2 as libc::c_int as isize)
3611            .offset(bulklen as isize)
3612            .offset(2 as libc::c_int as isize);
3613    };
3614}
3615#[no_mangle]
3616pub unsafe extern "C" fn ldbRedisProtocolToHuman_Status(
3617    mut o: *mut sds,
3618    mut reply: *mut libc::c_char,
3619) -> *mut libc::c_char {
3620    let mut p: *mut libc::c_char = strchr(
3621        reply.offset(1 as libc::c_int as isize),
3622        '\r' as i32,
3623    );
3624    *o = sdscatrepr(*o, reply, p.offset_from(reply) as libc::c_long as size_t);
3625    return p.offset(2 as libc::c_int as isize);
3626}
3627#[no_mangle]
3628pub unsafe extern "C" fn ldbRedisProtocolToHuman_MultiBulk(
3629    mut o: *mut sds,
3630    mut reply: *mut libc::c_char,
3631) -> *mut libc::c_char {
3632    let mut p: *mut libc::c_char = strchr(
3633        reply.offset(1 as libc::c_int as isize),
3634        '\r' as i32,
3635    );
3636    let mut mbulklen: libc::c_longlong = 0;
3637    let mut j: libc::c_int = 0 as libc::c_int;
3638    string2ll(
3639        reply.offset(1 as libc::c_int as isize),
3640        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3641            as size_t,
3642        &mut mbulklen,
3643    );
3644    p = p.offset(2 as libc::c_int as isize);
3645    if mbulklen == -(1 as libc::c_int) as libc::c_longlong {
3646        *o = sdscatlen(
3647            *o,
3648            b"NULL\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3649            4 as libc::c_int as size_t,
3650        );
3651        return p;
3652    }
3653    *o = sdscatlen(
3654        *o,
3655        b"[\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3656        1 as libc::c_int as size_t,
3657    );
3658    j = 0 as libc::c_int;
3659    while (j as libc::c_longlong) < mbulklen {
3660        p = ldbRedisProtocolToHuman(o, p);
3661        if j as libc::c_longlong != mbulklen - 1 as libc::c_int as libc::c_longlong {
3662            *o = sdscatlen(
3663                *o,
3664                b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3665                1 as libc::c_int as size_t,
3666            );
3667        }
3668        j += 1;
3669    }
3670    *o = sdscatlen(
3671        *o,
3672        b"]\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3673        1 as libc::c_int as size_t,
3674    );
3675    return p;
3676}
3677#[no_mangle]
3678pub unsafe extern "C" fn ldbRedisProtocolToHuman_Set(
3679    mut o: *mut sds,
3680    mut reply: *mut libc::c_char,
3681) -> *mut libc::c_char {
3682    let mut p: *mut libc::c_char = strchr(
3683        reply.offset(1 as libc::c_int as isize),
3684        '\r' as i32,
3685    );
3686    let mut mbulklen: libc::c_longlong = 0;
3687    let mut j: libc::c_int = 0 as libc::c_int;
3688    string2ll(
3689        reply.offset(1 as libc::c_int as isize),
3690        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3691            as size_t,
3692        &mut mbulklen,
3693    );
3694    p = p.offset(2 as libc::c_int as isize);
3695    *o = sdscatlen(
3696        *o,
3697        b"~(\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3698        2 as libc::c_int as size_t,
3699    );
3700    j = 0 as libc::c_int;
3701    while (j as libc::c_longlong) < mbulklen {
3702        p = ldbRedisProtocolToHuman(o, p);
3703        if j as libc::c_longlong != mbulklen - 1 as libc::c_int as libc::c_longlong {
3704            *o = sdscatlen(
3705                *o,
3706                b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3707                1 as libc::c_int as size_t,
3708            );
3709        }
3710        j += 1;
3711    }
3712    *o = sdscatlen(
3713        *o,
3714        b")\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3715        1 as libc::c_int as size_t,
3716    );
3717    return p;
3718}
3719#[no_mangle]
3720pub unsafe extern "C" fn ldbRedisProtocolToHuman_Map(
3721    mut o: *mut sds,
3722    mut reply: *mut libc::c_char,
3723) -> *mut libc::c_char {
3724    let mut p: *mut libc::c_char = strchr(
3725        reply.offset(1 as libc::c_int as isize),
3726        '\r' as i32,
3727    );
3728    let mut mbulklen: libc::c_longlong = 0;
3729    let mut j: libc::c_int = 0 as libc::c_int;
3730    string2ll(
3731        reply.offset(1 as libc::c_int as isize),
3732        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3733            as size_t,
3734        &mut mbulklen,
3735    );
3736    p = p.offset(2 as libc::c_int as isize);
3737    *o = sdscatlen(
3738        *o,
3739        b"{\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3740        1 as libc::c_int as size_t,
3741    );
3742    j = 0 as libc::c_int;
3743    while (j as libc::c_longlong) < mbulklen {
3744        p = ldbRedisProtocolToHuman(o, p);
3745        *o = sdscatlen(
3746            *o,
3747            b" => \0" as *const u8 as *const libc::c_char as *const libc::c_void,
3748            4 as libc::c_int as size_t,
3749        );
3750        p = ldbRedisProtocolToHuman(o, p);
3751        if j as libc::c_longlong != mbulklen - 1 as libc::c_int as libc::c_longlong {
3752            *o = sdscatlen(
3753                *o,
3754                b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3755                1 as libc::c_int as size_t,
3756            );
3757        }
3758        j += 1;
3759    }
3760    *o = sdscatlen(
3761        *o,
3762        b"}\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3763        1 as libc::c_int as size_t,
3764    );
3765    return p;
3766}
3767#[no_mangle]
3768pub unsafe extern "C" fn ldbRedisProtocolToHuman_Null(
3769    mut o: *mut sds,
3770    mut reply: *mut libc::c_char,
3771) -> *mut libc::c_char {
3772    let mut p: *mut libc::c_char = strchr(
3773        reply.offset(1 as libc::c_int as isize),
3774        '\r' as i32,
3775    );
3776    *o = sdscatlen(
3777        *o,
3778        b"(null)\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3779        6 as libc::c_int as size_t,
3780    );
3781    return p.offset(2 as libc::c_int as isize);
3782}
3783#[no_mangle]
3784pub unsafe extern "C" fn ldbRedisProtocolToHuman_Bool(
3785    mut o: *mut sds,
3786    mut reply: *mut libc::c_char,
3787) -> *mut libc::c_char {
3788    let mut p: *mut libc::c_char = strchr(
3789        reply.offset(1 as libc::c_int as isize),
3790        '\r' as i32,
3791    );
3792    if *reply.offset(1 as libc::c_int as isize) as libc::c_int == 't' as i32 {
3793        *o = sdscatlen(
3794            *o,
3795            b"#true\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3796            5 as libc::c_int as size_t,
3797        );
3798    } else {
3799        *o = sdscatlen(
3800            *o,
3801            b"#false\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3802            6 as libc::c_int as size_t,
3803        );
3804    }
3805    return p.offset(2 as libc::c_int as isize);
3806}
3807#[no_mangle]
3808pub unsafe extern "C" fn ldbRedisProtocolToHuman_Double(
3809    mut o: *mut sds,
3810    mut reply: *mut libc::c_char,
3811) -> *mut libc::c_char {
3812    let mut p: *mut libc::c_char = strchr(
3813        reply.offset(1 as libc::c_int as isize),
3814        '\r' as i32,
3815    );
3816    *o = sdscatlen(
3817        *o,
3818        b"(double) \0" as *const u8 as *const libc::c_char as *const libc::c_void,
3819        9 as libc::c_int as size_t,
3820    );
3821    *o = sdscatlen(
3822        *o,
3823        reply.offset(1 as libc::c_int as isize) as *const libc::c_void,
3824        (p.offset_from(reply) as libc::c_long - 1 as libc::c_int as libc::c_long)
3825            as size_t,
3826    );
3827    return p.offset(2 as libc::c_int as isize);
3828}
3829#[no_mangle]
3830pub unsafe extern "C" fn ldbLogRedisReply(mut reply: *mut libc::c_char) {
3831    let mut log: sds = sdsnew(b"<reply> \0" as *const u8 as *const libc::c_char);
3832    ldbRedisProtocolToHuman(&mut log, reply);
3833    ldbLogWithMaxLen(log);
3834}
3835#[no_mangle]
3836pub unsafe extern "C" fn ldbPrint(
3837    mut lua: *mut lua_State,
3838    mut varname: *mut libc::c_char,
3839) {
3840    let mut ar: lua_Debug = lua_Debug {
3841        event: 0,
3842        name: 0 as *const libc::c_char,
3843        namewhat: 0 as *const libc::c_char,
3844        what: 0 as *const libc::c_char,
3845        source: 0 as *const libc::c_char,
3846        currentline: 0,
3847        nups: 0,
3848        linedefined: 0,
3849        lastlinedefined: 0,
3850        short_src: [0; 60],
3851        i_ci: 0,
3852    };
3853    let mut l: libc::c_int = 0 as libc::c_int;
3854    while lua_getstack(lua, l, &mut ar) != 0 as libc::c_int {
3855        l += 1;
3856        let mut name: *const libc::c_char = 0 as *const libc::c_char;
3857        let mut i: libc::c_int = 1 as libc::c_int;
3858        loop {
3859            name = lua_getlocal(lua, &mut ar, i);
3860            if name.is_null() {
3861                break;
3862            }
3863            i += 1;
3864            if strcmp(varname, name) == 0 as libc::c_int {
3865                ldbLogStackValue(
3866                    lua,
3867                    b"<value> \0" as *const u8 as *const libc::c_char
3868                        as *mut libc::c_char,
3869                );
3870                lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
3871                return;
3872            } else {
3873                lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
3874            }
3875        }
3876    }
3877    if strcmp(varname, b"ARGV\0" as *const u8 as *const libc::c_char) == 0
3878        || strcmp(varname, b"KEYS\0" as *const u8 as *const libc::c_char) == 0
3879    {
3880        lua_getfield(lua, -(10002 as libc::c_int), varname);
3881        ldbLogStackValue(
3882            lua,
3883            b"<value> \0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3884        );
3885        lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
3886    } else {
3887        ldbLog(sdsnew(b"No such variable.\0" as *const u8 as *const libc::c_char));
3888    };
3889}
3890#[no_mangle]
3891pub unsafe extern "C" fn ldbPrintAll(mut lua: *mut lua_State) {
3892    let mut ar: lua_Debug = lua_Debug {
3893        event: 0,
3894        name: 0 as *const libc::c_char,
3895        namewhat: 0 as *const libc::c_char,
3896        what: 0 as *const libc::c_char,
3897        source: 0 as *const libc::c_char,
3898        currentline: 0,
3899        nups: 0,
3900        linedefined: 0,
3901        lastlinedefined: 0,
3902        short_src: [0; 60],
3903        i_ci: 0,
3904    };
3905    let mut vars: libc::c_int = 0 as libc::c_int;
3906    if lua_getstack(lua, 0 as libc::c_int, &mut ar) != 0 as libc::c_int {
3907        let mut name: *const libc::c_char = 0 as *const libc::c_char;
3908        let mut i: libc::c_int = 1 as libc::c_int;
3909        loop {
3910            name = lua_getlocal(lua, &mut ar, i);
3911            if name.is_null() {
3912                break;
3913            }
3914            i += 1;
3915            if (strstr(name, b"(*temporary)\0" as *const u8 as *const libc::c_char))
3916                .is_null()
3917            {
3918                let mut prefix: sds = sdscatprintf(
3919                    sdsempty(),
3920                    b"<value> %s = \0" as *const u8 as *const libc::c_char,
3921                    name,
3922                );
3923                ldbLogStackValue(lua, prefix);
3924                sdsfree(prefix);
3925                vars += 1;
3926            }
3927            lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
3928        }
3929    }
3930    if vars == 0 as libc::c_int {
3931        ldbLog(
3932            sdsnew(
3933                b"No local variables in the current context.\0" as *const u8
3934                    as *const libc::c_char,
3935            ),
3936        );
3937    }
3938}
3939#[no_mangle]
3940pub unsafe extern "C" fn ldbBreak(mut argv: *mut sds, mut argc: libc::c_int) {
3941    if argc == 1 as libc::c_int {
3942        if ldb.bpcount == 0 as libc::c_int {
3943            ldbLog(
3944                sdsnew(
3945                    b"No breakpoints set. Use 'b <line>' to add one.\0" as *const u8
3946                        as *const libc::c_char,
3947                ),
3948            );
3949            return;
3950        } else {
3951            ldbLog(
3952                sdscatfmt(
3953                    sdsempty(),
3954                    b"%i breakpoints set:\0" as *const u8 as *const libc::c_char,
3955                    ldb.bpcount,
3956                ),
3957            );
3958            let mut j: libc::c_int = 0;
3959            j = 0 as libc::c_int;
3960            while j < ldb.bpcount {
3961                ldbLogSourceLine(ldb.bp[j as usize]);
3962                j += 1;
3963            }
3964        }
3965    } else {
3966        let mut j_0: libc::c_int = 0;
3967        j_0 = 1 as libc::c_int;
3968        while j_0 < argc {
3969            let mut arg: *mut libc::c_char = *argv.offset(j_0 as isize);
3970            let mut line: libc::c_long = 0;
3971            if string2l(arg, sdslen(arg), &mut line) == 0 {
3972                ldbLog(
3973                    sdscatfmt(
3974                        sdsempty(),
3975                        b"Invalid argument:'%s'\0" as *const u8 as *const libc::c_char,
3976                        arg,
3977                    ),
3978                );
3979            } else if line == 0 as libc::c_int as libc::c_long {
3980                ldb.bpcount = 0 as libc::c_int;
3981                ldbLog(
3982                    sdsnew(
3983                        b"All breakpoints removed.\0" as *const u8 as *const libc::c_char,
3984                    ),
3985                );
3986            } else if line > 0 as libc::c_int as libc::c_long {
3987                if ldb.bpcount == 64 as libc::c_int {
3988                    ldbLog(
3989                        sdsnew(
3990                            b"Too many breakpoints set.\0" as *const u8
3991                                as *const libc::c_char,
3992                        ),
3993                    );
3994                } else if ldbAddBreakpoint(line as libc::c_int) != 0 {
3995                    ldbList(line as libc::c_int, 1 as libc::c_int);
3996                } else {
3997                    ldbLog(
3998                        sdsnew(
3999                            b"Wrong line number.\0" as *const u8 as *const libc::c_char,
4000                        ),
4001                    );
4002                }
4003            } else if line < 0 as libc::c_int as libc::c_long {
4004                if ldbDelBreakpoint(-line as libc::c_int) != 0 {
4005                    ldbLog(
4006                        sdsnew(
4007                            b"Breakpoint removed.\0" as *const u8 as *const libc::c_char,
4008                        ),
4009                    );
4010                } else {
4011                    ldbLog(
4012                        sdsnew(
4013                            b"No breakpoint in the specified line.\0" as *const u8
4014                                as *const libc::c_char,
4015                        ),
4016                    );
4017                }
4018            }
4019            j_0 += 1;
4020        }
4021    };
4022}
4023#[no_mangle]
4024pub unsafe extern "C" fn ldbEval(
4025    mut lua: *mut lua_State,
4026    mut argv: *mut sds,
4027    mut argc: libc::c_int,
4028) {
4029    let mut code: sds = sdsjoinsds(
4030        argv.offset(1 as libc::c_int as isize),
4031        argc - 1 as libc::c_int,
4032        b" \0" as *const u8 as *const libc::c_char,
4033        1 as libc::c_int as size_t,
4034    );
4035    let mut expr: sds = sdscatsds(
4036        sdsnew(b"return \0" as *const u8 as *const libc::c_char),
4037        code,
4038    );
4039    if luaL_loadbuffer(
4040        lua,
4041        expr as *const libc::c_char,
4042        sdslen(expr),
4043        b"@ldb_eval\0" as *const u8 as *const libc::c_char,
4044    ) != 0
4045    {
4046        lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
4047        if luaL_loadbuffer(
4048            lua,
4049            code as *const libc::c_char,
4050            sdslen(code),
4051            b"@ldb_eval\0" as *const u8 as *const libc::c_char,
4052        ) != 0
4053        {
4054            ldbLog(
4055                sdscatfmt(
4056                    sdsempty(),
4057                    b"<error> %s\0" as *const u8 as *const libc::c_char,
4058                    lua_tolstring(lua, -(1 as libc::c_int), 0 as *mut size_t),
4059                ),
4060            );
4061            lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
4062            sdsfree(code);
4063            sdsfree(expr);
4064            return;
4065        }
4066    }
4067    sdsfree(code);
4068    sdsfree(expr);
4069    if lua_pcall(lua, 0 as libc::c_int, 1 as libc::c_int, 0 as libc::c_int) != 0 {
4070        ldbLog(
4071            sdscatfmt(
4072                sdsempty(),
4073                b"<error> %s\0" as *const u8 as *const libc::c_char,
4074                lua_tolstring(lua, -(1 as libc::c_int), 0 as *mut size_t),
4075            ),
4076        );
4077        lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
4078        return;
4079    }
4080    ldbLogStackValue(
4081        lua,
4082        b"<retval> \0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4083    );
4084    lua_settop(lua, -(1 as libc::c_int) - 1 as libc::c_int);
4085}
4086#[no_mangle]
4087pub unsafe extern "C" fn ldbRedis(
4088    mut lua: *mut lua_State,
4089    mut argv: *mut sds,
4090    mut argc: libc::c_int,
4091) {
4092    let mut j: libc::c_int = 0;
4093    if lua_checkstack(lua, argc + 1 as libc::c_int) == 0 {
4094        ldbLogRedisReply(
4095            b"max lua stack reached\0" as *const u8 as *const libc::c_char
4096                as *mut libc::c_char,
4097        );
4098        return;
4099    }
4100    lua_getfield(
4101        lua,
4102        -(10002 as libc::c_int),
4103        b"redis\0" as *const u8 as *const libc::c_char,
4104    );
4105    lua_pushstring(lua, b"call\0" as *const u8 as *const libc::c_char);
4106    lua_gettable(lua, -(2 as libc::c_int));
4107    j = 1 as libc::c_int;
4108    while j < argc {
4109        lua_pushlstring(
4110            lua,
4111            *argv.offset(j as isize) as *const libc::c_char,
4112            sdslen(*argv.offset(j as isize)),
4113        );
4114        j += 1;
4115    }
4116    ldb.step = 1 as libc::c_int;
4117    lua_pcall(lua, argc - 1 as libc::c_int, 1 as libc::c_int, 0 as libc::c_int);
4118    ldb.step = 0 as libc::c_int;
4119    lua_settop(lua, -(2 as libc::c_int) - 1 as libc::c_int);
4120}
4121#[no_mangle]
4122pub unsafe extern "C" fn ldbTrace(mut lua: *mut lua_State) {
4123    let mut ar: lua_Debug = lua_Debug {
4124        event: 0,
4125        name: 0 as *const libc::c_char,
4126        namewhat: 0 as *const libc::c_char,
4127        what: 0 as *const libc::c_char,
4128        source: 0 as *const libc::c_char,
4129        currentline: 0,
4130        nups: 0,
4131        linedefined: 0,
4132        lastlinedefined: 0,
4133        short_src: [0; 60],
4134        i_ci: 0,
4135    };
4136    let mut level: libc::c_int = 0 as libc::c_int;
4137    while lua_getstack(lua, level, &mut ar) != 0 {
4138        lua_getinfo(lua, b"Snl\0" as *const u8 as *const libc::c_char, &mut ar);
4139        if !(strstr(
4140            (ar.short_src).as_mut_ptr(),
4141            b"user_script\0" as *const u8 as *const libc::c_char,
4142        ))
4143            .is_null()
4144        {
4145            ldbLog(
4146                sdscatprintf(
4147                    sdsempty(),
4148                    b"%s %s:\0" as *const u8 as *const libc::c_char,
4149                    if level == 0 as libc::c_int {
4150                        b"In\0" as *const u8 as *const libc::c_char
4151                    } else {
4152                        b"From\0" as *const u8 as *const libc::c_char
4153                    },
4154                    if !(ar.name).is_null() {
4155                        ar.name
4156                    } else {
4157                        b"top level\0" as *const u8 as *const libc::c_char
4158                    },
4159                ),
4160            );
4161            ldbLogSourceLine(ar.currentline);
4162        }
4163        level += 1;
4164    }
4165    if level == 0 as libc::c_int {
4166        ldbLog(
4167            sdsnew(
4168                b"<error> Can't retrieve Lua stack.\0" as *const u8
4169                    as *const libc::c_char,
4170            ),
4171        );
4172    }
4173}
4174#[no_mangle]
4175pub unsafe extern "C" fn ldbMaxlen(mut argv: *mut sds, mut argc: libc::c_int) {
4176    if argc == 2 as libc::c_int {
4177        let mut newval: libc::c_int = atoi(
4178            *argv.offset(1 as libc::c_int as isize) as *const libc::c_char,
4179        );
4180        ldb.maxlen_hint_sent = 1 as libc::c_int;
4181        if newval != 0 as libc::c_int && newval <= 60 as libc::c_int {
4182            newval = 60 as libc::c_int;
4183        }
4184        ldb.maxlen = newval as size_t;
4185    }
4186    if ldb.maxlen != 0 {
4187        ldbLog(
4188            sdscatprintf(
4189                sdsempty(),
4190                b"<value> replies are truncated at %d bytes.\0" as *const u8
4191                    as *const libc::c_char,
4192                ldb.maxlen as libc::c_int,
4193            ),
4194        );
4195    } else {
4196        ldbLog(
4197            sdscatprintf(
4198                sdsempty(),
4199                b"<value> replies are unlimited.\0" as *const u8 as *const libc::c_char,
4200            ),
4201        );
4202    };
4203}
4204#[no_mangle]
4205pub unsafe extern "C" fn ldbRepl(mut lua: *mut lua_State) -> libc::c_int {
4206    let mut argv: *mut sds = 0 as *mut sds;
4207    let mut argc: libc::c_int = 0;
4208    let mut err: *mut libc::c_char = 0 as *mut libc::c_char;
4209    loop {
4210        loop {
4211            argv = ldbReplParseCommand(&mut argc, &mut err);
4212            if !argv.is_null() {
4213                break;
4214            }
4215            let mut buf: [libc::c_char; 1024] = [0; 1024];
4216            if !err.is_null() {
4217                luaPushError(lua, err);
4218                luaError(lua);
4219            }
4220            let mut nread: libc::c_int = connRead(
4221                ldb.conn,
4222                buf.as_mut_ptr() as *mut libc::c_void,
4223                core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
4224            );
4225            if nread <= 0 as libc::c_int {
4226                ldb.step = 0 as libc::c_int;
4227                ldb.bpcount = 0 as libc::c_int;
4228                return -(1 as libc::c_int);
4229            }
4230            ldb
4231                .cbuf = sdscatlen(
4232                ldb.cbuf,
4233                buf.as_mut_ptr() as *const libc::c_void,
4234                nread as size_t,
4235            );
4236            if sdslen(ldb.cbuf)
4237                > ((1 as libc::c_int) << 20 as libc::c_int) as libc::c_ulong
4238            {
4239                sdsfree(ldb.cbuf);
4240                ldb.cbuf = sdsempty();
4241                luaPushError(
4242                    lua,
4243                    b"max client buffer reached\0" as *const u8 as *const libc::c_char,
4244                );
4245                luaError(lua);
4246            }
4247        }
4248        sdsfree(ldb.cbuf);
4249        ldb.cbuf = sdsempty();
4250        if strcasecmp(
4251            *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4252            b"h\0" as *const u8 as *const libc::c_char,
4253        ) == 0
4254            || strcasecmp(
4255                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4256                b"help\0" as *const u8 as *const libc::c_char,
4257            ) == 0
4258        {
4259            ldbLog(
4260                sdsnew(b"Redis Lua debugger help:\0" as *const u8 as *const libc::c_char),
4261            );
4262            ldbLog(
4263                sdsnew(
4264                    b"[h]elp               Show this help.\0" as *const u8
4265                        as *const libc::c_char,
4266                ),
4267            );
4268            ldbLog(
4269                sdsnew(
4270                    b"[s]tep               Run current line and stop again.\0"
4271                        as *const u8 as *const libc::c_char,
4272                ),
4273            );
4274            ldbLog(
4275                sdsnew(
4276                    b"[n]ext               Alias for step.\0" as *const u8
4277                        as *const libc::c_char,
4278                ),
4279            );
4280            ldbLog(
4281                sdsnew(
4282                    b"[c]ontinue           Run till next breakpoint.\0" as *const u8
4283                        as *const libc::c_char,
4284                ),
4285            );
4286            ldbLog(
4287                sdsnew(
4288                    b"[l]ist               List source code around current line.\0"
4289                        as *const u8 as *const libc::c_char,
4290                ),
4291            );
4292            ldbLog(
4293                sdsnew(
4294                    b"[l]ist [line]        List source code around [line].\0"
4295                        as *const u8 as *const libc::c_char,
4296                ),
4297            );
4298            ldbLog(
4299                sdsnew(
4300                    b"                     line = 0 means: current position.\0"
4301                        as *const u8 as *const libc::c_char,
4302                ),
4303            );
4304            ldbLog(
4305                sdsnew(
4306                    b"[l]ist [line] [ctx]  In this form [ctx] specifies how many lines\0"
4307                        as *const u8 as *const libc::c_char,
4308                ),
4309            );
4310            ldbLog(
4311                sdsnew(
4312                    b"                     to show before/after [line].\0" as *const u8
4313                        as *const libc::c_char,
4314                ),
4315            );
4316            ldbLog(
4317                sdsnew(
4318                    b"[w]hole              List all source code. Alias for 'list 1 1000000'.\0"
4319                        as *const u8 as *const libc::c_char,
4320                ),
4321            );
4322            ldbLog(
4323                sdsnew(
4324                    b"[p]rint              Show all the local variables.\0" as *const u8
4325                        as *const libc::c_char,
4326                ),
4327            );
4328            ldbLog(
4329                sdsnew(
4330                    b"[p]rint <var>        Show the value of the specified variable.\0"
4331                        as *const u8 as *const libc::c_char,
4332                ),
4333            );
4334            ldbLog(
4335                sdsnew(
4336                    b"                     Can also show global vars KEYS and ARGV.\0"
4337                        as *const u8 as *const libc::c_char,
4338                ),
4339            );
4340            ldbLog(
4341                sdsnew(
4342                    b"[b]reak              Show all breakpoints.\0" as *const u8
4343                        as *const libc::c_char,
4344                ),
4345            );
4346            ldbLog(
4347                sdsnew(
4348                    b"[b]reak <line>       Add a breakpoint to the specified line.\0"
4349                        as *const u8 as *const libc::c_char,
4350                ),
4351            );
4352            ldbLog(
4353                sdsnew(
4354                    b"[b]reak -<line>      Remove breakpoint from the specified line.\0"
4355                        as *const u8 as *const libc::c_char,
4356                ),
4357            );
4358            ldbLog(
4359                sdsnew(
4360                    b"[b]reak 0            Remove all breakpoints.\0" as *const u8
4361                        as *const libc::c_char,
4362                ),
4363            );
4364            ldbLog(
4365                sdsnew(
4366                    b"[t]race              Show a backtrace.\0" as *const u8
4367                        as *const libc::c_char,
4368                ),
4369            );
4370            ldbLog(
4371                sdsnew(
4372                    b"[e]val <code>        Execute some Lua code (in a different callframe).\0"
4373                        as *const u8 as *const libc::c_char,
4374                ),
4375            );
4376            ldbLog(
4377                sdsnew(
4378                    b"[r]edis <cmd>        Execute a Redis command.\0" as *const u8
4379                        as *const libc::c_char,
4380                ),
4381            );
4382            ldbLog(
4383                sdsnew(
4384                    b"[m]axlen [len]       Trim logged Redis replies and Lua var dumps to len.\0"
4385                        as *const u8 as *const libc::c_char,
4386                ),
4387            );
4388            ldbLog(
4389                sdsnew(
4390                    b"                     Specifying zero as <len> means unlimited.\0"
4391                        as *const u8 as *const libc::c_char,
4392                ),
4393            );
4394            ldbLog(
4395                sdsnew(
4396                    b"[a]bort              Stop the execution of the script. In sync\0"
4397                        as *const u8 as *const libc::c_char,
4398                ),
4399            );
4400            ldbLog(
4401                sdsnew(
4402                    b"                     mode dataset changes will be retained.\0"
4403                        as *const u8 as *const libc::c_char,
4404                ),
4405            );
4406            ldbLog(sdsnew(b"\0" as *const u8 as *const libc::c_char));
4407            ldbLog(
4408                sdsnew(
4409                    b"Debugger functions you can call from Lua scripts:\0" as *const u8
4410                        as *const libc::c_char,
4411                ),
4412            );
4413            ldbLog(
4414                sdsnew(
4415                    b"redis.debug()        Produce logs in the debugger console.\0"
4416                        as *const u8 as *const libc::c_char,
4417                ),
4418            );
4419            ldbLog(
4420                sdsnew(
4421                    b"redis.breakpoint()   Stop execution like if there was a breakpoint in the\0"
4422                        as *const u8 as *const libc::c_char,
4423                ),
4424            );
4425            ldbLog(
4426                sdsnew(
4427                    b"                     next line of code.\0" as *const u8
4428                        as *const libc::c_char,
4429                ),
4430            );
4431            ldbSendLogs();
4432        } else if strcasecmp(
4433            *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4434            b"s\0" as *const u8 as *const libc::c_char,
4435        ) == 0
4436            || strcasecmp(
4437                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4438                b"step\0" as *const u8 as *const libc::c_char,
4439            ) == 0
4440            || strcasecmp(
4441                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4442                b"n\0" as *const u8 as *const libc::c_char,
4443            ) == 0
4444            || strcasecmp(
4445                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4446                b"next\0" as *const u8 as *const libc::c_char,
4447            ) == 0
4448        {
4449            ldb.step = 1 as libc::c_int;
4450            break;
4451        } else {
4452            if strcasecmp(
4453                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4454                b"c\0" as *const u8 as *const libc::c_char,
4455            ) == 0
4456                || strcasecmp(
4457                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4458                    b"continue\0" as *const u8 as *const libc::c_char,
4459                ) == 0
4460            {
4461                break;
4462            }
4463            if strcasecmp(
4464                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4465                b"t\0" as *const u8 as *const libc::c_char,
4466            ) == 0
4467                || strcasecmp(
4468                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4469                    b"trace\0" as *const u8 as *const libc::c_char,
4470                ) == 0
4471            {
4472                ldbTrace(lua);
4473                ldbSendLogs();
4474            } else if strcasecmp(
4475                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4476                b"m\0" as *const u8 as *const libc::c_char,
4477            ) == 0
4478                || strcasecmp(
4479                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4480                    b"maxlen\0" as *const u8 as *const libc::c_char,
4481                ) == 0
4482            {
4483                ldbMaxlen(argv, argc);
4484                ldbSendLogs();
4485            } else if strcasecmp(
4486                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4487                b"b\0" as *const u8 as *const libc::c_char,
4488            ) == 0
4489                || strcasecmp(
4490                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4491                    b"break\0" as *const u8 as *const libc::c_char,
4492                ) == 0
4493            {
4494                ldbBreak(argv, argc);
4495                ldbSendLogs();
4496            } else if strcasecmp(
4497                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4498                b"e\0" as *const u8 as *const libc::c_char,
4499            ) == 0
4500                || strcasecmp(
4501                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4502                    b"eval\0" as *const u8 as *const libc::c_char,
4503                ) == 0
4504            {
4505                ldbEval(lua, argv, argc);
4506                ldbSendLogs();
4507            } else if strcasecmp(
4508                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4509                b"a\0" as *const u8 as *const libc::c_char,
4510            ) == 0
4511                || strcasecmp(
4512                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4513                    b"abort\0" as *const u8 as *const libc::c_char,
4514                ) == 0
4515            {
4516                luaPushError(
4517                    lua,
4518                    b"script aborted for user request\0" as *const u8
4519                        as *const libc::c_char,
4520                );
4521                luaError(lua);
4522            } else if argc > 1 as libc::c_int
4523                && (strcasecmp(
4524                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4525                    b"r\0" as *const u8 as *const libc::c_char,
4526                ) == 0
4527                    || strcasecmp(
4528                        *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4529                        b"redis\0" as *const u8 as *const libc::c_char,
4530                    ) == 0)
4531            {
4532                ldbRedis(lua, argv, argc);
4533                ldbSendLogs();
4534            } else if strcasecmp(
4535                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4536                b"p\0" as *const u8 as *const libc::c_char,
4537            ) == 0
4538                || strcasecmp(
4539                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4540                    b"print\0" as *const u8 as *const libc::c_char,
4541                ) == 0
4542            {
4543                if argc == 2 as libc::c_int {
4544                    ldbPrint(lua, *argv.offset(1 as libc::c_int as isize));
4545                } else {
4546                    ldbPrintAll(lua);
4547                }
4548                ldbSendLogs();
4549            } else if strcasecmp(
4550                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4551                b"l\0" as *const u8 as *const libc::c_char,
4552            ) == 0
4553                || strcasecmp(
4554                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4555                    b"list\0" as *const u8 as *const libc::c_char,
4556                ) == 0
4557            {
4558                let mut around: libc::c_int = ldb.currentline;
4559                let mut ctx: libc::c_int = 5 as libc::c_int;
4560                if argc > 1 as libc::c_int {
4561                    let mut num: libc::c_int = atoi(
4562                        *argv.offset(1 as libc::c_int as isize) as *const libc::c_char,
4563                    );
4564                    if num > 0 as libc::c_int {
4565                        around = num;
4566                    }
4567                }
4568                if argc > 2 as libc::c_int {
4569                    ctx = atoi(
4570                        *argv.offset(2 as libc::c_int as isize) as *const libc::c_char,
4571                    );
4572                }
4573                ldbList(around, ctx);
4574                ldbSendLogs();
4575            } else if strcasecmp(
4576                *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4577                b"w\0" as *const u8 as *const libc::c_char,
4578            ) == 0
4579                || strcasecmp(
4580                    *argv.offset(0 as libc::c_int as isize) as *const libc::c_char,
4581                    b"whole\0" as *const u8 as *const libc::c_char,
4582                ) == 0
4583            {
4584                ldbList(1 as libc::c_int, 1000000 as libc::c_int);
4585                ldbSendLogs();
4586            } else {
4587                ldbLog(
4588                    sdsnew(
4589                        b"<error> Unknown Redis Lua debugger command or wrong number of arguments.\0"
4590                            as *const u8 as *const libc::c_char,
4591                    ),
4592                );
4593                ldbSendLogs();
4594            }
4595        }
4596        sdsfreesplitres(argv, argc);
4597    }
4598    sdsfreesplitres(argv, argc);
4599    return 0 as libc::c_int;
4600}
4601#[no_mangle]
4602pub unsafe extern "C" fn luaLdbLineHook(
4603    mut lua: *mut lua_State,
4604    mut ar: *mut lua_Debug,
4605) {
4606    let mut rctx: *mut scriptRunCtx = luaGetFromRegistry(
4607        lua,
4608        b"__RUN_CTX__\0" as *const u8 as *const libc::c_char,
4609    ) as *mut scriptRunCtx;
4610    lua_getstack(lua, 0 as libc::c_int, ar);
4611    lua_getinfo(lua, b"Sl\0" as *const u8 as *const libc::c_char, ar);
4612    ldb.currentline = (*ar).currentline;
4613    let mut bp: libc::c_int = (ldbIsBreakpoint(ldb.currentline) != 0 || ldb.luabp != 0)
4614        as libc::c_int;
4615    let mut timeout: libc::c_int = 0 as libc::c_int;
4616    if (strstr(
4617        ((*ar).short_src).as_mut_ptr(),
4618        b"user_script\0" as *const u8 as *const libc::c_char,
4619    ))
4620        .is_null()
4621    {
4622        return;
4623    }
4624    if (*ar).event == 3 as libc::c_int && ldb.step == 0 as libc::c_int
4625        && bp == 0 as libc::c_int
4626    {
4627        let mut elapsed: mstime_t = elapsedMs((*rctx).start_time) as mstime_t;
4628        let mut timelimit: mstime_t = if server.busy_reply_threshold != 0 {
4629            server.busy_reply_threshold
4630        } else {
4631            5000 as libc::c_int as libc::c_longlong
4632        };
4633        if elapsed >= timelimit {
4634            timeout = 1 as libc::c_int;
4635            ldb.step = 1 as libc::c_int;
4636        } else {
4637            return
4638        }
4639    }
4640    if ldb.step != 0 || bp != 0 {
4641        let mut reason: *mut libc::c_char = b"step over\0" as *const u8
4642            as *const libc::c_char as *mut libc::c_char;
4643        if bp != 0 {
4644            reason = (if ldb.luabp != 0 {
4645                b"redis.breakpoint() called\0" as *const u8 as *const libc::c_char
4646            } else {
4647                b"break point\0" as *const u8 as *const libc::c_char
4648            }) as *mut libc::c_char;
4649        } else if timeout != 0 {
4650            reason = b"timeout reached, infinite loop?\0" as *const u8
4651                as *const libc::c_char as *mut libc::c_char;
4652        }
4653        ldb.step = 0 as libc::c_int;
4654        ldb.luabp = 0 as libc::c_int;
4655        ldbLog(
4656            sdscatprintf(
4657                sdsempty(),
4658                b"* Stopped at %d, stop reason = %s\0" as *const u8
4659                    as *const libc::c_char,
4660                ldb.currentline,
4661                reason,
4662            ),
4663        );
4664        ldbLogSourceLine(ldb.currentline);
4665        ldbSendLogs();
4666        if ldbRepl(lua) == -(1 as libc::c_int) && timeout != 0 {
4667            luaPushError(
4668                lua,
4669                b"timeout during Lua debugging with client closing connection\0"
4670                    as *const u8 as *const libc::c_char,
4671            );
4672            luaError(lua);
4673        }
4674        (*rctx).start_time = getMonotonicUs.expect("non-null function pointer")();
4675        (*rctx).snapshot_time = mstime();
4676    }
4677}