Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Annotation of /trunk/src/relations.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 561 - (hide annotations) (download) (as text)
Tue Dec 21 14:55:18 2010 UTC (14 years, 2 months ago) by amb
File MIME type: text/x-csrc
File size: 1988 byte(s)
Initial revision

1 amb 561 /***************************************
2     $Header: /home/amb/CVS/routino/src/relations.c,v 1.1 2010-12-21 14:54:56 amb Exp $
3    
4     Relation data type functions.
5    
6     Part of the Routino routing software.
7     ******************/ /******************
8     This file Copyright 2008-2010 Andrew M. Bishop
9    
10     This program is free software: you can redistribute it and/or modify
11     it under the terms of the GNU Affero General Public License as published by
12     the Free Software Foundation, either version 3 of the License, or
13     (at your option) any later version.
14    
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     GNU Affero General Public License for more details.
19    
20     You should have received a copy of the GNU Affero General Public License
21     along with this program. If not, see <http://www.gnu.org/licenses/>.
22     ***************************************/
23    
24    
25     #include <sys/types.h>
26     #include <stdlib.h>
27    
28     #include "relations.h"
29    
30     #include "files.h"
31    
32    
33     /*++++++++++++++++++++++++++++++++++++++
34     Load in a relation list from a file.
35    
36     Relations* LoadRelationList Returns the relation list.
37    
38     const char *filename The name of the file to load.
39     ++++++++++++++++++++++++++++++++++++++*/
40    
41     Relations *LoadRelationList(const char *filename)
42     {
43     Relations *relations;
44    
45     relations=(Relations*)malloc(sizeof(Relations));
46    
47     #if !SLIM
48    
49     relations->data=MapFile(filename);
50    
51     /* Copy the RelationsFile header structure from the loaded data */
52    
53     relations->file=*((RelationsFile*)relations->data);
54    
55     /* Set the pointers in the Relations structure. */
56    
57     relations->turnrelations=(TurnRelation*)(relations->data+sizeof(RelationsFile));
58    
59     #else
60    
61     relations->fd=ReOpenFile(filename);
62    
63     /* Copy the RelationsFile header structure from the loaded data */
64    
65     ReadFile(relations->fd,&relations->file,sizeof(RelationsFile));
66    
67     relations->troffset=sizeof(RelationsFile);
68    
69     #endif
70    
71     return(relations);
72     }