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 value val is 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, or NULL on 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 -1 on 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 (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).

https://github.com/dun/munge


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