You're not supposed to have to know or care what the numeric values of CSIZE, CS5, CS6, CS7, or CS8 are. All you need to know at the level of actual numbers, is that somewhere in c_cflag
is a bit field that can hold at least four distinct values (namely CS5, CS6, CS7, and CS8); that, assuming the termios structure has been initialized correctly, the expression c_cflag & CSIZE
will be equal to one of the four CSx quantities; and that you can set the field to one of those four quantities with the two steps
termios_p->c_cflag &= ~CSIZE;
termios_p->c_cflag |= CSx; // x = one of 5, 6, 7, 8
(Your version of those two steps uses ~(CSIZE|PARENB)
in the first step -- that means your first step clears the PARENB flag as well as the CSIZE bitfield.)
Now, the symbolic constants do have a meaning, which the termios manpage doesn't bother to document because this entire mechanism is super obsolete and the only thing anyone not engaged in retrocomputing is likely to want to do with it nowadays is ensure it's in CS8 mode, but I am old enough that I can guess what it means just from the names. Remember that this API was originally designed to control an actual, physical serial I/O port. One of the parameters you have to decide on, when you send character data over a serial line, is "how many bits per character?" Nowadays the only answer anyone ever wants is 8, but back in the 1970s, hardware terminals that transmitted 7, 6, or even (rarely) 5 bits per character were still common enough that the designers of this API thought it was worth being able to talk to them.
(I recall reading somewhere that a design goal of both this API, and the higher-level "curses" API, was being able to connect any of the dozens of different terminal models to be found on the campus of the University of California, Berkeley, circa 1980-1983, with any of the smaller (but still more than one) number of minicomputer models also found there.)
So that's what this does. Set the CSIZE field to CS5 and your serial line will transmit and receive five-bit characters. CS6, six-bit characters, and so on.