In C you need to pass a reference to the variable if you want to change an argument to a function. This is done by passing a pointer to the variable you want to change. In the function you use the C syntax for getting the value that a pointer points to.
Here is your code by way of example.
void change_state (boolean *var) {
if (*var == false) {
*var = true;
}
else {
*var = false;
}
}
void change_state2 (boolean *var) {
*var = !(*var);
}
void loop(){
boolean open = false;
change_state(&open); // pass a pointer to the open variable
//and now open = true
change_state(&open);
//and now open = false again
}
There are two version of the change_state function, the second one uses the C boolean 'not' syntax to invert the value.