SAFE_PARSE_ID_LIST(3)

πŸ“¦ version 1.0.5, in nixos 26.05, nixpkgs unstable

πŸ’– SAFE_PARSE_ID_LIST(3) πŸ’–

okay so bestie, welcome to SAFE_PARSE_ID_LIST(3) β€” the manual page all about parsing id lists into a safe_id_range_list. It's giving β€œtiny parser, big rules” energy, and we're gonna go through every single detail, no cap. ✨

🌸 NAME 🌸

safe_parse_id_list, safe_parse_uid_list, safe_parse_gid_list β€” parse a string for ids and store them in the safe_id_range_list. πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include "safe_id_range_list.h"

struct safe_id_range_list;
typedef struct safe_id_range_list safe_id_range_list;

int safe_parse_id_list(safe_id_range_list list, const char *value);
int safe_parse_uid_list(safe_id_range_list list, const char *value);
int safe_parse_gid_list(safe_id_range_list list, const char *value);

πŸ¦‹ DESCRIPTION πŸ¦‹

These functions add values to the list by parsing the value string. safe_parse_id_list only allows numeric values, while safe_parse_uid_list and safe_parse_gid_list allow non-numeric values that are converted to user and group ids respectively.

These functions differ from safe_strto_id_list(3), safe_strto_uid_list(3), and safe_strto_gid_list(3) because they return an error if non-whitespace exists in value after parsing as much as possible, i.e. the whole string must be a valid id range list. 😭 literally no sneaky trailing junk allowed.

🧸 Parameters 🧸

  • list β€” the safe_id_range_list to add values to. Must be non-NULL. 🫢
  • value β€” the range list string to parse. Must be non-NULL. 🌟

🌈 Range List Syntax 🌈

The syntax of a range list string is a set of ranges each separated by colons. Each range is either a single id, or a hyphen ('-') separated set of ids β€” and heads up: the first must be less than or equal to the second, and the second value may be a valid user or group name depending the function used. If a user or group name is used as the first part of a range, the name must be separated from the hyphen by whitespace, because a hyphen is a legitimate character in a name. πŸ’… iykyk.

It is an error if the whole string to be parsed is not an id range list with optional whitespace at the end of the string. If it is not or another error occurs -1 is returned.

       <RANGE_LIST>
              := <RANGE>
              := <RANGE> <whitespace>* ':' <RANGE_LIST>

       <RANGE>
              := <ID>
              := <ID> '-' <ID>
              := <ID> '-' <whitespace>* '*'

       <ID>   := <whitespace>* <number>
              := <whitespace>* <text_name>

πŸ“ Example Range Lists πŸ“

  • 3 β€” adds the value 3 to the list. iconic.
  • 0:5:100-103 β€” adds the values 0, 5, 100, 101, 102, and 103 to the list. slay.
  • root: user1 - user2 : 1000-* β€” when parsed with safe_parse_uid_list, adds the values 0, 500, 501 and 1000 and greater to the list assuming the user names root, user1 and user2 have the values 0, 500 and 501 respectively. The space after user1 is mandatory. 🚨 do not skip that space, bestie.

πŸ”₯ RETURN VALUE πŸ”₯

The function returns 0 if no errors were encountered and only whitespace follows the parsed id range list. -1 is returned otherwise. errno is set to 0 on success and an appropriate value on error. πŸ’–

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” list or value was NULL. An invalid number or non-exist user or group name was encountered. The first element of a range was larger than the second. A value consisting entirely of whitespace was encountered. Or non-whitespace characters follow the parsed id range list. 🫠
  • ERANGE β€” a numeric value was encountered that was too large. 😳
  • ENOMEM β€” a memory allocation failed. πŸ’Έ

πŸ‘‘ AUTHOR πŸ‘‘

James A. Kupsch. πŸ’œ

🌟 SEE ALSO 🌟

http://research.cs.wisc.edu/mist/safefile

mwah πŸ’‹ β€” this page is from SAFE_PARSE_ID_LIST(3) and it's dated 2011-07-26. periodt. πŸŽ€

πŸ“¦ where this page comes from