xpanslookup(3)

πŸ“¦
version 2.1.20 Β· 2 versions
  • 2.1.20 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2.1.20 Β· fedora 43, fedora 44
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’« NAME πŸ’«

XPANSLookup β€” the lil function that goes and looks up all the registered XPA access points for you πŸ’…


✨ SYNOPSIS ✨

#include <xpa.h>

int XPANSLookup(XPA xpa,
                char *template, char type,
                char ***classes, char ***names,
                char ***methods, char ***infos)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay bestie, sit with me for a sec, because this one is actually so good 🫢

So the whole XPA situation works on a class:name identifier, right? And the way it goes is: every single access point that matches that identifier gets processed. That's the default vibe. But sometimes β€” and hear me out β€” you don't want ALL of them. You want to choose which specific access points from the candidates actually match your template. Iconic behaviour, honestly.

That's literally what XPANSLookup is for. You call it, it hands you back a list of matches, and then you can take those specific class:name instances and feed them straight into XPAGet(), XPASet(), etc. Like a little matchmaking service but for access points πŸ’–


πŸŽ€ the args, one by one πŸŽ€

  • first arg β€” an optional XPA struct. If it's non-NULL, then the existing name server connection associated with the specified xpa is used to query the xpans name server for matching templates. If it's not, a brand new (temporary!) connection gets established with the name server instead. Casual ✨
  • second arg β€” the class:name template to match. That's the one, that's your search πŸ’…
  • third arg β€” the type of access, and ngl it can be any combination of these:
    • g β€” xpaget calls can be made on this access point
    • s β€” xpaset calls can be made on this access point
    • i β€” xpainfo calls can be made on this access point
lowkey the call usually specifies only one of these at a time. just saying πŸ‘€
  • final args β€” pointers to arrays that get filled in and returned by the name server. The name server allocates and returns arrays stuffed with the classes, names, and methods of all the XPA access points that match the template and have the specified type. You also get info strings back, which generally are used internally by the client routines. You can ignore those (but bestie. the strings must be freed. do not forget. 😭)

The function returns the number of matches β€” and that return value is exactly what you use to loop through them all πŸŒ€


🌸 example time 🌸

#include <xpa.h>

char **classes;
char **names;
char **methods;
char **infos;
int i, n;
n = XPANSLookup(NULL, "foo*", "g", &classes, &names, &methods, &infos);
for(i=0; i<n; i++){
  [more specific checks on possibilities ...]
  [perhaps a call to XPAGet for those that pass, etc. ...]
  /* don't forget to free alloc'ed strings when done */
  free(classes[i]);
  free(names[i]);
  free(methods[i]);
  free(infos[i]);
}
/* free up arrays alloc'ed by names server */
if( n > 0 ){
  free(classes);
  free(names);
  free(methods);
  free(infos);
}

🧚 the host:port plot twist 🧚

The specified template also can be a host:port specification, for example:

myhost:12345

In this case? No connection is made to the name server. None. Instead, the call will return one entry such that the ip array contains the ip for the specified host and the port array contains the port. And because the class and name of the access point are genuinely not known here, the class and name entries are just set to the character "?". Mystery era πŸ•΅οΈβ™€οΈπŸ’œ


🌈 SEE ALSO 🌈

See xpa(n) for a list of XPA help pages β€” go read it, it's giving encyclopedia but make it cute πŸ“šβœ¨


and that's the whole page, bestie!! this was version 2.1.15, dated July 23, 2013, brought to you by the SAORD Documentation crew πŸ’– mwah, go free your strings 🫢πŸ’