Hi,

Tuesday, October 21, 2003, 3:12:47 PM, you wrote:
VE> Hi,

VE> I'm trying to extract an binary file with unpack but I don't understand
VE> how it works... 

VE> The F6FBB program makes the file...
VE> It is a hamradio program http://www.f6fbb.org/

VE> This is the structure of 1 record in the file :
VE> struct inf_struct
VE> {  char     callsign[8];        /* Callsign             */
VE>    char     dummy1[64];
VE>    long     lastmes;
VE>    long     connects;           /* Number of connexions */
VE>    long     hcon;
VE>    long     lastyap;
VE>    int      flags;
VE>    int      on_base;
VE>    char     nbl;
VE>    char     lang;
VE>    long     newbanner;
VE>    int      download;
VE>    char     free[20];
VE>    char     thema;
VE>    char     nom[18];
VE>    char     prenom[13];
VE>    char     adres[61];
VE>    char     ville[31];
VE>    char     teld[13];
VE>    char     telp[13];
VE>    char     home[41];
VE>    char     gra[7];
VE>    char     priv[13];
VE>    char     filtre[7];
VE>    char     pass[13];
VE>    char     zip[1];
VE> }  inf;                 /* 360 bytes = lenght of one record */

VE> Can somebody help me?

VE> Regards,

VE> Vincent


Try this (assumes little endian byte ordering, if big endian V = N v = n)

$array = unpack("
  a8callsign/
  a64dummy1/
  Vlastmes/
  Vconnects/
  V/hcon/
  V/lastyap/
  vflags/
  von_base/
  cnbl/
  clang/
  Vnewbanner/
  vdownload/
  a20free/
  cthema/
  a8nom/
  a13prenom/
  a61adres/
  a31ville/
  a13teld/
  a13telp/
  a41home/
  a7gra/
  a13priv/
  a7filtre/
  a13pass/
  czip",$input);
print_r($array);

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to