Fix OpenBSD build of qemu-io

GCC 3.3.5 generates warnings for static forward declarations of data, so
rearrange code to use static forward declarations of functions instead.

Use <getopt.h> for optind instead of local definition.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
diff --git a/cmd.c b/cmd.c
index 3c89a05..cc70311 100644
--- a/cmd.c
+++ b/cmd.c
@@ -21,13 +21,12 @@
 #include <ctype.h>
 #include <errno.h>
 #include <sys/time.h>
+#include <getopt.h>
 
 #include "cmd.h"
 
 #define _(x)	x	/* not gettext support yet */
 
-extern int optind;
-
 /* from libxcmd/command.c */
 
 cmdinfo_t	*cmdtab;