
Dear Tom,
In message 20131006205527.GP15917@bill-the-cat you wrote:
Do we really need a static size here? Can we not auto-adjust to the needed size, say by dynamically allocating the buffer?
Doesn't look like it, without a big change to the parsing code.
I don't think this requires a big change. Eventually all it takes is changing the sscanf() call in get_config() to use a format "%ms" instead of plain "%s"; form the sscanf() man page:
ยท An optional 'm' character. This is used with string conversions (%s, %c, %[), and relieves the caller of the need to allocate a corresponding buffer to hold the input: instead, scanf() allocates a buffer of sufficient size, and assigns the address of this buffer to the corresponding pointer argument, which should be a pointer to a char * variable (this variable does not need to be initialized before the call). The caller should subsequently free(3) this buffer when it is no longer required.
OK, the struct should then of course contain a const char pointer instead of the buffer itself, but that's also a trivial change.
Best regards,
Wolfgang Denk