Esempio n. 1
0
/**
 * Request host: [string] listen: [string] pid: [string] callback: [block].
 *
 * Sets up Storm Server.
 * Storm Server is an SCGI server. Both the Request Object Plugin and Storm Server
 * are based on S. Losen's CCGI library (http://libccgi.sourceforge.net/doc.html)
 * licensed LGPL.
 *
 * To set up a Storm Server, specify host (i.e. 'localhost'),
 * a port to listen to (i.e. 9000) a pid file '/var/run/mypid.pid' and a
 * callback block.
 *
 * Usage:
 *
 * Request host:'localhost' listen:4000 pid:'/var/run/storm.pid' callback: {
 *  Pen write: 'Content-type: text/html\n\n'.
 *  var fname  := Command env: 'DOCUMENT_URI'.
 *  var script := File new: '/var/www/webapp'+fname.
 *  script include.
 * }.
 * 
 * Here we set up a server listening to port 4000. The callback prints out
 * the content type header. Then, we extract the DOCUMENT URI, i.e. '/hello.ctr'
 * and map this to a path '/var/www/webapp/hello.ctr'
 * 
 * By default there is no output buffering, either create another callback or
 * simply override the '<' or 'Pen' object to buffer instead of outputting
 * directly.
 */
ctr_object* ctr_request_serve(ctr_object* myself, ctr_argument* argumentList) {
	char* host;
	char* pid;
	int   port;
	int   minidle = 8;
	int   maxidle = 8;
	int   maxreq  = 1000;
	int   maxproc = 100;
	ctr_object* val;
	openlog("stormserver", 0, LOG_DAEMON);
	val = ctr_request_internal_option(myself, "minidle");
	if (val!=NULL) minidle = (int) ctr_internal_cast2number(val)->value.nvalue;
	val = ctr_request_internal_option(myself, "maxidle");
	if (val!=NULL) maxidle = (int) ctr_internal_cast2number(val)->value.nvalue;
	val = ctr_request_internal_option(myself, "maxproc");
	if (val!=NULL) maxproc = (int) ctr_internal_cast2number(val)->value.nvalue;
	val = ctr_request_internal_option(myself, "maxreq");
	if (val!=NULL) maxreq = (int) ctr_internal_cast2number(val)->value.nvalue;
	host = ctr_heap_allocate_cstring( ctr_internal_cast2string( argumentList->object ) );
	pid = ctr_heap_allocate_cstring( ctr_internal_cast2string( argumentList->next->next->object ) );
	port = (int) round(ctr_internal_cast2number(argumentList->next->object)->value.nvalue);
	ctr_heap_free( host );
	ctr_heap_free( pid );
	CtrStdSCGICB = argumentList->next->next->next->object;
	CGI_prefork_server(host, port, pid,
        /* maxproc */ maxproc,
        /* minidle */ minidle,
        /* maxidle */ maxidle,
        /* maxreq */   maxreq, ctr_request_serve_callback);
    return myself;
}
Esempio n. 2
0
/**
 * [List] join: [String].
 *
 * Joins the elements of a list together in a string
 * separated by a specified glue string. The example
 * code results in the string: '1,2,3'.
 *
 * Usage:
 *
 * collection := List new.
 * collection append: 1, append: 2, append 3.
 * collection join: ','.
 *
 * In other languages:
 * Dutch: [Reeks] samenvoegen: [Tekst] | Maakt een tekst door
 * reekselementen samen te voegen met gespecificeerde koppelteken(s).
 */
ctr_object* ctr_array_join(ctr_object* myself, ctr_argument* argumentList) {
	int i;
	char* result;
	ctr_size len = 0;
	ctr_size pos;
	ctr_object* o;
	ctr_object* str;
	ctr_object* resultStr;
	ctr_object* glue = ctr_internal_cast2string(argumentList->object);
	ctr_size glen = glue->value.svalue->vlen;
	for(i=myself->value.avalue->tail; i<myself->value.avalue->head; i++) {
		o = *( myself->value.avalue->elements + i );
		str = ctr_internal_cast2string(o);
		pos = len;
		if (i == myself->value.avalue->tail) {
			len = str->value.svalue->vlen;
			result = ctr_heap_allocate(sizeof(char)*len);
		} else {
			len += str->value.svalue->vlen + glen;
			result = ctr_heap_reallocate(result, sizeof(char)*len );
			memcpy(result+pos, glue->value.svalue->value, glen);
			pos += glen;
		}
		memcpy(result+pos, str->value.svalue->value, str->value.svalue->vlen);
	}
	resultStr = ctr_build_string(result, len);
	if (i > myself->value.avalue->tail) ctr_heap_free( result );
	return resultStr;
}
Esempio n. 3
0
/**
 * Request serverOption: [string] is: [string].
 * 
 * Sets a server option, available server option for SCGI server include:
 * 
 * - minidle, minimum number of idle processes
 * - maxidle, maximum number of idle processes
 * - maxproc, maximum number of processes
 * - maxreq,  maximum number of concurrent requests to allow
 * 
 * Usage:
 * 
 * Request
 *  serverOption: 'minidle' is: 8,
 *  serverOption: 'maxreq'  is: 100.
 * 
 * This sets the minimum number of idle processes to 8 and the
 * maximum number of concurrent requests to 100, you can chain
 * multiple options using a comma (,).
 */
ctr_object* ctr_request_server_option(ctr_object* myself, ctr_argument* argumentList) {
	ctr_internal_object_set_property(
		myself,
		ctr_internal_cast2string(argumentList->object),
		ctr_internal_cast2string(argumentList->next->object),
		CTR_CATEGORY_PRIVATE_PROPERTY
	);
	return myself;
}
Esempio n. 4
0
/**
 * [Program] env: [Key] val: [Value]
 *
 * Sets the value of an environment variable.
 */
ctr_object* ctr_command_set_env(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* envVarNameObj;
	ctr_object* envValObj;
	char*       envVarNameStr;
	char*       envValStr;
	envVarNameObj = ctr_internal_cast2string(argumentList->object);
	envValObj = ctr_internal_cast2string(argumentList->next->object);
	envVarNameStr = malloc((envVarNameObj->value.svalue->vlen+1)*sizeof(char));
	CTR_2CSTR(envVarNameStr, envVarNameObj);
	CTR_2CSTR(envValStr, envValObj);
	setenv(envVarNameStr, envValStr, 1);
	return myself;
}
Esempio n. 5
0
/**
 * [List] find: [Object].
 *
 * Checks whether the specified object occurs in the list
 * and returns the index number if so.
 * If not, the index number -1 will be returned. Note that the comparison
 * will be performed by converting both values to strings.
 *
 * In other languages:
 * Dutch: [Reeks] vind: [Object]
 * Geeft de positie van het object terug of -1 als niet gevonden.
 */
ctr_object* ctr_array_index_of( ctr_object* myself, ctr_argument* argumentList ) {
	int64_t found = -1, i = 0;
	ctr_object* needle = ctr_internal_cast2string(argumentList->object);
	ctr_object* element;
	for(i = myself->value.avalue->tail; i < myself->value.avalue->head; i++) {
		element = ctr_internal_cast2string( (ctr_object*) *(myself->value.avalue->elements + i) );
		if (
		element->value.svalue->vlen == needle->value.svalue->vlen &&
		strncmp(element->value.svalue->value,needle->value.svalue->value,needle->value.svalue->vlen)==0) {
			found = i;
			break;
		}
	}
	return ctr_build_number_from_float(found);
}
Esempio n. 6
0
/**
 * [Map] put: [Element] at: [Key]
 *
 * Puts a key-value pair in a map.
 *
 * Usage:
 *
 * map put: 'hello' at: 'world'.
 *
 * In other languages:
 * Dutch: [Lijst] zet: [Object] bij: [Object]
 * Zet het gespecificeerde object element bij de plek die bekend staat als
 * het andere object. Net als bij een reeks, alleen in dit geval is het tweede
 * Object de sleutel waarmee het eerste object weer uit de lijst gevist kan
 * worden.
 */
