File: frecord.c

package info (click to toggle)
calculix-ccx 2.11-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 10,188 kB
  • sloc: fortran: 115,312; ansic: 34,480; sh: 374; makefile: 35; perl: 15
file content (48 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download | duplicates (4)
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

#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <pthread.h>
#include "CalculiX.h"
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */



#include "readfrd.h"


/* liest einen Record bis '\n'; uebergibt Anzahl gelesene Zeichen */
int frecord( FILE *handle1,  char *string)
{
  register int i, n, c;

  for (i=0; i<MAX_LINE_LENGTH-1; i++)
  {
    string[i] = getc(handle1);
    if (string[i] == '\n')
      {
      for (n=i+1; n<MAX_LINE_LENGTH; ++n) string[n] = '\0';
      return(i);
      }
    if (string[i] == '\r')
      {
      c = getc(handle1);
      if (c != '\n')
        ungetc(c, handle1);

      for (n=i+1; n<MAX_LINE_LENGTH; ++n) string[n] = '\0';
      return(i);
     }
    else if (string[i] == (char)EOF)
      {
      for (n=i+1; n<MAX_LINE_LENGTH; ++n) string[n] = '\0';
      return(i);
      }
  }
  string[MAX_LINE_LENGTH-1] = '\0';
  return(MAX_LINE_LENGTH-1);
}