Esempio n. 1
0
static void test_string_substring_with_equal_large() {
	char* original_word = "hola";
	char* substring = string_substring(original_word, 0, 4);
	CU_ASSERT_STRING_EQUAL(substring, original_word);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
	free(substring);
}
Esempio n. 2
0
static void test_string_substring_extract_internal_text() {
        char* original_word = "hola mundo";
        char* substring = string_substring(original_word, 2, 5);
        CU_ASSERT_STRING_EQUAL(substring, "la mu");
        CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
        free(substring);
}
Esempio n. 3
0
static void test_string_substring_from_other_start() {
        char* original_word = "hola mundo!";
        char* substring = string_substring(original_word, 5, strlen(original_word) - 5);
        CU_ASSERT_STRING_EQUAL(substring, "mundo!");
        CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
        free(substring);
}
Esempio n. 4
0
static void test_string_substring_empty() {
	char* original_word = "";
	char* substring = string_substring(original_word, 0, 3);
	CU_ASSERT_STRING_EQUAL(substring, original_word);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
	free(substring);
}
Esempio n. 5
0
void mathg_math_cog_bsp (mathgMathCog *self) {
	gchar* s = NULL;
	mathgElmnt* _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gint _tmp1_ = 0;
	mathgElmnt _tmp2_ = {0};
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	mathgElmnt* _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	gint _tmp8_ = 0;
	gchar* _tmp9_ = NULL;
	_tmp0_ = (*self).stra;
	_tmp0__length1 = (*self).stra_length1;
	_tmp1_ = (*self).straind;
	_tmp2_ = _tmp0_[_tmp1_];
	_tmp3_ = _tmp2_.guess;
	_tmp4_ = g_strdup (_tmp3_);
	s = _tmp4_;
	_tmp5_ = (*self).stra;
	_tmp5__length1 = (*self).stra_length1;
	_tmp6_ = (*self).straind;
	_tmp7_ = strlen (s);
	_tmp8_ = _tmp7_;
	_tmp9_ = string_substring (s, (glong) 0, (glong) (_tmp8_ - 1));
	_g_free0 (_tmp5_[_tmp6_].guess);
	_tmp5_[_tmp6_].guess = _tmp9_;
	_g_free0 (s);
}
result test_string_substring_StringWithSubstring() {
	int passed = 0;
	char* description = "string_substring(char*, char*) : StringWithSubstring CASE";

	passed = is_true(string_substring("abc", "ab"));

	return (result){passed, description};
}
result test_string_substring_NULL() {
	int passed = 0;
	char* description = "string_substring(char*, char*) : NULL CASE";

	passed = is_false(string_substring(0, 0));

	return (result){passed, description};
}
result test_string_substring_EmptyStrings() {
	int passed = 0;
	char* description = "string_substring(char*, char*) : 2EmptyString CASE";

	passed = is_true(string_substring("", ""));

	return (result){passed, description};
}
result test_string_substring_StringWithBiggerSuperstring() {
	int passed = 0;
	char* description = "string_substring(char*, char*) : StringWithBiggerSuperstring CASE";

	passed = is_false(string_substring("abc", "abcdefg"));

	return (result){passed, description};
}
Esempio n. 10
0
char* header(int numero){										//Recibe numero de bytes, y lo devuelve en 4 bytes (Ej. recibe "2" y devuelve "0002")
	char* asd=string_new();
	char* num_char = string_itoa(numero);
	num_char = string_reverse(num_char);
	string_append(&asd,num_char);
	free(num_char);
	string_append(&asd,"0000");
	char* longitud=string_substring(asd,0,4);
	free(asd);
	char* longitudPosta=string_reverse(longitud);
	free(longitud);
	return longitudPosta;
}
Esempio n. 11
0
gchar* system_text_regular_expressions_capture_GetLeftSubString (SystemTextRegularExpressionsCapture* self) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gchar* _tmp2_ = NULL;
#line 73 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 75 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp0_ = self->_text;
#line 75 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp1_ = self->_index;
#line 75 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp2_ = string_substring (_tmp0_, (glong) 0, (glong) _tmp1_);
#line 75 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	result = _tmp2_;
#line 75 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	return result;
#line 335 "RegexCapture.c"
}
Esempio n. 12
0
static void plank_services_logger_print_log (PlankServicesLoggerLogMessage* log) {
	PlankServicesLoggerLogMessage* _tmp0_ = NULL;
	PlankServicesLogLevel _tmp1_ = 0;
	PlankServicesLogLevel _tmp2_ = 0;
	FILE* _tmp3_ = NULL;
	PlankServicesLoggerLogMessage* _tmp4_ = NULL;
	PlankServicesLogLevel _tmp5_ = 0;
	PlankServicesLogLevel _tmp6_ = 0;
	GEnumValue* _tmp7_;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	FILE* _tmp12_ = NULL;
	PlankServicesLoggerLogMessage* _tmp13_ = NULL;
	const gchar* _tmp14_ = NULL;
	const gchar* _tmp15_ = NULL;
	g_return_if_fail (log != NULL);
	_tmp0_ = log;
	_tmp1_ = plank_services_logger_log_message_get_Level (_tmp0_);
	_tmp2_ = _tmp1_;
	plank_services_logger_set_color_for_level (_tmp2_);
	_tmp3_ = stdout;
	_tmp4_ = log;
	_tmp5_ = plank_services_logger_log_message_get_Level (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_enum_get_value (g_type_class_ref (PLANK_SERVICES_TYPE_LOG_LEVEL), _tmp6_);
	_tmp8_ = string_substring ((_tmp7_ != NULL) ? _tmp7_->value_name : NULL, (glong) 25, (glong) (-1));
	_tmp9_ = _tmp8_;
	_tmp10_ = plank_services_logger_get_time ();
	_tmp11_ = _tmp10_;
	fprintf (_tmp3_, "[%s %s]", _tmp9_, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	plank_services_logger_reset_color ();
	_tmp12_ = stdout;
	_tmp13_ = log;
	_tmp14_ = plank_services_logger_log_message_get_Message (_tmp13_);
	_tmp15_ = _tmp14_;
	fprintf (_tmp12_, " %s\n", _tmp15_);
}
Esempio n. 13
0
int main()
{
	string *s = string_init();
	string *o;
	string *subs;
	string *q = string_init_cstring("quit");
	
	string_read_line(s);
	
	while(string_cmp(s, q))
	{
		string_print(s);
		
		string_reset(s);
		string_read_line(s);
	}

	string_append(s, q);
	o = string_cat(s, q);
	string_print(s);
	string_print(o);
	string_append_cstring(o, "hello");
	string_append_char(o, 'J');
	string_print(o);
	subs = string_substring(o, 5, 6);

	printf("--\n");
	printf("%c\n", string_get(s, 5));
	printf("%d\n", string_index(o, 'o'));
	string_print(subs);
	printf("--\n");

	o = string_free(o);
	s = string_free(s);
	q = string_free(q);
	subs = string_free(subs);

	return 0;
}
Esempio n. 14
0
gchar* system_text_regular_expressions_capture_get_Value (SystemTextRegularExpressionsCapture* self) {
	gchar* result;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gchar* _tmp3_ = NULL;
#line 54 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp0_ = self->_text;
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp1_ = self->_index;
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp2_ = self->_length;
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp3_ = string_substring (_tmp0_, (glong) _tmp1_, (glong) _tmp2_);
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	result = _tmp3_;
#line 56 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	return result;
#line 428 "RegexCapture.c"
}
Esempio n. 15
0
gchar* system_text_regular_expressions_capture_GetRightSubString (SystemTextRegularExpressionsCapture* self) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	const gchar* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	gchar* _tmp8_ = NULL;
#line 78 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp0_ = self->_text;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp1_ = self->_index;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp2_ = self->_length;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp3_ = self->_text;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp4_ = strlen (_tmp3_);
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp5_ = _tmp4_;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp6_ = self->_index;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp7_ = self->_length;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	_tmp8_ = string_substring (_tmp0_, (glong) (_tmp1_ + _tmp2_), (glong) ((_tmp5_ - _tmp6_) - _tmp7_));
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	result = _tmp8_;
#line 80 "/home/developer/projects/Backup/LibDotNet/src/System/Text/RegularExpressions/RegexCapture.vala"
	return result;
#line 374 "RegexCapture.c"
}
Esempio n. 16
0
//Recibe y procesa un mensaje recibido
void receiptMessage(void * arguments)
{
	args_receiptMessage * args = arguments;

	int numbytes;				/* bytes recibidos por cada lectura (0 = desconexion del cliente) */
	char buffer[MAXDATASIZE];	/* buffer de lectura */
	bool bufferUsed;			/* determina si se analizo por lo menos una vez un nuevo set de datos */

	unsigned int n = -1;		/* cantidad de argumentos del packete que recibo */
	int i = 0;					/* ayuda a saber la ultima posicion de lectura en el buffer (tambien se usa como i en otros casos) */
	int j = 0;					/* j de for */
	int seps = 0;				/* cantidad de separadores ,(coma) contados en el encabezado del paquete */
	char * packet_head;			/* encabezado del paquete */
	char * packet_body;			/* cuerpo del paquete */
	char * exceeded;			/* datos excedidos del final del paquete */
	char * str_tmp;				/* temporar para operaciones de string */
	bool isExceeded = false;	/* determina si hay datos excedidos cargados en el buffer */

	bool fullHead = false;		/* determina si ya fue recibido el encabezado del paquete */
	int bytesBody = 0;			/* determina los bytes que contendrá el cuerpo del paquete */
	char ** head = NULL;		/* encabezado divido por n, name y bytes de los args */
	char * b;					/* utilizado para extraer bytes del buffer */
	void (*fn)();				/* utilizado para guardar la funcion que hay que ejecutar del cliente */
	char ** packet_args;		/* Argumentos que se envian por la funcion */


	//loopeo
	while(1)
	{
		//si en la ultima lectura dejo informacion excedida la guardo
		if(isExceeded)
			exceeded = string_duplicate(buffer);

		//Pongo en blanco el buffer
		buffer[0] = '\0';

		//Espero a recibir un mensaje del job, si se produce un error lo informo error y finalizo hilo
		if ((numbytes=recv(args->connection->socket, buffer, MAXDATASIZE-1, 0)) == -1)
		{
			//perror("recv");
			break;
		}

		//si en la ultima lectura dejo informacion excedida la agrego al inicio del buffer
		if(isExceeded)
		{
			exceeded = string_new();
			string_append(&exceeded, buffer);

			buffer[sizeof(exceeded)] = '\0'; //mejor que memset?
			strcpy(buffer, exceeded);
			free(exceeded);
		}

		//finalizo el hilo
		if(numbytes == 0)
			break;

		else
		{
			//Corta el bufer hasta donde recibe informacion
			buffer[numbytes] = '\0';

			//analizo el buffer si es la primera vez que lo voy a analizar o si queda informacion excedida para seguir analizando
			//(Analizar significa, buscar paquetes completos y ejecutarlos)
			bufferUsed = false;
			while(!bufferUsed || isExceeded)
			{
				bufferUsed = true;
				isExceeded = false;
				i = 0;

				//si comienzo a leer un nuevo paquete inicializo el head y el body
				if(n == -1)
				{
					packet_head = string_new();
					packet_body = string_new();
				}

				//recorro buffer hasta armar cabezal si no esta armado
				if(!fullHead)
				{
					for(i = 0; i < strlen(buffer); i++)
					{
						b = buffer[i];

						//primer caracter es [n] (cantidad de args)
						if(n == -1)
							n = atoi(&b);
						//cuento comas
						else if(b == ',')
							seps++;

						//voy completando cabezal
						string_append(&packet_head, &b);

						//fianlizo cuando llego al ultimo separador
						if(n+2 == seps)
						{
							fullHead = true;
							i++; //dejo posicion en el primer byte del cuerpo del paquete
							break;
						}
					}
				}

				//cabezal completo
				if(fullHead)
				{
					//si el cabezal no fue explodiado, le doy explode y calculo los bytes del cabezal
					if(head == NULL)
					{
						//hago explode
						head = string_n_split(packet_head, n+2, ",");
						for(j = 2; j < n+2; j++)
							bytesBody += atoi(head[j]);
					}

					//Agrego al cuerpo del packete todos los datos
					str_tmp = string_substring_from(buffer, i);
					string_append(&packet_body, str_tmp);
					free(str_tmp);

					//paquete completo
					if(bytesBody <= strlen(packet_body))
					{
						//si el paquete esta excedido, corto el paquete en la posicion correspondiente y guardo el excedente sobre el buffer
						if(bytesBody < strlen(packet_body))
						{
							isExceeded = true;

							exceeded = string_substring_from(packet_body, bytesBody);
							str_tmp = string_substring_until(packet_body, bytesBody);
							free(packet_body);
							packet_body = str_tmp;

							buffer[0] = '\0';
							strcpy(buffer, exceeded);
							free(exceeded);
						}

						//llamo a la funcion que maneja los mensajes recibidos
						if(args->fns_receipts != NULL)
						{
							i = 0;

							//armo argumentos en array
							packet_args = malloc(sizeof(char*)*n);
							for(j = 2; j < n+2; j++)
							{
								char * part = string_substring(packet_body, i, atoi(head[j]));
								packet_args[j-2] = part;
								i += atoi(head[j]);
							}

							//Si n=0 el split no toma el vacio despues de la coma final.. quito ultima coma
							if(n==0)
								head[1][strlen(head[1])-1] = '\0';

							//Ejecuto la función solicitada, si no existe la función muestro error
							fn = dictionary_get(args->fns_receipts, head[1]);
							if(fn != NULL)
								fn(args->connection, packet_args);
							else
								printf("Cliente SOCK%d(%s:%d) intento ejecutar la función inexistente '%s'.\n", args->connection->socket, args->connection->ip, args->connection->port, head[1]);

							//libero argumentos
							for(i = 0; i < n; i++)
								free(packet_args[i]);
							free(packet_args);
						}

						free(packet_head);
						free(packet_body);
						for(i = 0; i < n+3; i++)
							free(head[i]);
						free(head);

						n = -1;
						seps = 0;
						fullHead = false;
						bytesBody = 0;
						head = NULL;
					}
				}
			}
		}
	}

	//cierro socket
	close(args->connection->socket);

	//Informo a la funcion que maneja los cierres (si existe y la estructura de conexion lo permite)
	if(args->connection->run_fn_connectionClosed && args->fn_connectionClosed != NULL)
		args->fn_connectionClosed(args->connection);

	//libero memoria
	if(isExceeded)
		free(exceeded);
	if(n != -1)
	{
		free(packet_head);
		free(packet_body);
	}
	free(args);
}
Esempio n. 17
0
static void fix_server_read_logon(int socket)
{
    unsigned long msg_start_idx, msg_end_idx;
    String *buffer, *fix_msg;
    FixSession *session;
    char buf[BUFSZ];
    ssize_t n;
    int done;

    session = NULL;
    done = 0;

    buffer = string_create();
    fix_msg = NULL;

    while(!done) {
        DBG("Server waiting for data from client\n");
        /* Read data onto the end of buffer */
        if((n = recv(socket, buf, BUFSZ, 0)) > 0) {
            string_append_buf(buffer, buf, n);
            /* Find BeginString tag and CheckSum tag */
            if((string_find(buffer, "8=", &msg_start_idx) == 0) &&
                    (string_find(buffer, "\00110=", &msg_end_idx) == 0)) {
                /* Length of "<SOH>10=xxx<SOH>" is 8 characters */
                if((string_length(buffer) - msg_end_idx) >= 8) {
                    /* Extract FIX message. Index of final SOH is
                     * msg_end_idx + 7.
                     */
                    fix_msg = string_substring(buffer, msg_start_idx,
                            (msg_end_idx + 7));

                    DBG("New msg: '%s'\n", string_get_chars(fix_msg));

                    /* Pass message to session object */
                    if(NULL == session) {
                        if(fix_session_manager_lookup_session(fix_msg,
                                    &session) < 0) {
                            done = 1;
                        } else {
                            if(NULL == session) {
                                done = 1;
                            } else {
                                if(!fix_session_is_active(session)) {
                                    fix_session_set_socket(session, socket);
                                    fix_session_activate(session);
                                    fix_session_receive_message(session, fix_msg);
                                }

                                done = 1;
                            }
                        }
                    }
                }
            }
        } else {
            /* Assume client disconnected.
             *
             * TODO Check more thoroughly the reason for
             * recv failure
             */
            done = 1;
        }
    }

    /* Free the buffer string since there should
     * be no other valid data in it. When a client
     * connects, the only thing they should send
     * us is a logon message.
     */
    string_free(buffer);

    DBG("Server is done waiting for data from client\n");
}
Esempio n. 18
0
void gtk_mate_pattern_replace_repository_includes (GeeArrayList* patlist, GtkMateGrammar* g) {
	GeeArrayList* include_patterns;
	GeeArrayList* patterns_to_include;
	gboolean any_included;
	g_return_if_fail (patlist != NULL);
	g_return_if_fail (g != NULL);
	include_patterns = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal);
	patterns_to_include = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal);
	any_included = TRUE;
	while (any_included) {
		/* stdout.printf("repo replacement pass\n");*/
		any_included = FALSE;
		{
			GeeIterator* _p_it;
			_p_it = gee_iterable_iterator ((GeeIterable*) patlist);
			while (gee_iterator_next (_p_it)) {
				GtkMatePattern* p;
				gboolean _tmp0;
				p = (GtkMatePattern*) gee_iterator_get (_p_it);
				_tmp0 = FALSE;
				if (GTK_MATE_IS_INCLUDE_PATTERN (p)) {
					_tmp0 = g_str_has_prefix (p->name, "#");
				} else {
					_tmp0 = FALSE;
				}
				if (_tmp0) {
					char* reponame;
					GeeArrayList* ps;
					gee_collection_add ((GeeCollection*) include_patterns, p);
					reponame = string_substring (p->name, (glong) 1, (glong) (((gint) strlen (p->name)) - 1));
					ps = (GeeArrayList*) gee_map_get ((GeeMap*) g->repository, reponame);
					/* stdout.printf("(%s) getting reponame: %s (%d)\n", this.name, reponame, ps.size);*/
					if (ps != NULL) {
						{
							GeeIterator* _p1_it;
							_p1_it = gee_iterable_iterator ((GeeIterable*) ps);
							while (gee_iterator_next (_p1_it)) {
								GtkMatePattern* p1;
								p1 = (GtkMatePattern*) gee_iterator_get (_p1_it);
								any_included = TRUE;
								gee_collection_add ((GeeCollection*) patterns_to_include, p1);
								(p1 == NULL) ? NULL : (p1 = (g_object_unref (p1), NULL));
							}
							(_p1_it == NULL) ? NULL : (_p1_it = (g_object_unref (_p1_it), NULL));
						}
					} else {
						fprintf (stdout, "warning: couldn't find repository key '%s' in grammar '%s'\n", reponame, gtk_mate_grammar_get_name (g));
					}
					reponame = (g_free (reponame), NULL);
					(ps == NULL) ? NULL : (ps = (g_object_unref (ps), NULL));
				}
				(p == NULL) ? NULL : (p = (g_object_unref (p), NULL));
			}
			(_p_it == NULL) ? NULL : (_p_it = (g_object_unref (_p_it), NULL));
		}
		gtk_mate_pattern_remove_patterns (patlist, include_patterns);
		gtk_mate_pattern_add_patterns (patlist, patterns_to_include);
		gee_collection_clear ((GeeCollection*) include_patterns);
		gee_collection_clear ((GeeCollection*) patterns_to_include);
	}
	(include_patterns == NULL) ? NULL : (include_patterns = (g_object_unref (include_patterns), NULL));
	(patterns_to_include == NULL) ? NULL : (patterns_to_include = (g_object_unref (patterns_to_include), NULL));
}
Esempio n. 19
0
void mathg_math_cog_put (mathgMathCog *self) {
	gchar* s = NULL;
	mathgElmnt* _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gint _tmp1_ = 0;
	mathgElmnt _tmp2_ = {0};
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gdouble d = 0.0;
	const gchar* _tmp25_ = NULL;
	gdouble _tmp26_ = 0.0;
	mathgElmnt* _tmp27_ = NULL;
	gint _tmp27__length1 = 0;
	gint _tmp28_ = 0;
	const gchar* _tmp29_ = NULL;
	gchar* _tmp30_ = NULL;
	gdouble ans = 0.0;
	mathgElmnt* _tmp31_ = NULL;
	gint _tmp31__length1 = 0;
	gint _tmp32_ = 0;
	mathgElmnt _tmp33_ = {0};
	gdouble _tmp34_ = 0.0;
	gboolean _tmp35_ = FALSE;
	gdouble _tmp36_ = 0.0;
	gdouble _tmp37_ = 0.0;
	gdouble _tmp38_ = 0.0;
	gdouble _tmp39_ = 0.0;
	_tmp0_ = (*self).stra;
	_tmp0__length1 = (*self).stra_length1;
	_tmp1_ = (*self).straind;
	_tmp2_ = _tmp0_[_tmp1_];
	_tmp3_ = _tmp2_.guess;
	_tmp4_ = g_strdup (_tmp3_);
	s = _tmp4_;
	_tmp5_ = (*self).ch;
	if (g_strcmp0 (_tmp5_, "-") == 0) {
		gchar* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gboolean _tmp8_ = FALSE;
		gchar* _tmp14_ = NULL;
		_tmp7_ = s;
		_tmp8_ = string_contains (_tmp7_, "-");
		if (_tmp8_) {
			const gchar* _tmp9_ = NULL;
			gchar* _tmp10_ = NULL;
			_tmp9_ = s;
			_tmp10_ = string_substring (_tmp9_, (glong) 1, (glong) -1);
			_g_free0 (_tmp6_);
			_tmp6_ = _tmp10_;
		} else {
			const gchar* _tmp11_ = NULL;
			const gchar* _tmp12_ = NULL;
			gchar* _tmp13_ = NULL;
			_tmp11_ = (*self).ch;
			_tmp12_ = s;
			_tmp13_ = g_strconcat (_tmp11_, _tmp12_, NULL);
			_g_free0 (_tmp6_);
			_tmp6_ = _tmp13_;
		}
		_tmp14_ = g_strdup (_tmp6_);
		_g_free0 (s);
		s = _tmp14_;
		_g_free0 (_tmp6_);
	} else {
		mathgNumberUtils _tmp15_ = {0};
		gint _tmp16_ = 0;
		gchar* _tmp17_ = NULL;
		gchar* _tmp18_ = NULL;
		const gchar* _tmp19_ = NULL;
		gboolean _tmp20_ = FALSE;
		gboolean _tmp21_ = FALSE;
		_tmp15_ = (*self).nu;
		_tmp16_ = _tmp15_.bas;
		_tmp17_ = string_substring (MATHG_digits, (glong) 0, (glong) _tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = (*self).ch;
		_tmp20_ = string_contains (_tmp18_, _tmp19_);
		_tmp21_ = _tmp20_;
		_g_free0 (_tmp18_);
		if (_tmp21_) {
			const gchar* _tmp22_ = NULL;
			const gchar* _tmp23_ = NULL;
			gchar* _tmp24_ = NULL;
			_tmp22_ = s;
			_tmp23_ = (*self).ch;
			_tmp24_ = g_strconcat (_tmp22_, _tmp23_, NULL);
			_g_free0 (s);
			s = _tmp24_;
		}
	}
	_tmp25_ = s;
	_tmp26_ = mathg_number_utils_td (&(*self).nu, _tmp25_);
	d = _tmp26_;
	_tmp27_ = (*self).stra;
	_tmp27__length1 = (*self).stra_length1;
	_tmp28_ = (*self).straind;
	_tmp29_ = s;
	_tmp30_ = g_strdup (_tmp29_);
	_g_free0 (_tmp27_[_tmp28_].guess);
	_tmp27_[_tmp28_].guess = _tmp30_;
	_tmp31_ = (*self).stra;
	_tmp31__length1 = (*self).stra_length1;
	_tmp32_ = (*self).straind;
	_tmp33_ = _tmp31_[_tmp32_];
	_tmp34_ = _tmp33_.answer;
	ans = _tmp34_;
	_tmp36_ = d;
	_tmp37_ = ans;
	_tmp38_ = fabs ((_tmp36_ / _tmp37_) - 1);
	_tmp39_ = (*self).deviation;
	if (_tmp38_ <= _tmp39_) {
		_tmp35_ = TRUE;
	} else {
		gboolean _tmp40_ = FALSE;
		_tmp40_ = (*self).isenter;
		_tmp35_ = _tmp40_;
	}
	if (_tmp35_) {
		gdouble _tmp41_ = 0.0;
		_tmp41_ = ans;
		mathg_math_cog_close (&(*self), _tmp41_);
	}
	(*self).isenter = FALSE;
	_g_free0 (s);
}
Esempio n. 20
0
/**
 * @NAME: string_substring_from
 * @DESC: Retorna el substring de text desde el caracter start hasta
 * el ultimo
 */
char *string_substring_from(char *text, int start) {
	return string_substring(text, start, strlen(text) - start);
}
Esempio n. 21
0
static gchar* vala_markup_reader_text (ValaMarkupReader* self, gchar end_char, gboolean rm_trailing_whitespace) {
	gchar* result = NULL;
	GString* _tmp0_;
	GString* content;
	gchar* _tmp1_;
	gchar* text_begin;
	gchar* _tmp2_;
	gchar* last_linebreak;
	gchar* _tmp84_;
	gchar* _tmp85_;
	gint _tmp92_;
	gchar* _tmp93_;
	gchar* _tmp94_;
	gboolean _tmp95_;
	GString* _tmp116_;
	const gchar* _tmp117_;
	gchar* _tmp118_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	content = _tmp0_;
	_tmp1_ = self->priv->current;
	text_begin = _tmp1_;
	_tmp2_ = self->priv->current;
	last_linebreak = _tmp2_;
	while (TRUE) {
		gboolean _tmp3_ = FALSE;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gboolean _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gunichar _tmp13_ = 0U;
		gunichar u;
		gunichar _tmp14_;
		_tmp4_ = self->priv->current;
		_tmp5_ = self->priv->end;
		if (_tmp4_ < _tmp5_) {
			gchar* _tmp6_;
			gchar _tmp7_;
			gchar _tmp8_;
			_tmp6_ = self->priv->current;
			_tmp7_ = _tmp6_[0];
			_tmp8_ = end_char;
			_tmp3_ = _tmp7_ != _tmp8_;
		} else {
			_tmp3_ = FALSE;
		}
		_tmp9_ = _tmp3_;
		if (!_tmp9_) {
			break;
		}
		_tmp10_ = self->priv->current;
		_tmp11_ = self->priv->end;
		_tmp12_ = self->priv->current;
		_tmp13_ = g_utf8_get_char_validated ((const gchar*) _tmp10_, (gssize) ((glong) (_tmp11_ - _tmp12_)));
		u = _tmp13_;
		_tmp14_ = u;
		if (_tmp14_ == ((gunichar) (-1))) {
			vala_report_error (NULL, "invalid UTF-8 character");
		} else {
			gunichar _tmp15_;
			_tmp15_ = u;
			if (_tmp15_ == ((gunichar) '&')) {
				gchar* _tmp16_;
				gunichar _tmp17_;
				gint _tmp18_ = 0;
				gchar* next_pos;
				gchar* _tmp19_;
				gboolean _tmp20_ = FALSE;
				_tmp16_ = self->priv->current;
				_tmp17_ = u;
				_tmp18_ = g_unichar_to_utf8 (_tmp17_, NULL);
				next_pos = _tmp16_ + _tmp18_;
				_tmp19_ = next_pos;
				_tmp20_ = g_str_has_prefix ((const gchar*) _tmp19_, "amp;");
				if (_tmp20_) {
					GString* _tmp21_;
					gchar* _tmp22_;
					gchar* _tmp23_;
					gchar* _tmp24_;
					gchar* _tmp25_ = NULL;
					gchar* _tmp26_;
					GString* _tmp27_;
					gchar* _tmp28_;
					gchar* _tmp29_;
					_tmp21_ = content;
					_tmp22_ = text_begin;
					_tmp23_ = self->priv->current;
					_tmp24_ = text_begin;
					_tmp25_ = string_substring ((const gchar*) _tmp22_, (glong) 0, (glong) ((gint) (_tmp23_ - _tmp24_)));
					_tmp26_ = _tmp25_;
					g_string_append (_tmp21_, _tmp26_);
					_g_free0 (_tmp26_);
					_tmp27_ = content;
					g_string_append_c (_tmp27_, '&');
					_tmp28_ = self->priv->current;
					self->priv->current = _tmp28_ + 5;
					_tmp29_ = self->priv->current;
					text_begin = _tmp29_;
				} else {
					gchar* _tmp30_;
					gboolean _tmp31_ = FALSE;
					_tmp30_ = next_pos;
					_tmp31_ = g_str_has_prefix ((const gchar*) _tmp30_, "quot;");
					if (_tmp31_) {
						GString* _tmp32_;
						gchar* _tmp33_;
						gchar* _tmp34_;
						gchar* _tmp35_;
						gchar* _tmp36_ = NULL;
						gchar* _tmp37_;
						GString* _tmp38_;
						gchar* _tmp39_;
						gchar* _tmp40_;
						_tmp32_ = content;
						_tmp33_ = text_begin;
						_tmp34_ = self->priv->current;
						_tmp35_ = text_begin;
						_tmp36_ = string_substring ((const gchar*) _tmp33_, (glong) 0, (glong) ((gint) (_tmp34_ - _tmp35_)));
						_tmp37_ = _tmp36_;
						g_string_append (_tmp32_, _tmp37_);
						_g_free0 (_tmp37_);
						_tmp38_ = content;
						g_string_append_c (_tmp38_, '"');
						_tmp39_ = self->priv->current;
						self->priv->current = _tmp39_ + 6;
						_tmp40_ = self->priv->current;
						text_begin = _tmp40_;
					} else {
						gchar* _tmp41_;
						gboolean _tmp42_ = FALSE;
						_tmp41_ = next_pos;
						_tmp42_ = g_str_has_prefix ((const gchar*) _tmp41_, "apos;");
						if (_tmp42_) {
							GString* _tmp43_;
							gchar* _tmp44_;
							gchar* _tmp45_;
							gchar* _tmp46_;
							gchar* _tmp47_ = NULL;
							gchar* _tmp48_;
							GString* _tmp49_;
							gchar* _tmp50_;
							gchar* _tmp51_;
							_tmp43_ = content;
							_tmp44_ = text_begin;
							_tmp45_ = self->priv->current;
							_tmp46_ = text_begin;
							_tmp47_ = string_substring ((const gchar*) _tmp44_, (glong) 0, (glong) ((gint) (_tmp45_ - _tmp46_)));
							_tmp48_ = _tmp47_;
							g_string_append (_tmp43_, _tmp48_);
							_g_free0 (_tmp48_);
							_tmp49_ = content;
							g_string_append_c (_tmp49_, '\'');
							_tmp50_ = self->priv->current;
							self->priv->current = _tmp50_ + 6;
							_tmp51_ = self->priv->current;
							text_begin = _tmp51_;
						} else {
							gchar* _tmp52_;
							gboolean _tmp53_ = FALSE;
							_tmp52_ = next_pos;
							_tmp53_ = g_str_has_prefix ((const gchar*) _tmp52_, "lt;");
							if (_tmp53_) {
								GString* _tmp54_;
								gchar* _tmp55_;
								gchar* _tmp56_;
								gchar* _tmp57_;
								gchar* _tmp58_ = NULL;
								gchar* _tmp59_;
								GString* _tmp60_;
								gchar* _tmp61_;
								gchar* _tmp62_;
								_tmp54_ = content;
								_tmp55_ = text_begin;
								_tmp56_ = self->priv->current;
								_tmp57_ = text_begin;
								_tmp58_ = string_substring ((const gchar*) _tmp55_, (glong) 0, (glong) ((gint) (_tmp56_ - _tmp57_)));
								_tmp59_ = _tmp58_;
								g_string_append (_tmp54_, _tmp59_);
								_g_free0 (_tmp59_);
								_tmp60_ = content;
								g_string_append_c (_tmp60_, '<');
								_tmp61_ = self->priv->current;
								self->priv->current = _tmp61_ + 4;
								_tmp62_ = self->priv->current;
								text_begin = _tmp62_;
							} else {
								gchar* _tmp63_;
								gboolean _tmp64_ = FALSE;
								_tmp63_ = next_pos;
								_tmp64_ = g_str_has_prefix ((const gchar*) _tmp63_, "gt;");
								if (_tmp64_) {
									GString* _tmp65_;
									gchar* _tmp66_;
									gchar* _tmp67_;
									gchar* _tmp68_;
									gchar* _tmp69_ = NULL;
									gchar* _tmp70_;
									GString* _tmp71_;
									gchar* _tmp72_;
									gchar* _tmp73_;
									_tmp65_ = content;
									_tmp66_ = text_begin;
									_tmp67_ = self->priv->current;
									_tmp68_ = text_begin;
									_tmp69_ = string_substring ((const gchar*) _tmp66_, (glong) 0, (glong) ((gint) (_tmp67_ - _tmp68_)));
									_tmp70_ = _tmp69_;
									g_string_append (_tmp65_, _tmp70_);
									_g_free0 (_tmp70_);
									_tmp71_ = content;
									g_string_append_c (_tmp71_, '>');
									_tmp72_ = self->priv->current;
									self->priv->current = _tmp72_ + 4;
									_tmp73_ = self->priv->current;
									text_begin = _tmp73_;
								} else {
									gchar* _tmp74_;
									gunichar _tmp75_;
									gint _tmp76_ = 0;
									_tmp74_ = self->priv->current;
									_tmp75_ = u;
									_tmp76_ = g_unichar_to_utf8 (_tmp75_, NULL);
									self->priv->current = _tmp74_ + _tmp76_;
								}
							}
						}
					}
				}
			} else {
				gunichar _tmp77_;
				gchar* _tmp80_;
				gunichar _tmp81_;
				gint _tmp82_ = 0;
				gint _tmp83_;
				_tmp77_ = u;
				if (_tmp77_ == ((gunichar) '\n')) {
					gint _tmp78_;
					gchar* _tmp79_;
					_tmp78_ = self->priv->line;
					self->priv->line = _tmp78_ + 1;
					self->priv->column = 0;
					_tmp79_ = self->priv->current;
					last_linebreak = _tmp79_;
				}
				_tmp80_ = self->priv->current;
				_tmp81_ = u;
				_tmp82_ = g_unichar_to_utf8 (_tmp81_, NULL);
				self->priv->current = _tmp80_ + _tmp82_;
				_tmp83_ = self->priv->column;
				self->priv->column = _tmp83_ + 1;
			}
		}
	}
	_tmp84_ = text_begin;
	_tmp85_ = self->priv->current;
	if (_tmp84_ != _tmp85_) {
		GString* _tmp86_;
		gchar* _tmp87_;
		gchar* _tmp88_;
		gchar* _tmp89_;
		gchar* _tmp90_ = NULL;
		gchar* _tmp91_;
		_tmp86_ = content;
		_tmp87_ = text_begin;
		_tmp88_ = self->priv->current;
		_tmp89_ = text_begin;
		_tmp90_ = string_substring ((const gchar*) _tmp87_, (glong) 0, (glong) ((gint) (_tmp88_ - _tmp89_)));
		_tmp91_ = _tmp90_;
		g_string_append (_tmp86_, _tmp91_);
		_g_free0 (_tmp91_);
	}
	_tmp92_ = self->priv->column;
	_tmp93_ = self->priv->current;
	_tmp94_ = last_linebreak;
	self->priv->column = _tmp92_ + ((gint) (_tmp93_ - _tmp94_));
	_tmp95_ = rm_trailing_whitespace;
	if (_tmp95_) {
		GString* _tmp96_;
		const gchar* _tmp97_;
		GString* _tmp98_;
		gssize _tmp99_;
		gchar* str_pos;
		GString* _tmp112_;
		gchar* _tmp113_;
		GString* _tmp114_;
		const gchar* _tmp115_;
		_tmp96_ = content;
		_tmp97_ = _tmp96_->str;
		_tmp98_ = content;
		_tmp99_ = _tmp98_->len;
		str_pos = ((gchar*) _tmp97_) + _tmp99_;
		{
			gchar* _tmp100_;
			gboolean _tmp101_;
			_tmp100_ = str_pos;
			str_pos = _tmp100_ - 1;
			_tmp101_ = TRUE;
			while (TRUE) {
				gboolean _tmp102_;
				gboolean _tmp104_ = FALSE;
				gchar* _tmp105_;
				GString* _tmp106_;
				const gchar* _tmp107_;
				gboolean _tmp111_;
				_tmp102_ = _tmp101_;
				if (!_tmp102_) {
					gchar* _tmp103_;
					_tmp103_ = str_pos;
					str_pos = _tmp103_ - 1;
				}
				_tmp101_ = FALSE;
				_tmp105_ = str_pos;
				_tmp106_ = content;
				_tmp107_ = _tmp106_->str;
				if (_tmp105_ > ((gchar*) _tmp107_)) {
					gchar* _tmp108_;
					gchar _tmp109_;
					gboolean _tmp110_ = FALSE;
					_tmp108_ = str_pos;
					_tmp109_ = _tmp108_[0];
					_tmp110_ = g_ascii_isspace (_tmp109_);
					_tmp104_ = _tmp110_;
				} else {
					_tmp104_ = FALSE;
				}
				_tmp111_ = _tmp104_;
				if (!_tmp111_) {
					break;
				}
			}
		}
		_tmp112_ = content;
		_tmp113_ = str_pos;
		_tmp114_ = content;
		_tmp115_ = _tmp114_->str;
		g_string_erase (_tmp112_, (gssize) ((_tmp113_ - ((gchar*) _tmp115_)) + 1), (gssize) (-1));
	}
	_tmp116_ = content;
	_tmp117_ = _tmp116_->str;
	_tmp118_ = g_strdup (_tmp117_);
	result = _tmp118_;
	_g_string_free0 (content);
	return result;
}
Esempio n. 22
0
static gchar* vala_markup_reader_read_name (ValaMarkupReader* self) {
	gchar* result = NULL;
	gchar* _tmp0_;
	gchar* begin;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->current;
	begin = _tmp0_;
	while (TRUE) {
		gchar* _tmp1_;
		gchar* _tmp2_;
		gboolean _tmp3_ = FALSE;
		gboolean _tmp4_ = FALSE;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		gboolean _tmp7_ = FALSE;
		gchar* _tmp8_;
		gchar _tmp9_;
		gboolean _tmp12_;
		gboolean _tmp15_;
		gboolean _tmp18_;
		gboolean _tmp21_;
		gboolean _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		gunichar _tmp28_ = 0U;
		gunichar u;
		gunichar _tmp29_;
		_tmp1_ = self->priv->current;
		_tmp2_ = self->priv->end;
		if (!(_tmp1_ < _tmp2_)) {
			break;
		}
		_tmp8_ = self->priv->current;
		_tmp9_ = _tmp8_[0];
		if (_tmp9_ == ' ') {
			_tmp7_ = TRUE;
		} else {
			gchar* _tmp10_;
			gchar _tmp11_;
			_tmp10_ = self->priv->current;
			_tmp11_ = _tmp10_[0];
			_tmp7_ = _tmp11_ == '\t';
		}
		_tmp12_ = _tmp7_;
		if (_tmp12_) {
			_tmp6_ = TRUE;
		} else {
			gchar* _tmp13_;
			gchar _tmp14_;
			_tmp13_ = self->priv->current;
			_tmp14_ = _tmp13_[0];
			_tmp6_ = _tmp14_ == '>';
		}
		_tmp15_ = _tmp6_;
		if (_tmp15_) {
			_tmp5_ = TRUE;
		} else {
			gchar* _tmp16_;
			gchar _tmp17_;
			_tmp16_ = self->priv->current;
			_tmp17_ = _tmp16_[0];
			_tmp5_ = _tmp17_ == '/';
		}
		_tmp18_ = _tmp5_;
		if (_tmp18_) {
			_tmp4_ = TRUE;
		} else {
			gchar* _tmp19_;
			gchar _tmp20_;
			_tmp19_ = self->priv->current;
			_tmp20_ = _tmp19_[0];
			_tmp4_ = _tmp20_ == '=';
		}
		_tmp21_ = _tmp4_;
		if (_tmp21_) {
			_tmp3_ = TRUE;
		} else {
			gchar* _tmp22_;
			gchar _tmp23_;
			_tmp22_ = self->priv->current;
			_tmp23_ = _tmp22_[0];
			_tmp3_ = _tmp23_ == '\n';
		}
		_tmp24_ = _tmp3_;
		if (_tmp24_) {
			break;
		}
		_tmp25_ = self->priv->current;
		_tmp26_ = self->priv->end;
		_tmp27_ = self->priv->current;
		_tmp28_ = g_utf8_get_char_validated ((const gchar*) _tmp25_, (gssize) ((glong) (_tmp26_ - _tmp27_)));
		u = _tmp28_;
		_tmp29_ = u;
		if (_tmp29_ != ((gunichar) (-1))) {
			gchar* _tmp30_;
			gunichar _tmp31_;
			gint _tmp32_ = 0;
			_tmp30_ = self->priv->current;
			_tmp31_ = u;
			_tmp32_ = g_unichar_to_utf8 (_tmp31_, NULL);
			self->priv->current = _tmp30_ + _tmp32_;
		} else {
			vala_report_error (NULL, "invalid UTF-8 character");
		}
	}
	_tmp33_ = self->priv->current;
	_tmp34_ = begin;
	if (_tmp33_ == _tmp34_) {
	}
	_tmp35_ = begin;
	_tmp36_ = self->priv->current;
	_tmp37_ = begin;
	_tmp38_ = string_substring ((const gchar*) _tmp35_, (glong) 0, (glong) ((gint) (_tmp36_ - _tmp37_)));
	result = _tmp38_;
	return result;
}
Esempio n. 23
0
static RestProxyCall* ease_flickr_service_real_create_call (EasePluginImportService* base, RestProxy* proxy, const char* search) {
#line 184 "ease-import-flickr-service.c"
	EaseFlickrService * self;
	RestProxyCall* result = NULL;
	char* licenses;
	RestProxyCall* call;
	char* _tmp4_;
	self = (EaseFlickrService*) base;
#line 40 "ease-import-flickr-service.vala"
	g_return_val_if_fail (proxy != NULL, NULL);
#line 40 "ease-import-flickr-service.vala"
	g_return_val_if_fail (search != NULL, NULL);
#line 195 "ease-import-flickr-service.c"
	licenses = NULL;
#line 44 "ease-import-flickr-service.vala"
	if (gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->share_alike)) {
#line 199 "ease-import-flickr-service.c"
		char* _tmp0_;
#line 46 "ease-import-flickr-service.vala"
		licenses = (_tmp0_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY_SA), _g_free0 (licenses), _tmp0_);
#line 47 "ease-import-flickr-service.vala"
		if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) {
#line 205 "ease-import-flickr-service.c"
			char* _tmp1_;
#line 47 "ease-import-flickr-service.vala"
			licenses = (_tmp1_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC_SA, NULL), _g_free0 (licenses), _tmp1_);
