read DTED data

Hi GRASSers,

  I am trying to write a simple program to read and convert
some DTED 1 degree data to GRASS cell format. There are no problems
for me to get header part information read through. However, when I
get to the stage to read the data records ( each data record starts
with Recognition Sentinel of octal number of 0252. I got this part
right), I don't know how to read and convert those Fixed Binary type
data into integers. According to the information that I have Fixed
Binary type denotes signed magnitude, right-justified binary integer.
Some of these data have 2 bytes and some of them have 3 bytes.

  Does anyone can tell me how to read them out and print them
to standard output as integer?

  Does anyone know is there a new version of m.dted.extract
can handle the post-1987 format?

  Thank you for any help.

  PK Lin
  Tel: (617) 942-1655
  E-mail: pklin@cerf.net