/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/Makefile |
---|
0,0 → 1,4 |
THIS_SRCS= fsync.c ftruncat.c getdtabl.c gethostn.c getpages.c getwd.c \ |
nice.c sync.c truncate.c usleep.c vfork.c basename.c dirname.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/basename.c |
---|
0,0 → 1,28 |
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
#include <libc/unconst.h> |
char * |
basename (const char *fname) |
{ |
const char *base = fname; |
if (fname && *fname) |
{ |
if (fname[1] == ':') |
{ |
fname += 2; |
base = fname; |
} |
while (*fname) |
{ |
if (*fname == '\\' || *fname == '/') |
base = fname + 1; |
fname++; |
} |
} |
return unconst (base, char *); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/dirname.c |
---|
0,0 → 1,62 |
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <string.h> |
#include <unistd.h> |
char * |
dirname (const char *fname) |
{ |
const char *p = fname; |
const char *slash = NULL; |
if (fname) |
{ |
size_t dirlen; |
char * dirpart; |
if (*fname && fname[1] == ':') |
{ |
slash = fname + 1; |
p += 2; |
} |
/* Find the rightmost slash. */ |
while (*p) |
{ |
if (*p == '/' || *p == '\\') |
slash = p; |
p++; |
} |
if (slash == NULL) |
{ |
fname = "."; |
dirlen = 1; |
} |
else |
{ |
/* Remove any trailing slashes. */ |
while (slash > fname && (slash[-1] == '/' || slash[-1] == '\\')) |
slash--; |
/* How long is the directory we will return? */ |
dirlen = slash - fname + (slash == fname || slash[-1] == ':'); |
if (*slash == ':' && dirlen == 1) |
dirlen += 2; |
} |
dirpart = (char *)malloc (dirlen + 1); |
if (dirpart != NULL) |
{ |
strncpy (dirpart, fname, dirlen); |
if (slash && *slash == ':' && dirlen == 3) |
dirpart[2] = '.'; /* for "x:foo" return "x:." */ |
dirpart[dirlen] = '\0'; |
} |
return dirpart; |
} |
return NULL; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/fsync.c |
---|
0,0 → 1,11 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <unistd.h> |
#include <errno.h> |
#include <libc/dosio.h> |
#include <assert.h> |
int fsync(int _fd) |
{ |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/ftruncat.c |
---|
0,0 → 1,12 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <unistd.h> |
#include <io.h> |
#include <errno.h> |
int ftruncate(int fd, off_t where) |
{ |
int res = dosemu_truncate(fd, where); |
if (res) {errno = res; return -1;} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getdtabl.c |
---|
0,0 → 1,7 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
int getdtablesize(void) |
{ |
return 255; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/gethostn.c |
---|
0,0 → 1,14 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <unistd.h> |
#include <errno.h> |
#include <string.h> |
#include <stdlib.h> |
static char pc_n[]= "pc"; |
int gethostname (char *buf, int size) |
{ |
strcpy(buf,"MenuetOS"); |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getpages.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
int |
getpagesize(void) |
{ |
return 4096; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getwd.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
#include <limits.h> |
extern char* __get_curdir(void); |
char * getwd(char *buffer) |
{ |
if (buffer == 0) |
return 0; |
char * p=__get_curdir(); |
sprintf(buffer,"%s",p); |
return buffer; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/nice.c |
---|
0,0 → 1,29 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
#include <errno.h> |
/* The references disagree on the values of these. Higher value |
means less important process. */ |
#define NICE_MIN -20 |
#define NICE_MAX +20 |
#define NICE_USER 0 |
static int nice_val = NICE_USER; |
int nice (int incr) |
{ |
if (incr < 0 && getuid () != 0) { |
errno = EPERM; |
return -1; |
} |
nice_val += incr; |
if (nice_val < NICE_MIN) nice_val = NICE_MIN; |
if (nice_val > NICE_MAX) nice_val = NICE_MAX; |
/* This is braindead by design! If -1 returned you don't know |
if you had an error! Luckily you can ignore errors for a |
function like this. */ |
errno = 0; |
return (nice_val - NICE_USER); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/sync.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <unistd.h> |
int |
sync(void) |
{ |
int i; |
/* Update files with handles 0 thru 254 (incl). */ |
for (i = 0; i < 255; i++) |
fsync (i); |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/truncate.c |
---|
0,0 → 1,24 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <io.h> |
#include <assert.h> |
int truncate(const char *fn, off_t where) |
{ |
int fd = open(fn, O_WRONLY); |
if (fd < 0) |
return -1; |
if (lseek(fd, where, 0) < 0) |
{ |
close(fd); |
return -1; |
} |
if (_write(fd, 0, 0) < 0) |
{ |
close(fd); |
return -1; |
} |
return close(fd); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/usleep.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <unistd.h> |
#include <time.h> |
unsigned int usleep(unsigned int _useconds) |
{ |
clock_t cl_time; |
clock_t start_time = clock(); |
_useconds >>= 10; |
cl_time = _useconds * CLOCKS_PER_SEC / 977; |
while (1) |
{ |
clock_t elapsed = clock() - start_time; |
if (elapsed >= cl_time) break; |
__menuet__delay100(1); |
} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/vfork.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <errno.h> |
#include <unistd.h> |
pid_t |
vfork(void) |
{ |
errno = ENOMEM; /* The only other choice is EAGAIN, and we don't want that */ |
return -1; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |