Exemple #1
0
void searchTree(TreeNode* root, ConstTable* MainConstTable, TypeTable* MainTypeTable, VarTable* MainVarTable, ProcedureTable* MainProcedureTable)
{
	enumlist = NULL;
	errorOccur = 0;
	current_procedure = (char*)malloc(100);
	memset(current_procedure, 0, 100);
	strcpy(current_procedure, "main");

	TreeNode *head = root->child->sibling->child;//routine_heads


	TreeNode *const_type = getChild(2, head);
	makeNewConstTable(const_type, MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	
	makeNewTypeTable(getChild(3, head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	
	makeNewVarTable((TreeNode*)getChild(4,head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);

	ProcedureTableNode* mainnode = makeNewProcedureTableNode();
	mainnode->name = "main";
	mainnode->returntype = NULL;
	mainnode->next = NULL;
	mainnode->paranum = mainnode->line_no = mainnode->size = 0;
	mainnode->paralist = NULL;
	int t = insertIntoProcedureTable(mainnode, MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	if(t == -1)
		return;

	makeNewProcedureTable((TreeNode*)getChild(5,head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);

	//if(getType("days", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable) != NULL)
	//	printType(getType("days", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));
	/*
	printf("\nnum: %d\n", get_args_list_num("testfunc", MainProcedureTable));
	*/
	printType(get_args_type(1, "testfunc", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));
	printType(get_return_type("testfunc", "main_testfunc", MainProcedureTable));
	
	int size, address, totallevel, leveltofather;
	char* label = (char*)malloc(100);
	memset(label, 0, 100);
	
	getAddress("k", "main_testfunc", &size, &label, &address, &totallevel, &leveltofather, MainConstTable, MainVarTable, MainProcedureTable);
	printf("size:%d address:%d totallevel:%d leveltofather:%d label:%s\n", size, address, totallevel, leveltofather, label);
	free(label);
	printf("ifexists: %d", ifExists("dt.year", "main_testfunc", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));


}
Exemple #2
0
int
remove_gtmProxy(char *name, bool clean_opt)
{
	FILE *f;
	int idx;

	/* Check if gtm proxy exists */
	if ((idx = gtmProxyIdx(name)) < 0)
	{
		elog(ERROR, "ERROR: %s is not a gtm proxy.\n", name);
		return 1;
	}
	/* Check if it is in use */
	if (ifExists(VAR_coordMasterServers, aval(VAR_gtmProxyServers)[idx]) ||
		ifExists(VAR_coordSlaveServers, aval(VAR_gtmProxyServers)[idx]) ||
		ifExists(VAR_datanodeMasterServers, aval(VAR_gtmProxyServers)[idx]) ||
		ifExists(VAR_datanodeSlaveServers, aval(VAR_gtmProxyServers)[idx]))
	{
		elog(ERROR, "ERROR: GTM Proxy %s is in use\n", name);
		return 1;
	}
	elog(NOTICE, "NOTICE: removing gtm_proxy %s\n", name);
	/* Clean */
	if (clean_opt)
	{
		char **nodelist = NULL;

		elog(NOTICE, "NOTICE: cleaning target resources.\n");
		AddMember(nodelist, name);
		clean_gtm_proxy(nodelist);
		CleanArray(nodelist);
	}
	/* Reconfigure */
	var_assign(&aval(VAR_gtmProxyNames)[idx], Strdup("none"));
	var_assign(&aval(VAR_gtmProxyServers)[idx], Strdup("none"));
	var_assign(&aval(VAR_gtmProxyPorts)[idx], Strdup("-1"));
	var_assign(&aval(VAR_gtmProxyDirs)[idx], Strdup("none"));
	handle_no_slaves();
	makeServerList();
	/* Update configuration file and backup it */
	if ((f = fopen(pgxc_ctl_config_path, "a")) == NULL)
	{
		/* Should it be panic? */
		elog(ERROR, "ERROR: cannot open configuration file \"%s\", %s\n", pgxc_ctl_config_path, strerror(errno));
		return 1;
	}
	fprintf(f, 
			"#===================================================\n"
			"# pgxc configuration file updated due to GTM proxy addition\n"
			"#        %s\n"
			"%s=%s\n"					/* gtmProxy */
			"%s=( %s )\n"				/* gtmProxyNames */
			"%s=( %s )\n"				/* gtmProxyServers */
			"%s=( %s )\n"				/* gtmProxyPorts */
			"%s=( %s )\n"				/* gtmProxyDirs */
			"#----End of reconfiguration -------------------------\n",
			timeStampString(date, MAXTOKEN+1),
			VAR_gtmProxy, sval(VAR_gtmProxy),
			VAR_gtmProxyNames, listValue(VAR_gtmProxyNames),
			VAR_gtmProxyServers, listValue(VAR_gtmProxyServers),
			VAR_gtmProxyPorts, listValue(VAR_gtmProxyPorts),
			VAR_gtmProxyDirs, listValue(VAR_gtmProxyDirs));
	fclose(f);
	backup_configuration();
	elog(NOTICE, "Done.\n");
	return 0;
}