changeset 1906:a6fd2dd5cc77

Minor changes for Windows build
author bert <bert>
date Fri, 03 Dec 2004 21:52:35 +0000
parents cb74a4aac69c
children 054f27610998
files libsrc/config.h.msvc-win32 libsrc/hdf_convenience.c libsrc/minc.h libsrc/minc_compat.c libsrc/minc_compat.h libsrc/minc_convenience.c libsrc/minc_error.h libsrc/netcdf_convenience.c libsrc2/convert.c libsrc2/dimension.c libsrc2/grpattr.c libsrc2/hyper.c libsrc2/label.c libsrc2/m2util.c libsrc2/valid.c libsrc2/volume.c progs/rawtominc/rawtominc.c
diffstat 17 files changed, 176 insertions(+), 140 deletions(-) [+]
line wrap: on
line diff
--- a/libsrc/config.h.msvc-win32
+++ b/libsrc/config.h.msvc-win32
@@ -2,22 +2,30 @@
  *
  * Author: Bert Vincent
  *
- * $Header: /private-cvsroot/minc/libsrc/config.h.msvc-win32,v 6.1 2004-11-01 22:21:42 bert Exp $
+ * $Header: /private-cvsroot/minc/libsrc/config.h.msvc-win32,v 6.2 2004-12-03 21:52:35 bert Exp $
  */
 
+#ifndef _CONFIG_H_
+#define _CONFIG_H_ 1
+
 #define HAVE_FCNTL_H 1
 #define HAVE_FLOAT_H 1
 #define HAVE_MEMORY_H 1
 #define HAVE_STDINT_H 1
 #define HAVE_STDLIB_H 1
-#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
 #define HAVE_SYS_STAT_H 1
 #define HAVE_SYS_TYPES_H 1
 #define HAVE_TEMPNAM 1
 #define HAVE_TMPNAM 1
 #define STDC_HEADERS 1
-#define VERSION "1.4"
+#define VERSION "2.0.08"
 #define sleep(x) _sleep(x)
+#define snprintf _snprintf
+#define strncasecmp(x,y,z) strnicmp(x,y,z)
+#define tempnam(x,y) _tempnam(x,y)
+
+int __stdcall gethostname(char *name, int namelen);
 
 /* Quick implmentation of rint() for Intel, since thoughtless Microsoft
  * programmers failed to provide us with one...
@@ -29,3 +37,5 @@
   __asm fst dblvar
   return dblvar;
 }
+
+#endif /* _CONFIG_H_ not defined */
--- a/libsrc/hdf_convenience.c
+++ b/libsrc/hdf_convenience.c
@@ -1,7 +1,6 @@
 #ifdef MINC2                    /* Ignore this file if not MINC2 */
 
 /* #define NC_FILL_INT 1 */
-#include "minc.h"
 #include "minc_private.h"
 #include "hdf_convenience.h"
 
