Compiles and runs on Visual C. What an uphill climb THAT was.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 23 Aug 2001 18:01:43 +0000
changeset 74 a4a5066fb640
parent 73 96828990c739
child 75 8f3ccaaea1cd
Compiles and runs on Visual C. What an uphill climb THAT was.
Makefile
physfs.c
physfs.h
test/test_physfs.c
--- a/Makefile	Thu Aug 23 17:09:20 2001 +0000
+++ b/Makefile	Thu Aug 23 18:01:43 2001 +0000
@@ -168,14 +168,18 @@
 MAINSRCS := physfs.c archivers/dir.c
 
 ifeq ($(strip $(use_archive_zip)),true)
-MAINSRCS += archivers/zip.c archivers/unzip.c
-CFLAGS += -DPHYSFS_SUPPORTS_ZIP
-ifeq ($(strip $(cygwin)),true)
-CFLAGS += -Izlibwin32
-LDFLAGS += zlibwin32/zlibstat.lib
-else
-LDFLAGS += -lz
-endif
+  MAINSRCS += archivers/zip.c archivers/unzip.c
+  CFLAGS += -DPHYSFS_SUPPORTS_ZIP
+  ifeq ($(strip $(cygwin)),true)
+    CFLAGS += -Izlibwin32
+    ifeq ($(strip $(debugging)),true)
+      LDFLAGS += zlibwin32/zlibstat_multid.lib  
+    else
+      LDFLAGS += zlibwin32/zlibstat_multir.lib  
+    endif
+  else
+    LDFLAGS += -lz
+  endif
 endif
 
 ifeq ($(strip $(use_archive_grp)),true)
@@ -185,6 +189,7 @@
 
 ifeq ($(strip $(cygwin)),true)
 MAINSRCS += platform/win32.c
+CFLAGS += -DWIN32
 else
 MAINSRCS += platform/unix.c
 endif