ctr_object* ctr_map_put(ctr_object* myself, ctr_argument* argumentList) {
	char* key;
	long keyLen;
	ctr_object* putKey;
	ctr_object* putValue = argumentList->object;
	ctr_argument* nextArgument = argumentList->next;
	ctr_argument* emptyArgumentList = ctr_heap_allocate(sizeof(ctr_argument));
	emptyArgumentList->next = NULL;
	emptyArgumentList->object = NULL;

	putKey = ctr_send_message(nextArgument->object, CTR_DICT_TOSTRING, strlen(CTR_DICT_TOSTRING), emptyArgumentList);

	/* If developer returns something other than string (ouch, toString), then cast anyway */
	if (putKey->info.type != CTR_OBJECT_TYPE_OTSTRING) {
		putKey = ctr_internal_cast2string(putKey);
	}

	key = ctr_heap_allocate( putKey->value.svalue->vlen * sizeof( char ) );
	keyLen = putKey->value.svalue->vlen;
	memcpy(key, putKey->value.svalue->value, keyLen);
	ctr_internal_object_delete_property(myself, ctr_build_string(key, keyLen), 0);
	ctr_internal_object_add_property(myself, ctr_build_string(key, keyLen), putValue, 0);
	ctr_heap_free( emptyArgumentList );
	ctr_heap_free( key );
	return myself;
}
Esempio n. 7
0
/**
 * [Map] at: [Key]
 *
 * Retrieves the value specified by the key from the map.
 *
 * In other languages:
 * Dutch: [Lijst] bij: [Object] | Geeft de waarde bij de bijbehorende sleutel.
 */
ctr_object* ctr_map_get(ctr_object* myself, ctr_argument* argumentList) {

	ctr_argument* emptyArgumentList;
	ctr_object*   searchKey;
	ctr_object*   foundObject;

	emptyArgumentList = ctr_heap_allocate(sizeof(ctr_argument));
	emptyArgumentList->next = NULL;
	emptyArgumentList->object = NULL;

	searchKey = argumentList->object;

	/* Give developer a chance to define a key for array */
	searchKey = ctr_send_message(searchKey, CTR_DICT_TOSTRING, strlen(CTR_DICT_TOSTRING), emptyArgumentList);
	ctr_heap_free( emptyArgumentList );

	/* If developer returns something other than string (ouch, toString), then cast anyway */
	if (searchKey->info.type != CTR_OBJECT_TYPE_OTSTRING) {
		searchKey = ctr_internal_cast2string(searchKey);
	}

	foundObject = ctr_internal_object_find_property(myself, searchKey, 0);
	if (foundObject == NULL) foundObject = ctr_build_nil();
	return foundObject;
}
Esempio n. 8
0
/**
 * @internal
 * 
 * Returns an array from the request, either for GET, POST or COOKIE.
 */
ctr_object* ctr_request_array(ctr_object* myself, ctr_argument* argumentList, CGI_varlist* varlist) {
	ctr_object* cgiVarObject;
	ctr_object* list;
	char* cgiVar;
	const CGI_value* value;
	char* val;
	ctr_argument* arg;
	int i = 0;
	list = ctr_array_new(CtrStdArray, NULL);	
	cgiVarObject = ctr_internal_cast2string(argumentList->object);
	cgiVar = ctr_heap_allocate_cstring( cgiVarObject );
	value = CGI_lookup_all(varlist, (const char*)cgiVar);
	ctr_heap_free( cgiVar );
	if (value == NULL) {
		return list;
	}
	for (i = 0; value[i] != 0; i++) {
		arg = (ctr_argument*) ctr_heap_allocate( sizeof( ctr_argument ) );
		val = (char*) value[i];
		arg->object = ctr_build_string_from_cstring(val);
		ctr_array_push(list, arg);
		ctr_heap_free( arg );
	}
	return list;
}
Esempio n. 9
0
/**
 * StringReplaceWith
 *
 * Replaces needle with replacement in original string and returns
 * the result as a new string object.
 *
 * Usage:
 *
 * 'LiLo BootLoader' replace: 'L' with: 'l'. #lilo Bootloader
 */
ctr_object* ctr_string_replace_with(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* needle = ctr_internal_cast2string(argumentList->object);
	ctr_object* replacement = ctr_internal_cast2string(argumentList->next->object);
	char* dest;
	char* odest;
	char* src = myself->value.svalue->value;
	char* ndl = needle->value.svalue->value;
	char* rpl = replacement->value.svalue->value;
	long hlen = myself->value.svalue->vlen;
	long nlen = needle->value.svalue->vlen;
	long rlen = replacement->value.svalue->vlen;
	long dlen = hlen;
	char* p;
	long i = 0;
	long offset = 0;
	long d;
	dest = (char*) malloc(dlen*sizeof(char));
	odest = dest;
	if (nlen == 0 || hlen == 0) {
		return ctr_build_string(src, hlen);
	}
	while(1) {
		p = ctr_internal_memmem(src, hlen, ndl, nlen, 0);
		if (p == NULL) break;
		d = (dest - odest);
		if ((dlen - nlen + rlen)>dlen) {
			dlen = (dlen - nlen + rlen);
			odest = (char*) realloc(odest, dlen * sizeof(char));
			dest = (odest + d);
		} else {
			dlen = (dlen - nlen + rlen);
		}
		offset = (p - src);
		memcpy(dest, src, offset);
		dest = dest + offset;
		memcpy(dest, rpl, rlen);
		dest = dest + rlen;
		hlen = hlen - (offset + nlen);
		src  = src + (offset + nlen);
		i++;
	}
	memcpy(dest, src, hlen);
	return ctr_build_string(odest, dlen);
}
Esempio n. 10
0
/**
 * [Map] has: [Object]
 *
 * Checks whether the map contains the specified value.
 * Note that the object gets converted to a string before
 * comparison. In case of a map or array this means the comparison
 * will be based on the serialized structure.
 * The example will output: True False False False False.
 *
 * Usage:
 *
 * ☞ shop := (Map new
 *	put: 'magazine' at: 'books',
 *	put: 'computer' at: 'electronics',
 *	put: 'lipstick' at: 'cosmetics'
 * ).
 * ✎ write: (shop has: 'computer'), end.
 * ✎ write: (shop has: 'sausage'), end.
 * ✎ write: (shop has: 'computers'), end.
 * ✎ write: (shop has: 'compute'), end.
 * ✎ write: (shop has: '2computer'), end.
 *
 * In other languages:
 * Dutch: [Lijst] heeft: [Object]
 * Beantwoord de vraag of het object op de lijst staat met Waar of Onwaar.
 */
ctr_object* ctr_map_has(ctr_object* myself, ctr_argument* argumentList) {
	int found = 0;
	ctr_mapitem* m;
	ctr_object* candidate;
	ctr_object* needle = ctr_internal_cast2string(argumentList->object);
	m = myself->properties->head;
	while(m) {
		candidate = ctr_internal_cast2string(m->value);
		if ( needle->value.svalue->vlen == candidate->value.svalue->vlen ) {
			if ( strncmp(
			candidate->value.svalue->value,
			needle->value.svalue->value, needle->value.svalue->vlen)) {
				found = 1;
			}
		}
		m = m->next;
	}
	return ctr_build_bool(found);
}
Esempio n. 11
0
/**
 * [Shell] call: [String]
 *
 * Performs a Shell operation. The Shell object uses a fluid API, so you can
 * mix shell code with programming logic. For instance to list the contents
 * of a directory use:
 *
 * Shell ls
 *
 * This will output the contents of the current working directly, you
 * can also pass keyword messages like so:
 *
 * Shell echo: 'Hello from the Shell!'.
 *
 * The example above will output the specified message to the console.
 * Every message you send will be turned into a string and dispatched to
 * the 'call:' message.
 */
