fileutil::magic::cgen(3tcl)
β¨ 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 thestruct::treepackage to build the tree, fyi. and the script? it's in the format thatmagic(5)specifies. slay.::fileutil::magic::cgen::treedump treeβ give it a tree that came out of::fileutil::magic::cgen::2treeand 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::2treeand 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 packagefileutil::magic::rtto 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
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms