/* Store the command-name in cmdname, and return a pointer to the remaining of the command string.  */
static const char* get_command_name(const char *cmdline, char *cmdname, size_t nlen)
/* Store the command-name in cmdname, and return a pointer to the remaining of the command string.  */
static const char* get_command_name(const char *cmdline, char *cmdname, size_t nlen)
{
    size_t len;
    const char *p, *pstart;
    p = cmdline;
    while (qemu_isspace(*p))
        p++;
    if (*p == '\0')
        return NULL;
    pstart = p;
    while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
        p++;
    len = p - pstart;
    if (len > nlen - 1)
        len = nlen - 1;
    memcpy(cmdname, pstart, len);
    cmdname[len] = '\0';
    return p;
}