SAFE_STRTO_ID_LIST(3)
π SAFE_STRTO_ID_LIST(3) β bestie, letβs parse some ids π
πΈ NAME πΈ
safe_strto_id_list, safe_strto_uid_list, safe_strto_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;
void safe_strto_id_list(safe_id_range_list list, const char *value,
const char **endptr);
void safe_strto_uid_list(safe_id_range_list list, const char *value,
const char **endptr);
void safe_strto_gid_list(safe_id_range_list list, const char *value,
const char **endptr);
π¦ DESCRIPTION π¦
Okay so these functions add values to the list by parsing the value string. safe_strto_id_list only allows numeric values, while safe_strto_uid_list and safe_strto_gid_list allow non-numeric values that are converted to user and group ids respectively.
The functions safe_parse_id_list(3), safe_parse_uid_list(3), and safe_parse_gid_list(3) are simpler to use alternatives β lowkey convenient, fr fr.
π Parameters π
listβ Thesafe_id_range_listto add values to. Must be non-NULL.valueβ The range list string to parse. Must be non-NULL.endptrβ If non-NULL, the value pointed to by this parameter will be updated to point to the location just past the last character ofvalueparsed.
π 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 β the first must be less than or equal to the second, and the second value may be a valid user or group name depending on 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.
β οΈ Parsing stops when an expected punctuation mark (-or:) is not found. This is not an error, and*endptrmust be checked to detect this condition. Do not skip the vibe check onendptr, bestie π
A grammar for the range list is as follows:
<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 value3to the list.0:5:100-103β Adds the values0,5,100,101,102, and103to the list.root: user1 - user2 : 1000-*β When parsed withsafe_strto_uid_list, adds the values0,500,501and1000and greater to the list assuming the user namesroot,user1anduser2have the values0,500and501respectively. The space afteruser1is mandatory.
π RETURN VALUE π
No return value, but errno is set to 0 on success and an appropriate value on error. Also endptr, if non-NULL, will be set to the location in value just past the last value parsed. Slay.
π ERRORS π
EINVALβlistorvaluewasNULL. An invalid number or non-exist user or group name was encountered. The first element of a range was larger than the second. Or a value consisting entirely of whitespace was encountered.ERANGEβ A numeric value was encountered that was too large.ENOMEMβ A memory allocation failed.
π AUTHOR π
James A. Kupsch β iconic, honestly.
π«Ά SEE ALSO π«Ά
safe_init_id_range_list(3)safe_destroy_id_range_list(3)safe_parse_id_list(3)safe_parse_uid_list(3)safe_parse_gid_list(3)
http://research.cs.wisc.edu/mist/safefile
This page is dated 2011-07-26 and comes from the SAFE_STRTO_ID_LIST(3) manual. Stay safe out there, bestie πβ¨π
π¦ where this page comes from
- nixos 26.05: safefile 1.0.5
- nixpkgs unstable: safefile 1.0.5
- Copyright 2007-2008, 2011 James A. Kupsch
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms