Re: Suggested dual human/binary interface for proc/devfs

From: Ph. Marek (marek@mail.bmlv.gv.at)
Date: Wed Apr 05 2000 - 00:55:00 EST


I have a suggestion: why not use somethink like pack/unpack in perl?
  every structure has a "description", eg iiia - 3 integers, 1 string.

then a function could do the reading of this - with generalized
formats (any non-number-character between numbers [ ,;:-] etc., strings started and ended with ", escape sequences allowed ...).

this function could be called as follows:

int parse_ascii_input(void *structure, int maxlength, char *struct_description);

...

/* Data got from user via write/ioctl or whatever (even kernel-commandline) */

memcpy(temporary_buffer,current_contents,sizeof(current_contents));
if (parse_ascii_input(temporary_buffer,sizeof(current_contents),"icii"))
  return EINVAL;

memcpy(current_contents,temporary_buffer,sizeof(current_contents));

--
that would allow a user to pass (the previously given example)
echo "57600,,,1" > /proc/tty/ttyS0 
and change only baud rate and stop bits - without disturbing the rest.

another, similar, function could output this structure via the description.

of course, it would be some "bloat" - but the ascii interface is worth enough to have it.

?

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:14 EST