Skip to content

Add alternative hostname and service name helpers - #9

Merged
alexpevzner merged 1 commit into
OpenPrinting:masterfrom
devgianlu:alternative
Sep 22, 2026
Merged

alexpevzner merged 1 commit into
OpenPrinting:masterfrom
devgianlu:alternative

Conversation

@devgianlu

Copy link
Copy Markdown
Contributor

No description provided.

@devgianlu

Copy link
Copy Markdown
Contributor Author

@alexpevzner Any chance for this to get merged? These helpers are quite important for implementing service name conflict resolution.

@alexpevzner

Copy link
Copy Markdown
Member

Any chance for this to get merged?

Yes — sorry for not spotting this earlier.

To get this merged, we'll need proper function comments that explain what each function does, not just what it calls.

One of the core values of this project is providing clear, usable documentation for Avahi's API, since the native documentation is often opaque and incomplete. So simply stating that AlternativeHostname calls avahi_alternative_host_name won't be enough — we need to explain the semantics: what the function actually does, why you'd use it, and what the expected behavior is.

Could you add that? Happy to review once it's in.

@devgianlu

Copy link
Copy Markdown
Contributor Author

Done ;)

@alexpevzner

Copy link
Copy Markdown
Member

Hi!

I have reviewed avahi_alternative_host_name source. It can return NULL in a case of error, but doesn't indicate the error reason, so we have to guess.

But this is very unlikely that it will fail due to insufficient memory, so ErrNoMemory doesn't look to be the best guess. This function works by adding numerical suffix to the first label of DNS domain name, and to do it, it parses the hostname. So if this function fails, must likely this is due to the syntax error in the hostname. So ErrInvalidHostName looks to be the best guess if it happens.

Similarly, ErrInvalidServiceName is the best guess for AlternativeServiceName

And also please add to the functions explanations a couple of words that these functions are helper functions to resolve possible name collisions.

Everything else looks good for me.

@alexpevzner
alexpevzner merged commit 3dd7846 into OpenPrinting:master Sep 22, 2026
@alexpevzner

Copy link
Copy Markdown
Member

I have merged and updated by myself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants