/[PAMELA software]/yoda/techmodel/forroutines/tracker/readraw/getbytes.c
ViewVC logotype

Annotation of /yoda/techmodel/forroutines/tracker/readraw/getbytes.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Tue Jun 27 10:25:42 2006 UTC (18 years, 5 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_3/19, YODA6_3/18, YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/10, YODA6_3/17, YODA6_3/16, YODA6_3/15, YODA6_3/14, YODA6_3/06, YODA6_3/04, YODA6_3/05, YODA6_3/20, YODA6_3/07, YODA6_3/08, YODA6_3/09, HEAD
Changes since 6.0: +4 -0 lines
File MIME type: text/plain
Final release for the Traker's routines.

1 kusanagi 5.1 /*
2     * include needed system headers
3     */
4     #include <stdio.h> /* include standard i/o library */
5     #include <stdlib.h> /* include standard library */
6     #include <string.h> /* include string library */
7     #include <unistd.h> /* include unix standard library */
8     #include <sys/types.h> /* */
9     #include <sys/stat.h> /* */
10     #include <fcntl.h> /* */
11     #include <errno.h> /* error simbol definitions */
12     #include <time.h> /* system time definitions */
13     #include <math.h> /* math library */
14    
15    
16 kusanagi 6.1 /**
17     * Read nbytes at position p of buffer, and fill value
18     */
19    
20 kusanagi 5.1 void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value)
21    
22     {
23     char bytes[4];
24     int i;
25    
26     for(i=0; i<*nbytes; i++) {
27     bytes[i] = *(buffer+(*p)-1+i);
28     }
29     if(*nbytes == 1)
30     *value = 0x000000ff & bytes[0];
31     if(*nbytes == 2)
32     *value = ((bytes[0]<<8)&0x0000ff00) |
33     (bytes[1]&0x000000ff);
34     if(*nbytes == 4)
35     *value = ((bytes[0]<<24)&0xff000000) |
36     ((bytes[1]<<16)&0x00ff0000) |
37     ((bytes[2]<<8)&0x0000ff00) |
38     (bytes[3]&0x000000ff);
39    
40     *p += *nbytes;
41    
42     return;
43     }

  ViewVC Help
Powered by ViewVC 1.1.23