]> www.wagner.pp.ru Git - oss/catdoc.git/blob - src/numutils.c
Erroneusly inserted data removed
[oss/catdoc.git] / src / numutils.c
1 /*****************************************************************/
2 /* Utilities to convert various numeric types from the Windows   */
3 /* (Little endian) format to native types                        */
4 /*                                                               */
5 /* This file is part of catdoc project                           */
6 /* (c) Victor Wagner 1996-2003, (c) Alex Ott 2003                    */
7 /*****************************************************************/
8
9
10 /********************************************************************/
11 /* Reads 2-byte LSB  int from buffer at given offset platfom-indepent
12  * way
13  *********************************************************************/ 
14 unsigned int getshort(unsigned char *buffer,int offset) {
15         return (unsigned short int)buffer[offset]|((unsigned short int)buffer[offset+1]<<8);
16 }  
17 /********************************************************************/
18 /* Reads 4-byte LSB  int from buffer at given offset almost platfom-indepent
19  * way
20  *********************************************************************/ 
21 long int getlong(unsigned char *buffer,int offset) {
22         return (long)buffer[offset]|((long)buffer[offset+1]<<8L)
23                 |((long)buffer[offset+2]<<16L)|((long)buffer[offset+3]<<24L);
24 }  
25
26 unsigned long int getulong(unsigned char *buffer,int offset) {
27         return (unsigned long)buffer[offset]|((unsigned long)buffer[offset+1]<<8L)
28                 |((unsigned long)buffer[offset+2]<<16L)|((unsigned long)buffer[offset+3]<<24L);
29 }