Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


*** empty log message ***
Lei Xia [Mon, 21 Jul 2008 16:38:24 +0000 (16:38 +0000)]
palacios/include/libc/string.h
palacios/src/common/string.c

index fb146c0..74b205c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * String library
  * Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
  * 
  * This is free software.  You are permitted to use,
  * redistribute, and modify it as specified in the file "COPYING".
 
 #include <stddef.h>
 
+/* Definition of the control structure for streams
+*/
+typedef struct file_struct {
+        short           level;          /* fill/empty level of buffer */
+        unsigned        flags;          /* File status flags    */
+        char            fd;             /* File descriptor      */
+        unsigned char   hold;           /* Ungetc char if no buffer */
+        short           bsize;          /* Buffer size          */
+        unsigned char   *buffer;        /* Data transfer buffer */
+        unsigned char   *curp;          /* Current active pointer */
+        unsigned        istemp;         /* Temporary file indicator */
+        short           token;          /* Used for validity checking */
+}       FILE;    
+
 void* memset(void* s, int c, size_t n);
 void* memcpy(void *dst, const void* src, size_t n);
 void *memmove(void *dst, const void *src, size_t n);
@@ -28,10 +42,20 @@ int atoi(const char *buf);
 char *strchr(const char *s, int c);
 char *strrchr(const char *s, int c);
 char *strpbrk(const char *s, const char *accept);
+char *strncat(char *s1, const char *s2, size_t limit);
+int fprintf(FILE *file, char *fmt, ...);
+//int fflush(FILE *file);
+
+void abort (void) __attribute__ ((__noreturn__));
+#define _tolower(c)    ((c) + 'a' - 'A')
+
+int tolower(int ch);
 
 /* Note: The ISO C standard puts this in <stdio.h>, but we don't
  * have that header in GeekOS (yet). */
 int snprintf(char *s, size_t size, const char *fmt, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));
 
+
 #endif  /* STRING_H */
+
index 7db896c..7415067 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * String library
  * Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
  * 
  * This is free software.  You are permitted to use,
  * redistribute, and modify it as specified in the file "COPYING".
 
 #include <fmtout.h>
 #include <string.h>
+#include <palacios/vmm.h>
+
+//extern int PrintDebug(char *fmt, ...);
 
 extern void *Malloc(size_t size);
 
+/* Standard I/O predefined streams
+*/
+FILE   _streams = {0, 0, 0, 0, 0, NULL, NULL, 0, 0};
+
+FILE  *stdin = (&_streams);
+FILE  *stdout = (&_streams);
+FILE  *stderr = (&_streams);
+
 void* memset(void* s, int c, size_t n)
 {
     unsigned char* p = (unsigned char*) s;
@@ -122,6 +133,21 @@ char *strcat(char *s1, const char *s2)
     return t1;
 }
 
+char *strncat(char *s1, const char *s2, size_t limit)
+{
+    size_t i = 0;
+    char *t1;
+    t1 = s1;
+    while (*s1) s1++;
+    while (i < limit) {
+               if(*s2 == '\0') break;
+               *s1++ = *s2++;          
+    }
+    *s1 = '\0';
+    return t1;
+}
+       
+
 char *strcpy(char *dest, const char *src)
 {
     char *ret = dest;
@@ -259,3 +285,36 @@ int snprintf(char *s, size_t size, const char *fmt, ...)
 
     return rc;
 }
+
+int fprintf(FILE *file, char *fmt, ...)
+{
+   // PrintDebug("In fprintf!!\n");
+
+   return 0;
+
+}
+
+/* int fflush(FILE *stream)
+{
+    PrintDebug("In fflush!!\n");
+
+    return 0;
+}*/
+
+void abort(void)
+{
+   //PrintDebug("Abort!!\n");
+
+   //__asm__ __volatile__("trap"); 
+   //__builtin_unreached();
+
+
+   while(1);
+   
+}
+
+int tolower(int ch)
+{
+     return _tolower(ch);
+}
+