#line 209 "ease-import-flickr-service.c"
		}
	} else {
		char* _tmp2_;
#line 51 "ease-import-flickr-service.vala"
		licenses = (_tmp2_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY), _g_free0 (licenses), _tmp2_);
#line 52 "ease-import-flickr-service.vala"
		if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) {
#line 217 "ease-import-flickr-service.c"
			char* _tmp3_;
#line 52 "ease-import-flickr-service.vala"
			licenses = (_tmp3_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC, NULL), _g_free0 (licenses), _tmp3_);
#line 221 "ease-import-flickr-service.c"
		}
	}
#line 55 "ease-import-flickr-service.vala"
	call = rest_proxy_new_call (proxy);
#line 56 "ease-import-flickr-service.vala"
	rest_proxy_call_set_function (call, "flickr.photos.search");
#line 57 "ease-import-flickr-service.vala"
	rest_proxy_call_add_params (call, "tags", search, "tag_mode", "all", "per_page", "10", "format", "json", "sort", "relevance", "nojsoncallback", "1", "license", _tmp4_ = string_substring (licenses, (glong) 0, string_get_length (licenses) - 1), "extras", "description,license", NULL, NULL);
#line 230 "ease-import-flickr-service.c"
	_g_free0 (_tmp4_);
	result = call;
	_g_free0 (licenses);
