~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to read_file.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                read_file.c
 
6
 
 
7
Purpose:
 
8
        Try to recognize input  file format;  read file  if recognized.  In
 
9
        fact, this function does almost nothing:  file format is recognized
 
10
        by RecogFileFormat_ and ReadPDBFile_ reads PDB file.
 
11
 
 
12
Input:
 
13
        (1) Pointer to MolComplexS structure (macromolecular complexes). It
 
14
            should point to the first free MolComplexS structure.
 
15
        (2) Input file name (pointer).
 
16
        (3) Pointer to ConfigS structure, with configuration data.
 
17
 
 
18
Output:
 
19
        (1) If PDB file is recognized, a function which read atomic data
 
20
            is called.
 
21
        (2) Return value.
 
22
 
 
23
Return value:
 
24
        (1) Positive on success.
 
25
        (2) Zero if there is nothing to read (strlen (file_nameP) is zero).
 
26
        (3) Negative on failure.
 
27
 
 
28
========includes:============================================================*/
 
29
 
 
30
#include <stdio.h>
 
31
#include <X11/Xlib.h>
 
32
#include <X11/Xutil.h>
 
33
#include <X11/Xos.h>
 
34
#include <X11/Xatom.h>
 
35
 
 
36
#include "defines.h"
 
37
#include "typedefs.h"
 
38
 
 
39
/*======function prototypes:=================================================*/
 
40
 
 
41
int             RecogFileFormat_ (char *);
 
42
int             ReadPDBFile_ (MolComplexS *, char *, ConfigS *);
 
43
void            ErrorMessage_ (char *, char *, char *,
 
44
                               char *, char *, char *, char *);
 
45
 
 
46
/*======recognize file format, read file:====================================*/
 
47
 
 
48
int ReadFile_ (MolComplexS *mol_complexSP, char *file_nameP, ConfigS *configSP)
 
49
{
 
50
int             file_format;
 
51
 
 
52
/* Is file name specified at all? */
 
53
if (strlen (file_nameP) == 0) return 0;
 
54
 
 
55
/* Try to recognize file format: */
 
56
file_format = RecogFileFormat_ (file_nameP);
 
57
if (file_format < 0) return -1;
 
58
 
 
59
/* Read file (switch could be used here, but I don't like it): */
 
60
if (file_format == PDB_FORMAT)
 
61
        {
 
62
        if (ReadPDBFile_ (mol_complexSP, file_nameP, configSP) < 0) return -2;
 
63
        else return 1;
 
64
        }
 
65
 
 
66
/* If this point is reached, format is recognized, but file is not read: */
 
67
ErrorMessage_ ("garlic", "ReadFile_", file_nameP,
 
68
        "Unable to read file - file format not supported!\n", "", "", "");
 
69
return -3;
 
70
}
 
71
 
 
72
/*===========================================================================*/
 
73
 
 
74