Henning Meier-Geinitz wrote: > So the backend would call the callback immediatly, when a fatal error > occurs. Fatal means, that it will return anything other than > SANE_STATUS_GOOD. This would work for command-line programs but may be > messy for graphical frontends. Errr... Since you're defining a new API, then why not return a ptr to typedef struct { int errornum; const char *errmsg; } SANE_error; or momething similar ? This way, the failing function sets both the numerical error code AND the (verbose) error message. You don't like structs? :-) Then a success might be indicated by a NULL ptr, while an error is a string like "NNN verbose message follows error code" (like many net progs already do). Want numerical error code? atoi(retval) and you get it. Is atoi() too slow? Then use #define ERRCODE(rv) (rv?(rv[0]*10+rv[1])*10+rv[2]:0)
So you could even have the same error code for different error messages. Really useful when debugging a module: the error code tells the failure type, and the rest of the message helps tracing it down. The pointer should point to a list of static strings, so it remains valid as long as it's needed. Just my $.01 :-) BYtE, Diego.