Опубликовано pushkin в Втр, 05/01/2010 - 21:03
Просмотр конференции fido7.ru.python:
Предыдущее Следующее
Дата: 05 Nov 2020, 05:56:20
От: Denis Mosko @ 2:5064/54.1315
Кому: All
Тема: Re: Ресурсы
--- GoldED+/W32-MINGW 1.1.5-b20120519 (Kubik 3.0)
Origin: В начале было слово. В конце будет ориджин. (2:5064/54.1315)
Предыдущее Следующее
К списку сообщений
К списку конференций
Предыдущее Следующее
Дата: 05 Nov 2020, 05:56:20
От: Denis Mosko @ 2:5064/54.1315
Кому: All
Тема: Re: Ресурсы
SD> Jam headers http://www.vlzn.nl/fmail/files/jhrprint.py
На что обратить внимание, All: ?
#!/usr/bin/python
#
# Copyright (C) 2016 Wilfred van Velzen 2:280/464
#
""" Prints the contents of a JAM messagebase .jhr file (containing the message headers) to stdout """
import struct
import sys
import time
DATETIMEFMT = "%Y-%m-%d %H:%M:%S"
SUBFIELDTYPES = \
{
0 : "OADDRESS"
, 1 : "DADDRESS"
, 2 : "SENDERNAME"
, 3 : "RECVRNAME"
, 4 : "MSGID"
, 5 : "REPLYID"
, 6 : "SUBJECT"
, 7 : "PID"
, 8 : "TRACE"
, 9 : "ENCLFILE"
, 10 : "ENCLFWALIAS"
, 11 : "ENCLFREQ"
, 12 : "ENCLFILEWC"
, 13 : "ENCLINDFILE"
, 1000 : "EMBINDAT"
, 2000 : "FTSKLUDGE"
, 2001 : "SEENBY2D"
, 2002 : "PATH2D"
, 2003 : "FLAGS"
, 2004 : "TZUTCINFO"
, 0xffff : "UNKNOWN"
}
#------------------------------------------------------------------------------
def TimeStr(t):
return time.strftime(DATETIMEFMT, time.gmtime(t)) if t != 0 else "0"
#------------------------------------------------------------------------------
# main
jhrf = open(sys.argv[1], "rb")
# /*
# ** Header file information block, stored first in all .JHR files
# */
# typedef struct
# {
# CHAR8 Signature[4]; /* <J><A><M> followed by <NUL> */
# UINT32 DateCreated; /* Creation date */
# UINT32 ModCounter; /* Last processed counter */
# UINT32 ActiveMsgs; /* Number of active (not deleted) msgs */
# UINT32 PasswordCRC; /* CRC-32 of password to access */
# UINT32 BaseMsgNum; /* Lowest message number in index file */
# CHAR8 RSRVD[1000]; /* Reserved space */
# }
fmthdr = "<4s5L1000x"
fmthdr_s = struct.calcsize(fmthdr)
hdrstr = jhrf.read(fmthdr_s)
hdr = struct.unpack(fmthdr, hdrstr)
print "Header"
print " Signature :", hdr[0]
print " DateCreated:", TimeStr(hdr[1])
print " ModCounter :", hdr[2]
print " ActiveMsgs :", hdr[3]
print " PasswordCRC: %08X" % (hdr[4], )
print " BaseMsgNum :", hdr[5]
print
# /*
# ** Message header
# */
# typedef struct
# {
# CHAR8 Signature[4]; /* <J><A><M> followed by <NUL> */
# UINT16 Revision; /* CURRENTREVLEV */
# UINT16 ReservedWord; /* Reserved */
# UINT32 SubfieldLen; /* Length of subfields */
# UINT32 TimesRead; /* Number of times message read */
# UINT32 MsgIdCRC; /* CRC-32 of MSGID line */
# UINT32 ReplyCRC; /* CRC-32 of REPLY line */
# UINT32 ReplyTo; /* This msg is a reply to.. */
# UINT32 Reply1st; /* First reply to this msg */
# UINT32 ReplyNext; /* Next msg in reply chain */
# UINT32 DateWritten; /* When msg was written */
# UINT32 DateReceived; /* When msg was received/read */
# UINT32 DateProcessed; /* When msg was processed by packer */
# UINT32 MsgNum; /* Message number (1-based) */
# UINT32 Attribute; /* Msg attribute, see "Status bits" */
# UINT32 Attribute2; /* Reserved for future use */
# UINT32 TxtOffset; /* Offset of text in text file */
# UINT32 TxtLen; /* Length of message text */
# UINT32 PasswordCRC; /* CRC-32 of password to access msg */
# UINT32 Cost; /* Cost of message */
# }
class MSGHDR:
pass
fmtmhdr = "<4s2H17L"
fmtmhdr_s = struct.calcsize(fmtmhdr)
while True:
msgstr = jhrf.read(fmtmhdr_s)
l = len(msgstr)
if l != fmtmhdr_s:
if l > 0:
print "Error: %d extranious bytes at end of file", l
break
mh = MSGHDR()
( mh.Signature
, mh.Revision
, mh.ReservedWord
, mh.SubfieldLen
, mh.TimesRead
, mh.MsgIdCRC
, mh.ReplyCRC
, mh.ReplyTo
, mh.Reply1st
, mh.ReplyNext
, mh.DateWritten
, mh.DateReceived
, mh.DateProcessed
, mh.MsgNum
, mh.Attribute
, mh.Attribute2
, mh.TxtOffset
, mh.TxtLen
, mh.PasswordCRC
, mh.Cost ) = struct.unpack(fmtmhdr, msgstr)
print "Msg"
print " Header"
print " Signature :", mh.Signature
print " Revision :", mh.Revision
print " ReservedWord :", mh.ReservedWord
print " SubfieldLen :", mh.SubfieldLen
print " TimesRead :", mh.TimesRead
print " MsgIdCRC : %08X" % mh.MsgIdCRC
print " ReplyCRC : %08X" % mh.ReplyCRC
print " ReplyTo :", mh.ReplyTo
print " Reply1st :", mh.Reply1st
print " ReplyNext :", mh.ReplyNext
print " DateWritten :", TimeStr(mh.DateWritten)
print " DateReceived :", TimeStr(mh.DateReceived)
print " DateProcessed:", TimeStr(mh.DateProcessed)
print " MsgNum :", mh.MsgNum
print " Attribute : %08X" % mh.Attribute
print " Attribute2 :", mh.Attribute2
print " TxtOffset :", mh.TxtOffset
print " TxtLen :", mh.TxtLen
print " PasswordCRC : %08X" % mh.PasswordCRC
print " Cost :", mh.Cost
# /*
# ** Message header subfield types
# */
# #define JAMSFLD_OADDRESS 0
# #define JAMSFLD_DADDRESS 1
# #define JAMSFLD_SENDERNAME 2
# #define JAMSFLD_RECVRNAME 3
# #define JAMSFLD_MSGID 4
# #define JAMSFLD_REPLYID 5
# #define JAMSFLD_SUBJECT 6
# #define JAMSFLD_PID 7
# #define JAMSFLD_TRACE 8
# #define JAMSFLD_ENCLFILE 9
# #define JAMSFLD_ENCLFWALIAS 10
# #define JAMSFLD_ENCLFREQ 11
# #define JAMSFLD_ENCLFILEWC 12
# #define JAMSFLD_ENCLINDFILE 13
# #define JAMSFLD_EMBINDAT 1000
# #define JAMSFLD_FTSKLUDGE 2000
# #define JAMSFLD_SEENBY2D 2001
# #define JAMSFLD_PATH2D 2002
# #define JAMSFLD_FLAGS 2003
# #define JAMSFLD_TZUTCINFO 2004
# #define JAMSFLD_UNKNOWN 0xffff
# /*
# ** Message header subfield
# */
# typedef struct
# {
# UINT16 LoID; /* Field ID, 0 - 0xffff */
# UINT16 HiID; /* Reserved for future use */
# UINT32 DatLen; /* Length of buffer that follows */
# CHAR8 Buffer[1]; /* DatLen bytes of data */
# }
# JAMSUBFIELD, _JAMDATA * JAMSUBFIELDptr;
#
class SUBFIELD:
pass
b = 0
subfieldstr = jhrf.read(mh.SubfieldLen)
fmtsf = "<2HL"
fmtsf_s = struct.calcsize(fmtsf)
while b < mh.SubfieldLen:
sf = SUBFIELD()
(sf.LoID, sf.HiID, sf.DatLen) = struct.unpack(fmtsf, subfieldstr[b:b + fmtsf_s])
b += fmtsf_s
sf.Buffer = subfieldstr[b:b + sf.DatLen]
b += sf.DatLen
sftype = SUBFIELDTYPES[sf.LoID] if sf.LoID in SUBFIELDTYPES else "Undefined"
print " Subfield"
print " LoID :", sf.LoID, sftype
print " HiID :", sf.HiID
print " DatLen:", sf.DatLen
print " Buffer:", sf.Buffer
print
jhrf.close()
--- GoldED+/W32-MINGW 1.1.5-b20120519 (Kubik 3.0)
Origin: В начале было слово. В конце будет ориджин. (2:5064/54.1315)
Предыдущее Следующее
К списку сообщений
К списку конференций
Последние комментарии
7 года 44 недели назад
7 года 44 недели назад
8 года 31 недели назад
8 года 49 недели назад
8 года 49 недели назад
8 года 49 недели назад
8 года 49 недели назад
8 года 49 недели назад
8 года 49 недели назад
9 года 5 дня назад