changeset 203:719d007d0639 src

Add some more getbit code.
author jcdutton
date Sun, 18 May 2003 19:55:39 +0000
parents a8b35f4c63b9
children abb25c194c1b
files nav_read.c
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/nav_read.c	Sun May 18 18:03:29 2003 +0000
+++ b/nav_read.c	Sun May 18 19:55:39 2003 +0000
@@ -96,8 +96,32 @@
   return result;
 }
 
+/* WARNING: This function can only be used on a byte boundary.
+            No checks are made that we are in fact on a byte boundary.
+ */
+static uint16_t get16bits(getbits_state_t *state) {
+  uint16_t result;
+  state->byte_position++;
+  result = (state->byte << 8) + state->start[state->byte_position++];
+  state->byte = state->start[state->byte_position];
+  return result;
+}
+
+/* WARNING: This function can only be used on a byte boundary.
+            No checks are made that we are in fact on a byte boundary.
+ */
+static uint32_t get32bits(getbits_state_t *state) {
+  uint32_t result;
+  state->byte_position++;
+  result = (state->byte << 8) + state->start[state->byte_position++];
+  result = (result << 8) + state->start[state->byte_position++];
+  result = (result << 8) + state->start[state->byte_position++];
+  state->byte = state->start[state->byte_position];
+  return result;
+}
+
 void navRead_PCI(pci_t *pci, unsigned char *buffer) {
-  int32_t result, i, j;
+  int32_t i, j;
   getbits_state_t state;
   if (getbits_init(&state, buffer)) assert(0); /* Passed NULL pointers */