File: nbrf.c

package info (click to toggle)
squizz 0.99d%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,772 kB
  • sloc: sh: 4,799; ansic: 2,640; lex: 1,992; yacc: 1,650; makefile: 123
file content (67 lines) | stat: -rw-r--r-- 1,207 bytes parent folder | download | duplicates (5)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* nbrf.c - NBRF sequence functions */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>

#include "sequence.h"
#include "sequence/nbrf.h"


/* Functions prototypes */
extern sequence_t *nbrfy_parse(FILE *);
extern int nbrfy_check(FILE *);


/* Parse NBRF sequence */
sequence_t *nbrf_parse(FILE *f) {
  sequence_t *seq;

  seq = nbrfy_parse(f);

  return seq; }


/* Check NBRF sequence */
int nbrf_check(FILE *f) {
  int i;

  i = nbrfy_check(f);

  return i; }


/* Print NBRF sequence */
void nbrf_print(FILE *f, sequence_t *seq) {
  char *p;
  const char *q, *r;
  int max;
  long l;
  seqtyp_t t;

  if (seq == NULL) { return; }

  t = sequence_type(seq->str);

  /* Header */
  q = (t == SEQTYP_PRO) ? "P1" : "DL";
  r = (seq->nam != NULL) ? seq->nam : "unknown";
  (void)fprintf(f, ">%s;%s\n", q, r);
  if (seq->dsc) { (void)fprintf(f, "%s", seq->dsc); }
  (void)fputc('\n', f);

  /* Sequence */
  p = seq->str; max = 80;
  while (*p) {
    l = p - seq->str;
    if (l % max == 0 && l > 0) { (void)fputc('\n', f); }
    if (*p == '*' && *(p+1) == '\0') { break; }
    (void)fputc(*p, f);
    p++; }
  l = p - seq->str;
  (void)fputc('*', f);
  (void)fputc('\n', f);

  return; }