Merge branch 'master' of github.com:thepowersgang/acess2
[tpg/acess2.git] / Usermode / Libraries / liburi.so_src / main.c
index bf88b98..a9f2e17 100644 (file)
@@ -32,7 +32,7 @@ void  URI_Close(tURIFile *File);
 size_t URI_file_Read(int Handle, size_t Bytes, void *Buffer);
 size_t URI_file_Write(int Handle, size_t Bytes, void *Buffer);
 void   URI_file_Close(int Handle);
-size_t URI_file_GetSize(int Handle);
+off_t  URI_file_GetSize(int Handle);
 
 // === CONSTANTS ===
 // Builtin URI protocol handlers
@@ -63,7 +63,7 @@ tURI *URI_Parse(const char *String)
        {
                 int    hostlen, portlen, pathlen;
                tmp += 3;       // Eat '://'
-               ret = malloc(sizeof(tURI) + strlen(String) - 2);
+               ret = malloc(sizeof(tURI) + protolen + 1 + strlen(tmp) + 1);
                
                ret->Proto = (char*)ret + sizeof(tURI);
                memcpy(ret->Proto, String, protolen);
@@ -140,14 +140,8 @@ tURI *URI_Parse(const char *String)
                else
                        ret->Path = ret->Host + hostlen + 1;
                
-               tmp ++;
                pathlen = 0;
-               while(*tmp)
-               {
-                       ret->Path[pathlen] = *tmp;
-                       tmp ++;
-                       pathlen ++;
-               }
+               strcpy(ret->Path, tmp);
                
                return ret;
        }
@@ -319,7 +313,7 @@ int URI_file_Open(char *Host, int Port, char *Path, int Mode)
 //     printf("URI_file_Open: open('%s', 0x%x)\n", Path, smode);
        {
                 int    ret;
-               ret = open(Path, smode);
+               ret = _SysOpen(Path, smode);
                return ret;
        }
 }
@@ -327,22 +321,22 @@ size_t URI_file_Read(int Handle, size_t Bytes, void *Buffer)
 {
 //     printf("URI_file_Read: (Handle=%i, Buffer=%p, Bytes=%i)\n",
 //             Handle, Buffer, (int)Bytes);
-       return read(Handle, Buffer, Bytes);
+       return _SysRead(Handle, Buffer, Bytes);
 }
 size_t URI_file_Write(int Handle, size_t Bytes, void *Buffer)
 {
-       return write(Handle, Buffer, Bytes);
+       return _SysWrite(Handle, Buffer, Bytes);
 }
 void URI_file_Close(int Handle)
 {
-       close(Handle);
+       _SysClose(Handle);
 }
-size_t URI_file_GetSize(int Handle)
+off_t URI_file_GetSize(int Handle)
 {
-       uint64_t curpos = tell(Handle);
-       size_t ret;
-       seek(Handle, 0, SEEK_END);
-       ret = tell(Handle);
-       seek(Handle, curpos, SEEK_SET);
+       uint64_t curpos = _SysTell(Handle);
+       off_t ret;
+       _SysSeek(Handle, 0, SEEK_END);
+       ret = _SysTell(Handle);
+       _SysSeek(Handle, curpos, SEEK_SET);
        return ret;
 }

UCC git Repository :: git.ucc.asn.au