#include <windows.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

extern char *_oscmd ;
extern HINSTANCE *_hinstance ;

int _argc;
char **_argv_arr;
char *_passed_name ;
#pragma startup argset 15

static void argset(void)
{
	char buf[200];
	char *bufp[100], *ocl ;
	char *_cmdline = _oscmd ;
  int inquote = 0 ;
	_argc = 0;
	while (*_cmdline) {
		while (isspace(*_cmdline)) _cmdline++;
		if (*_cmdline) {
			int i = 0;
			while ((inquote || !isspace(*_cmdline)) && *_cmdline)  {
				if (*_cmdline == '"') {
					inquote = !inquote ;
					_cmdline++ ;
					continue ;
				}
				buf[i++] = *_cmdline++;
			}
			buf[i++] = 0;
			bufp[_argc++] = strdup(buf) ;
		}
	}
	_argv_arr = calloc((_argc+1),sizeof(char *));
	memcpy(_argv_arr,bufp,_argc*sizeof(char *));
	_passed_name = _argv_arr[0] ;
	GetModuleFileName(_hinstance,buf,200) ;
	_argv_arr[0] = strdup(buf) ;
}