\r
INCFILES := stdio.h stdlib.h\r
\r
-OBJ = stub.o heap.o stdlib.o env.o stdio.o string.o rand.o\r
-OBJ += scanf.o signals.o strtoi.o strtof.o\r
+OBJ = stub.o heap.o stdlib.o env.o string.o rand.o\r
+OBJ += scanf.o signals.o strtoi.o strtof.o \r
OBJ += printf.o time.o timeconv.o errno.o ctype.o\r
+OBJ += stdio.o stdio_files.o\r
OBJ += arch/$(ARCHDIR).ao\r
# signals.o\r
DEPFILES := $(OBJ:%.o=%.d)\r
--- /dev/null
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * stdio_files.c
+ * - non-stream file manipulation
+ */
+#include <stdio.h>
+#include <acess/sys.h> // _SysDebug
+
+// === CODE ===
+int remove(const char *filename)
+{
+ _SysDebug("TODO: libc remove('%s')", filename);
+ return 1;
+}
+
+int rename(const char *old, const char *new)
+{
+ _SysDebug("TODO: libc rename('%s','%s')", old, new);
+ return 1;
+}
+
#include <string.h>
#include "timeconv.h"
#include <errno.h>
+#include <stdio.h> // sprintf
#define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years
return ret;
}
+//! Convert the time structure into a string of form 'Sun Sep 16 01:03:52 1973\n\0'
+char *asctime(const struct tm *timeptr)
+{
+ static char staticbuf[sizeof("Sun Sep 16 01:03:52 1973\n")];
+ return asctime_r(timeptr, staticbuf);
+}
+char *asctime_r(const struct tm *timeptr, char *buf)
+{
+ const char *WDAYS[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
+ const char *MONS[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
+ sprintf(buf,
+ "%s %s %i %02i:%02i:%02i %4i\n",
+ WDAYS[timeptr->tm_wday],
+ MONS[timeptr->tm_mon],
+ timeptr->tm_mday,
+ timeptr->tm_hour,
+ timeptr->tm_min,
+ timeptr->tm_sec,
+ timeptr->tm_year
+ );
+ return buf;
+}
+
+//! asctime(localtime(timer))
+char *ctime(const time_t *timer)
+{
+ struct tm time_buf;
+ localtime_r(timer, &time_buf);
+ return asctime(&time_buf);
+}
+extern char *ctime_r(const time_t *timer, char *buf)
+{
+ struct tm time_buf;
+ localtime_r(timer, &time_buf);
+ return asctime_r(&time_buf, buf);
+}
+
+//! Convert \a timter into UTC
+struct tm *gmtime(const time_t *timer)
+{
+ // Ignore UTC
+ return localtime(timer);
+}
+struct tm *gmtime_r(const time_t *timer, struct tm *result)
+{
+ return localtime_r(timer, result);
+}
+
static struct tm static_tm;
struct tm *localtime(const time_t *timer)
// Month and Day of Month
get_month_day(ret->tm_yday, is_ly, &ret->tm_mon, &ret->tm_mday);
+ ret->tm_mon --;
ret->tm_isdst = 0; // Fuck DST