/*
    analyzing all arguments of the function call
*/
void analyze_args(Exprs args, char* procName, char* callee, int paramNum)
{
    Expr first = args->first;
    Exprs rest = args->rest;
    if(first && getParamType(callee, paramNum)!=-1)
    {
        analyze_expr(first, procName);
        analyze_arg(first, callee, paramNum, procName);
    }
    else if(first && getParamType(callee, paramNum)==-1)
    {
        printf("function call %s has more number of parameter.\n",
                                                    callee);
        errorNum++;
        return;
    }
    if(rest == 0 && getParamType(callee, paramNum+1)!=-1)
    {
        printf("function call %s has less number of parameter.\n",
                                                    callee);
        errorNum++;
    }
    if(rest)
        analyze_args(rest, procName, callee, paramNum+1);

}
/*
    analyzing function call statements of procedure
    check if the callee function is defined
*/
void analyze_fncall(Stmt stmt, char* procName)
{
    if(procExist(stmt->info.fncall.id)==0)
    {
        printf("function %s dosen't exist.\n", stmt->info.fncall.id);
        errorNum++;
    }
    else if(stmt->info.fncall.args)
    {
        analyze_args(stmt->info.fncall.args,procName,stmt->info.fncall.id,0);
    }
}
Beispiel #3
0
int						main(int argc, char **argv)
{
	struct s_file	*sfile;
	t_lsargs		lsargs;

	if (argc == 0)
		exit(1);
	lsargs = analyze_args(argv);
	sfile = s_file_init(lsargs);
	initialize(sfile, lsargs);
	//free(sfile);//?
	s_file_free(sfile);		////
	return (0);
}
Beispiel #4
0
int		main(int ac, char **av)
{
	t_box	box;
	int		fd;

	ft_bzero(&box, sizeof(t_box));
	box.color = 0xFFFFFF;
	if (ac > 2)
		analyze_args(ac, av, &box);
	if (ac < 2)
		error_lem("NO ARGUMENT\n", &box);
	fd = open(av[ac - 1], O_RDONLY);
	setup_env(&box, fd);
	setup_map(&box);
	display_info();
	mlx_hook(box.win, 2, (1L << 0), command, &box);
	mlx_loop(box.mlx);
	return (0);
}
Beispiel #5
0
//
//	Windows メイン関数
//
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgs, int nWinMode)
{
    MSG msg;
	HWND hMain;
	int err;

	// 初期化
	install_flag = FALSE;
	uninstall_flag = FALSE;
	read_ini_flag = FALSE;
	start_flag = FALSE;
	no_error_flag = FALSE;
	question_flag = FALSE;
	ok_flag = FALSE;

	h_instance = hInstance;

	// 実行ディレクトリにある sexe.exe のフルパスを作成
	GetModuleFileName(NULL, module_name, sizeof(module_name));
	lstrcpy(execute_path, module_name);
	extract_directory(execute_path);
	lstrcpy(ini_name, execute_path);
	lstrcat(ini_name, _T("\\sexe.ini"));

	// コマンドライン解析
	analyze_args(lpszArgs);

	// サービスで動作しているか?
	service_flag = check_execute_service();
	// WindowsNT/2000 ?
	if(nt_flag) {
		// サービスとして動作中?
		if(service_flag) {
			// すでに動作中?
			if(!check_already()) {
				// サービスとして起動
				start_service();
			}
		} else {
			// 2011/5/31
			// コマンドラインパラメータでインストール・アンインストール
			if(install_flag) {
				TCHAR *ext;
				if(service_name[0] == _T('\0')) {
					if(!no_error_flag) {
						// サービス名を指定してください
						MessageBoxResourceText(NULL, IDS_ERROR_NO_SERVICE_NAME, NULL, ERROR_HEADER, MB_OK);
					}
					return ERROR_PARAMETER;
				}
				ext = extract_ext(exe_name);
				if(exe_name[0] == _T('\0') || (_tcsicmp(ext, _T("exe")) && _tcsicmp(ext, _T("bat")))) {
					if(!no_error_flag) {
						// プログラム名を指定してください
						MessageBoxResourceText(NULL, IDS_ERROR_NO_PROGRAM_NAME, NULL, ERROR_HEADER, MB_OK);
					}
					return ERROR_PARAMETER;
				}
				if(question_flag) {
					// サービス service_name を登録しますか?
					if(MessageBoxResourceText(NULL, IDS_QUESTION_INSTALL, service_name, ERROR_HEADER, MB_YESNO) != IDYES) {
						return ERROR_NO_INSTALL;
					}
				}
				if(!read_ini_flag) {
					// ini ファイルから読み出したのでなければ設定値を保存
					set_inifile();
				}
				// インストール
				if((err = install_service()) == ERROR_SUCCESS) {
					if(start_flag) {
						// サービス開始
						if(restart_service()) {
							if(ok_flag) {
								// サービス service_name を登録し、開始しました。
								MessageBoxResourceText(NULL, IDS_INSTALL_START_OK, service_name, HEADER, MB_OK);
							}
						} else if(!no_error_flag) {
							// サービス service_name を登録しましたが、開始に失敗しました。
							MessageBoxResourceText(NULL, IDS_ERROR_INSTALL_START, service_name, HEADER, MB_OK);
							return ERROR_START;
						}
					} else if(ok_flag) {
						// サービス service_name を登録しました。
						MessageBoxResourceText(NULL, IDS_INSTALL_OK, service_name, HEADER, MB_OK);
					}
				} else {
					if(!no_error_flag) {
						if(err == ERROR_SERVICE_EXISTS) {
							// すでに同名のサービスが登録済みです
							MessageBoxResourceText(NULL, IDS_ERROR_SAME_SERVICE, NULL, ERROR_HEADER, MB_OK);
						} else {
							// サービスに登録できませんでした。\nサービスの権限があるユーザーでログインして実行してください。
							MessageBoxResourceText(NULL, IDS_ERROR_INSTALL_SERVICE, NULL, ERROR_HEADER, MB_OK);
						}
					}
					return ERROR_INSTALL;
				}
			} else if(uninstall_flag) {
				if(service_name[0] == _T('\0')) {
					if(!no_error_flag) {
						// サービス名を指定してください
						MessageBoxResourceText(NULL, IDS_ERROR_NO_SERVICE_NAME, NULL, ERROR_HEADER, MB_OK);
					}
					return ERROR_PARAMETER;
				}
				if(question_flag) {
					// サービス service_name を削除しますか?
					if(MessageBoxResourceText(NULL, IDS_QUESTION_UNINSTALL, service_name, HEADER, MB_YESNO) != IDYES) {
						return ERROR_NO_INSTALL;
					}
				}
				if(service_install_flag) {
					// サービスから削除
					if(remove_service()) {
						if(ok_flag) {
							// サービス service_name を削除しました
							MessageBoxResourceText(NULL, IDS_UNINSTALL_OK, service_name, HEADER, MB_OK);
						}
					} else {
						if(!no_error_flag) {
							// サービスから削除できませんでした。\nサービスの権限があるユーザーでログインして実行してください。
							MessageBoxResourceText(NULL, IDS_ERROR_UNINSTALL_SERVICE, NULL, ERROR_HEADER, MB_OK);
						}
						return ERROR_INSTALL;
					}
				} else {
					if(!no_error_flag) {
						// サービス service_name は登録されていません
						MessageBoxResourceText(NULL, IDS_ERROR_NOT_INSTALL_SERVICE, service_name, ERROR_HEADER, MB_OK);
					}
					return ERROR_INSTALL;
				}
			} else {
				// 2010/6/10 Vista/7 で WM_DROPFILES を受ける
				funcChangeWindowMessageFilter ChangeWindowMessageFilter;
				if(ChangeWindowMessageFilter = (funcChangeWindowMessageFilter)GetProcAddress(LoadLibrary(_T("user32.dll")) ,"ChangeWindowMessageFilter")) {
					ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
					ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
					ChangeWindowMessageFilter(0x0049, MSGFLT_ADD);
				}

				// 設定ダイアログを表示
				hMain = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_SETUP), GetDesktopWindow(), (DLGPROC)MainFunc);
				ShowWindow(hMain, SW_SHOW);
				// Drag&Drop を受け入れる準備
				DragAcceptFiles(hMain, TRUE);
				while(GetMessage(&msg, NULL, 0, 0)) {
					if(!IsDialogMessage(hMain, &msg)) {
						TranslateMessage(&msg);
						DispatchMessage(&msg);
					}
				}
			}
		}
	} else {
		// Windows NT/2000/XP/Vista/7 で起動してください。
		MessageBoxResourceText(NULL, IDS_ERROR_OS, NULL, ERROR_HEADER, MB_OK);
	}
	return 0;
}