Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

ctox.c

Go to the documentation of this file.
00001 
00002 /*
00003  * Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993,
00004  * by Steve McMillan, Drexel University, Philadelphia, PA.
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms are permitted
00009  * provided that the above copyright notice and this paragraph are
00010  * duplicated in all such forms and that any documentation,
00011  * advertising materials, and other materials related to such
00012  * distribution and use acknowledge that the software was developed
00013  * by the author named above.
00014  *
00015  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00016  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00017  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018  */
00019 
00020 #include <stdio.h>
00021 #include <sys/file.h>
00022 
00023 ctox(file, x, n, nmax, lf)
00024 char *file;
00025 float *x;
00026 int *n, *nmax;
00027 long int lf;                    /* SUN FORTRAN convention! */
00028 {
00029     int i;
00030     FILE *fpin, *fopen();       /* file pointer and function declaration */
00031     char *name, *malloc();
00032     unsigned char c;
00033 
00034     *n = 0;
00035 
00036     if ( (name = malloc(lf+1)) == NULL) return;
00037 
00038     for (i = 0; i < lf; i++) name[i] = file[i];
00039     name[lf] = '\0';
00040 
00041     if ( (fpin = fopen(name, "r")) == NULL) return;
00042 
00043     /* Discard the first 8 characters. */
00044 
00045     if ((int)fread(x, sizeof(unsigned char), 8, fpin) < 8) return;
00046 
00047     /* Read up to nmax characters from the file. */
00048 
00049     while (fread(&c, sizeof(unsigned char), 1, fpin) == 1 && *n < *nmax )
00050         x[(*n)++] = (float) c;
00051 
00052     fclose(fpin);
00053 }
00054 
00055 ctox_(file, x, n, nmax, lf)
00056 char *file;
00057 float *x;
00058 int *n, *nmax;
00059 long int lf;                    /* SUN FORTRAN convention! */
00060 {
00061     ctox(file, x, n, nmax, lf);
00062 }

Generated at Sun Feb 24 09:56:57 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001