paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/src/physfs/platform beos.c,1.1.1.1,1.1.1.1.6.


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/src/physfs/platform beos.c,1.1.1.1,1.1.1.1.6.1
Date: Fri, 03 May 2002 06:55:33 -0400

Update of /cvsroot/paragui/paragui/src/physfs/platform
In directory subversions:/tmp/cvs-serv5204/platform

Modified Files:
      Tag: devel-1-0
        beos.c 
Log Message:
adapted beos.c to new physfs arch (this is completely untested
and will surely fail to compile).



Index: beos.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/beos.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -C2 -r1.1.1.1 -r1.1.1.1.6.1
*** beos.c      15 Apr 2002 13:22:14 -0000      1.1.1.1
--- beos.c      3 May 2002 10:55:30 -0000       1.1.1.1.6.1
***************
*** 8,32 ****
   */
  
- #if (defined __STRICT_ANSI__)
- #define __PHYSFS_DOING_STRICT_ANSI__
- #endif
- 
- /*
-  * We cheat a little: I want the symlink version of stat() (lstat), and
-  *  GCC/Linux will not declare it if compiled with the -ansi flag.
-  *  If you are really lacking symlink support on your platform,
-  *  you should #define __PHYSFS_NO_SYMLINKS__ before compiling this
-  *  file. That will open a security hole, though, if you really DO have
-  *  symlinks on your platform; it renders PHYSFS_permitSymbolicLinks(0)
-  *  useless, since every symlink will be reported as a regular file/dir.
-  */
- #if (defined __PHYSFS_DOING_STRICT_ANSI__)
- #undef __STRICT_ANSI__
- #endif
- #include <stdio.h>
- #if (defined __PHYSFS_DOING_STRICT_ANSI__)
- #define __STRICT_ANSI__
- #endif
- 
  #include <be/kernel/OS.h>
  #include <be/kernel/fs_info.h>
--- 8,11 ----
***************
*** 51,117 ****
  #include "physfs_internal.h"
  
- 
  const char *__PHYSFS_platformDirSeparator = "/";
  
- char **__PHYSFS_platformDetectAvailableCDs(void)
- {
- 
- //    char **retval = (char **) malloc(sizeof (char *));
- //    int cd_count = 1;  /* We count the NULL entry. */
- //    FILE *mounts = NULL;
- //    struct mntent *ent = NULL;
- 
- //    *retval = NULL;
- //    mounts = setmntent("/etc/mtab", "r");
- //    BAIL_IF_MACRO(mounts == NULL, ERR_IO_ERROR, retval);
- 
- //    while ( (ent = getmntent(mounts)) != NULL )
- //    {
- //        int add_it = 0;
- //        if (strcmp(ent->mnt_type, "iso9660") == 0)
- //            add_it = 1;
-         /* !!! other mount types? */
- 
- //        if (add_it)
- //        {
- //            char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
- //            if (tmp)
- //            {
- //                retval = tmp;
- //                retval[cd_count-1] = (char *) malloc(strlen(ent->mnt_dir) + 
1);
- //                if (retval[cd_count-1])
- //                {
- //                    strcpy(retval[cd_count-1], ent->mnt_dir);
- //                    cd_count++;
- //                } /* if */
- //            } /* if */
- //        } /* if */
- //    } /* while */
- 
- //    endmntent(mounts);
  
! //    retval[cd_count - 1] = NULL;
! //    return(retval);
!     return NULL;
! } /* __PHYSFS_detectAvailableCDs */
  
  
! static char *copyEnvironmentVariable(const char *varname)
  {
!     const char *envr = getenv(varname);
!     char *retval = NULL;
  
!     if (envr != NULL)
!     {
!         retval = malloc(strlen(envr) + 1);
!         if (retval != NULL)
!             strcpy(retval, envr);
!     } /* if */
! 
!     return(retval);
! } /* copyEnvironmentVariable */
  
  
- /* !!! this is ugly. */
  char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  {
--- 30,54 ----
  #include "physfs_internal.h"
  
  const char *__PHYSFS_platformDirSeparator = "/";
  
  
! int __PHYSFS_platformInit(void)
! {
!     return(1);  /* always succeed. */
! } /* __PHYSFS_platformInit */
  
  
! int __PHYSFS_platformDeinit(void)
  {
!     return(1);  /* always succeed. */
! } /* __PHYSFS_platformDeinit */
  
! // FIXME - needs to be implemented
! char **__PHYSFS_platformDetectAvailableCDs(void)
! {
!     return NULL;
! } /* __PHYSFS_platformDetectAvailableCDs */
  
  
  char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  {
***************
*** 160,164 ****
  
      free(envr);
!     return(retval);
  } /* __PHYSFS_platformCalcBaseDir */
  
--- 97,101 ----
  
      free(envr);
!     return(retval);   
  } /* __PHYSFS_platformCalcBaseDir */
  
