Write Output to environment variable?

So, I ran into this piece of code. It is part of a library I am trying to implement as a test. I did some google searching around and really don’t understand the argument of the function … it isn’t defined anywhere… I looked at environment variables, but is this setting the environment variable or calling the ERFI function … this one has me a bit stumped. I looked around also for some includes I might have been missing … no luck there.


/*+ Write output to ERFI_OUT environment variable or stderr. */
static void Write_Output(const char *buf, ERFI_Fault_Action FA)

// ERFI_Fault_Action FA
    FILE	*fp;

    if (Print_File_Name != NULL && FA == ERFI_Print_Env) {
	fp = Vfopen(Print_File_Name, "a");
	fprintf(fp, buf);
    } else {
	fprintf(stderr, buf);

There’s a tool call silver searcher:

Or, you can also just use plain grep from the command line. What you need to do is look for this in the code:


Or, you can do this:


I’d also look up ERFI_Print_Env. What you’re trying to do is find all the places this is used, then find where it’s defined. Being that it’s an environment variable it’ll probably come from some C calls to access the environment. To learn how that’s done start here:


Then you can also search for any uses of those functions with the above commands as well. Finally, there’s a terrible but very useful tool called cscope. It does these kinds of searches too, and I find if I’m trying to understand C code it’s very helpful.

Cool, thanks for your help, I was confused because assert and stdio are the only libs added and of course the code I am going through (Mersenne Twister) … . I will take a look and see where how far I am go. Thanks ! )