File: extract_field.c

package info (click to toggle)
garlic 1.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,492 kB
  • ctags: 1,013
  • sloc: ansic: 29,925; makefile: 753
file content (46 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				extract_field.c

Purpose:
	Extract field (substring) from ATOM or HETATM line (string).
	Arguments are not checked: it should be done in caller!

Input:
	(1) Output string pointer.
	(2) Position of the first character.
	(3) Position of the last character.
	(4) Input string pointer.

Output:
	(1) Substring stored at location pointed at by output string pointer.
	(2) Return value.

Return value:
	(1) Output substring length.

========includes:============================================================*/

#include <stdio.h>
#include <string.h>

/*======extract field (substring):===========================================*/

int ExtractField_ (char *substringP, int start, int end, char *stringP)
{
int		i;

/* Copy (end - start + 1) characters: */
for (i = start; i <= end; i++) *(substringP + i - start) = *(stringP + i);

/* Terminate the substring: */
*(substringP + i - start) = '\0';

return strlen (substringP);
}

/*===========================================================================*/