ctr_object* ctr_shell_call(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* arg = ctr_internal_cast2string(argumentList->object);
	long vlen = arg->value.svalue->vlen;
	char* comString = malloc(vlen + 1);
	int r;
	memcpy(comString, arg->value.svalue->value, vlen);
	memcpy(comString+vlen,"\0",1);
	r = system(comString);
	return ctr_build_number_from_float( (ctr_number) r );
}
Esempio n. 12
0
/**
 * [Map] [Key]: [Value]
 *
 * You can fill the map object with key-value pairs by sending any
 * binary or keyword message that is not part if its standard behaviour.
 * Likewise you can retrieve any value from the map by sending the corresponding key
 * as a unary message. This allows for a very natural looking notation to create
 * and modify map objects.
 *
 * Usage:
 *
 * ☞ menu := Map new
 *	Margherita: 11.90,
 *	Hawaii: 12.99,
 *	QuattroFormaggi: 13.00.
 *
 * ✎ write: ( menu ? 'Hawaii' ), brk.
 * ✎ write: ( menu Margherita ), brk.
 *
 * In other languages:
 *
 * Dutch: [Lijst] [Object]: [Object]
 * Snelle en leesbare notatie om objecten toe te voegen aan een lijst.
 * Elk bericht dat niet wordt herkend wordt door de lijst als een
 * sleutel beschouwd, het opvolgende object zal op de plek worden
 * gezet in de lijst die door de sleutel wordt aangegeven. Dus om een
 * menukaart te vullen kan men zeggen:
 *
 * ☞ menu := Lijst nieuw.
 * menu pannekoek: 10. (hier kopppelen we pannekoek aan 10)
 *
 * Om nu op te vragen hoeveel een pannekoek kost schrijven we:
 * ☞ prijs := menu pannekoek.
 */
ctr_object* ctr_map_key_value(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* newKey;
	ctr_object* key = ctr_internal_cast2string(argumentList->object);
	newKey = key;
	if (key->value.svalue->vlen>1) {
		newKey = ctr_build_string(key->value.svalue->value,key->value.svalue->vlen-1);
	}
	argumentList->object = argumentList->next->object;
	argumentList->next->object = newKey;
	return ctr_map_put( myself, argumentList );
}
Esempio n. 13
0
/**
 * @internal
 * 
 * Returns a string from the request, either for GET, POST or COOKIE.
 */
ctr_object* ctr_request_string(ctr_object* myself, ctr_argument* argumentList, CGI_varlist* varlist) {
	ctr_object* cgiVarObject;
	char* cgiVar;
	char* value;
	cgiVarObject = ctr_internal_cast2string(argumentList->object);
	cgiVar = ctr_heap_allocate_cstring( cgiVarObject );
	value = (char*) CGI_lookup(varlist, (const char*)cgiVar);
	ctr_heap_free( cgiVar );
	if (value == NULL) return CtrStdNil;
	return ctr_build_string_from_cstring(value);
}
Esempio n. 14
0
/**
 * @internal
 *
 * Shell Object uses a fluid API.
 */
ctr_object* ctr_shell_respond_to_with(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object*   commandObj;
	ctr_object*   prefix;
	ctr_object*   suffix;
	ctr_argument* newArgumentList;
	char* command;
	int len;
	prefix = ctr_internal_cast2string(argumentList->object);
	suffix = ctr_internal_cast2string(argumentList->next->object);
	len = prefix->value.svalue->vlen + suffix->value.svalue->vlen;
	if (len == 0) return myself;
	command = (char*) malloc(len); /* actually we need +1 for the space between commands, but we dont because we remove the colon : !*/
	strncpy(command, prefix->value.svalue->value, prefix->value.svalue->vlen - 1); /* remove colon, gives room for space */
	strncpy(command + (prefix->value.svalue->vlen - 1), " ", 1); /* space to separate commands */
	strncpy(command + (prefix->value.svalue->vlen), suffix->value.svalue->value, suffix->value.svalue->vlen);
	commandObj = ctr_build_string(command, len);
	newArgumentList = CTR_CREATE_ARGUMENT();
	newArgumentList->object = commandObj;
	ctr_shell_call(myself, newArgumentList);
	return myself;
}
Esempio n. 15
0
/**
 * StringLastIndexOf
 *
 * Returns the index (character number, not the byte!) of the
 * needle in the haystack.
 * 
 * Usage:
 * 'find the needle' lastIndexOf: 'needle'. #9
 */
ctr_object* ctr_string_last_index_of(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* sub = ctr_internal_cast2string(argumentList->object);
	long hlen = myself->value.svalue->vlen;
	long nlen = sub->value.svalue->vlen;
	ctr_size uchar_index;
	ctr_size byte_index;
	char* p = ctr_internal_memmem(myself->value.svalue->value, hlen, sub->value.svalue->value, nlen, 1);
	if (p == NULL) return ctr_build_number_from_float((float)-1);
	byte_index = (ctr_size) ( (uintptr_t) p - (uintptr_t) (myself->value.svalue->value) );
	uchar_index = ctr_getutf8len(myself->value.svalue->value, byte_index);
	return ctr_build_number_from_float((float) uchar_index);
}
Esempio n. 16
0
/**
 * [File] writeBytes: [String].
 *
 * Takes a string and writes the bytes in the string to the file
 * object. Returns the number of bytes actually written.
 *
 * Usage:
 *
 * f := File new: '/path/to/file.txt'.
 * f open: 'r+'.
 * n := f writeBytes: 'Hello World'.
 * f close.
 *
 * The example above writes 'Hello World' to the specified file as bytes.
 * The number of bytes written is returned in variable n.
 */
ctr_object* ctr_file_write_bytes(ctr_object* myself, ctr_argument* argumentList) {
	int bytes, written;
	ctr_object* string2write;
	char* buffer;
	if (myself->value.rvalue == NULL) return myself;
	if (myself->value.rvalue->type != 1) return myself;
	string2write = ctr_internal_cast2string(argumentList->object);
	buffer = ctr_heap_allocate_cstring( string2write );
	bytes = string2write->value.svalue->vlen;
	written = fwrite(buffer, sizeof(char), (int)bytes, (FILE*)myself->value.rvalue->ptr);
	ctr_heap_free( buffer );
	return ctr_build_number_from_float((double_t) written);
}
Esempio n. 17
0
/**
 * [Program] env: [String]
 *
 * Returns the value of an environment variable.
 *
 * Usage:
 *
 * x := Command env: 'MY_PATH_VAR'.
 */
ctr_object* ctr_command_get_env(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* envVarNameObj;
	char*       envVarNameStr;
	char*       envVal;
	envVarNameObj = ctr_internal_cast2string(argumentList->object);
	envVarNameStr = malloc((envVarNameObj->value.svalue->vlen+1)*sizeof(char));
	strncpy(envVarNameStr, envVarNameObj->value.svalue->value, envVarNameObj->value.svalue->vlen);
	*(envVarNameStr + (envVarNameObj->value.svalue->vlen)) = '\0';
	envVal = getenv(envVarNameStr);
	if (envVal == NULL) {
		return CtrStdNil;
	}
	return ctr_build_string_from_cstring(envVal);
}
Esempio n. 18
0
/**
 * StringConcat
 *
 * Appends other string to self and returns the resulting
 * string as a new object.
 */
