New API call for path conversion

Václav Haisman
Mon Feb 25 21:19:00 GMT 2008

Corinna Vinschen wrote, On 25.2.2008 12:30:
> On Feb 23 18:51, V?clav Haisman wrote:
>> Corinna Vinschen wrote, On 22.2.2008 13:19:
>>> Hi,
>> [...]
>>> Therefore, as a first cut, I'd propose something along the lines of:
>>>   typedef enum
>>>     {
>>>       CCP_WIN_A_TO_POSIX, /* from is char*, to is char*     */
>>>       CCP_WIN_W_TO_POSIX, /* from is wchar_t*, to is char*  */
>>>       CCP_POSIX_TO_WIN_A, /* from is char*, to is char*     */
>>>       CCP_POSIX_TO_WIN_W  /* from is char*, to is wchar_t*  */
>>>     } cygwin_conv_path_t;
>>>   ssize_t cygwin_conv_path (cygwin_conv_path_t what, const void *from,
>>>                             void *to, size_t size);
>>> "size" is the size of the "to" buffer in bytes (not in characters).
>>> If size is 0, cygwin_conv_path returns the required buffer size in
>>> bytes.
>>> Otherwise, it returns 0 on success, or -1 on error and errno is set to
>>> one of the below values:
>> [...]
>>> Does that sound reasonable?
>> I suggest that you use four different functions with different signatures 
>> instead of one with void pointers to buffers. Using just one function like 
>> that seems too error prone.
> The idea was to have not too many new API calls.  One thing which bugged
> me with the old API was the long function names which I never get right
> the first time.  I always have to look the names up in sys/cygwin.h.  If
> you create a lot of different functions you have this problem again.
> OTOH, with my proposal you will have to look up the values for "what", I
> guess...  How should the new functions be named?  Care to make a
> proposal yourself?
> Corinna
Well, personally I am not opposed to longer function names. But if you want 
shorter cygwin_conv_XXX where XXX is one of p2a, p2w, a2p, w2p. That would be 
just generic conversion routines. If you want to keep all the variants that 
are at the top of sys/cygwin.h then you will end up either with longer names 
(though still shorter than they are now) or with cryptic names, if you would 
abbreviate words "full" or "list" into "f" and "l" suffixes. One could even 
use OOish scheme like cygwin_subject_action_modifiers:



Then there is cygwin_internal(). I do not like the va_args/switch combination 
very much. Nicer interface would be C style OO, returning pointer to 
structure filled with function pointers. That way you can expose many 
functions without having them as DLL exports. You could even do that with the 
conversion routines above and make the DLL exports list even shorter.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin-developers mailing list