#line 71 "ease-import-flickr-service.vala"
	return result;
#line 236 "ease-import-flickr-service.c"
}
Esempio n. 24
0
/**
 * @NAME: string_substring_until
 * @DESC: Retorna los primeros length caracteres de text como un nuevo
 * string
 */
char *string_substring_until(char *text, int length) {
	return string_substring(text, 0, length);
}
Esempio n. 25
0
void consola() {

	//char eleccion[30];
	char* eleccion;
	char* comando;
	char* parametro;
	char c = 0;
	int longComando = 0;
	int posInicioParametro = 0;
	int consola = 1;

	while (consola) {
		posInicioParametro = 0;
		eleccion = string_new();
		comando = string_new();
		puts(
				"____________________________________________________________________\n\n"
						"Comandos disponibles: \n"
						"- 1) correr PATH \n"
						"- 2) finalizar PID \n"
						"- 3) ps \n"
						"- 4) cpu \n"
						"Ingrese un comando: ");
		scanf("%c", &c);
		//printf("Escanee %c\n",c);
		longComando++;
		eleccion = (char*) malloc( sizeof(char) * longComando );
		string_append(&eleccion, string_repeat(c,1));
		while(c != '\n'){
			scanf("%c", &c);
			//printf("Escanee %c\n",c);
			longComando++;
			eleccion = (char*) realloc(eleccion, sizeof(char) * longComando );
			string_append(&eleccion, string_repeat(c,1));
		}

		eleccion = (char*) realloc(eleccion, sizeof(char) * (longComando+1) );
		eleccion[longComando] = '\0';

		int i = 0;
		while(eleccion[i] != '\0'){
			if(eleccion[i] == ' ') posInicioParametro = i+1;
			i++;
		}
		//printf("El parametro empieza en la posicion %d\n", posInicioParametro);

		if(posInicioParametro != 0){
			parametro = string_new();
			comando = (char*) malloc( sizeof(char) * strlen(string_substring(eleccion, 0, posInicioParametro-1)));
			comando = string_substring(eleccion, 0, posInicioParametro-1);
			parametro = (char*) malloc( sizeof(char) * strlen(string_substring_from(eleccion, posInicioParametro)));
			parametro = string_substring_from(eleccion, posInicioParametro);
		}
		else{
			//printf("strlen %d \n", strlen(eleccion));
			eleccion[strlen(eleccion)-1] = '\0';
			//printf("strlen %d \n", strlen(eleccion));
			comando = (char*) malloc( sizeof(char) * strlen(eleccion) );
			comando = string_duplicate(eleccion);
		}

		if(posInicioParametro == 0){
			if(strcmp(eleccion, "ps") == 0){
				printf("3Comando a ejecutar: %s\n", comando);
			}
			else{
				if(strcmp(eleccion, "cpu") == 0){
					printf("4Comando a ejecutar: %s\n", comando);
				}
				else{
					printf("El comando (%s) ingresado no es valido \n", comando);
					eleccion[0] = '\0';
					comando[0] = '\0';
				}
			}
		}

		if(posInicioParametro != 0){
			if(strcmp(comando, "correr") == 0){
				printf("1Comando a ejecutar: %s %s\n", comando, parametro);
				Enviar(socketCPU, comando);
				Enviar(socketCPU, parametro);
			}
			else{
				if(strcmp(comando, "finalizar") == 0){
					printf("2Comando a ejecutar: %s %s\n", comando, parametro);
				}
				else{
					printf("El comando (%s %s) ingresado no es valido \n", comando, parametro);
					eleccion[0] = '\0';
					comando[0] = '\0';
					parametro[0] = '\0';
				}
			}
		}

		free(eleccion);
		free(comando);
		if(posInicioParametro != 0){
			free(parametro);
		}
	}
}