getopt(argc, argv, "s:h:v:w") in main() should probably be getopt(argc, argv, "s:hvw") (only -s accepting an argument, as I understand it.)
"The options argument is a string that specifies the option characters that are valid for this program. An option character in this string can be followed by a colon (‘:’) to indicate that it takes a required argument. If an option character is followed by two colons (‘::’), its argument is optional; this is a GNU extension." - https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html
example; https://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html