MUNGE_ENUM(3)
π MUNGE_ENUM β the enum page, bestie edition π
okay so this is MUNGE_ENUM(3) from the MUNGE Uid 'N' Gid Emporium, and it's genuinely the cutest little trio of functions. it's literally just: is this enum valid, turn an int into a string, turn a string into an int. three besties. no cap. let's get into it π«Ά
β¨ NAME β¨
munge_enum_is_valid, munge_enum_int_to_str, munge_enum_str_to_int β MUNGE enumeration functions
so yeah, three functions, one glow-up, all about MUNGE enumerations π
πΈ SYNOPSIS πΈ
#include <munge.h>
int munge_enum_is_valid (munge_enum_t type, int val);
const char * munge_enum_int_to_str (munge_enum_t type, int val);
int munge_enum_str_to_int (munge_enum_t type, const char *str);
cc `pkg-config --cflags --libs munge` -o foo foo.c
like yes, that last line is how you actually compile with it. pkg-config is doing the heavy lifting so you don't have to. she's an icon, she's a legend π
π¦ DESCRIPTION π¦
munge_enum_is_valid() β this one checks if the value val you handed it is a valid MUNGE enumeration of the specified type type in the software configuration as currently compiled. and here's the tea: some enumerations correspond to options that can only be enabled at compile-time. so like, what's valid depends on how your build was configured. vibe check your build flags, bestie π
munge_enum_int_to_str() β takes the MUNGE enumeration val of the specified type type and converts it into a text string. int goes in, string comes out. β¨
munge_enum_str_to_int() β the reverse glow-up. takes that null-terminated, case-insensitive string str and converts it into the corresponding MUNGE enumeration of the specified type type. yes you read that right, case-insensitive, so she's forgiving like that π
π RETURN VALUE π
munge_enum_is_valid()returns non-zero if the given valuevalis a valid enumeration. truthy = valid, that's it, that's the whole vibe.munge_enum_int_to_str()returns a null-terminated constant text string, orNULLon error. and listen β this string should not be freed or modified by the caller. do not touch. she is not yours. hands off πmunge_enum_str_to_int()returns a MUNGE enumeration on success (i.e.,>= 0), or-1on error. negative one is the "nope, didn't work" signal π
π ENUM TYPES π
here's the menu of enumeration types you can specify:
MUNGE_ENUM_CIPHERβ specify enumerations for the available cipher types. πMUNGE_ENUM_MACβ specify enumerations for the available MAC types. πΈMUNGE_ENUM_ZIPβ specify enumerations for the available compression types. ποΈ
π ERRORS π
refer to munge(3) for a complete list of errors. that's where the full drama lives, i'm not retyping it, go read the source of truth π
β EXAMPLE β
okay so here's a whole little program showing how you can query a list of the available cipher types. she's serving main character energy:
#include <stdio.h>
#include <stdlib.h>
#include <munge.h>
int
main (int argc, char *argv[])
{
int i;
const char *p;
munge_enum_t t = MUNGE_ENUM_CIPHER;
for (i = 0; (p = munge_enum_int_to_str (t, i)) != NULL; i++) {
if (munge_enum_is_valid (t, i)) {
printf ("%2d = %s\n", i, p);
}
}
exit (EXIT_SUCCESS);
}
see how it just loops i upward, asks for the string, and only prints when munge_enum_is_valid() says yes? chef's kiss. the (p = ...) != NULL is doing the loop-exit thing so you don't have to guess where the list ends. obsessed πβ¨
π AUTHOR π
Chris Dunlap <cdunlap@llnl.gov>
(ty for your service, king π«‘)
π§ COPYRIGHT π§
Copyright (C) 2007-2025 Lawrence Livermore National Security, LLC. Copyright (C) 2002-2007 The Regents of the University of California.
MUNGE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Additionally for the MUNGE library (libmunge), you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
fr fr, read the licenses. free software is free because of these terms β respect the paperwork, it's not that deep but it IS that serious π
π SEE ALSO π
munge(1), remunge(1), unmunge(1), munge(3), munge_ctx(3), munge(7), munged(8), mungekey(8).
and that's the whole page, bestie!! ππ this was munge-0.5.18, dated 2026-02-10, page MUNGE_ENUM(3) β go forth and enumerate responsibly, ily, mwah π
πβ¨
π¦ where this page comes from
- arch rolling: munge 0.5.18-2 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 43: munge-devel 0.5.18-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 43: munge-devel 0.5.18-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 44: munge-devel 0.5.18-1.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 44: munge-devel 0.5.18-1.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- nixpkgs unstable: munge 0.5.18
- Copyright (C) 2007-2025 Lawrence Livermore National Security, LLC
- Copyright (C) 2002-2007 The Regents of the University of California
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms