Exemple #1
0
static StringList
uclConstructOptList(String name, StringList given)
{
	StringList res;
	String flag;
	String tmp;
	Bool sep;
	
	flag = cfgLookupString(name, uclOptions);

	tmp = strConcat(name, "-sep");
	sep = cfgLookupBoolean(tmp, uclOptions);
	strFree(tmp);
	
	res = listNil(String);
	while (given) {
		if (sep) {
			res = listCons(String)(flag, res);
			res = listCons(String)(car(given), res);  
		}
		else {
			tmp = strConcat(flag, car(given));
			res = listCons(String)(tmp, res);
		}
		given = cdr(given);
	}
	return listNReverse(String)(res);
}
Exemple #2
0
String 
strNConcat(String s1, String s2)
{
	String s3 = strConcat(s1, s2);
	strFree(s1);
	return s3;
}
Exemple #3
0
static String
uclGetKeyName(String s)
{
	String r = strCopy(s);
	String mode, std;
	String tmp;
	mode   = uclIsCompileOnly ? "cc-" 	: "link-";
	std    = uclStdc 	  ? "std-" 	: "";
	tmp = r;

	r = strConcat(mode, r);
	strFree(tmp); tmp = r;
	r = strConcat(std, r);
	strFree(tmp); 

	return r;
}
Exemple #4
0
static void
openStreams()
{
    LPSTR outFile = strConcat(tmpDir, AXLOUT);
    LPSTR inFile  = strConcat(tmpDir, AXLIN);
    LPSTR errFile = strConcat(tmpDir, AXLERR);    

    win32out = fopen(outFile, "w+");
    win32in  = fopen(inFile, "r");
    win32err = fopen(errFile, "w");    
    
    if (!win32out || !win32err)
        FatalAppExit(0, "Cannot open output streams...");

    osSetStreams(win32in, win32out, win32err);
    
    stoFree(outFile);
    stoFree(inFile);
    stoFree(errFile);    
}
Exemple #5
0
local void
wglQuit()
{
    LPSTR   outFile = strConcat(tmpDir, AXLOUT);
    
    compGLoopFinish(fn, finfo);
    
    /* Clean output file */
    fclose(win32out);
    unlink(outFile);
    win32out = fopen(outFile, "w");
    stoFree(outFile);
    winaxlExit(0);
}
Exemple #6
0
AbSyn
abqParseLinesAsSeq(StringList lines)
{
	SrcLineList sll = listNil(SrcLine);

	while (lines != listNil(String))
	{
		char *p = car(lines);
		lines = cdr(lines);
		int indent;
		while (*p == ' ') { p++; indent++; }
		String tmp = strConcat(p, "\n");
		SrcLine line = slineNew(sposNone, indent, tmp);
		strFree(tmp);
		sll = listCons(SrcLine)(line, sll);
	}

	return abqParseSrcLines(listNReverse(SrcLine)(sll));
}
Exemple #7
0
local void
wglShowOutput(int editBox)
{
    LPSTR   outFile = strConcat(tmpDir, AXLOUT);
    char    buf [BUF_SIZE + 1];

    pfcAppendText(editBox, "\r\r\n");
    fseek(win32out, 0L, SEEK_SET);
    while (TRUE) {
        fgets(buf, BUF_SIZE, win32out);
        if (feof(win32out)) break;      /* <---- */
        if (buf[0] != 0)
            buf[pfcStrLen(buf) - 1] = 0; /* Remove 0x0A character */
         
        pfcAppendText(editBox, buf);
        pfcAppendText(editBox, "\r\r\n");
    }
    fclose(win32out);
    win32out = fopen(outFile, "w+");
    fseek(win32out, 0L, SEEK_SET);
    
    stoFree(outFile);
}
Exemple #8
0
static StringList
uclExpandLibs(StringList path0, StringList libs, String ext)
{
	StringList res = listNil(String);
	
	while (libs != listNil(String)) {
		String basename = car(libs);
		StringList path = path0;
                basename = strConcat("lib", basename);
		while (path != listNil(String)) {
			FileName name = fnameNew(car(path), basename, ext);
			if (fileIsOpenable(name, osIoRdMode)) {
				res = listCons(String)(fnameUnparse(name), res);
				break;
			}
			path = cdr(path);
		}
		if (path == listNil(String))
			printf("Warning: %s not found\n", basename);
                strFree(basename);
		libs = cdr(libs);
	}
	return listNReverse(String)(res);
}
private int intercloudGW_create(struct occi_category * optr, void * vptr, struct rest_request * rptr)
{
	struct occi_kind_node * nptr;
	struct intercloudGW * pptr;
	char sendstr[1024];
	char strtmp[1024];
	char srcdir[1024];
	char * response = NULL;
	char * token;
	listcc categoryAtr;
	PyObject    *pName=NULL, *pModule=NULL, *pDict=NULL, *pFunc=NULL,*result=NULL;

	PyThreadState* pythr=NULL;
	if (!( nptr = vptr ))
		return(0);
	else if (!( pptr = nptr->contents ))
		return(0);

	if(!(pptr->name)) strcpy(sendstr," ");
	else if(pptr->name[0]=='\0') strcpy(sendstr," ");
	else strcpy(sendstr,pptr->name);
	if(!(pptr->node)){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else if(pptr->node[0]=='\0'){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->node,',');
	if(!(pptr->account)){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else if(pptr->account[0]=='\0'){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->account,',');
	if(!(pptr->price)){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else if(pptr->price[0]=='\0'){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->price,',');
	if(!(pptr->state)){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else if(pptr->state[0]=='\0'){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->state,',');
		//           python interface
		sprintf(srcdir,"%s/pyaccords/pysrc",PYPATH);
		pythr = Py_NewInterpreter();
		python_path(srcdir);
		pName = PyString_FromString("intercloudGW");
		if(pName == NULL) printf("erro: in intercloudGW no such file name\n");
		else pModule = PyImport_Import(pName);
		if(pModule == NULL) printf("error: failed to load intercloudGW module\n");
		else pDict = PyModule_GetDict(pModule);
		if(pDict == NULL) printf("error: failed to load dict name in intercloudGW module\n");
		else pFunc = PyDict_GetItemString(pDict,"create");
		if(pFunc == NULL) printf("error: failed to load create function in intercloudGW module\n");
		else result=PyObject_CallFunction(pFunc,"s",sendstr);
		if(result) response=allocate_string(PyString_AsString( result ));
		Py_DECREF(pModule);
		Py_DECREF(pName);
		Py_EndInterpreter(pythr);

	resetListe(&categoryAtr);
	token= strtok(response,",");
	for(; token != NULL ;)
	{
		addBacke(&categoryAtr,token);
		token=strtok(NULL, ",");
	}
	elemm *pelem = categoryAtr.first;
	if(pelem){
		pptr->name = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->node = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->account = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->price = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->state = pelem->value;
	}
	return 1;
}
/*	-----------------------------------------------------------------	*/
int	restart_ec2_instance( struct amazonEc2 * pptr )
{
	struct	ec2_subscription * subptr = (struct ec2_subscription *) 0;
	int     status = 0;
	char srcdir[1024];
	char * response;
	char * token;
	char sendstr[1024]=" ";
	char strtmp[1024]=" ";
	listcc	categoryAtr;
	PyObject    *pName=NULL, *pModule=NULL, *pDict=NULL, *pFunc=NULL,*result=NULL;
	PyThreadState* pythr=NULL;

	/* ------------------------ */
	/* prepare the subscription */
	/* ------------------------ */
	if (!( pptr ))
		return(118);
	else if (!(subptr = use_ec2_configuration( get_default_agent(),default_tls(),pptr->profile )))
		return(118);
		
	if(!(strValid(pptr->id))) strcpy(sendstr," ");
	else strcpy(sendstr,pptr->id);

	if(!(strValid(pptr->name))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->name,',');

	if(!(strValid(pptr->flavor))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->flavor,',');
	
	if(!(strValid(pptr->image))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->image,',');
	
	if(!(strValid(pptr->original))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->original,',');
	
	if(!(strValid(pptr->profile))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->profile,',');

	if(!(strValid(pptr->node))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->node,',');
	
	if(!(strValid(pptr->price))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->price,',');

	if(!(strValid(pptr->account))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->account,',');

	if(!(strValid(pptr->number))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->number,',');

	if(!(strValid(pptr->rootpass))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->rootpass,',');

	if(!(strValid(pptr->reference))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->reference,',');

	if(!(strValid(pptr->network))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->network,',');

	if(!(strValid(pptr->access))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->access,',');

	if(!(strValid(pptr->accessip))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->accessip,',');

	if(!(strValid(pptr->keypair))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->keypair,',');

	if(!(strValid(pptr->placementgroup))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->placementgroup,',');

	if(!(strValid(pptr->publicaddr))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->publicaddr,',');

	 if(!(strValid(pptr->privateaddr))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->privateaddr,',');

	 if(!(strValid(pptr->firewall))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->firewall,',');

	if(!(strValid(pptr->group))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->group,',');

	if(!(strValid(pptr->zone))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->zone,',');

	if(!(strValid(pptr->hostname))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->hostname,',');

	if(!(strValid(pptr->workload))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->workload,',');

	if(!(strValid(pptr->agent))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->agent,',');

	sprintf(strtmp,"%d",pptr->when);
	if(strValid(strcmp)) strConcat(sendstr,strtmp,',');
	else strConcat(sendstr," ",',');
	
	sprintf(strtmp,"%d",pptr->state);
	if(strValid(strtmp)) strConcat(sendstr,strtmp,',');
	else strConcat(sendstr," ",',');	

	//           python interface
	sprintf(srcdir,"%s/pyaccords/pysrc",PYPATH);
	pythr = Py_NewInterpreter();
	python_path(srcdir);
	pName = PyString_FromString("amazonEc2Act");
	if(pName == NULL) printf("erro: in amazonEc2Act.py no such file name\n");
	else pModule = PyImport_Import(pName);
	if(pModule == NULL) printf("error: failed to load amazonEc2Act module\n");
	else pDict = PyModule_GetDict(pModule);
	if(pDict == NULL) printf("error: failed to load dict name in amazonEc2Act module\n");
	else pFunc = PyDict_GetItemString(pDict,"restart");
	if(pFunc == NULL) printf("error: failed to load start function in amazonEc2Act module\n");
	else result=PyObject_CallFunction(pFunc,"ssss",subptr->accesskey,subptr->secretkey,subptr->zone,sendstr);
		
	if (!result || PyErr_Occurred())
        {
       		PyErr_Print();
       		return (0);
       	}

	response=allocate_string(PyString_AsString( result ));
	Py_DECREF(pModule);
	Py_DECREF(pName);
	Py_EndInterpreter(pythr);

	resetListe(&categoryAtr);
	token= strtok(response,",");
	for(; token != NULL ;)
	{
		addBacke(&categoryAtr,token);
		token=strtok(NULL, ",");
	}
	elemm *pelem = categoryAtr.first;
	if(pelem){
		pptr->id = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->name = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->flavor = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->image = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->original = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->profile = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->node = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->price = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->account = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->number = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->rootpass = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->reference = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->network = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->access = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->accessip = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->keypair = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->placementgroup = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->publicaddr = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->privateaddr = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->firewall = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->group = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->zone = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->hostname = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->workload = pelem->value;
		pelem = pelem->next;
	}
        if(pelem){
		pptr->agent = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->when = atoi(pelem->value);
		pelem = pelem->next;
	}
	if(pelem){
		pptr->state = atoi(pelem->value);
	}

	return status;

}
/*-------------------------------------------------------------------------------*/
struct rest_response * start_intercloudGW(
	struct occi_category * optr,
	struct rest_client * cptr,
	struct rest_request * rptr,
	struct rest_response * aptr,
	void * vptr )
{
	struct intercloudGW * pptr;
	char sendstr[1024]=" ";
	char strtmp[1024]=" ";
	int status;
	char message[1024];
	char srcdir[1024];
	char * response = NULL;
	char * token;
	FILE * exp_file;
	listcc restResponse;
	PyObject    *pName=NULL, *pModule=NULL, *pDict=NULL, *pFunc=NULL,*result=NULL;

	PyThreadState* pythr=NULL;
	if (!( pptr = vptr ))
		return( rest_html_response( aptr, 404, "Invalid Action" ) );
	else{
		if(!(pptr->name))strcpy(sendstr," ");
		else if(pptr->name[0]=='\0') strcpy(sendstr," ");
		else strcpy(sendstr,pptr->name);
		if(!(pptr->node)){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else if(pptr->node[0]=='\0'){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else strConcat(sendstr,pptr->node,',');
		if(!(pptr->account)){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else if(pptr->account[0]=='\0'){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else strConcat(sendstr,pptr->account,',');
		if(!(pptr->price)){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else if(pptr->price[0]=='\0'){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else strConcat(sendstr,pptr->price,',');
		if(!(pptr->state)){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else if(pptr->state[0]=='\0'){
			strcpy(strtmp," ");
			strConcat(sendstr,strtmp,',');
		}
		else strConcat(sendstr,pptr->state,',');
		//           python interface
		sprintf(srcdir,"%s/pyaccords/pysrc",PYPATH);
		pythr = Py_NewInterpreter();
		python_path(srcdir);
		pName = PyString_FromString("intercloudGWAct");
		if(pName == NULL) printf("erro: in intercloudGWAct no such file name\n");
		else pModule = PyImport_Import(pName);
		if(pModule == NULL) printf("error: failed to load intercloudGWAct module\n");
		else pDict = PyModule_GetDict(pModule);
		if(pDict == NULL) printf("error: failed to load dict name in intercloudGW module\n");
		else pFunc = PyDict_GetItemString(pDict,"start");
		if(pFunc == NULL) printf("error: failed to load start function in intercloudGW module\n");
		else result=PyObject_CallFunction(pFunc,"s",sendstr);
		if(result) response=allocate_string(PyString_AsString( result ));
		Py_DECREF(pModule);
		Py_DECREF(pName);
		Py_EndInterpreter(pythr);

		resetListe(&restResponse);
		token= strtok(response,",");
		for(; token != NULL ;)
		{
			addBacke(&restResponse,token);
			token=strtok(NULL, ",");
		}
		elemm *pelem = restResponse.first;
		if(pelem){
			status = atoi(pelem->value);
			pelem = pelem->next;
		}
		if(pelem){
			strcpy(message, pelem->value);
			pelem = pelem->next;
		}
		return( rest_html_response( aptr, status, message ) );
	}
}
Exemple #12
0
Doc
docMerge(Doc doc1, Doc doc2)
{
	return docNewFrString(strConcat(docString(doc1), docString(doc2)));
}