Re: [PATCH 5/6] Agent's DisplayPasskey implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

On Thu, Mar 14, 2013 at 2:22 PM, Alex Deymo <deymo@xxxxxxxxxxxx> wrote:
> +       dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
> +                       DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_UINT16, &entered,
> +                                                       DBUS_TYPE_INVALID);
> +
> +       snprintf(passkey_entered, 7, "%.6u", passkey);
> +       passkey_entered[6] = '\0';
> +       strncpy(passkey_remaining, passkey_entered, 7);
> +       if (entered > strlen(passkey_entered))
> +               entered = strlen(passkey_entered);
> +       passkey_entered[entered] = '\0';
> +
> +       rl_printf(AGENT_PROMPT "Passkey: " COLOR_BOLDGRAY "%s" COLOR_BOLDWHITE
> +               "%s\n" COLOR_OFF, passkey_entered, passkey_remaining+entered);
> +
> +       return dbus_message_new_method_return(msg);
> +}
> +

What about using the "%.*s" printf format specifier to simplify
things? Something like (not tested):


    snprintf(passkey_full, sizeof(passkey_full), "%.6u", passkey);
    passkey_full[6] = '\0';

    if (entered > strlen(passkey_full))
        entered = strlen(passkey_full);

    rl_printf(AGENT_PROMPT "Passkey: " COLOR_BOLDGRAY "%.*s" COLOR_BOLDWHITE
            "%s\n" COLOR_OFF, entered, passkey_full, passkey_full + entered);


Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux