logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

fileutil::magic::rt - Runtime core for file type recognition engines written in pure Tcl

Bugs, Ideas, Feedback

       This  document,  and  the package it describes, will undoubtedly contain bugs and other problems.  Please
       report    such    in    the    category    fileutil::magic     of     the     TcllibTrackers
       [http://core.tcl.tk/tcllib/reportlist].   Please  also report any ideas for enhancements you may have for
       either package and/or documentation.

       When proposing code changes, please provide unifieddiffs, i.e the output of diff-u.

       Note further that attachments are strongly preferred over inlined patches. Attachments  can  be  made  by
       going  to the Edit form of the ticket immediately after its creation, and then using the left-most button
       in the secondary navigation bar.

Category

       Programming tools

tcllib                                                 2.0                             fileutil::magic::rt(3tcl)

Commands

::fileutil::magic::rt::>
              Increment the level and perform related housekeeping

       ::fileutil::magic::rt::<
              Decrement the level and perform related housekeeping

       ::fileutil::magic::rt::newchannamedanalyze
              Create a new command which returns one description of the file each time it is called, and a  code
              of  break  when  there  are  no  more  descriptions.   chan  is the channel containing the data to
              describe.  The channel configuration is then managed as needed.  named is a  dictionary  of  named
              tests,  as  generated by fileutil::magic::cfront::compile.  test is a command prefix for a routine
              composed of the list of commands as returned by fileutil::magic::cfront::compile.

       ::fileutil::magic::rt::file_startname
              This command marks the start of a magic file when debugging. It returns the empty  string  as  its
              result.

       ::fileutil::magic::rt::emitmsg
              This command adds the text msg to the result buffer. The message may contain the following special
              character sequences. They will be replaced with buffered values before the message is added to the
              result. The command returns the empty string as its result.

              \b     This sequence is removed

              %s     Replaced with the last buffered string value.

              %ld    Replaced with the last buffered numeric value.

              %d     See above.

              ${x:...?...}
                     Substitute one string if the file is executable, and another string otherwise.

       ::fileutil::magic::rt::Owhere
              Produce  an offset from where, relative to the cursor one level up.  Produce an offset from where,
              relative to the offset one level up.

       ::fileutil::magic::rt::Nvtypeoffsetcompinvertcompexpected
              A limited form of ::fileutile::magic::rt::N that only checks for equality and  can't  be  told  to
              invert the test.

       ::fileutil::magic::rt::Ntypeoffsettestinvertcompinvertmodmandcompexpected
              Fetch  the  numeric  value  with  type from the absolute location offset, compare it with expected
              using comp as the comparision operator,  and returns the result.

              The argument comp must be one of Tcl's comparison operators.

                <comp> <fetched-and-masked-value> <comp> <expected>

       The special comparison operator x signals that no comparison should be done, or, in other words, that the
       fetched value will always match val.

       ::fileutil::magic::rt::Stypeoffsettestinvertmodmandcompval
              Like ::fileutil::magic::rt::N except that it fetches and compares string types , not numeric data.

       ::fileutil::magic::rt::Lnewlevel
              Sets the current level in the calling context to newlevel. The command returns the empty string as
              its result.

       ::fileutil::magic::rt::Ioffsetitioiiooiirio
              Calculates an offset based on an initial offset and the provided modifiers.

       ::fileutil::magic::rt::Roffset
              Given an initial offset, calculates an offset relative to the cursor at the  next  level  up.  The
              cursor  is the position in the data one character after the data extracted from the file one level
              up.

       ::fileutil::magic::rt::Ufileindexname
              Add a level and use a named test script.

Description

       This  package provides the runtime core for file type recognition engines written in pure Tcl and is thus
       used by all other packages in this module such as fileutil::magic::filetype and the two compiler packages
       fileutil::magic::cgen and fileutil::magic::cfront.

Keywords

       file recognition, file type, file utilities, mime, type

Name

       fileutil::magic::rt - Runtime core for file type recognition engines written in pure Tcl

Numeric Types

byte   8-bit integer

       short  16-bit integer, stored in native endianess

       beshort
              see above, stored in big endian

       leshort
              see above, stored in small/little endian

       long   32-bit integer, stored in native endianess

       belong see above, stored in big endian

       lelong see above, stored in small/little endian

       All of the types above exit in an unsigned form as well. The type names are the same, with the  character
       "u" added as prefix.

       date   32-bit integer timestamp, stored in native endianess

       bedate see above, stored in big endian

       ledate see above, stored in small/little endian

       ldate  32-bit integer timestamp, stored in native endianess

       beldate
              see above, stored in big endian

       leldate
              see above, stored in small/little endian

See Also

file(1), fileutil, magic(5)

Synopsis

       package require Tcl8.59

       package require fileutil::magic::rt?2.0?::fileutil::magic::rt::>::fileutil::magic::rt::<::fileutil::magic::rt::newchannamedanalyze::fileutil::magic::rt::file_startname::fileutil::magic::rt::emitmsg::fileutil::magic::rt::Owhere::fileutil::magic::rt::Rwhere::fileutil::magic::rt::Nvtypeoffsetcompinvertcompexpected::fileutil::magic::rt::Ntypeoffsettestinvertcompinvertmodmandcompexpected::fileutil::magic::rt::Stypeoffsettestinvertmodmandcompval::fileutil::magic::rt::Lnewlevel::fileutil::magic::rt::Ioffsetitioiiooiirio::fileutil::magic::rt::Roffset::fileutil::magic::rt::Ufileindexname

________________________________________________________________________________________________________________

See Also