*/
#include "sysincludes.h"
-#include "msdos.h"
#include "stream.h"
-#include "vfat.h"
#include "mtools.h"
uid_t uid;
char *homedir;
char *username;
-
- homedir = getenv ("HOME");
- /*
- * first we call getlogin.
- * There might be several accounts sharing one uid
+
+ homedir = getenv ("HOME");
+ /*
+ * first we call getlogin.
+ * There might be several accounts sharing one uid
*/
if ( homedir )
return homedir;
-
+
pw = 0;
-
+
username = getenv("LOGNAME");
if ( !username )
username = getlogin();
if ( username )
pw = getpwnam( username);
-
+
if ( pw == 0 ){
/* if we can't getlogin, look up the pwent by uid */
uid = geteuid();
pw = getpwuid(uid);
}
-
+
/* we might still get no entry */
if ( pw )
return pw->pw_dir;
struct MT_STAT sbuf;
char file[MAXPATHLEN+1];
time_t now;
-
+
get_mcwd_file_name(file);
if (*mode == 'r'){
if (MT_STAT(file, &sbuf) < 0)
return NULL;
}
}
-
+
return fopen(file, mode);
}
-
+
void *safe_malloc(size_t size)
int row;
printf("%s:\n", message);
-
+
for(row = 0; row * 16 < size; row++){
printf("%03x ", row * 16);
- for(col = 0; col < 16; col++)
+ for(col = 0; col < 16; col++)
printf("%02x ", data [row*16+col]);
for(col = 0; col < 16; col++) {
if(isprint(data [row*16+col]))
}
}
}
-
+
if(!haveTime) {
time(&sharedNow);
haveTime = 1;
/* Convert a string to a size. The string should be a number,
optionally followed by S (sectors), K (K-Bytes), M (Megabytes), G
(Gigabytes) */
-size_t str_to_size_with_end(const char *str, char **endp) {
+mt_off_t str_to_off_with_end(const char *str, char **endp) {
char s;
- size_t siz;
+ mt_off_t siz;
*endp = NULL;
- siz = strtoul(str, endp, 0);
+ siz = strtol(str, endp, 0);
s = **endp;
/* trailing char, see if it is a size specifier */
if (s == 's' || s == 'S') /* sector */