Xfennec here, thank you so much for this message. ManiaDrive was a small game made with a bunch of friends, I'm so glad it had an impact on you. I'm now a dad, and it makes me very emotional to read this. Thanks again.
The internet used to feel so human most of the time back in mid-90's because there was somehow an awareness that the person you where talking to was a human in a way we've lost.
Those where the days you could email a webmaster and get a response, when you hung around with like minded people in self-organised communities around a thing that interested them - like reddit without the massive negativity and astroturfing.
The modern internet (or web really) has lost much of that flavour, there are a few places that still maintain it with anonymity - HN is one, specific subreddits, the IRC server I've hung around forever, I've friends on there going back more than 15 years, we where all early 20's computer geeks, now a lot of them are married with kids or have kids on the way - I know a tonne of details about them personally and sometimes don't know their real name.
I do see some echoes of that world in some modern platforms (discord for specific games (in my case Arma) captures some of it).
The way "switch" works in C is very weird. It behaves more like a "goto", where each "case ...:" is a label to which it can jump.
So when the character is '-', it starts just before the "if (0)" (this part is hidden within the ARG_BEGIN macro), and as you noted, it will never enter that block. However, when the character is 'a', 'b', 'c', or nothing (the end-of-string marker), it will jump directly to the corresponding "case ...:" label, even though it's within that "unreachable" block.
Because there's really a switch statement (hidden behind a macro) that will jump to labels within that block.
The fact that the if condition is false means it won't just run the whole block straight through but you can still jump to a label in it. A goto statement would also allow you to jump into an otherwise-unreachable block.
The whole `if` portion is for if the second character of the argument (after the initial `-`) is a second `-` [0].
In that case, the switch jumped to `case '-':` hidden within the macro, and the if statement is about processing long arguments (like `--help`). arguments only available as a short flag should never get executed as part of a short flag, so putting them inside the if(0) case is an easy option.
An alternative without if(0) of any variety would be:
ARG_BEGIN {
if (ARG_LONG("reverse")) case 'r': {
reverse = 1;
ARG_FLAG();
} else if (ARG_LONG("input")) case 'i': {
input = ARG_VAL();
} else if (ARG_LONG("output")) case 'o': {
output = ARG_VAL();
} else if (ARG_LONG("help")) case 'h': case '?': {
printf("Usage: %s [OPTION...] [STRING...]\n", argv0);
puts("Example usage of arg.h\n");
puts("Options:");
puts(" -a, set a to true");
puts(" -b, set a to true");
puts(" -c, set a to true");
puts(" -r, --reverse set reverse to true");
puts(" -i, --input=STR set input string to STR");
puts(" -o, --output=STR set output string to STR");
puts(" -h, --help display this help and exit");
return EXIT_SUCCESS;
} else { default:
fprintf(stderr,
"%s: invalid option '%s'\n"
"Try '%s --help' for more information.\n",
argv0, *argv, argv0);
return EXIT_FAILURE;
}
break;
case 'a': a = 1; ARG_FLAG(); break;
case 'b': b = 1; ARG_FLAG(); break;
case 'c': c = 1; ARG_FLAG(); break;
case '\0': readstdin = 1; break;
} ARG_END;
The downside is that those few short flag only arguments no longer line up nicely with the others, and they come after the default, which could be a little bit confusing.
Footnote:
[0] Except if that second dash is the last character of the argument, in which case -- is the end of flags marker, meaning any further arguments that begin with `-` are just funky positional paramaters
We've build our own automated hosting infrastructure* a few years ago on top of libvirt. Using the libvirt API was a breeze and libvirt is rock solid since day one for us, I can only recommend this project.
We're using libvirt-go binding (Daniel Berrangé and his team is doing a excellent job maintaining it!), and KVM/QEMU hypervisior. For a small team like us, it's incredibly valuable to have access to such powerful tools in a such easy way.