fileutil::magic::cgen(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ fileutil::magic::cgen ✨

okay bestie, so this is a page from the file utilities corner of the manual β€” fileutil::magic::cgen, generator core for the compiler of magic(5) files. yes it's a mouthful, yes it's iconic, let's go πŸ’…


πŸ’– NAME πŸ’–

fileutil::magic::cgen β€” the generator core for the compiler of magic(5) files. it's giving backend brain, and we love her for it 🧠✨


🌸 SYNOPSIS 🌸

package require Tcl 8.5 9

package require fileutil::magic::cgen ?1.2.0?

package require fileutil::magic::rt ?1.2.0?

package require struct::tree

package require struct::list

::fileutil::magic::cgen::2tree script

::fileutil::magic::cgen::treedump tree

::fileutil::magic::cgen::treegen tree node

no cap, that's the whole vibe check up top 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so like β€” this package is the generator backend for a compiler that takes magic(5) files and turns them into recognizers. the recognizers themselves are built on the fileutil::magic::rt recognizer runtime package. bestie if you're looking for the compiler frontend that uses this generator, that's a whole other girl: fileutil::magic::cfront. periodt 🌈


πŸ‘‘ COMMANDS πŸ‘‘

  • ::fileutil::magic::cgen::2tree script β€” this one takes the recognizer that the script specifies and converts it into a tree, then hands you back the object command of that tree as its result. it's using the struct::tree package to build the tree, fyi. and the script? it's in the format that magic(5) specifies. slay.
  • ::fileutil::magic::cgen::treedump tree β€” give it a tree that came out of ::fileutil::magic::cgen::2tree and it returns a string that encodes the tree for human consumption, purely to help you debug. it's the "show me what you did" of commands, and honestly? we love the transparency πŸ”₯
  • ::fileutil::magic::cgen::treegen tree node β€” takes a tree from ::fileutil::magic::cgen::2tree and returns a Tcl script: the recognizer for the file types represented by the sub-tree rooted at node. the generated script makes extensive use of the commands from the recognizer runtime package fileutil::magic::rt to do its duties. main character energy fr fr πŸ’œ

😭 BUGS, IDEAS, FEEDBACK 😭

not me having to say this, but: this document, and the package it describes, will undoubtedly contain bugs and other problems. πŸ’€

please report them in the category fileutil :: magic of the Tcllib Trackers β€” [http://core.tcl.tk/tcllib/reportlist](http://core.tcl.tk/tcllib/reportlist).

also please report any ideas you have for enhancements to either the package and/or the documentation. we want the glow-up πŸŽ€

when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. no chaos, only clarity.

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. iykyk 🫢


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

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


πŸŽ€ CATEGORY πŸŽ€

Programming tools


okay that's the whole page bestie, you ate that πŸ’…βœ¨

and for the cute sign-off: this is from tcllib, version 1.2.0, and it lives at the manual name fileutil::magic::cgen(3tcl) β€” go forth and recognize some file types, you absolute icon πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from