| 1 |
mocchiut |
1.1 |
/*************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* routine read_ev: routine to extract an event information |
| 4 |
|
|
* from file acquired with Pamela acquisition programs |
| 5 |
|
|
* |
| 6 |
|
|
* June 2002 |
| 7 |
|
|
* |
| 8 |
|
|
***************************************************************/ |
| 9 |
|
|
/* |
| 10 |
|
|
* include needed system headers |
| 11 |
|
|
*/ |
| 12 |
|
|
#include <stdio.h> /* include standard i/o library */ |
| 13 |
|
|
#include <stdlib.h> /* include standard library */ |
| 14 |
|
|
#include <string.h> /* include string library */ |
| 15 |
|
|
#include <unistd.h> /* include unix standard library */ |
| 16 |
|
|
#include <sys/types.h> /* */ |
| 17 |
|
|
#include <sys/stat.h> /* */ |
| 18 |
|
|
#include <fcntl.h> /* */ |
| 19 |
|
|
#include <errno.h> /* error simbol definitions */ |
| 20 |
|
|
#include <time.h> /* system time definitions */ |
| 21 |
|
|
#include <math.h> /* math library */ |
| 22 |
|
|
|
| 23 |
|
|
void reads_(char *data, int *error, int *fd) |
| 24 |
|
|
{ |
| 25 |
|
|
char header; |
| 26 |
|
|
header = (char) malloc (sizeof(char)); |
| 27 |
|
|
|
| 28 |
|
|
*error = 0; |
| 29 |
|
|
|
| 30 |
|
|
*error = read(*fd,&header,sizeof(char)) == sizeof(char) ? 0 : -1; |
| 31 |
|
|
|
| 32 |
|
|
// printf("%X\n",*data); |
| 33 |
|
|
|
| 34 |
|
|
if (*error) { |
| 35 |
|
|
/* printf ("%d \n", *error); */ |
| 36 |
|
|
free (header); |
| 37 |
|
|
return; |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
*data = header ; |
| 41 |
|
|
|
| 42 |
|
|
/* printf ("%d \n", *data); */ |
| 43 |
|
|
|
| 44 |
|
|
*error = 0; |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
|
| 48 |
|
|
|
| 49 |
|
|
|
| 50 |
|
|
|
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
|