Skip to content
Tcl Source Code Artifact [9722a584e1]
Login

Artifact [9722a584e1]

Artifact 9722a584e1dec78f1ea4a0dd9b5ead9d88ead6f4fb62c2c9688c410aaa2c3f10:


type binary — niveau 1 / level 1

FR — filebinary.tcl (pur Tcl) lit et écrit des valeurs typées dans des fichiers ou canaux binaires. Aucune syntaxe de plus : la représentation binaire d'un champ est portée par son TYPE (int(u,16,be), string(raw,4), string(utf-8,z), bitarray(16), une constante "MZ"...), fournis par le patch noyau noyau/types-binaires.patch ; type binary T décrit la représentation.

EN — filebinary.tcl (pure Tcl) reads and writes typed values in binary files or channels. No extra syntax: a field's binary representation is carried by its TYPE, provided by the core patch noyau/types-binaires.patch; type binary T describes the representation.

source binaliases.tcl                       ;# u16be = int(u,16,be), u32be, f64le ... (alias courts)
type def tcp {{u16be}src; {u16be}dst; ... {bitarray(16,msb0,be)}flags; ...}

chan binary read   CANAL TYPE ?-endian E?
chan binary write  CANAL TYPE VALEUR ?-endian E?
type binary decode TYPE OCTETS ?-offset N? ?-endian E? ?-consumed VAR?
type binary encode TYPE VALEUR ?-endian E?
type binary {sizeof?}TYPE

Le canal est mis en mode binaire le temps de l'appel puis rétabli / the channel is put in binary mode for the call, then restored. La même table servira à chan binary / the same table will serve chan binary.

Voir MANUEL.md (chapitre « Types binaires »), exemples/layout_plat.tcl, tests_tclsh/t32_layout_plat.tcl, t33_types_binaires.tcl.

Nouveautés de cette version (0.4)

Niveau 2 (0.5) / Level 2 (0.5)