***************
*** 182,185 ****
--- 119,131 ----
  
  
+ char *__PHYSFS_platformGetUserName(void)
+ {
+     char *retval = getUserNameByUID();
+     if (retval == NULL)
+         retval = copyEnvironmentVariable("USER");
+     return(retval);   
+ } /* __PHYSFS_platformGetUserName */
+ 
+ 
  static char *getUserDirByUID(void)
  {
***************
*** 200,212 ****
  
  
- char *__PHYSFS_platformGetUserName(void)
- {
-     char *retval = getUserNameByUID();
-     if (retval == NULL)
-         retval = copyEnvironmentVariable("USER");
-     return(retval);
- } /* __PHYSFS_platformGetUserName */
- 
- 
  char *__PHYSFS_platformGetUserDir(void)
  {
--- 146,149 ----
***************
*** 214,228 ****
      if (retval == NULL)
          retval = getUserDirByUID();
!     return(retval);
  } /* __PHYSFS_platformGetUserDir */
  
  
! int __PHYSFS_platformGetThreadID(void)
  {
!     return((int) find_thread(NULL));
  } /* __PHYSFS_platformGetThreadID */
  
  
- /* -ansi and -pedantic flags prevent use of strcasecmp() on Linux. */
  int __PHYSFS_platformStricmp(const char *x, const char *y)
  {
--- 151,164 ----
      if (retval == NULL)
          retval = getUserDirByUID();
!     return(retval);   
  } /* __PHYSFS_platformGetUserDir */
  
  
! PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
  {
!     return((PHYSFS_uint64)find_thread(NULL)); 
  } /* __PHYSFS_platformGetThreadID */
  
  
  int __PHYSFS_platformStricmp(const char *x, const char *y)
  {
***************
*** 241,245 ****
      } while ((ux) && (uy));
  
!     return(0);
  } /* __PHYSFS_platformStricmp */
  
--- 177,181 ----
      } while ((ux) && (uy));
  
!     return(0);        
  } /* __PHYSFS_platformStricmp */
  
***************
*** 248,252 ****
  {
      struct stat statbuf;
!     return(stat(fname, &statbuf) == 0);
  } /* __PHYSFS_platformExists */
  
--- 184,188 ----
  {
      struct stat statbuf;
!     return(stat(fname, &statbuf) == 0);       
  } /* __PHYSFS_platformExists */
  
***************
*** 269,273 ****
      return(retval);
  
! #endif
  } /* __PHYSFS_platformIsSymlink */
  
--- 205,209 ----
      return(retval);
  
! #endif        
  } /* __PHYSFS_platformIsSymlink */
  
***************
*** 284,288 ****
      } /* if */
      
!     return(retval);
  } /* __PHYSFS_platformIsDirectory */
  
--- 220,224 ----
      } /* if */
      
!     return(retval);   
  } /* __PHYSFS_platformIsDirectory */
  
***************
*** 315,322 ****
  
  
- /* Much like my college days, try to sleep for 10 milliseconds at a time... */
  void __PHYSFS_platformTimeslice(void)
  {
!     snooze(10);
  } /* __PHYSFS_platformTimeslice */
  
--- 251,257 ----
  
  
  void __PHYSFS_platformTimeslice(void)
  {
!       snooze(10);     
  } /* __PHYSFS_platformTimeslice */
  
***************
*** 423,439 ****
      fs_close_query(dir);
      
!     return(retval);
  } /* __PHYSFS_platformEnumerateFiles */
  
  
- int __PHYSFS_platformFileLength(FILE *handle)
- {
-     struct stat statbuf;
-     errno = 0;
-     BAIL_IF_MACRO(fstat(fileno(handle), &statbuf) == -1, strerror(errno), -1);
-     return(statbuf.st_size);
- } /* __PHYSFS_platformFileLength */
- 
- 
  char *__PHYSFS_platformCurrentDir(void)
  {
--- 358,365 ----
      fs_close_query(dir);
      
!     return(retval);   
  } /* __PHYSFS_platformEnumerateFiles */
  
  
  char *__PHYSFS_platformCurrentDir(void)
  {
***************
*** 464,468 ****
        BAIL_IF_MACRO(1, ERR_NO_SUCH_FILE, NULL);
      }
!     return(retval);
  } /* __PHYSFS_platformCurrentDir */
  
--- 390,394 ----
        BAIL_IF_MACRO(1, ERR_NO_SUCH_FILE, NULL);
      }
!     return(retval);   
  } /* __PHYSFS_platformCurrentDir */
  
***************
*** 470,489 ****
  char *__PHYSFS_platformRealPath(const char *path)
  {
! // hmm,.. didn't solve this from BeOS till now
! // trying the easy route (FIXME)
! 
! //    char resolved_path[MAXPATHLEN];
! //    char *retval = NULL;
  
      char *retval = malloc(strlen(path) + 1);
      strcpy(retval, path);
  
! //    errno = 0;
! //    BAIL_IF_MACRO(!realpath(path, resolved_path), strerror(errno), NULL);
! //    retval = malloc(strlen(resolved_path) + 1);
! //    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
! //    strcpy(retval, resolved_path);
! 
!     return(retval);   
  } /* __PHYSFS_platformRealPath */
  
--- 396,406 ----
  char *__PHYSFS_platformRealPath(const char *path)
  {
!       // hmm,.. didn't solve this for BeOS till now
!       // trying the easy route (FIXME)
  
      char *retval = malloc(strlen(path) + 1);
      strcpy(retval, path);
  
!     return(retval);           
  } /* __PHYSFS_platformRealPath */
  
***************
*** 495,501 ****
      rc = mkdir(path, S_IRWXU);
      BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
!     return(1);
  } /* __PHYSFS_platformMkDir */
  
! /* end of beos.c ... */
  
--- 412,560 ----
      rc = mkdir(path, S_IRWXU);
      BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
!     return(1);        
  } /* __PHYSFS_platformMkDir */
  
! 
! static void *doOpen(const char *filename, const char *mode)
! {
!     FILE *retval;
!     errno = 0;
! 
!     retval = fopen(filename, mode);
!     if (retval == NULL)
!         __PHYSFS_setError(strerror(errno));
! 
!     return((void *) retval);
! } /* doOpen */
! 
! 
! void *__PHYSFS_platformOpenRead(const char *filename)
! {
!     return(doOpen(filename, "rb"));
! } /* __PHYSFS_platformOpenRead */
! 
! 
! void *__PHYSFS_platformOpenWrite(const char *filename)
! {
!     return(doOpen(filename, "wb"));   
! } /* __PHYSFS_platformOpenWrite */
! 
! 
! void *__PHYSFS_platformOpenAppend(const char *filename)
! {
!     return(doOpen(filename, "wb+"));  
! } /* __PHYSFS_platformOpenAppend */
! 
! 
! PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
!                                     PHYSFS_uint32 size, PHYSFS_uint32 count)
! {
!     FILE *io = (FILE *) opaque;
!     int rc = fread(buffer, size, count, io);
!     if (rc < count)
!     {
!         int err = errno;
!         BAIL_IF_MACRO(ferror(io), strerror(err), rc);
!         BAIL_MACRO(ERR_PAST_EOF, rc);
!     } /* if */
! 
!     return(rc);       
! } /* __PHYSFS_platformRead */
! 
! 
! PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
!                                      PHYSFS_uint32 size, PHYSFS_uint32 count)
! {
!     FILE *io = (FILE *) opaque;
!     int rc = fwrite((void *) buffer, size, count, io);
!     if (rc < count)
!         __PHYSFS_setError(strerror(errno));
! 
!     return(rc);       
! } /* __PHYSFS_platformWrite */
! 
! 
! int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
! {
!     FILE *io = (FILE *) opaque;
! 
!     /* !!! FIXME: Use llseek where available. */
!     errno = 0;
!     BAIL_IF_MACRO(fseek(io, pos, SEEK_SET) != 0, strerror(errno), 0);
! 
!     return(1);        
! } /* __PHYSFS_platformSeek */
! 
! 
! PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
! {
!     FILE *io = (FILE *) opaque;
!     PHYSFS_sint64 retval = ftell(io);
!     BAIL_IF_MACRO(retval == -1, strerror(errno), -1);
!     return(retval);   
! } /* __PHYSFS_platformTell */
! 
! 
! PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
! {
!     FILE *io = (FILE *) opaque;
!     struct stat statbuf;
!     errno = 0;
!     BAIL_IF_MACRO(fstat(fileno(io), &statbuf) == -1, strerror(errno), -1);
!     return((PHYSFS_sint64) statbuf.st_size);  
! } /* __PHYSFS_platformFileLength */
! 
! 
! int __PHYSFS_platformEOF(void *opaque)
! {
!     return(feof((FILE *) opaque));    
! } /* __PHYSFS_platformEOF */
! 
! 
! int __PHYSFS_platformFlush(void *opaque)
! {
!     errno = 0;
!     BAIL_IF_MACRO(fflush((FILE *) opaque) == EOF, strerror(errno), 0);
!     return(1);        
! } /* __PHYSFS_platformFlush */
! 
! 
! int __PHYSFS_platformClose(void *opaque)
! {
!     errno = 0;
!     BAIL_IF_MACRO(fclose((FILE *) opaque) == EOF, strerror(errno), 0);
!     return(1);        
! } /* __PHYSFS_platformClose */
! 
! 
! int __PHYSFS_platformDelete(const char *path)
! {
!     errno = 0;
!     BAIL_IF_MACRO(remove(path) == -1, strerror(errno), 0);
!     return(1);        
! } /* __PHYSFS_platformDelete */
! 
! 
! void *__PHYSFS_platformCreateMutex(void)
! {
!     return((void *) 0x0001);  
! } /* __PHYSFS_platformCreateMutex */
! 
! 
! void __PHYSFS_platformDestroyMutex(void *mutex)
! {
! } /* __PHYSFS_platformDestroyMutex */
! 
! 
! int __PHYSFS_platformGrabMutex(void *mutex)
! {
!       return(1);
! } /* __PHYSFS_platformGrabMutex */
! 
! 
! void __PHYSFS_platformReleaseMutex(void *mutex)
! {
! } /* __PHYSFS_platformReleaseMutex */
! 
! /* end of skeleton.c ... */
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]