These are the same as lookup_location_name() and lookup_location_code() except that they allow for calling them additional times to get the next match. If idx != NULL set idx to the position + 1 for the next call. If location != NULL then set location to the matching location. Then in location's main() (see location_main.c) it prints (if code/name != NULL) both the return value and then the name/code, depending on whether -N is used. When *idx >= the sizeof the table or no more matches are found then the functions will return NULL, signalling to location's main() that there are no more matches. This also means that instead of calling err() on NULL return value it just exits 1 if -a is used and no matches are found.
Note that without -N -s and -a are not very useful as the function that does country code checks explicitly checks for two characters so there's no real substring match that can be done. However the function was added to have matching functions.
Use of -s requires at least one arg.
Use of -a with an exact country name (if -N) is not very useful as it will only find an exact match (obviously). Nevertheless the only error condition is if -s is used without an arg.
With -a if -v 1 show text in the form of:
XX ==> Anonymous location
DE ==> Germany
or more generally:
foo ==> bar
and
Anonymous location ==> XX
DE ==> Germany
...
Example command and output:
./soup/location -a -s -N -v 1 germ
German Democratic Republic ==> DD
Germany ==> DE
The joke here, of course, is that 'Germ'any is a country full of 'germ ridden people' (obviously not but it's a fun pun of mine :-) ).
Note that chkentry does NOT use these new features as the checks must be exact in that tool. The rationale of these changes is to help users of mkiocccentry find the right country code, even if they know their own (as they can also find country codes / names for other countries).
New version of location is 1.0.1 2023-08-03.
New option -s searches by substring rather than exact match.
New option -a shows all matches. Only useful with -s as otherwise it's an exact match.
To implement -a we have two new re-entrant functions:
These are the same as lookup_location_name() and lookup_location_code() except that they allow for calling them additional times to get the next match. If idx != NULL set idx to the position + 1 for the next call. If location != NULL then set location to the matching location. Then in location's main() (see location_main.c) it prints (if code/name != NULL) both the return value and then the name/code, depending on whether -N is used. When *idx >= the sizeof the table or no more matches are found then the functions will return NULL, signalling to location's main() that there are no more matches. This also means that instead of calling err() on NULL return value it just exits 1 if -a is used and no matches are found.
Note that without -N -s and -a are not very useful as the function that does country code checks explicitly checks for two characters so there's no real substring match that can be done. However the function was added to have matching functions.
Use of -s requires at least one arg.
Use of -a with an exact country name (if -N) is not very useful as it will only find an exact match (obviously). Nevertheless the only error condition is if -s is used without an arg.
With -a if -v 1 show text in the form of:
or more generally:
and
Example command and output:
The joke here, of course, is that 'Germ'any is a country full of 'germ ridden people' (obviously not but it's a fun pun of mine :-) ).
Note that chkentry does NOT use these new features as the checks must be exact in that tool. The rationale of these changes is to help users of mkiocccentry find the right country code, even if they know their own (as they can also find country codes / names for other countries).