ctr_object* ctr_string_concat(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* strObject = ctr_internal_create_object(CTR_OBJECT_TYPE_OTSTRING);
	ctr_size n1;
	ctr_size n2;
	char* dest;
	ctr_object* newString;
	strObject = ctr_internal_cast2string(argumentList->object);
	n1 = myself->value.svalue->vlen;
	n2 = strObject->value.svalue->vlen;
	dest = calloc(sizeof(char), (n1 + n2));
	memcpy(dest, myself->value.svalue->value, n1);
	memcpy(dest+n1, strObject->value.svalue->value, n2);
	newString = ctr_build_string(dest, (n1 + n2));
	return newString;	
}
Esempio n. 19
0
ctr_object* ctr_number_add(ctr_object* myself, ctr_argument* argumentList) {
	ctr_argument* newArg;
	ctr_object* otherNum = argumentList->object;
	ctr_number a;
	ctr_number b;
	ctr_object* strObject;
	if (otherNum->info.type == CTR_OBJECT_TYPE_OTSTRING) {
		strObject = ctr_internal_create_object(CTR_OBJECT_TYPE_OTSTRING);
		strObject = ctr_internal_cast2string(myself);
		newArg = CTR_CREATE_ARGUMENT();
		newArg->object = otherNum;
		return ctr_string_concat(strObject, newArg);
	}
	a = myself->value.nvalue;
	b = otherNum->value.nvalue;
	return ctr_build_number_from_float((a+b));
}
Esempio n. 20
0
/**
 * [File] write: [String]
 *
 * Writes content to a file.
 */
ctr_object* ctr_file_write(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* str = ctr_internal_cast2string(argumentList->object);
	ctr_object* path = ctr_internal_object_find_property(myself, ctr_build_string("path",4), 0);
	FILE* f;
	ctr_size vlen;
	char* pathString;
	if (path == NULL) return CtrStdNil;
	vlen = path->value.svalue->vlen;
	pathString = malloc(vlen + 1);
	memcpy(pathString, path->value.svalue->value, vlen);
	memcpy(pathString+vlen,"\0",1);
	f = fopen(pathString, "wb+");
	free(pathString);
	if (!f) {
		CtrStdError = ctr_build_string_from_cstring("Unable to open file.\0");
		return CtrStdNil;
	}
	fwrite(str->value.svalue->value, sizeof(char), str->value.svalue->vlen, f);
	fclose(f);
	return myself;
}
Esempio n. 21
0
/**
 * [File] open: [string]
 *
 * Open a file with using the specified mode.
 *
 * Usage:
 *
 * f := File new: '/path/to/file'.
 * f open: 'r+'. #opens file for reading and writing
 *
 * The example above opens the file in f for reading and writing.
 */
ctr_object* ctr_file_open(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* pathObj = ctr_internal_object_find_property(myself, ctr_build_string_from_cstring( "path" ), 0);
	char* mode;
	char* path;
	FILE* handle;
	ctr_resource* rs = ctr_heap_allocate(sizeof(ctr_resource));
	ctr_object* modeStrObj = ctr_internal_cast2string( argumentList->object );
	if ( myself->value.rvalue != NULL ) {
		ctr_heap_free( rs );
		CtrStdFlow = ctr_build_string_from_cstring( "File has already been opened." );
		CtrStdFlow->info.sticky = 1;
		return myself;
	}
	if ( pathObj == NULL ) return myself;
	path = ctr_heap_allocate_cstring( pathObj );
	mode = ctr_heap_allocate_cstring( modeStrObj );
	handle = fopen(path,mode);
	ctr_heap_free( path );
	ctr_heap_free( mode );
	rs->type = 1;
	rs->ptr = handle;
	myself->value.rvalue = rs;
	return myself;
}
Esempio n. 22
0
/**
 * StringSplit
 *
 * Converts a string to an array by splitting the string using
 * the specified delimiter (also a string).
 */
ctr_object* ctr_string_split(ctr_object* myself, ctr_argument* argumentList) {
	char* str = myself->value.svalue->value;
	long len = myself->value.svalue->vlen;
	ctr_object* delimObject  = ctr_internal_cast2string(argumentList->object);
	char* dstr = delimObject->value.svalue->value;
	long dlen = delimObject->value.svalue->vlen;
	ctr_argument* arg;
	char* elem;
	ctr_object* arr = ctr_array_new(CtrStdArray, NULL);
	long i;
	long j = 0;
	char* buffer = malloc(sizeof(char)*len);
	for(i=0; i<len; i++) {
		buffer[j] = str[i];
		j++;
		if (ctr_internal_memmem(buffer, j, dstr, dlen, 0)!=NULL) {
			elem = malloc(sizeof(char)*(j-dlen));
			memcpy(elem,buffer,j-dlen);
			arg = malloc(sizeof(ctr_argument));
			arg->object = ctr_build_string(elem, j-dlen);
			ctr_array_push(arr, arg);
			free(arg);
			j=0;
		}
	}
	if (j>0) {
		elem = malloc(sizeof(char)*j);
		memcpy(elem,buffer,j);
		arg = malloc(sizeof(ctr_argument));
		arg->object = ctr_build_string(elem, j);
		ctr_array_push(arr, arg);
		free(arg);
	}
	free(buffer);
	return arr;
}
Esempio n. 23
0
/**
 * [Curl] respondTo: [string] with: [Object]
 *
 * Default response sets Curl option
 *
 **/