--- a/physfs.c	Thu Aug 23 17:09:20 2001 +0000
+++ b/physfs.c	Thu Aug 23 18:01:43 2001 +0000
@@ -626,7 +626,7 @@
 
 
 int PHYSFS_setSaneConfig(const char *appName, const char *archiveExt,
-                         int includeCdRoms, int archivesFirst)
+                                     int includeCdRoms, int archivesFirst)
 {
     const char *basedir = PHYSFS_getBaseDir();
     const char *userdir = PHYSFS_getUserDir();
@@ -737,9 +737,9 @@
 
 
 /* string manipulation in C makes my ass itch. */
-char *__PHYSFS_convertToDependent(const char *prepend,
-                                  const char *dirName,
-                                  const char *append)
+char * __PHYSFS_convertToDependent(const char *prepend,
+                                              const char *dirName,
+                                              const char *append)
 {
     const char *dirsep = PHYSFS_getDirSeparator();
     int sepsize = strlen(dirsep);
@@ -1233,7 +1233,7 @@
 
 
 int PHYSFS_read(PHYSFS_file *handle, void *buffer,
-                unsigned int objSize, unsigned int objCount)
+                            unsigned int objSize, unsigned int objCount)
 {
     FileHandle *h = (FileHandle *) handle->opaque;
     assert(h != NULL);
@@ -1244,7 +1244,7 @@
 
 
 int PHYSFS_write(PHYSFS_file *handle, void *buffer,
-                 unsigned int objSize, unsigned int objCount)
+                            unsigned int objSize, unsigned int objCount)
 {
     FileHandle *h = (FileHandle *) handle->opaque;
     assert(h != NULL);
@@ -1294,6 +1294,5 @@
     return(h->funcs->fileLength(h));
 } /* PHYSFS_filelength */
 
-
 /* end of physfs.c ... */
 
--- a/physfs.h	Thu Aug 23 17:09:20 2001 +0000
+++ b/physfs.h	Thu Aug 23 18:01:43 2001 +0000
@@ -141,6 +141,12 @@
 extern "C" {
 #endif
 
+#if (defined _MSC_VER)
+#define __EXPORT__ __declspec(dllexport)
+#else
+#define __EXPORT__
+#endif
+
 
 typedef struct __PHYSFS_FILE__
 {
@@ -195,7 +201,7 @@
  *
  * This function may be called safely at any time, even before PHYSFS_init().
  */
-void PHYSFS_getLinkedVersion(PHYSFS_Version *ver);
+__EXPORT__ void PHYSFS_getLinkedVersion(PHYSFS_Version *ver);
 
 
 /**
@@ -209,7 +215,7 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_init(const char *argv0);
+__EXPORT__ int PHYSFS_init(const char *argv0);
 
 
 /**
@@ -231,7 +237,7 @@
  *          gleaned from PHYSFS_getLastError(). If failure, state of PhysFS is
  *          undefined, and probably badly screwed up.
  */
-int PHYSFS_deinit(void);
+__EXPORT__ int PHYSFS_deinit(void);
 
 
 /**
@@ -257,7 +263,7 @@
  *
  *   @return READ ONLY Null-terminated array of READ ONLY structures.
  */
-const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void);
+__EXPORT__ const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void);
 
 
 /**
@@ -266,7 +272,7 @@
  *
  *   @param list List of information specified as freeable by this function.
  */
-void PHYSFS_freeList(void *list);
+__EXPORT__ void PHYSFS_freeList(void *list);
 
 
 /**
@@ -280,7 +286,7 @@
  *
  *   @return READ ONLY string of last error message.
  */
-const char *PHYSFS_getLastError(void);
+__EXPORT__ const char *PHYSFS_getLastError(void);
 
 
 /**
@@ -294,7 +300,7 @@
  *
  *   @return READ ONLY null-terminated string of platform's dir separator.
  */
-const char *PHYSFS_getDirSeparator(void);
+__EXPORT__ const char *PHYSFS_getDirSeparator(void);
 
 
 /**
@@ -322,7 +328,7 @@
  *
  *   @param allow nonzero to permit symlinks, zero to deny linking.
  */
-void PHYSFS_permitSymbolicLinks(int allow);
+__EXPORT__ void PHYSFS_permitSymbolicLinks(int allow);
 
 
 /**
@@ -354,7 +360,7 @@
  *
  *   @return Null-terminated array of null-terminated strings.
  */
-char **PHYSFS_getCdRomDirs(void);
+__EXPORT__ char **PHYSFS_getCdRomDirs(void);
 
 
 /**
@@ -368,7 +374,7 @@
  *
  *  @return READ ONLY string of base dir in platform-dependent notation.
  */
-const char *PHYSFS_getBaseDir(void);
+__EXPORT__ const char *PHYSFS_getBaseDir(void);
 
 
 /**
@@ -386,7 +392,7 @@
  *
  *  @return READ ONLY string of user dir in platform-dependent notation.
  */
-const char *PHYSFS_getUserDir(void);
+__EXPORT__ const char *PHYSFS_getUserDir(void);
 
 
 /**
@@ -395,7 +401,7 @@
  *  @return READ ONLY string of write dir in platform-dependent notation,
  *           OR NULL IF NO WRITE PATH IS CURRENTLY SET.
  */
-const char *PHYSFS_getWriteDir(void);
+__EXPORT__ const char *PHYSFS_getWriteDir(void);
 
 
 /**
@@ -415,7 +421,7 @@
  *           Specifics of the error can be gleaned from PHYSFS_getLastError().
  *
  */
-int PHYSFS_setWriteDir(const char *newDir);
+__EXPORT__ int PHYSFS_setWriteDir(const char *newDir);
 
 
 /**
@@ -429,7 +435,7 @@
  *                   missing, etc). Specifics of the error can be
  *                   gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_addToSearchPath(const char *newDir, int appendToPath);
+__EXPORT__ int PHYSFS_addToSearchPath(const char *newDir, int appendToPath);
 
 
 /**
@@ -445,7 +451,7 @@
  *   @return nonzero on success, zero on failure.
  *            Specifics of the error can be gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_removeFromSearchPath(const char *oldDir);
+__EXPORT__ int PHYSFS_removeFromSearchPath(const char *oldDir);
 
 
 /**
@@ -465,7 +471,7 @@
  *   @return Null-terminated array of null-terminated strings. NULL if there
  *            was a problem (read: OUT OF MEMORY).
  */
-char **PHYSFS_getSearchPath(void);
+__EXPORT__ char **PHYSFS_getSearchPath(void);
 
 
 /**
@@ -521,8 +527,10 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_setSaneConfig(const char *appName, const char *archiveExt,
-                          int includeCdRoms, int archivesFirst);
+__EXPORT__ int PHYSFS_setSaneConfig(const char *appName,
+                                    const char *archiveExt,
+                                    int includeCdRoms,
+                                    int archivesFirst);
 
 
 /**
@@ -541,7 +549,7 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_mkdir(const char *dirName);
+__EXPORT__ int PHYSFS_mkdir(const char *dirName);
 
 
 /**
@@ -564,7 +572,7 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_delete(const char *filename);
+__EXPORT__ int PHYSFS_delete(const char *filename);
 
 
 /**
@@ -586,7 +594,7 @@
  *    @return READ ONLY string of element of search path containing the
  *             the file in question. NULL if not found.
  */
-const char *PHYSFS_getRealDir(const char *filename);
+__EXPORT__ const char *PHYSFS_getRealDir(const char *filename);
 
 
 
@@ -625,7 +633,7 @@
  *    @param dir directory in platform-independent notation to enumerate.
  *   @return Null-terminated array of null-terminated strings.
  */
-char **PHYSFS_enumerateFiles(const char *dir);
+__EXPORT__ char **PHYSFS_enumerateFiles(const char *dir);
 
 
 /**
@@ -639,7 +647,7 @@
  *    @param fname filename in platform-independent notation.
  *   @return non-zero if filename exists. zero otherwise.
  */
-int PHYSFS_exists(const char *fname);
+__EXPORT__ int PHYSFS_exists(const char *fname);
 
 
 /**
@@ -653,7 +661,7 @@
  *    @param fname filename in platform-independent notation.
  *   @return non-zero if filename exists and is a directory.  zero otherwise.
  */
-int PHYSFS_isDirectory(const char *fname);
+__EXPORT__ int PHYSFS_isDirectory(const char *fname);
 
 
 /**
@@ -667,7 +675,7 @@
  *    @param fname filename in platform-independent notation.
  *   @return non-zero if filename exists and is a symlink.  zero otherwise.
  */
-int PHYSFS_isSymbolicLink(const char *fname);
+__EXPORT__ int PHYSFS_isSymbolicLink(const char *fname);
 
 
 /**
@@ -684,7 +692,7 @@
  *  @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  *           of the error can be gleaned from PHYSFS_getLastError().
  */
-PHYSFS_file *PHYSFS_openWrite(const char *filename);
+__EXPORT__ PHYSFS_file *PHYSFS_openWrite(const char *filename);
 
 
 /**
@@ -702,7 +710,7 @@
  *  @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  *           of the error can be gleaned from PHYSFS_getLastError().
  */
-PHYSFS_file *PHYSFS_openAppend(const char *filename);
+__EXPORT__ PHYSFS_file *PHYSFS_openAppend(const char *filename);
 
 
 /**
@@ -719,7 +727,7 @@
  *  @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  *           of the error can be gleaned from PHYSFS_getLastError().
  */
-PHYSFS_file *PHYSFS_openRead(const char *filename);
+__EXPORT__ PHYSFS_file *PHYSFS_openRead(const char *filename);
 
 
 /**
@@ -734,7 +742,7 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_close(PHYSFS_file *handle);
+__EXPORT__ int PHYSFS_close(PHYSFS_file *handle);
 
 
 /**
@@ -748,8 +756,8 @@
  *           the reason this might be < (objCount), as can PHYSFS_eof().
  *            -1 if complete failure.
  */
-int PHYSFS_read(PHYSFS_file *handle, void *buffer,
-                unsigned int objSize, unsigned int objCount);
+__EXPORT__ int PHYSFS_read(PHYSFS_file *handle, void *buffer,
+                           unsigned int objSize, unsigned int objCount);
 
 
 /**
@@ -762,8 +770,8 @@
  *  @return number of objects written. PHYSFS_getLastError() can shed light on
  *           the reason this might be < (objCount). -1 if complete failure.
  */
-int PHYSFS_write(PHYSFS_file *handle, void *buffer,
-                 unsigned int objSize, unsigned int objCount);
+__EXPORT__ int PHYSFS_write(PHYSFS_file *handle, void *buffer,
+                            unsigned int objSize, unsigned int objCount);
 
 
 /**
@@ -772,7 +780,7 @@
  *   @param handle handle returned from PHYSFS_openRead().
  *  @return nonzero if EOF, zero if not.
  */
-int PHYSFS_eof(PHYSFS_file *handle);
+__EXPORT__ int PHYSFS_eof(PHYSFS_file *handle);
 
 
 /**
@@ -782,7 +790,7 @@
  *  @return offset in bytes from start of file. -1 if error occurred.
  *           Specifics of the error can be gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_tell(PHYSFS_file *handle);
+__EXPORT__ int PHYSFS_tell(PHYSFS_file *handle);
 
 
 /**
@@ -795,7 +803,7 @@
  *  @return nonzero on success, zero on error. Specifics of the error can be
  *          gleaned from PHYSFS_getLastError().
  */
-int PHYSFS_seek(PHYSFS_file *handle, int pos);
+__EXPORT__ int PHYSFS_seek(PHYSFS_file *handle, int pos);
 
 
 /**
@@ -809,7 +817,7 @@
  *   @param handle handle returned from PHYSFS_open*().
  *  @return size in bytes of the file. -1 if can't be determined.
  */
-int PHYSFS_fileLength(PHYSFS_file *handle);
+__EXPORT__ int PHYSFS_fileLength(PHYSFS_file *handle);
 
 #ifdef __cplusplus
 }
--- a/test/test_physfs.c	Thu Aug 23 17:09:20 2001 +0000
+++ b/test/test_physfs.c	Thu Aug 23 18:01:43 2001 +0000
@@ -572,10 +572,35 @@
 #if (defined HAVE_READLINE)
         buf = readline("> ");
 #else
+        int i;
         buf = malloc(512);
         memset(buf, '\0', 512);
-        scanf("%s", buf);
+        printf("> ");
+        for (i = 0; i < 511; i++)
+        {
+            int ch = fgetc(stdin);
+            if (ch == EOF)
+            {
+                strcpy(buf, "quit");
+                break;
+            } /* if */
+            else if ((ch == '\n') || (ch == '\r'))
+            {
+                buf[i] = '\0';
+                break;
+            } /* else if */
+            else if (ch == '\b')
+            {
+                if (i > 0)
+                    i--;
+            } /* else if */
+            else
+            {
+                buf[i] = (char) ch;
+            } /* else */
+        } /* for */
 #endif
+
         rc = process_command(buf);
         free(buf);
     } while (rc);