diff --git a/src/sbbs3/upgrade_to_v320.c b/src/sbbs3/upgrade_to_v320.c index 359d446e697971e4ab62329c492dd612333eb78b..d7f9a27ed1e078402b505b7ba1ae527c421164e1 100644 --- a/src/sbbs3/upgrade_to_v320.c +++ b/src/sbbs3/upgrade_to_v320.c @@ -397,175 +397,13 @@ static int v31x_fgetuserdat(scfg_t* cfg, user_t *user, int file) return v31x_parseuserdat(cfg, userdat, user); } -/* Returns length of specified user record 'field', or -1 if invalid */ -static int user_rec_len(int offset) -{ - switch(offset) { - - /* Strings (of different lengths) */ - case U_ALIAS: return(LEN_ALIAS); - case U_NAME: return(LEN_NAME); - case U_HANDLE: return(LEN_HANDLE); - case U_NOTE: return(LEN_NOTE); - case U_COMP: return(LEN_COMP); - case U_COMMENT: return(LEN_COMMENT); - case U_NETMAIL: return(LEN_NETMAIL); - case U_ADDRESS: return(LEN_ADDRESS); - case U_LOCATION: return(LEN_LOCATION); - case U_ZIPCODE: return(LEN_ZIPCODE); - case U_PASS: return(LEN_PASS); - case U_PHONE: return(LEN_PHONE); - case U_BIRTH: return(LEN_BIRTH); - case U_MODEM: return(LEN_MODEM); - case U_IPADDR: return(LEN_IPADDR); - - /* Internal codes (16 chars) */ - case U_CURSUB: - case U_CURDIR: - return (16); - - /* Dates in time_t format (8 hex digits) */ - case U_LASTON: - case U_FIRSTON: - case U_EXPIRE: - case U_PWMOD: - case U_NS_TIME: - case U_LOGONTIME: - - /* 32-bit integers (8 hex digits) */ - case U_FLAGS1: - case U_FLAGS2: - case U_FLAGS3: - case U_FLAGS4: - case U_EXEMPT: - case U_REST: - case U_MISC: - case U_QWK: - case U_CHAT: - - /* Internal codes (8 chars) */ - case U_CURXTRN: - case U_XEDIT: - case U_SHELL: - return(8); - - /* 16-bit integers (5 decimal digits) */ - case U_LOGONS: - case U_LTODAY: - case U_TIMEON: - case U_TEXTRA: - case U_TTODAY: - case U_TLAST: - case U_POSTS: - case U_EMAILS: - case U_FBACKS: - case U_ETODAY: - case U_PTODAY: - case U_ULS: - case U_DLS: - return(5); - - /* 32-bit integers (10 decimal digits) */ - case U_ULB: - case U_DLB: - case U_MIN: - return(10); - - /* 64-bit integers (20 decimal digits) */ - case U_CDT: - case U_FREECDT: - return 20; - - /* 3 char strings */ - case U_TMPEXT: - return(3); - case U_ROWS: - return LEN_ROWS; - case U_COLS: - return LEN_COLS; - - /* 2 digit integers (0-99 or 00-FF) */ - case U_LEVEL: - case U_TL: - case U_LEECH: - return(2); - - /* Single digits chars */ - case U_SEX: - case U_PROT: - return(1); - } - - return(-1); -} - -/****************************************************************************/ -/* Fills 'str' with record for usernumber starting at start for length bytes*/ -/* Called from function ??? */ -/****************************************************************************/ -static int getuserrec(scfg_t* cfg, int usernumber,int start, int length, char *str) -{ - char path[256]; - int i,c,file; - - if(!VALID_CFG(cfg) || usernumber<1 || str==NULL) - return(-1); - SAFEPRINTF(path,"%suser/user.dat",cfg->data_dir); - if((file=nopen(path,O_RDONLY|O_DENYNONE))==-1) - return(errno); - if(usernumber<1 - || filelength(file)<(long)((long)(usernumber-1L)*U_LEN)+(long)start) { - close(file); - return(-2); - } - (void)lseek(file,(long)((long)(usernumber-1)*U_LEN)+start,SEEK_SET); - - if(length < 1) { /* auto-length */ - length=user_rec_len(start); - if(length < 1) { - close(file); - return -5; - } - } - - i=0; - while(i<LOOP_NODEDAB - && lock(file,(long)((long)(usernumber-1)*U_LEN)+start,length)==-1) { - if(i) - mswait(100); - i++; - } - - if(i>=LOOP_NODEDAB) { - close(file); - return(-3); - } - - if(read(file,str,length)!=length) { - unlock(file,(long)((long)(usernumber-1)*U_LEN)+start,length); - close(file); - return(-4); - } - - unlock(file,(long)((long)(usernumber-1)*U_LEN)+start,length); - close(file); - for(c=0;c<length;c++) - if(str[c]==ETX || str[c]==CR) break; - str[c]=0; - - if(c == 0 && start == LEN_PASS) // Backwards compatibility hack - return getuserrec(cfg, usernumber, U_OLDPASS, LEN_OLDPASS, str); - - return(0); -} - bool compare_user(user_t* before, user_t* after) { uint8_t* b = (uint8_t*)before; uint8_t* a = (uint8_t*)after; bool result = true; - for(size_t i = 0; i < sizeof(user_t); i++) { + for(uint i = 0; i < sizeof(user_t); i++) { if(a[i] != b[i]) { printf("user #%-4u offset %04X: %02X != %02X\n", before->number, i, (uint)b[i], (uint)a[i]); result = false;