Show 22 quoted lines
> Please do not throw in conditional compilation in a codepath that is
> otherwise generic.
>
> Do something like this near the beginning of the file (or if they are
> common, in an appropriate header):
>
> #ifdef NO_GETPASS
> #define getpass(ignored) NULL
> #endif
>
> #ifdef NO_PW_GECOS
> #define get_gecos(ignored) "&"
> #else
> #define get_gecos(struct_passwd) (struct_passwd->pw_gecos)
> #endif
>
> That way, you do not have to change connect.c at all, and the code that
> accesses gecos field would get a slight abstraction, i.e.
>
> for (len = 0, dst = name, src = get_gecos(w); len < sz; src++) {
> ...
> I don't think that it is a lot of fun to call Android UI code from C as it is normally only done from Java.
The same problem occurs in dropbear on Android. There, it is solved by including a NetBSD version of getpass.c: https://github.com/CyanogenMod/android_external_dropbear/blob/master/netbsd_getpass.c .
If including NetBSD code is okay, the new patch will work. There currently is very limited use for this on Android, however, as there is no libcurl by default on Android. So, the only usage is git-imap-send, which works fine with this patch.
Compiling libcurl for Android should be possible with some work, though. So compat/getpass.c would be used for libcurl/HTTP access, too.