Imported Upstream version 1.5
[routino] / src / ways.c
index 3142415..f3c0d3c 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************
- $Header: /home/amb/routino/src/RCS/ways.c,v 1.44 2010/04/28 17:27:02 amb Exp $
+ $Header: /home/amb/routino/src/RCS/ways.c,v 1.46 2010/07/24 10:09:07 amb Exp $
 
  Way data type functions.
 
 
 #include <stdlib.h>
 
-#include "functions.h"
 #include "ways.h"
 
+#include "files.h"
+
 
 /*++++++++++++++++++++++++++++++++++++++
   Load in a way list from a file.
 
 Ways *LoadWayList(const char *filename)
 {
- void *data;
  Ways *ways;
 
  ways=(Ways*)malloc(sizeof(Ways));
 
- data=MapFile(filename);
+#if !SLIM
+
+ ways->data=MapFile(filename);
+
+ /* Copy the WaysFile structure from the loaded data */
+
+ ways->file=*((WaysFile*)ways->data);
+
+ /* Set the pointers in the Ways structure. */
+
+ ways->ways =(Way *)(ways->data+sizeof(WaysFile));
+ ways->names=(char*)(ways->data+sizeof(WaysFile)+ways->file.number*sizeof(Way));
+
+#else
+
+ ways->fd=ReOpenFile(filename);
+
+ /* Copy the WaysFile header structure from the loaded data */
 
- /* Copy the Ways structure from the loaded data */
+ ReadFile(ways->fd,&ways->file,sizeof(WaysFile));
 
- *ways=*((Ways*)data);
+ ways->namesoffset=sizeof(WaysFile)+ways->file.number*sizeof(Way);
 
- /* Adjust the pointers in the Ways structure. */
+ ways->nincache=~0;
+ ways->ncached=NULL;
 
- ways->data =data;
- ways->ways =(Way *)(data+sizeof(Ways));
- ways->names=(char*)(data+(sizeof(Ways)+ways->number*sizeof(Way)));
+#endif
 
  return(ways);
 }