00001 #include <stdio.h> 00002 #include "bytedecoders.h" 00003 00004 /*-----------------------------------------------------------------\ 00005 Function Name : int 00006 Returns Type : unsigned 00007 ----Parameter List 00008 1. get_byte_value( unsigned char *start , 00009 ------------------ 00010 Exit Codes : 00011 Side Effects : 00012 -------------------------------------------------------------------- 00013 Comments: 00014 00015 -------------------------------------------------------------------- 00016 Changes: 00017 00018 \------------------------------------------------------------------*/ 00019 int get_1byte_value( char *start ) 00020 { 00021 return (int) *start; 00022 } 00023 00024 /*-----------------------------------------------------------------\ 00025 Function Name : int 00026 Returns Type : unsigned 00027 ----Parameter List 00028 1. get_ushort_value( unsigned char *start , 00029 ------------------ 00030 Exit Codes : 00031 Side Effects : 00032 -------------------------------------------------------------------- 00033 Comments: 00034 00035 -------------------------------------------------------------------- 00036 Changes: 00037 00038 \------------------------------------------------------------------*/ 00039 int get_2byte_value( char *start ) 00040 { 00041 int value = 0; 00042 00043 value = (unsigned char)*start | (((unsigned char)*(start +1)) << 8); 00044 00045 return value; 00046 } 00047 00048 /*-----------------------------------------------------------------\ 00049 Function Name : int 00050 Returns Type : unsigned 00051 ----Parameter List 00052 1. get_ulong_value( unsigned char *start , 00053 ------------------ 00054 Exit Codes : 00055 Side Effects : 00056 -------------------------------------------------------------------- 00057 Comments: 00058 00059 -------------------------------------------------------------------- 00060 Changes: 00061 00062 \------------------------------------------------------------------*/ 00063 int get_4byte_value( char *start ) 00064 { 00065 int value = 0; 00066 00067 value = ((unsigned char)*start) 00068 |(((unsigned char)*(start +1)) << 8) 00069 |(((unsigned char)*(start +2)) << 16) 00070 |(((unsigned char)*(start +3)) << 24); 00071 00072 /* printf("String=0x%x %x %x %x:%u = %d\n", *start, *(start +1), *(start +2), *(start +3), *(start +3), value);*/ 00073 00074 return value; 00075 } 00076 00077
1.5.1