Where is the benefit to call a function to query individual parameters instead of the actual command if you still have to call the function for every parameter? Sorry it does not make sense to me. Perhaps you can provide a better explanation.
There are default kernel parameters that do not need to listed in /etc/sysctl.conf. You can use the sysctl command line utility to query and maintain kernel parameters.
sysctl -a | grep max
To query several entries in /etc/sysctl with one command you could use egrep and and query separate items using the pipe character, for instance:
egrep -i 'shmmax|shmall' /etc/sysctl.conf
You probably want to use -i to ignore case distinctions.