ctr_object* ctr_curl_respondto(ctr_object* myself, ctr_argument* argumentList) {

	ctr_object* msgObj = ctr_internal_cast2string(argumentList->object);
	char* msg = ctr_heap_allocate_cstring(msgObj);
	msg[strlen(msg)-1] = 0;

	ctr_object *argObj = argumentList->next->object;
	void* val = NULL;

	char msg_and_args[200];
	CURLoption opt;

	unsigned int cancel = 0;
	unsigned int ctrstr = 0;

	switch (argObj->info.type) {
		case CTR_OBJECT_TYPE_OTNIL:
			val = NULL;
			break;
		case CTR_OBJECT_TYPE_OTBOOL:
			val = &argObj->value.bvalue;
			break;
		case CTR_OBJECT_TYPE_OTNUMBER:
			val = &argObj->value.nvalue;
			break;
		case CTR_OBJECT_TYPE_OTSTRING:
			val = ctr_heap_allocate_cstring(argObj);
			ctrstr = 1;
			break;
		case CTR_OBJECT_TYPE_OTNATFUNC:
		case CTR_OBJECT_TYPE_OTBLOCK:
			argumentList->next->object = ctr_block_run(argObj, NULL, myself);
			ctr_curl_respondto(myself, argumentList);
			break;
		case CTR_OBJECT_TYPE_OTOBJECT:
		case CTR_OBJECT_TYPE_OTARRAY:
		case CTR_OBJECT_TYPE_OTMISC:
		case CTR_OBJECT_TYPE_OTEX:

			CtrStdFlow = ctr_build_string_from_cstring("Invalid argument type.");
			return myself;
	}
	if (val == NULL) { cancel = 1; }

#ifdef CTRPLUGIN_CURL_CURLOPT_URL
	else if (strcasecmp(msg, "url") == 0) { opt = CURLOPT_URL; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PATH_AS_IS
	else if (strcasecmp(msg, "path_as_is") == 0) { opt = CURLOPT_PATH_AS_IS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY
	else if (strcasecmp(msg, "proxy") == 0) { opt = CURLOPT_PROXY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PRE_PROXY
	else if (strcasecmp(msg, "pre_proxy") == 0) { opt = CURLOPT_PRE_PROXY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYPORT
	else if (strcasecmp(msg, "proxyport") == 0) { opt = CURLOPT_PROXYPORT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYTYPE
	else if (strcasecmp(msg, "proxytype") == 0) { opt = CURLOPT_PROXYTYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NOPROXY
	else if (strcasecmp(msg, "noproxy") == 0) { opt = CURLOPT_NOPROXY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTPPROXYTUNNEL
	else if (strcasecmp(msg, "httpproxytunnel") == 0) { opt = CURLOPT_HTTPPROXYTUNNEL; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CONNECT_TO
	else if (strcasecmp(msg, "connect_to") == 0) { opt = CURLOPT_CONNECT_TO; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SOCKS5_GSSAPI_SERVICE
	else if (strcasecmp(msg, "socks5_gssapi_service") == 0) { opt = CURLOPT_SOCKS5_GSSAPI_SERVICE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SOCKS5_GSSAPI_NEC
	else if (strcasecmp(msg, "socks5_gssapi_nec") == 0) { opt = CURLOPT_SOCKS5_GSSAPI_NEC; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SERVICE_NAME
	else if (strcasecmp(msg, "proxy_service_name") == 0) { opt = CURLOPT_PROXY_SERVICE_NAME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SERVICE_NAME
	else if (strcasecmp(msg, "service_name") == 0) { opt = CURLOPT_SERVICE_NAME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_INTERFACE
	else if (strcasecmp(msg, "interface") == 0) { opt = CURLOPT_INTERFACE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_LOCALPORT
	else if (strcasecmp(msg, "localport") == 0) { opt = CURLOPT_LOCALPORT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_LOCALPORTRANGE
	else if (strcasecmp(msg, "localportrange") == 0) { opt = CURLOPT_LOCALPORTRANGE; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_CACHE_TIMEOUT
	else if (strcasecmp(msg, "dns_cache_timeout") == 0) { opt = CURLOPT_DNS_CACHE_TIMEOUT; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_USE_GLOBAL_CACHE
	else if (strcasecmp(msg, "dns_use_global_cache") == 0) { opt = CURLOPT_DNS_USE_GLOBAL_CACHE; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_BUFFERSIZE
	else if (strcasecmp(msg, "buffersize") == 0) { opt = CURLOPT_BUFFERSIZE; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_PORT
	else if (strcasecmp(msg, "port") == 0) { opt = CURLOPT_PORT; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_TCP_FASTOPEN
	else if (strcasecmp(msg, "tcp_fastopen") == 0) { opt = CURLOPT_TCP_FASTOPEN; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_TCP_NODELAY
	else if (strcasecmp(msg, "tcp_nodelay") == 0) { opt = CURLOPT_TCP_NODELAY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_ADDRESS_SCOPE
	else if (strcasecmp(msg, "address_scope") == 0) { opt = CURLOPT_ADDRESS_SCOPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TCP_KEEPALIVE
	else if (strcasecmp(msg, "tcp_keepalive") == 0) { opt = CURLOPT_TCP_KEEPALIVE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TCP_KEEPIDLE
	else if (strcasecmp(msg, "tcp_keepidle") == 0) { opt = CURLOPT_TCP_KEEPIDLE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TCP_KEEPINTVL
	else if (strcasecmp(msg, "tcp_keepintvl") == 0) { opt = CURLOPT_TCP_KEEPINTVL; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_UNIX_SOCKET_PATH
	else if (strcasecmp(msg, "unix_socket_path") == 0) { opt = CURLOPT_UNIX_SOCKET_PATH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_ABSTRACT_UNIX_SOCKET
	else if (strcasecmp(msg, "abstract_unix_socket") == 0) { opt = CURLOPT_ABSTRACT_UNIX_SOCKET; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NETRC
	else if (strcasecmp(msg, "netrc") == 0) { opt = CURLOPT_NETRC; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NETRC_FILE
	else if (strcasecmp(msg, "netrc_file") == 0) { opt = CURLOPT_NETRC_FILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_USERPWD
	else if (strcasecmp(msg, "userpwd") == 0) { opt = CURLOPT_USERPWD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYUSERPWD
	else if (strcasecmp(msg, "proxyuserpwd") == 0) { opt = CURLOPT_PROXYUSERPWD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_USERNAME
	else if (strcasecmp(msg, "username") == 0) { opt = CURLOPT_USERNAME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PASSWORD
	else if (strcasecmp(msg, "password") == 0) { opt = CURLOPT_PASSWORD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_LOGIN_OPTIONS
	else if (strcasecmp(msg, "login_options") == 0) { opt = CURLOPT_LOGIN_OPTIONS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYUSERNAME
	else if (strcasecmp(msg, "proxyusername") == 0) { opt = CURLOPT_PROXYUSERNAME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYPASSWORD
	else if (strcasecmp(msg, "proxypassword") == 0) { opt = CURLOPT_PROXYPASSWORD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTPAUTH
	else if (strcasecmp(msg, "httpauth") == 0) { opt = CURLOPT_HTTPAUTH; }
#endif	
	
#ifdef CTRPLUGIN_CURL_CURLOPT_TLSAUTH_USERNAME
	else if (strcasecmp(msg, "tlsauth_username") == 0) { opt = CURLOPT_TLSAUTH_USERNAME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_TLSAUTH_USERNAME
	else if (strcasecmp(msg, "proxy_tlsauth_username") == 0) { opt = CURLOPT_PROXY_TLSAUTH_USERNAME; }
#endif
	
#ifdef CTRPLUGIN_CURL_CURLOPT_TLSAUTH_PASSWORD
	else if (strcasecmp(msg, "tlsauth_password") == 0) { opt = CURLOPT_TLSAUTH_PASSWORD; }
#endif 

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_TLSAUTH_PASSWORD
	else if (strcasecmp(msg, "proxy_tlsauth_password") == 0) { opt = CURLOPT_PROXY_TLSAUTH_PASSWORD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TLSAUTH_TYPE 
  else if (strcasecmp(msg, "tlsauth_type") == 0) {  opt = CURLOPT_TLSAUTH_TYPE; }
#endif 

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_TLSAUTH_TYPE 
  else if (strcasecmp(msg, "proxy_tlsauth_type") == 0) {  opt = CURLOPT_PROXY_TLSAUTH_TYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYAUTH 
  else if (strcasecmp(msg, "proxyauth") == 0) {  opt = CURLOPT_PROXYAUTH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SASL_IR 
  else if (strcasecmp(msg, "sasl_ir") == 0) {  opt = CURLOPT_SASL_IR; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_XOAUTH2_BEARER 
  else if (strcasecmp(msg, "xoauth2_bearer") == 0) {  opt = CURLOPT_XOAUTH2_BEARER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_AUTOREFERER 
  else if (strcasecmp(msg, "autoreferer") == 0) {  opt = CURLOPT_AUTOREFERER; }
#endif 

#ifdef CTRPLUGIN_CURL_CURLOPT_ACCEPT_ENCODING 
  else if (strcasecmp(msg, "accept_encoding") == 0) {  opt = CURLOPT_ACCEPT_ENCODING; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TRANSFER_ENCODING 
  else if (strcasecmp(msg, "transfer_encoding") == 0) {  opt = CURLOPT_TRANSFER_ENCODING; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FOLLOWLOCATION 
  else if (strcasecmp(msg, "followlocation") == 0) {  opt = CURLOPT_FOLLOWLOCATION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_UNRESTRICTED_AUTH 
  else if (strcasecmp(msg, "unrestricted_auth") == 0) {  opt = CURLOPT_UNRESTRICTED_AUTH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAXREDIRS 
  else if (strcasecmp(msg, "maxredirs") == 0) {  opt = CURLOPT_MAXREDIRS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POSTREDIR 
  else if (strcasecmp(msg, "postredir") == 0) {  opt = CURLOPT_POSTREDIR; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PUT 
  else if (strcasecmp(msg, "put") == 0) {  opt = CURLOPT_PUT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POST 
  else if (strcasecmp(msg, "post") == 0) {  opt = CURLOPT_POST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POSTFIELDS 
  else if (strcasecmp(msg, "postfields") == 0) {  opt = CURLOPT_POSTFIELDS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POSTFIELDSIZE 
  else if (strcasecmp(msg, "postfieldsize") == 0) {  opt = CURLOPT_POSTFIELDSIZE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POSTFIELDSIZE_LARGE 
  else if (strcasecmp(msg, "postfieldsize_large") == 0) {  opt = CURLOPT_POSTFIELDSIZE_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COPYPOSTFIELDS 
  else if (strcasecmp(msg, "copypostfields") == 0) {  opt = CURLOPT_COPYPOSTFIELDS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTPPOST 
  else if (strcasecmp(msg, "httppost") == 0) {  opt = CURLOPT_HTTPPOST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_REFERER 
  else if (strcasecmp(msg, "referer") == 0) {  opt = CURLOPT_REFERER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_USERAGENT 
  else if (strcasecmp(msg, "useragent") == 0) {  opt = CURLOPT_USERAGENT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTPHEADER 
  else if (strcasecmp(msg, "httpheader") == 0) {  opt = CURLOPT_HTTPHEADER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HEADEROPT 
  else if (strcasecmp(msg, "headeropt") == 0) {  opt = CURLOPT_HEADEROPT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXYHEADER 
  else if (strcasecmp(msg, "proxyheader") == 0) {  opt = CURLOPT_PROXYHEADER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTP200ALIASES 
  else if (strcasecmp(msg, "http200aliases") == 0) {  opt = CURLOPT_HTTP200ALIASES; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COOKIE 
  else if (strcasecmp(msg, "cookie") == 0) {  opt = CURLOPT_COOKIE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COOKIEFILE 
  else if (strcasecmp(msg, "cookiefile") == 0) {  opt = CURLOPT_COOKIEFILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COOKIEJAR 
  else if (strcasecmp(msg, "cookiejar") == 0) {  opt = CURLOPT_COOKIEJAR; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COOKIESESSION 
  else if (strcasecmp(msg, "cookiesession") == 0) {  opt = CURLOPT_COOKIESESSION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_COOKIELIST 
  else if (strcasecmp(msg, "cookielist") == 0) {  opt = CURLOPT_COOKIELIST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTPGET 
  else if (strcasecmp(msg, "httpget") == 0) {  opt = CURLOPT_HTTPGET; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTP_VERSION 
  else if (strcasecmp(msg, "http_version") == 0) {  opt = CURLOPT_HTTP_VERSION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_IGNORE_CONTENT_LENGTH 
  else if (strcasecmp(msg, "ignore_content_length") == 0) {  opt = CURLOPT_IGNORE_CONTENT_LENGTH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTP_CONTENT_DECODING 
  else if (strcasecmp(msg, "http_content_decoding") == 0) {  opt = CURLOPT_HTTP_CONTENT_DECODING; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_HTTP_TRANSFER_DECODING 
  else if (strcasecmp(msg, "http_transfer_decoding") == 0) {  opt = CURLOPT_HTTP_TRANSFER_DECODING; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_EXPECT_100_TIMEOUT_MS 
  else if (strcasecmp(msg, "expect_100_timeout_ms") == 0) {  opt = CURLOPT_EXPECT_100_TIMEOUT_MS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PIPEWAIT 
  else if (strcasecmp(msg, "pipewait") == 0) {  opt = CURLOPT_PIPEWAIT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_STREAM_DEPENDS 
  else if (strcasecmp(msg, "stream_depends") == 0) {  opt = CURLOPT_STREAM_DEPENDS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_STREAM_DEPENDS_E 
  else if (strcasecmp(msg, "stream_depends_e") == 0) {  opt = CURLOPT_STREAM_DEPENDS_E; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_STREAM_WEIGHT 
  else if (strcasecmp(msg, "stream_weight") == 0) {  opt = CURLOPT_STREAM_WEIGHT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAIL_FROM 
  else if (strcasecmp(msg, "mail_from") == 0) {  opt = CURLOPT_MAIL_FROM; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAIL_RCPT 
  else if (strcasecmp(msg, "mail_rcpt") == 0) {  opt = CURLOPT_MAIL_RCPT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAIL_AUTH 
  else if (strcasecmp(msg, "mail_auth") == 0) {  opt = CURLOPT_MAIL_AUTH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TFTP_BLKSIZE 
  else if (strcasecmp(msg, "tftp_blksize") == 0) {  opt = CURLOPT_TFTP_BLKSIZE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TFTP_NO_OPTIONS 
  else if (strcasecmp(msg, "tftp_no_options") == 0) {  opt = CURLOPT_TFTP_NO_OPTIONS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTPPORT 
  else if (strcasecmp(msg, "ftpport") == 0) {  opt = CURLOPT_FTPPORT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_QUOTE 
  else if (strcasecmp(msg, "quote") == 0) {  opt = CURLOPT_QUOTE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_POSTQUOTE 
  else if (strcasecmp(msg, "postquote") == 0) {  opt = CURLOPT_POSTQUOTE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PREQUOTE 
  else if (strcasecmp(msg, "prequote") == 0) {  opt = CURLOPT_PREQUOTE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_APPEND 
  else if (strcasecmp(msg, "append") == 0) {  opt = CURLOPT_APPEND; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_USE_EPRT 
  else if (strcasecmp(msg, "ftp_use_eprt") == 0) {  opt = CURLOPT_FTP_USE_EPRT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_USE_EPSV 
  else if (strcasecmp(msg, "ftp_use_epsv") == 0) {  opt = CURLOPT_FTP_USE_EPSV; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_USE_PRET 
  else if (strcasecmp(msg, "ftp_use_pret") == 0) {  opt = CURLOPT_FTP_USE_PRET; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_CREATE_MISSING_DIRS 
  else if (strcasecmp(msg, "ftp_create_missing_dirs") == 0) {  opt = CURLOPT_FTP_CREATE_MISSING_DIRS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_RESPONSE_TIMEOUT 
  else if (strcasecmp(msg, "ftp_response_timeout") == 0) {  opt = CURLOPT_FTP_RESPONSE_TIMEOUT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_ALTERNATIVE_TO_USER 
  else if (strcasecmp(msg, "ftp_alternative_to_user") == 0) {  opt = CURLOPT_FTP_ALTERNATIVE_TO_USER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_SKIP_PASV_IP 
  else if (strcasecmp(msg, "ftp_skip_pasv_ip") == 0) {  opt = CURLOPT_FTP_SKIP_PASV_IP; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTPSSLAUTH 
  else if (strcasecmp(msg, "ftpsslauth") == 0) {  opt = CURLOPT_FTPSSLAUTH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_SSL_CCC 
  else if (strcasecmp(msg, "ftp_ssl_ccc") == 0) {  opt = CURLOPT_FTP_SSL_CCC; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_ACCOUNT 
  else if (strcasecmp(msg, "ftp_account") == 0) {  opt = CURLOPT_FTP_ACCOUNT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FTP_FILEMETHOD 
  else if (strcasecmp(msg, "ftp_filemethod") == 0) {  opt = CURLOPT_FTP_FILEMETHOD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_REQUEST 
  else if (strcasecmp(msg, "rtsp_request") == 0) {  opt = CURLOPT_RTSP_REQUEST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_SESSION_ID 
  else if (strcasecmp(msg, "rtsp_session_id") == 0) {  opt = CURLOPT_RTSP_SESSION_ID; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_STREAM_URI 
  else if (strcasecmp(msg, "rtsp_stream_uri") == 0) {  opt = CURLOPT_RTSP_STREAM_URI; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_TRANSPORT 
  else if (strcasecmp(msg, "rtsp_transport") == 0) {  opt = CURLOPT_RTSP_TRANSPORT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_CLIENT_CSEQ 
  else if (strcasecmp(msg, "rtsp_client_cseq") == 0) {  opt = CURLOPT_RTSP_CLIENT_CSEQ; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RTSP_SERVER_CSEQ 
  else if (strcasecmp(msg, "rtsp_server_cseq") == 0) {  opt = CURLOPT_RTSP_SERVER_CSEQ; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TRANSFERTEXT 
  else if (strcasecmp(msg, "transfertext") == 0) {  opt = CURLOPT_TRANSFERTEXT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_TRANSFER_MODE 
  else if (strcasecmp(msg, "proxy_transfer_mode") == 0) {  opt = CURLOPT_PROXY_TRANSFER_MODE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CRLF 
  else if (strcasecmp(msg, "crlf") == 0) {  opt = CURLOPT_CRLF; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RANGE 
  else if (strcasecmp(msg, "range") == 0) {  opt = CURLOPT_RANGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RESUME_FROM 
  else if (strcasecmp(msg, "resume_from") == 0) {  opt = CURLOPT_RESUME_FROM; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RESUME_FROM_LARGE 
  else if (strcasecmp(msg, "resume_from_large") == 0) {  opt = CURLOPT_RESUME_FROM_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CUSTOMREQUEST 
  else if (strcasecmp(msg, "customrequest") == 0) {  opt = CURLOPT_CUSTOMREQUEST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FILETIME 
  else if (strcasecmp(msg, "filetime") == 0) {  opt = CURLOPT_FILETIME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_DIRLISTONLY 
  else if (strcasecmp(msg, "dirlistonly") == 0) {  opt = CURLOPT_DIRLISTONLY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NOBODY 
  else if (strcasecmp(msg, "nobody") == 0) {  opt = CURLOPT_NOBODY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_INFILESIZE 
  else if (strcasecmp(msg, "infilesize") == 0) {  opt = CURLOPT_INFILESIZE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_INFILESIZE_LARGE 
  else if (strcasecmp(msg, "infilesize_large") == 0) {  opt = CURLOPT_INFILESIZE_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_UPLOAD 
  else if (strcasecmp(msg, "upload") == 0) {  opt = CURLOPT_UPLOAD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAXFILESIZE 
  else if (strcasecmp(msg, "maxfilesize") == 0) {  opt = CURLOPT_MAXFILESIZE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAXFILESIZE_LARGE 
  else if (strcasecmp(msg, "maxfilesize_large") == 0) {  opt = CURLOPT_MAXFILESIZE_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TIMECONDITION 
  else if (strcasecmp(msg, "timecondition") == 0) {  opt = CURLOPT_TIMECONDITION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TIMEVALUE 
  else if (strcasecmp(msg, "timevalue") == 0) {  opt = CURLOPT_TIMEVALUE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TIMEOUT 
  else if (strcasecmp(msg, "timeout") == 0) {  opt = CURLOPT_TIMEOUT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TIMEOUT_MS 
  else if (strcasecmp(msg, "timeout_ms") == 0) {  opt = CURLOPT_TIMEOUT_MS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_LOW_SPEED_LIMIT 
  else if (strcasecmp(msg, "low_speed_limit") == 0) {  opt = CURLOPT_LOW_SPEED_LIMIT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_LOW_SPEED_TIME 
  else if (strcasecmp(msg, "low_speed_time") == 0) {  opt = CURLOPT_LOW_SPEED_TIME; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAX_SEND_SPEED_LARGE 
  else if (strcasecmp(msg, "max_send_speed_large") == 0) {  opt = CURLOPT_MAX_SEND_SPEED_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAX_RECV_SPEED_LARGE 
  else if (strcasecmp(msg, "max_recv_speed_large") == 0) {  opt = CURLOPT_MAX_RECV_SPEED_LARGE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_MAXCONNECTS 
  else if (strcasecmp(msg, "maxconnects") == 0) {  opt = CURLOPT_MAXCONNECTS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FRESH_CONNECT 
  else if (strcasecmp(msg, "fresh_connect") == 0) {  opt = CURLOPT_FRESH_CONNECT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_FORBID_REUSE 
  else if (strcasecmp(msg, "forbid_reuse") == 0) {  opt = CURLOPT_FORBID_REUSE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CONNECTTIMEOUT 
  else if (strcasecmp(msg, "connecttimeout") == 0) {  opt = CURLOPT_CONNECTTIMEOUT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CONNECTTIMEOUT_MS 
  else if (strcasecmp(msg, "connecttimeout_ms") == 0) {  opt = CURLOPT_CONNECTTIMEOUT_MS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_IPRESOLVE 
  else if (strcasecmp(msg, "ipresolve") == 0) {  opt = CURLOPT_IPRESOLVE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CONNECT_ONLY 
  else if (strcasecmp(msg, "connect_only") == 0) {  opt = CURLOPT_CONNECT_ONLY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_USE_SSL 
  else if (strcasecmp(msg, "use_ssl") == 0) {  opt = CURLOPT_USE_SSL; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RESOLVE 
  else if (strcasecmp(msg, "resolve") == 0) {  opt = CURLOPT_RESOLVE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_INTERFACE 
  else if (strcasecmp(msg, "dns_interface") == 0) {  opt = CURLOPT_DNS_INTERFACE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_LOCAL_IP4 
  else if (strcasecmp(msg, "dns_local_ip4") == 0) {  opt = CURLOPT_DNS_LOCAL_IP4; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_LOCAL_IP6 
  else if (strcasecmp(msg, "dns_local_ip6") == 0) {  opt = CURLOPT_DNS_LOCAL_IP6; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_DNS_SERVERS 
  else if (strcasecmp(msg, "dns_servers") == 0) {  opt = CURLOPT_DNS_SERVERS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_ACCEPTTIMEOUT_MS 
  else if (strcasecmp(msg, "accepttimeout_ms") == 0) {  opt = CURLOPT_ACCEPTTIMEOUT_MS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLCERT 
  else if (strcasecmp(msg, "sslcert") == 0) {  opt = CURLOPT_SSLCERT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSLCERT 
  else if (strcasecmp(msg, "proxy_sslcert") == 0) {  opt = CURLOPT_PROXY_SSLCERT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLCERTTYPE 
  else if (strcasecmp(msg, "sslcerttype") == 0) {  opt = CURLOPT_SSLCERTTYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSLCERTTYPE 
  else if (strcasecmp(msg, "proxy_sslcerttype") == 0) {  opt = CURLOPT_PROXY_SSLCERTTYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLKEY 
  else if (strcasecmp(msg, "sslkey") == 0) {  opt = CURLOPT_SSLKEY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSLKEY 
  else if (strcasecmp(msg, "proxy_sslkey") == 0) {  opt = CURLOPT_PROXY_SSLKEY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLKEYTYPE 
  else if (strcasecmp(msg, "sslkeytype") == 0) {  opt = CURLOPT_SSLKEYTYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSLKEYTYPE 
  else if (strcasecmp(msg, "proxy_sslkeytype") == 0) {  opt = CURLOPT_PROXY_SSLKEYTYPE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_KEYPASSWD 
  else if (strcasecmp(msg, "keypasswd") == 0) {  opt = CURLOPT_KEYPASSWD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_KEYPASSWD 
  else if (strcasecmp(msg, "proxy_keypasswd") == 0) {  opt = CURLOPT_PROXY_KEYPASSWD; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_ENABLE_ALPN 
  else if (strcasecmp(msg, "ssl_enable_alpn") == 0) {  opt = CURLOPT_SSL_ENABLE_ALPN; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_ENABLE_NPN 
  else if (strcasecmp(msg, "ssl_enable_npn") == 0) {  opt = CURLOPT_SSL_ENABLE_NPN; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLENGINE 
  else if (strcasecmp(msg, "sslengine") == 0) {  opt = CURLOPT_SSLENGINE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLENGINE_DEFAULT 
  else if (strcasecmp(msg, "sslengine_default") == 0) {  opt = CURLOPT_SSLENGINE_DEFAULT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_FALSESTART 
  else if (strcasecmp(msg, "ssl_falsestart") == 0) {  opt = CURLOPT_SSL_FALSESTART; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSLVERSION 
  else if (strcasecmp(msg, "sslversion") == 0) {  opt = CURLOPT_SSLVERSION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSLVERSION 
  else if (strcasecmp(msg, "proxy_sslversion") == 0) {  opt = CURLOPT_PROXY_SSLVERSION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_VERIFYHOST 
  else if (strcasecmp(msg, "ssl_verifyhost") == 0) {  opt = CURLOPT_SSL_VERIFYHOST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSL_VERIFYHOST 
  else if (strcasecmp(msg, "proxy_ssl_verifyhost") == 0) {  opt = CURLOPT_PROXY_SSL_VERIFYHOST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_VERIFYPEER 
  else if (strcasecmp(msg, "ssl_verifypeer") == 0) {  opt = CURLOPT_SSL_VERIFYPEER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSL_VERIFYPEER 
  else if (strcasecmp(msg, "proxy_ssl_verifypeer") == 0) {  opt = CURLOPT_PROXY_SSL_VERIFYPEER; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_VERIFYSTATUS 
  else if (strcasecmp(msg, "ssl_verifystatus") == 0) {  opt = CURLOPT_SSL_VERIFYSTATUS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CAINFO 
  else if (strcasecmp(msg, "cainfo") == 0) {  opt = CURLOPT_CAINFO; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_CAINFO 
  else if (strcasecmp(msg, "proxy_cainfo") == 0) {  opt = CURLOPT_PROXY_CAINFO; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_ISSUERCERT 
  else if (strcasecmp(msg, "issuercert") == 0) {  opt = CURLOPT_ISSUERCERT; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CAPATH 
  else if (strcasecmp(msg, "capath") == 0) {  opt = CURLOPT_CAPATH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_CAPATH 
  else if (strcasecmp(msg, "proxy_capath") == 0) {  opt = CURLOPT_PROXY_CAPATH; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CRLFILE 
  else if (strcasecmp(msg, "crlfile") == 0) {  opt = CURLOPT_CRLFILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_CRLFILE 
  else if (strcasecmp(msg, "proxy_crlfile") == 0) {  opt = CURLOPT_PROXY_CRLFILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_CERTINFO 
  else if (strcasecmp(msg, "certinfo") == 0) {  opt = CURLOPT_CERTINFO; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PINNEDPUBLICKEY 
  else if (strcasecmp(msg, "pinnedpublickey") == 0) {  opt = CURLOPT_PINNEDPUBLICKEY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_PINNEDPUBLICKEY 
  else if (strcasecmp(msg, "proxy_pinnedpublickey") == 0) {  opt = CURLOPT_PROXY_PINNEDPUBLICKEY; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_RANDOM_FILE 
  else if (strcasecmp(msg, "random_file") == 0) {  opt = CURLOPT_RANDOM_FILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_EGDSOCKET 
  else if (strcasecmp(msg, "egdsocket") == 0) {  opt = CURLOPT_EGDSOCKET; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_CIPHER_LIST 
  else if (strcasecmp(msg, "ssl_cipher_list") == 0) {  opt = CURLOPT_SSL_CIPHER_LIST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSL_CIPHER_LIST 
  else if (strcasecmp(msg, "proxy_ssl_cipher_list") == 0) {  opt = CURLOPT_PROXY_SSL_CIPHER_LIST; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_SESSIONID_CACHE 
  else if (strcasecmp(msg, "ssl_sessionid_cache") == 0) {  opt = CURLOPT_SSL_SESSIONID_CACHE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSL_OPTIONS 
  else if (strcasecmp(msg, "ssl_options") == 0) {  opt = CURLOPT_SSL_OPTIONS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PROXY_SSL_OPTIONS 
  else if (strcasecmp(msg, "proxy_ssl_options") == 0) {  opt = CURLOPT_PROXY_SSL_OPTIONS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_KRBLEVEL 
  else if (strcasecmp(msg, "krblevel") == 0) {  opt = CURLOPT_KRBLEVEL; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_GSSAPI_DELEGATION 
  else if (strcasecmp(msg, "gssapi_delegation") == 0) {  opt = CURLOPT_GSSAPI_DELEGATION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_AUTH_TYPES 
  else if (strcasecmp(msg, "ssh_auth_types") == 0) {  opt = CURLOPT_SSH_AUTH_TYPES; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 
  else if (strcasecmp(msg, "ssh_host_public_key_md5") == 0) {  opt = CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_PUBLIC_KEYFILE 
  else if (strcasecmp(msg, "ssh_public_keyfile") == 0) {  opt = CURLOPT_SSH_PUBLIC_KEYFILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_PRIVATE_KEYFILE 
  else if (strcasecmp(msg, "ssh_private_keyfile") == 0) {  opt = CURLOPT_SSH_PRIVATE_KEYFILE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_KNOWNHOSTS 
  else if (strcasecmp(msg, "ssh_knownhosts") == 0) {  opt = CURLOPT_SSH_KNOWNHOSTS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_KEYFUNCTION 
  else if (strcasecmp(msg, "ssh_keyfunction") == 0) {  opt = CURLOPT_SSH_KEYFUNCTION; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SSH_KEYDATA 
  else if (strcasecmp(msg, "ssh_keydata") == 0) {  opt = CURLOPT_SSH_KEYDATA; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_PRIVATE 
  else if (strcasecmp(msg, "private") == 0) {  opt = CURLOPT_PRIVATE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_SHARE 
  else if (strcasecmp(msg, "share") == 0) {  opt = CURLOPT_SHARE; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NEW_FILE_PERMS 
  else if (strcasecmp(msg, "new_file_perms") == 0) {  opt = CURLOPT_NEW_FILE_PERMS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_NEW_DIRECTORY_PERMS 
  else if (strcasecmp(msg, "new_directory_perms") == 0) {  opt = CURLOPT_NEW_DIRECTORY_PERMS; }
#endif

#ifdef CTRPLUGIN_CURL_CURLOPT_TELNETOPTIONS 
  else if (strcasecmp(msg, "telnetoptions") == 0) {  opt = CURLOPT_TELNETOPTIONS; }
#endif

	else {
		CtrStdFlow = ctr_build_string_from_cstring("Invalid option.");
		cancel = 1;
       	}
	if (!cancel) {
	       	CURLcode res = curl_easy_setopt(myself->value.rvalue->ptr, opt, val);
		if (res != CURLE_OK) {
			char* args = ctr_heap_allocate_cstring(ctr_internal_cast2string(argObj));
			snprintf(msg_and_args, 200, "Curl %s `%s` : %s", msg, args, (char *)curl_easy_strerror(res));
			CtrStdFlow = ctr_build_string_from_cstring(msg_and_args);
			ctr_heap_free(args);
		}
	}
	ctr_heap_free(msg);
	if (ctrstr) ctr_heap_free(val);
	return myself;
}
Esempio n. 24
0
/**
 * [Map] - [String]
 *
 * Deletes the entry, identified by the key specified in [String], from
 * the map.
 *
 * In other languages:
 * Dutch: [Lijst] - [Tekst] | Verwijderd de ingang voor aangegeven sleutel.
 */
ctr_object* ctr_map_delete(ctr_object* myself, ctr_argument* argumentList) {
	ctr_internal_object_delete_property(myself, ctr_internal_cast2string(argumentList->object), 0);
	return myself;
}
Esempio n. 25
0
/**
 * NumberToString
 *
 * Wrapper for cast function.
 */
ctr_object* ctr_number_to_string(ctr_object* myself, ctr_argument* argumentList) {
	return ctr_internal_cast2string(myself);
}
Esempio n. 26
0
ctr_object* ctr_block_set(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* key = ctr_internal_cast2string(argumentList->object);
	ctr_object* value = argumentList->next->object;
	ctr_internal_object_set_property(myself, key, value, 0);
	return myself; 
}
Esempio n. 27
0
/**
 * [Pen] write: [String]
 *
 * Writes string to console. 
 */
ctr_object* ctr_console_write(ctr_object* myself, ctr_argument* argumentList) {
	ctr_object* argument1 = argumentList->object;
	ctr_object* strObject = ctr_internal_cast2string(argument1);
	fwrite(strObject->value.svalue->value, sizeof(char), strObject->value.svalue->vlen, stdout);
	return myself;
}
Esempio n. 28
0
/**
 * InternalObjectIndexHash
 *
 * Given an object, this function will calculate a hash to speed-up
 * lookup.
 */
uint64_t ctr_internal_index_hash(ctr_object* key) {
	ctr_object* stringKey = ctr_internal_cast2string(key);
	return siphash24(stringKey->value.svalue->value, stringKey->value.svalue->vlen, CtrHashKey);
}