/[PAMELA software]/chewbacca/PamOffLineSW/forroutines/tracker/readraw/getbytes.c
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/forroutines/tracker/readraw/getbytes.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Sep 23 07:20:17 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: v0r00, MAIN
CVS Tags: v1r02, v1r00, v1r01, start, v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Imported sources, 23/09/2008

1 mocchiut 1.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     /**
17     * Read nbytes at position p of buffer, and fill value
18     */
19    
20     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