@@ -2133,6 +2132,7 @@
     struct m2_var *var;
 
     H5E_BEGIN_TRY {
+#ifdef HDF5_MMAP_TEST
         if (mode & 0x8000) {
             hid_t prp_id;
 
@@ -2144,6 +2144,9 @@
         else {
             fd = H5Fopen(path, mode, H5P_DEFAULT);
         }
+#else
+        fd = H5Fopen(path, mode, H5P_DEFAULT);
+#endif
     } H5E_END_TRY;
 
     if (fd < 0) {
--- a/libsrc/minc.h
+++ b/libsrc/minc.h
@@ -19,7 +19,10 @@
 @CREATED    : July 24, 1992. (Peter Neelin, Montreal Neurological Institute)
 @MODIFIED   : 
  * $Log: minc.h,v $
- * Revision 6.15  2004-10-15 13:48:13  bert
+ * Revision 6.16  2004-12-03 21:52:35  bert
+ * Minor changes for Windows build
+ *
+ * Revision 6.15  2004/10/15 13:48:13  bert
  * Minor changes for Windows compatibility
  *
  * Revision 6.14  2004/08/11 20:50:54  bert
@@ -131,16 +134,11 @@
               make no representations about the suitability of this
               software for any purpose.  It is provided "as is" without
               express or implied warranty.
-@RCSID      : $Header: /private-cvsroot/minc/libsrc/minc.h,v 6.15 2004-10-15 13:48:13 bert Exp $ MINC (MNI)
+@RCSID      : $Header: /private-cvsroot/minc/libsrc/minc.h,v 6.16 2004-12-03 21:52:35 bert Exp $ MINC (MNI)
 ---------------------------------------------------------------------------- */
 
 #include <netcdf.h>
 
-#ifdef MINC2
-#include <hdf5.h>
-#include "minc_compat.h"
-#endif /* MINC2 defined */
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -580,6 +578,9 @@
     int chunk_param;
 };
 
+#include <hdf5.h>
+#include "minc_compat.h"
+
 #define MI2_ISH5OBJ(x) (H5Iget_type(x) > 0)
 
 #endif /* MINC2 defined */
--- a/libsrc/minc_compat.c
+++ b/libsrc/minc_compat.c
@@ -9,13 +9,11 @@
  * of whether this is an HDF5 handle or a NetCDF file descriptor.
  */
 #define _MI2_FORCE_NETCDF_
-#include "netcdf.h"
-#include "minc.h"
 #include "minc_private.h"
 #include "hdf_convenience.h"
 
 /* */
-int
+MNCAPI int
 MI2varname(int fd, int varid, char *varnm)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -27,7 +25,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2varid(int fd, const char *varnm)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -39,7 +37,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2attinq(int fd, int varid, const char *attnm, nc_type *type_ptr,
           int *length_ptr)
 {
@@ -63,7 +61,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2attname(int fd, int varid, int attid, char *name)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -75,7 +73,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2inquire(int fd, int *ndims_ptr, int *nvars_ptr, int *natts_ptr,
            int *unlimdim_ptr)
 {
@@ -88,7 +86,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2varinq(int fd, int varid, char *varnm_ptr, nc_type *type_ptr,
           int *ndims_ptr, int *dims_ptr, int *natts_ptr)
 {
@@ -103,7 +101,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2dimid(int fd, const char *dimnm)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -115,7 +113,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2diminq(int fd, int dimid, char *dimnm_ptr, long *len_ptr)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -127,7 +125,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2dimdef(int fd, const char *dimnm, long length)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -139,7 +137,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2attget(int fd, int varid, const char *attnm, void *value)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -151,7 +149,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2attput(int fd, int varid, const char *attnm, nc_type val_typ, 
           int val_len, void *val_ptr)
 {
@@ -169,7 +167,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2endef(int fd)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -181,7 +179,7 @@
 }  
 
 /* */
-int
+MNCAPI int
 MI2vardef(int fd, const char *varnm, nc_type vartype, int ndims,
           const int *dimids)
 {
@@ -194,7 +192,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2varget(int fd, int varid, const long *start_ptr, 
           const long *count_ptr, void *val_ptr)
 {
@@ -207,7 +205,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2varput(int fd, int varid, const long *start_ptr,
           const long *count_ptr, const void *val_ptr)
 {
@@ -220,7 +218,7 @@
 }
 
 /* */
-int
+MNCAPI int
 MI2varput1(int fd, int varid, const long *mindex_ptr,
            const void *val_ptr)
 {
@@ -232,7 +230,8 @@
     }
 }
 
-int MI2attdel(int fd, int varid, const char *attnm)
+MNCAPI int
+MI2attdel(int fd, int varid, const char *attnm)
 {
     if (MI2_ISH5OBJ(fd)) {
         return (hdf_attdel(fd, varid, attnm));
@@ -244,7 +243,7 @@
 
 
 /* */
-int
+MNCAPI int
 MI2dimrename(int fd, int dimid, const char *new_name)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -255,7 +254,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2varputg(int fd, int varid, const long *startp, const long *countp,
            const long *stridep, const long *imapp, const void *valp)
 {
@@ -267,7 +266,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2attcopy(int infd, int invarid, const char *name, int outfd, 
            int outvarid)
 {
@@ -319,7 +318,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2typelen(int type_id)
 {
     switch (type_id) {
@@ -340,7 +339,7 @@
     return (-1);
 }
 
-int
+MNCAPI int
 MI2redef(int fd)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -352,7 +351,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2sync(int fd)
 {
     if (MI2_ISH5OBJ(fd)) {
@@ -369,7 +368,7 @@
     }
 }
 
-int
+MNCAPI int
 MI2setfill(int fd, int fillmode)
 {
     if (MI2_ISH5OBJ(fd)) {
--- a/libsrc/minc_compat.h
+++ b/libsrc/minc_compat.h
@@ -1,61 +1,61 @@
 /* Functions for enabling/disabling error messages from the library.
  */
-extern int MI2typelen(int);
+MNCAPI int MI2typelen(int);
 
-extern int MI2varname(int fd, int varid, char *varnm);
+MNCAPI int MI2varname(int fd, int varid, char *varnm);
 
-extern int MI2varid(int fd, const char *varnm);
+MNCAPI int MI2varid(int fd, const char *varnm);
 
-extern int MI2attinq(int fd, int varid, const char *attnm, nc_type *type_ptr,
+MNCAPI int MI2attinq(int fd, int varid, const char *attnm, nc_type *type_ptr,
 		     int *length_ptr);
 
-extern int MI2attname(int fd, int varid, int attid, char *name);
+MNCAPI int MI2attname(int fd, int varid, int attid, char *name);
 
-extern int MI2inquire(int fd, int *ndims_ptr, int *nvars_ptr, int *natts_ptr,
+MNCAPI int MI2inquire(int fd, int *ndims_ptr, int *nvars_ptr, int *natts_ptr,
 		      int *unlimdim_ptr);
 
-extern int MI2varinq(int fd, int varid, char *varnm_ptr, nc_type *type_ptr,
+MNCAPI int MI2varinq(int fd, int varid, char *varnm_ptr, nc_type *type_ptr,
 		     int *ndims_ptr, int *dims_ptr, int *natts_ptr);
 
-extern int MI2dimid(int fd, const char *dimnm);
+MNCAPI int MI2dimid(int fd, const char *dimnm);
 
-extern int MI2diminq(int fd, int dimid, char *dimnm_ptr, long *len_ptr);
+MNCAPI int MI2diminq(int fd, int dimid, char *dimnm_ptr, long *len_ptr);
 
-extern int MI2dimdef(int fd, const char *dimnm, long length);
+MNCAPI int MI2dimdef(int fd, const char *dimnm, long length);
 
-extern int MI2attget(int fd, int varid, const char *attnm, void *value);
+MNCAPI int MI2attget(int fd, int varid, const char *attnm, void *value);
 
-extern int MI2attput(int fd, int varid, const char *attnm, nc_type val_typ, 
+MNCAPI int MI2attput(int fd, int varid, const char *attnm, nc_type val_typ, 
 		     int val_len, void *val_ptr);
 
-extern int MI2endef(int fd);
+MNCAPI int MI2endef(int fd);
 
-extern int MI2vardef(int fd, const char *varnm, nc_type vartype, int ndims,
+MNCAPI int MI2vardef(int fd, const char *varnm, nc_type vartype, int ndims,
 		     const int *dimids);
 
-extern int MI2varget(int fd, int varid, const long *start_ptr, 
+MNCAPI int MI2varget(int fd, int varid, const long *start_ptr, 
 		     const long *count_ptr, void *val_ptr);
 
-extern int MI2varput(int fd, int varid, const long *start_ptr,
+MNCAPI int MI2varput(int fd, int varid, const long *start_ptr,
 		     const long *count_ptr, const void *val_ptr);
 
-extern int MI2varput1(int fd, int varid, const long *mindex_ptr,
+MNCAPI int MI2varput1(int fd, int varid, const long *mindex_ptr,
 		      const void *val_ptr);
 
-extern int MI2attdel(int fd, int varid, const char *attnm);
+MNCAPI int MI2attdel(int fd, int varid, const char *attnm);
 
-extern int MI2dimrename(int fd, int dimid, const char *new_name);
+MNCAPI int MI2dimrename(int fd, int dimid, const char *new_name);
 
-extern int MI2varputg(int fd, int varid, const long *startp, 
+MNCAPI int MI2varputg(int fd, int varid, const long *startp, 
 		      const long *countp, const long *stridep, 
 		      const long *imapp, const void *valp);
 
-extern int MI2attcopy(int infd, int invarid, const char *name, int outfd, 
+MNCAPI int MI2attcopy(int infd, int invarid, const char *name, int outfd, 
 		      int outvarid);
 
-extern int MI2redef(int fd);
-extern int MI2sync(int fd);
-extern int MI2setfill(int fd, int fillmode);
+MNCAPI int MI2redef(int fd);
+MNCAPI int MI2sync(int fd);
+MNCAPI int MI2setfill(int fd, int fillmode);
 
 #ifndef _MI2_FORCE_NETCDF_
 #define nctypelen MI2typelen
--- a/libsrc/minc_convenience.c
+++ b/libsrc/minc_convenience.c
@@ -30,7 +30,10 @@
 @CREATED    : July 27, 1992. (Peter Neelin, Montreal Neurological Institute)
 @MODIFIED   : 
  * $Log: minc_convenience.c,v $
- * Revision 6.16  2004-10-15 13:46:15  bert
+ * Revision 6.17  2004-12-03 21:52:35  bert
+ * Minor changes for Windows build
+ *
+ * Revision 6.16  2004/10/15 13:46:15  bert
  * Minor changes for Windows compatibility
  *
  * Revision 6.15  2004/08/26 16:14:21  bert
@@ -131,7 +134,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/minc_convenience.c,v 6.16 2004-10-15 13:46:15 bert Exp $ MINC (MNI)";
+static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/minc_convenience.c,v 6.17 2004-12-03 21:52:35 bert Exp $ MINC (MNI)";
 #endif
 
 #include "minc_private.h"
@@ -1477,7 +1480,11 @@
 
 
     time(&now);
+#ifdef _MSC_VER
+    memcpy(&tm_buf, localtime(&now), sizeof(tm_buf));
+#else
     localtime_r(&now, &tm_buf);
+#endif
     strftime(time_str, sizeof(time_str), "%Y.%m.%d.%H.%M.%S", &tm_buf);
 
     result = snprintf(id_str, length, "%s%c%s%c%s%c%u%c%u", 
--- a/libsrc/minc_error.h
+++ b/libsrc/minc_error.h
@@ -7,7 +7,10 @@
 @MODIFIED   : 
  *
  * $Log: minc_error.h,v $
- * Revision 6.2  2004-10-15 13:46:15  bert
+ * Revision 6.3  2004-12-03 21:52:35  bert
+ * Minor changes for Windows build
+ *
+ * Revision 6.2  2004/10/15 13:46:15  bert
  * Minor changes for Windows compatibility
  *
  * Revision 6.1  2004/04/27 15:42:47  bert
@@ -93,5 +96,5 @@
     MI_MSG_BADOP
 } mimsgcode_t;
 
-SEMIPRIVATE int milog_message(mimsgcode_t code, ...);
+MNCAPI int milog_message(mimsgcode_t code, ...);
 #endif /* _MINC_ERROR_H_ not defined */
--- a/libsrc/netcdf_convenience.c
+++ b/libsrc/netcdf_convenience.c
@@ -39,7 +39,10 @@
 @CREATED    : July 27, 1992. (Peter Neelin, Montreal Neurological Institute)
 @MODIFIED   : 
  * $Log: netcdf_convenience.c,v $
- * Revision 6.14  2004-10-15 13:48:33  bert
+ * Revision 6.15  2004-12-03 21:52:35  bert
+ * Minor changes for Windows build
+ *
+ * Revision 6.14  2004/10/15 13:48:33  bert
  * Minor changes for Windows compatibility
  *
  * Revision 6.13  2004/06/04 18:16:25  bert
@@ -157,7 +160,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/netcdf_convenience.c,v 6.14 2004-10-15 13:48:33 bert Exp $ MINC (MNI)";
+static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/netcdf_convenience.c,v 6.15 2004-12-03 21:52:35 bert Exp $ MINC (MNI)";
 #endif
 
 #include "config.h"             /* From configure */
@@ -186,6 +189,8 @@
 #include <fcntl.h>
 #endif
 
+#include <stdio.h>		/* for tempnam() */
+
 /* Private functions */
 PRIVATE int execute_decompress_command(char *command, char *infile, 
                                        char *outfile, int header_only);
@@ -584,6 +589,9 @@
    else {
      hmode = H5F_ACC_RDONLY;
    }
+
+   hmode = (mode & 0x8000);     /* !!!! Pass along magic memory-mapping bit */
+
    status = hdf_open(path, hmode);
 
    /* If there is no error then return */
@@ -1963,9 +1971,13 @@
     char *home_ptr = getenv("HOME");
     char path[256];
 
-    strcpy(path, home_ptr);
+    if (home_ptr != NULL) {
+      strcpy(path, home_ptr);
+    }
+    else {
+      path[0] = '\0';
+    }
     strcat(path, "/.mincrc");
-      
     
     if ((fp = fopen(path, "r")) != NULL) {
         while (fgets(buffer, maxlen, fp)) {
--- a/libsrc2/convert.c
+++ b/libsrc2/convert.c
@@ -9,12 +9,10 @@
 /**
  * \defgroup mi2Cvt MINC 2.0 Coordinate and Voxel Conversion Functions
  */
-
 #include <stdlib.h>
 #include <hdf5.h>
 #include <math.h>
 #include <float.h>
-#include "minc.h"
 #include "minc2.h"
 #include "minc2_private.h"
 
--- a/libsrc2/dimension.c
+++ b/libsrc2/dimension.c
@@ -9,7 +9,6 @@
 #include <hdf5.h>
 #include "minc2.h"
 #include "minc2_private.h"
-#include "minc.h"
 
 
 /*! 
@@ -370,8 +369,8 @@
      to search the dimensions otherwise use dim_handles
    */
   
-  
   for (i=0; i < max_dims; i++) {
+      midimhandle_t hdim;
       if (order == MI_DIMORDER_APPARENT) {
 	  hdim = volume->dim_handles[volume->dim_indices[i]];
       }
--- a/libsrc2/grpattr.c
+++ b/libsrc2/grpattr.c
@@ -75,70 +75,69 @@
 static int
 milist_recursion(milisthandle_t handle, char *path)
 {
-  struct milistdata *data = (struct milistdata *) handle;
+    struct milistdata *data = (struct milistdata *) handle;
+    herr_t r;
+    int i=0;
+    struct milistframe *frame;
   
+    for(;;){
 
-  herr_t r;
-  int i=0;
-  
-  for(;;){
-    
-    struct milistframe *frame;
-    H5E_BEGIN_TRY {
+        H5E_BEGIN_TRY {
     
-      r = H5Gget_objtype_by_idx(data->frame_ptr->grp_id,
-				data->frame_ptr->grp_idx);
-    } H5E_END_TRY;
+            r = H5Gget_objtype_by_idx(data->frame_ptr->grp_id,
+                                      data->frame_ptr->grp_idx);
+        } H5E_END_TRY;
+ 
+        if (r < 0) {
+
+            /* End of this group, need to pop the frame. */
+            frame = data->frame_ptr->next;
+            H5Gclose(data->frame_ptr->grp_id);
+            free(data->frame_ptr);
+            data->frame_ptr = frame;
+            if (frame == NULL) {
+                return (MI_ERROR);
+            }
+        }
+        else {
     
-    if (r < 0) {
-      
-      /* End of this group, need to pop the frame. */
-      frame = data->frame_ptr->next;
-      H5Gclose(data->frame_ptr->grp_id);
-      free(data->frame_ptr);
-      data->frame_ptr = frame;
-      if (frame == NULL) {
-	return (MI_ERROR);
-      }
-    }
-    else {
+            data->frame_ptr->grp_idx++;
+            /* If the object is a group, we need to recurse into it.
+             */
+            if (r == H5G_GROUP) {
+                char tmp[256];
+                int l;
+          
+                H5Gget_objname_by_idx(data->frame_ptr->grp_id,
+                                      data->frame_ptr->grp_idx - 1,
+                                      tmp, sizeof(tmp));
+                frame = malloc(sizeof(struct milistframe));
+                if (frame == NULL) {
+                    return (MI_ERROR);
+                }
       
-      data->frame_ptr->grp_idx++;
-      /* If the object is a group, we need to recurse into it.
-       */
-      if (r == H5G_GROUP) {
-	char tmp[256];
-	int l;
+                frame->grp_idx = 0;
+                frame->att_idx = 0;
+                frame->grp_id = H5Gopen(data->frame_ptr->grp_id, tmp);
+			
+                strcpy(frame->relpath, data->frame_ptr->relpath);
+                l = strlen(frame->relpath);
+                            
+                if (l > 0 && frame->relpath[l - 1] != '/') {
+                    strcat(frame->relpath, "/");
+                }
+                strcat(frame->relpath, tmp);
 
-	H5Gget_objname_by_idx(data->frame_ptr->grp_id,
-			      data->frame_ptr->grp_idx - 1,
-			      tmp, sizeof(tmp));
-	frame = malloc(sizeof(struct milistframe));
-	if (frame == NULL) {
-	  return (MI_ERROR);
-	}
-      
-	frame->grp_idx = 0;
-	frame->att_idx = 0;
-	frame->grp_id = H5Gopen(data->frame_ptr->grp_id, tmp);
-	
-	strcpy(frame->relpath, data->frame_ptr->relpath);
-	l = strlen(frame->relpath);
-                            
-	if (l > 0 && frame->relpath[l - 1] != '/') {
-	  strcat(frame->relpath, "/");
-	}
-	strcat(frame->relpath, tmp);
-	
-	/* Start working on the next frame.
-	 */
-	frame->next = data->frame_ptr;
-	data->frame_ptr = frame;
-	strncpy(path, data->frame_ptr->relpath, MILIST_MAX_PATH);
-	break;  /* Out of inner for(;;) */
-      }
-    }       
-  }  
+                /* Start working on the next frame.
+                 */
+                frame->next = data->frame_ptr;
+                data->frame_ptr = frame;
+                strncpy(path, data->frame_ptr->relpath, MILIST_MAX_PATH);
+                break;  /* Out of inner for(;;) */
+            }
+        }       
+    }  
+    return (MI_NOERROR);
 }
 
 
--- a/libsrc2/hyper.c
+++ b/libsrc2/hyper.c
@@ -6,7 +6,6 @@
  ************************************************************************/
 #include <stdlib.h>
 #include <hdf5.h>
-#include "minc.h"
 #include "minc2.h"
 #include "minc2_private.h"
 
--- a/libsrc2/label.c
+++ b/libsrc2/label.c
@@ -20,7 +20,7 @@
 
 int miswap2(unsigned short tmp)
 {
-    unsigned char *x = &tmp;
+    unsigned char *x = (unsigned char *) &tmp;
     unsigned char t = x[0];
     x[0] = x[1];
     x[1] = t;
@@ -29,7 +29,7 @@
 
 int miswap4(unsigned int tmp)
 {
-    unsigned char *x = &tmp;
+    unsigned char *x = (unsigned char *) &tmp;
     unsigned char t = x[0];
     x[0] = x[3];
     x[3] = t;
--- a/libsrc2/m2util.c
+++ b/libsrc2/m2util.c
@@ -6,7 +6,6 @@
 #include <stdlib.h>
 #include <math.h>
 #include <hdf5.h>
-#include <minc.h>
 #include <limits.h>
 #include <float.h>
 #include "minc2.h"
@@ -1644,7 +1643,7 @@
     if (H5Gget_num_objs(grp_id, &n) < 0) {
         return (MI_ERROR);      /* Error getting object count. */
     }
-
+    grp_no = -1;
     for (i = 0; i < n; i++) {
         if (H5Gget_objname_by_idx(grp_id, i, name, MI2_MAX_PATH) < 0) {
             return (MI_ERROR);
@@ -1798,7 +1797,7 @@
     double **a, **solution;
     int success;
 
-    row = alloc1d( n );
+    row = (int *) alloc1d( n ); /* Ugly and wasteful but OK for 1D array */
     a = alloc2d( n, n );
     solution = alloc2d( n, n_values );
 
--- a/libsrc2/valid.c
+++ b/libsrc2/valid.c
@@ -11,7 +11,6 @@
  ************************************************************************/
 #include <stdlib.h>
 #include <hdf5.h>
-#include "minc.h"               /* For MINC 1 routines we use */
 #include "minc2.h"
 #include "minc2_private.h"
 
--- a/libsrc2/volume.c
+++ b/libsrc2/volume.c
@@ -189,6 +189,7 @@
             }
         }
     }
+    return (MI_NOERROR);
 }
 
 /** Create and initialize a MINC 2.0 volume structure.
--- a/progs/rawtominc/rawtominc.c
+++ b/progs/rawtominc/rawtominc.c
@@ -11,7 +11,10 @@
 @CREATED    : September 25, 1992 (Peter Neelin)
 @MODIFIED   : 
  * $Log: rawtominc.c,v $
- * Revision 6.15  2004-11-01 22:38:39  bert
+ * Revision 6.16  2004-12-03 21:54:27  bert
+ * Minor changes for Windows build
+ *
+ * Revision 6.15  2004/11/01 22:38:39  bert
  * Eliminate all references to minc_def.h
  *
  * Revision 6.14  2004/04/27 15:26:34  bert
@@ -146,7 +149,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/progs/rawtominc/rawtominc.c,v 6.15 2004-11-01 22:38:39 bert Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/progs/rawtominc/rawtominc.c,v 6.16 2004-12-03 21:54:27 bert Exp $";
 #endif
 
 #include "config.h"
@@ -155,9 +158,13 @@
 #include <string.h>
 #include <ctype.h>
 #include <minc.h>
+#if HAVE_FLOAT_H
 #include <float.h>
+#endif /* HAVE_FLOAT_H */
 #include <math.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include <ParseArgv.h>
 #include <time_stamp.h>
 #include <convert_origin_to_start.h>