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

« back to all changes in this revision

Viewing changes to headerline.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
                                headerline.c
 
6
 
 
7
Purpose:
 
8
        Check the input line;  if recognized  as mandatory record,  copy
 
9
        the line to HeaderS structure,  which is  member of  MolComplexS
 
10
        structure.  The trailing newline is removed (if present at all).
 
11
        The PDB header contains,  among others, a keyword called HEADER.
 
12
        Don't get confused with the usage of word "header"!
 
13
 
 
14
Input:
 
15
        (1) Pointer to HeaderS structure,  where line should be added if
 
16
            recognized as mandatory record.
 
17
        (2) Input line.
 
18
        (3) The first character in the line.
 
19
 
 
20
Output:
 
21
        (1) If line is mandatory, it will be added to HeaderS structure.
 
22
        (2) Return value.
 
23
 
 
24
Return value:
 
25
        (1) Positive if line added to HeaderS structure.
 
26
        (2) Zero if line does not contain mandatory record.
 
27
        (3) Negative  if line does  contain  mandatory record,  but  the
 
28
            maximal number of  records of this type is  reached already.
 
29
 
 
30
========includes:============================================================*/
 
31
 
 
32
#include <stdio.h>
 
33
#include <string.h>
 
34
#include <X11/Xlib.h>
 
35
#include <X11/Xutil.h>
 
36
#include <X11/Xos.h>
 
37
#include <X11/Xatom.h>
 
38
 
 
39
#include "defines.h"
 
40
#include "typedefs.h"
 
41
 
 
42
/*======check line, copy it if contains mandatory record:====================*/
 
43
 
 
44
int CopyHeaderLine_ (HeaderS *hSP, char *lineP, int first_char)
 
45
{
 
46
char            *P;
 
47
 
 
48
P = hSP->dataP;
 
49
 
 
50
/* Check is there a mandatory record in input line: */
 
51
switch (first_char)
 
52
        {
 
53
        case 'H':
 
54
                if (strstr (lineP, "HEADER") != lineP) return 0;
 
55
                if (hSP->header_linesN >= MAXHEADERLINES) return -1;
 
56
                hSP->header_linesN++;
 
57
                P += hSP->header_offset + hSP->header_linesN * HEADERLINESIZE;
 
58
                break;
 
59
        case 'T':
 
60
                if (strstr (lineP, "TITLE")  != lineP) return 0;
 
61
                if (hSP->title_linesN  >= MAXTITLELINES)  return -2;
 
62
                hSP->title_linesN++;
 
63
                P += hSP->title_offset  + hSP->title_linesN  * HEADERLINESIZE; 
 
64
                break;
 
65
        case 'C':
 
66
                if (strstr (lineP, "COMPND") != lineP) return 0;
 
67
                if (hSP->compnd_linesN >= MAXCOMPNDLINES) return -3;
 
68
                hSP->compnd_linesN++;
 
69
                P += hSP->compnd_offset + hSP->compnd_linesN * HEADERLINESIZE;
 
70
                break;
 
71
        case 'S':
 
72
                if (strstr (lineP, "SOURCE") != lineP) return 0;
 
73
                if (hSP->source_linesN >= MAXSOURCELINES) return -4;
 
74
                hSP->source_linesN++;
 
75
                P += hSP->source_offset + hSP->source_linesN * HEADERLINESIZE;
 
76
                break;
 
77
        case 'E':
 
78
                if (strstr (lineP, "EXPDTA") != lineP) return 0;
 
79
                if (hSP->expdta_linesN >= MAXEXPDTALINES) return -5;
 
80
                hSP->expdta_linesN++;
 
81
                P += hSP->expdta_offset + hSP->expdta_linesN * HEADERLINESIZE;
 
82
                break;
 
83
        case 'A':
 
84
                if (strstr (lineP, "AUTHOR") != lineP) return 0;
 
85
                if (hSP->author_linesN >= MAXAUTHORLINES) return -6;
 
86
                hSP->author_linesN++;
 
87
                P += hSP->author_offset + hSP->author_linesN * HEADERLINESIZE;
 
88
                break;
 
89
        default:
 
90
                return 0;
 
91
        }
 
92
 
 
93
/* If this point is reached, line contains mandatory record - copy it: */
 
94
strncpy (P, lineP, HEADERLINESIZE - 1);
 
95
*(P + HEADERLINESIZE - 1) = '\0';
 
96
 
 
97
return 1;
 
98
}
 
99
 
 
100
/*===========================================================================*/
 
101
 
 
102