Logo Search packages:      
Sourcecode: avahi version File versions  Download package

AVAHI_C_DECL_BEGIN char* avahi_alternative_host_name ( const char *  s  ) 

Find an alternative for the specified host name. If called with an original host name, "2" is appended, Afterwards the number is increased on each call. (i.e. "foo" becomes "foo2" becomes "foo3" and so on.) avahi_free() the result.

Definition at line 34 of file alternative.c.

    const char *p, *e;
    char *r;


    e = s;
    for (p = s; *p; p++)
        if (!isdigit(*p))
            e = p+1;

    if (*e) {
        char *c;

        if (!(c = avahi_strndup(s, e-s)))
            return NULL;

        r = avahi_strdup_printf("%s%i", c, atoi(e)+1);
    } else
        r = avahi_strdup_printf("%s2", s);
    return r;

Generated by  Doxygen 1.6.0   Back to index