Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
getfield.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file getfield.c
5 
6  \version V1.2
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) Dr. Andrew C. R. Martin, University of Reading, 2002-14
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 30.05.02 Original
50 - V1.1 18.06.02 Added string.h
51 - V1.2 07.07.14 Use bl prefix for functions By: CTP
52 
53 *************************************************************************/
54 /* Doxygen
55  -------
56  #GROUP General Programming
57  #SUBGROUP String handling
58  #FUNCTION blGetfield()
59  Reads a column out of a buffer. If the specfied column extends beyond
60  the size of the buffer, then it will be padded with spaces.
61 */
62 /************************************************************************/
63 /* Includes
64 */
65 #include <string.h>
66 
67 /************************************************************************/
68 /* Defines and macros
69 */
70 
71 /************************************************************************/
72 /* Globals
73 */
74 
75 /************************************************************************/
76 /* Prototypes
77 */
78 
79 /************************************************************************/
80 /*>void blGetfield(char *buffer, int start, int width, char *str)
81  --------------------------------------------------------------
82 *//**
83 
84  \param[in] *buffer Buffer from which to read a field
85  \param[in] start Starting column (count from 0)
86  \param[in] width Width of field to read
87  \param[out] *str Field read from buffer
88 
89  Reads a column out of a buffer. If the specfied column extends beyond
90  the size of the buffer, then it will be padded with spaces.
91 
92  Note that the output string must be of at lease width+1 characters
93  to store the field read from the buffer plus the terminating
94  character.
95 
96 - 30.05.02 Original By: ACRM
97 - 07.07.14 Use bl prefix for functions By: CTP
98 */
99 void blGetfield(char *buffer, int start, int width, char *str)
100 {
101  int i,
102  j,
103  len;
104 
105  len = strlen(buffer);
106 
107  for(i=0, j=0; i<width; i++)
108  {
109  if(start+i >= len)
110  {
111  str[j++] = ' ';
112  }
113  else
114  {
115  str[j++] = buffer[start+i];
116  }
117  }
118  str[j] = '\0';
119 }
120 
121 
void blGetfield(char *buffer, int start, int width, char *str)
Definition: getfield.c:99