/* Saves an encoded length. The first two bits in the first byte are used to * hold the encoding type. See the REDIS_RDB_* definitions for more information * on the types of encoding. */ int rdbSaveLen(rio *rdb, uint32_t len) { unsigned char buf[2]; size_t nwritten; if (len < (1<<6)) { /* Save a 6 bit len */ buf[0] = (len&0xFF)|(REDIS_RDB_6BITLEN<<6); if (rdbWriteRaw(rdb,buf,1) == -1) return -1; nwritten = 1; } else if (len < (1<<14)) { /* Save a 14 bit len */ buf[0] = ((len>>8)&0xFF)|(REDIS_RDB_14BITLEN<<6); buf[1] = len&0xFF; if (rdbWriteRaw(rdb,buf,2) == -1) return -1; nwritten = 2; } else {
int rdbSaveMillisecondTime(rio *rdb, long long t) { int64_t t64 = (int64_t) t; return rdbWriteRaw(rdb,&t64,8); }
int rdbSaveTime(FILE *fp, time_t t) { int32_t t32 = (int32_t) t; return rdbWriteRaw(fp,&t32,4); }
int rdbSaveType(rio *rdb, unsigned char type) { return rdbWriteRaw(rdb,&type,1); }
int rdbSaveType(FILE *fp, unsigned char type) { return rdbWriteRaw(fp,&type,1); }