示例#1
0
int
cli_cmd_getwd_cbk (struct cli_state *state, struct cli_cmd_word *word,
                   const char **words, int wordcount)
{
        int                             ret = -1;
        rpc_clnt_procedure_t            *proc = NULL;
        call_frame_t                    *frame = NULL;

        if (wordcount != 2) {
                cli_usage_out (word->pattern);
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GETWD];
        if (proc && proc->fn) {
                frame = create_frame (THIS, THIS->ctx->pool);
                if (!frame)
                        goto out;
                ret = proc->fn (frame, THIS, NULL);
        }
out:
        return ret;
}
示例#2
0
int
cli_cmd_peer_status_cbk (struct cli_state *state, struct cli_cmd_word *word,
                        const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        int                     sent = 0;
        int                     parse_error = 0;

        if (wordcount != 2) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LIST_FRIENDS];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        if (proc->fn) {
                ret = proc->fn (frame, THIS, (void *)GF_CLI_LIST_PEERS);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Peer status failed");
        }

        CLI_STACK_DESTROY (frame);

        return ret;
}
示例#3
0
static portTASK_FUNCTION(PilAuto,pvParameters)
{

	unsigned char frame[MAX_FRAME_SIZE];
	int num_datos;


	//Desactivamos las lecturas del ADC
	ADCSequenceDisable(ADC0_BASE,0);


	bool pilotoAutomatico =true;
	EventBits_t bits;

	// Enviamos la trama para indicar a QT que estamos con el piloto Automatico
	num_datos=create_frame(frame, COMANDO_AUTOMATICO, &pilotoAutomatico, sizeof(pilotoAutomatico), MAX_FRAME_SIZE);
	if (num_datos>=0){
		send_frame(frame, num_datos);
	}else{

		logError(num_datos);

	}


	while(1)
	{
		vTaskDelay(configTICK_RATE_HZ); // Esperamos 1 seg

		bits=xEventGroupGetBits(xEventGroup); // Leemos los flags

		if(bits  == 0 || bits== 1){  //Si el flags de pilotoAutomatico esta a cero quitamos el pilotoAutomatico
			pilotoAutomatico=false;
			num_datos=create_frame(frame, COMANDO_AUTOMATICO, &pilotoAutomatico, sizeof(pilotoAutomatico), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);

			}else{

				logError(num_datos);

			}
			ADCSequenceEnable(ADC0_BASE,0); // Habilitamos el ADC
			vTaskDelete(NULL);
			while(1){
				//Por si falla
			}
		}


		//Centramos el avion, ponemos la velocidad a 100 y lo mandamos a QT
		setEjes(0,0,0);
		setVelocidad(100.0f);
		num_datos=create_frame(frame, COMANDO_EJES, &ejes, sizeof(ejes), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}
		num_datos=create_frame(frame, COMANDO_SPEED, &velocidad, sizeof(velocidad), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}



	}
}
示例#4
0
/*---------------------------------------------------------------------------*/
static int
hdr_length(void)
{
  return create_frame(FRAME802154_DATAFRAME, 0);
}
示例#5
0
文件: shelm_about.c 项目: Limsik/e17
void 
shelm_about_dialog()
{
  Evas_Object *window, *background, *frame, *box, *icon, *label, *sublabel, *scroller, *textinfo, *buttonbar, *button_close;
  char buf[PATH_MAX];

  window = create_window("shellementary-about", _("About Shellementary"), destroy);

  background = create_background(window, NULL, EINA_TRUE);
  elm_win_resize_object_add(window, background);
  evas_object_show(background);

  frame = create_frame(window, EINA_FALSE);
  elm_win_resize_object_add(window, frame);
  evas_object_show(frame);

  box = create_box(window, EINA_FALSE);
  elm_object_content_set(frame, box);
  evas_object_show(box);

  snprintf(buf, sizeof(buf), "%s/logo.png", PACKAGE_DATA_DIR);
  icon = create_icon(window, buf);
  elm_box_pack_start(box, icon);
  evas_object_show(icon);

  snprintf(buf, sizeof(buf), "<b>Shellementary %s</>", PACKAGE_VERSION);
  label = create_label(window, buf);
  elm_object_scale_set(label, 1.6);
  elm_box_pack_end(box, label);
  evas_object_show(label);

  sublabel = create_label(window, _("<b>Display dialogs from shell scripts</><br>Written as a zenity replacement, supports the same arguments<br><b>http://svn.enlightenment.org/svn/e/trunk/PROTO/shellementary</><br>Based on great Elementary toolkit by <b>raster</> and C programming language.<br><b>License:</> MIT"));
  elm_box_pack_end(box, sublabel);
  evas_object_show(sublabel);

  scroller = create_scroller(window, EINA_TRUE);
  elm_box_pack_end(box, scroller);
  evas_object_show(scroller);

  textinfo = create_entry(window, EINA_TRUE, NULL, EINA_FALSE, EINA_FALSE, EINA_FALSE);
  elm_entry_entry_set(textinfo, _("<b>Author:</> quaker ([email protected])<br>"
			"<br>"
			"<b>Credits:</><br>"
			"<b>Carsten Haitzler (raster)</> "
			"for Enlightenment DR17, great Elementary toolkit and help with developenment<br>"
			"<b>Christopher Michael (devilhorns)</> "
			"for help with developenment<br>"));
  elm_object_content_set(scroller, textinfo);
  evas_object_show(textinfo);

  buttonbar = create_box(window, EINA_TRUE);
  elm_box_pack_end(box, buttonbar);
  evas_object_show(buttonbar);

  snprintf(buf, sizeof(buf), "%s/icon-cancel.png", PACKAGE_DATA_DIR);
  button_close = create_button(window, buf, _("Close"));
  evas_object_smart_callback_add(button_close, "clicked", destroy, NULL);
  elm_box_pack_end(buttonbar, button_close);
  evas_object_show(button_close);



  evas_object_show(window);
}
示例#6
0
static void como_compile(ast_node* p, ComoFrame *frame)
{
    assert(p);

    switch(p->type) {
        default:
            printf("%s(): invalid node type(%d)\n", __func__, p->type);
            exit(1);
        break;
        case AST_NODE_TYPE_STRING:
            arrayPushEx(frame->code, newPointer((void *)create_op(LOAD_CONST, 
                newString(p->u1.string_value.value)))); 
        break;
        case AST_NODE_TYPE_PRINT:
            como_compile(p->u1.print_node.expr, frame);
            arrayPushEx(frame->code, 
                newPointer((void *)create_op(IPRINT, NULL)));
        break;
        case AST_NODE_TYPE_NUMBER:
            arrayPushEx(frame->code, newPointer((void *)create_op(LOAD_CONST, 
                newLong((long)p->u1.number_value))));
        break;
        case AST_NODE_TYPE_ID:
            arrayPushEx(frame->code, newPointer((void *)create_op(LOAD_NAME, 
                newString(p->u1.string_value.value)))); 
        break;
        case AST_NODE_TYPE_RET:
            if(p->u1.return_node.expr != NULL) {
                como_compile(p->u1.return_node.expr, frame);
                arrayPushEx(frame->code, newPointer((void *)create_op(IRETURN, 
                    newLong(1L))));
            } else {
                arrayPushEx(frame->code, newPointer((void *)create_op(IRETURN, 
                    newLong(0L))));
            }
        break;
        case AST_NODE_TYPE_STATEMENT_LIST: {
            size_t i;
            for(i = 0; i < p->u1.statements_node.count; i++) {
                ast_node* stmt = p->u1.statements_node.statement_list[i];
                como_compile(stmt, frame);
            }
        } 
        break;
        case AST_NODE_TYPE_WHILE: {
            Object *l = newLong((long)(O_AVAL(frame->code)->size));
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, l)));
            
            Object *l2 = newLong(0);
            como_compile(p->u1.while_node.condition, frame);
            arrayPushEx(frame->code, newPointer((void *)create_op(JZ, l2)));

            como_compile(p->u1.while_node.body, frame);
            arrayPushEx(frame->code, newPointer((void *)create_op(JMP, 
                    newLong(O_LVAL(l)))));
        
            Object *l3 = newLong((long)(O_AVAL(frame->code)->size));
    
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                    l3))); 

            O_LVAL(l2) = O_LVAL(l3);
        }
        break;
        case AST_NODE_TYPE_FOR: {
            Object *l = newLong((long)(O_AVAL(frame->code)->size));
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                    l))); 
            
            Object *l2 = newLong(0);
            como_compile(p->u1.for_node.initialization, frame);
            como_compile(p->u1.for_node.condition, frame);
            arrayPushEx(frame->code, newPointer((void *)create_op(JZ, 
                    l2))); 

            Object *l4 = newLong((long)(O_AVAL(frame->code)->size));
            /* label for the body */
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                    l4)));    

            como_compile(p->u1.for_node.body, frame);
            
            como_compile(p->u1.for_node.final_expression, frame);

            como_compile(p->u1.for_node.condition, frame);
            arrayPushEx(frame->code, newPointer((void *)create_op(JZ, 
                    l2))); 

            arrayPushEx(frame->code, newPointer((void *)create_op(JMP, 
                    newLong(O_LVAL(l4))))); 
        
            Object *l3 = newLong((long)(O_AVAL(frame->code)->size));
    
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                l3))); 
        
            O_LVAL(l2) = O_LVAL(l3);
        }
        break;
        case AST_NODE_TYPE_IF: {
            Object *l2 = newLong(0);
            Object *l4 = newLong(0);
            como_compile(p->u1.if_node.condition, frame);
        
            arrayPushEx(frame->code, newPointer((void *)create_op(JZ, 
                l2))); 
        

            como_compile(p->u1.if_node.b1, frame);

            arrayPushEx(frame->code, newPointer((void *)create_op(JMP, 
                    l4))); 
            
            Object *l3 = newLong((long)(O_AVAL(frame->code)->size));
        
            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                    l3))); 

            if(p->u1.if_node.b2 != NULL) {
                como_compile(p->u1.if_node.b2, frame);
            }
        
            O_LVAL(l2) = O_LVAL(l3);
            O_LVAL(l4) = (long)(O_AVAL(frame->code)->size);

            arrayPushEx(frame->code, newPointer((void *)create_op(LABEL, 
                    newLong((long)(O_AVAL(frame->code)->size))))); 

        } 
        break;
        case AST_NODE_TYPE_FUNC_DECL: { 
            const char *name = p->u1.function_node.name;
            Object *func_decl = newArray(4);
            Object *func_decl_parameters = newArray(2);
            ComoFrame *func_decl_frame = create_frame(func_decl);
            func_decl_frame->namedparameters = func_decl_parameters;

            if(frame->filename != NULL) {
                func_decl_frame->filename = copyObject(frame->filename);
            } else {
                func_decl_frame->filename = newString("<unknown>");
            }

            size_t i;
            ast_node_statements *parameters = &p->u1.function_node
                .parameter_list->u1
                .statements_node;

            for(i = 0; i < parameters->count; i++) {
                arrayPushEx(func_decl_parameters, newString(
                            AST_NODE_AS_ID(
                                parameters->statement_list[i]
                            )
                        )
                );
            }

            arrayPushEx(func_decl_frame->code, newPointer((void *)create_op(LOAD_CONST, 
                newString(name)))); 
            arrayPushEx(func_decl_frame->code, newPointer((void *)create_op(STORE_NAME, 
										newString("__FUNCTION__"))));

            como_compile(p->u1.function_node.body, func_decl_frame);

            Array *temp = O_AVAL(func_decl_frame->code);
            Object *temp2 = temp->table[temp->size - 1];

            ComoOpCode *opcode = (ComoOpCode *)(O_PTVAL(temp2));

            if(opcode->op_code != IRETURN) {
                //como_debug("automatically inserting IRETURN for function %s", name);
                arrayPushEx(func_decl_frame->code, newPointer(
                    (void *)create_op(LOAD_CONST, newLong(0L)))); 
                arrayPushEx(func_decl_frame->code, newPointer(
                    (void *)create_op(IRETURN, newLong(1L))));           
            } 

            mapInsertEx(global_frame->cf_symtab, name, newPointer(
                (void *)func_decl_frame));

            break;
        } 
        case AST_NODE_TYPE_CALL: {
            const char *name = p->u1.call_node.id->u1.id_node.name;
            const long argcount = (long)p->u1
                .call_node
                .arguments->u1
                .statements_node
                .count;

            como_compile(p->u1.call_node.arguments, frame);
            arrayPushEx(frame->code, newPointer(
                    (void *)create_op(LOAD_CONST, newLong(argcount)))); 

            arrayPushEx(frame->code, newPointer(
                    (void *)create_op(LOAD_NAME, newString(name))));

            arrayPushEx(frame->code, newPointer(
                    (void *)create_op(CALL_FUNCTION, newString(name))));

            break;
        } 
        case AST_NODE_TYPE_POSTFIX: {
            Object *name = newString(AST_NODE_AS_ID(p->u1.postfix_node.expr));
            switch(p->u1.postfix_node.type) {
                case AST_POSTFIX_OP_INC:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(POSTFIX_INC, name)));
                break;
                case AST_POSTFIX_OP_DEC:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(POSTFIX_DEC, name)));
                break;
            }
            break;
        }
        case AST_NODE_TYPE_UNARY_OP: {
            switch(p->u1.unary_node.type) {
                case AST_UNARY_OP_MINUS:
                    como_compile(p->u1.unary_node.expr, frame);
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(UNARY_MINUS, NULL)));
                break;
            }
        }
        break;
        case AST_NODE_TYPE_BIN_OP: {
            if(p->u1.binary_node.type != AST_BINARY_OP_ASSIGN) {
                como_compile(p->u1.binary_node.left, frame);
                como_compile(p->u1.binary_node.right, frame);       
            }  
            switch(p->u1.binary_node.type) {
                case AST_BINARY_OP_REM:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IREM, NULL)));
                break;  
                case AST_BINARY_OP_LTE:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_LESS_THAN_OR_EQUAL, NULL)));
                break;  
                case AST_BINARY_OP_GTE:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_GREATER_THAN_OR_EQUAL, NULL)));
                break;
                case AST_BINARY_OP_LT: 
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_LESS_THAN, NULL)));                    
                break;
                case AST_BINARY_OP_GT:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_GREATER_THAN, NULL)));  
                break;
                case AST_BINARY_OP_CMP:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_EQUAL, NULL)));  
                break;
                case AST_BINARY_OP_NEQ:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IS_NOT_EQUAL, NULL)));  
                break;
                case AST_BINARY_OP_MINUS: 
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IMINUS, NULL)));  
                break;
                case AST_BINARY_OP_DIV:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IDIV, NULL)));  
                break;
                case AST_BINARY_OP_ADD:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(IADD, NULL)));  
                break;
                case AST_BINARY_OP_TIMES:
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(ITIMES, NULL)));  
                break;
                case AST_BINARY_OP_ASSIGN: 
                    como_compile(p->u1.binary_node.right, frame);
                    arrayPushEx(frame->code, newPointer(
                        (void *)create_op(STORE_NAME, newString(
                            p->u1.binary_node.left->u1.id_node.name))));        
                break;
            }   
        } break;
    }
}
示例#7
0
文件: test.c 项目: sebsgit/toolbox
/*
 * Class:     Test
 * Method:    create_frame_raw
 * Signature: (JJ[B)V
 */
JNIEXPORT void JNICALL Java_Test_create_1frame_1raw(JNIEnv * env, jclass klass, jlong index, jlong image, jbyteArray result) {
	frame_t temp = create_frame(index, (monochrome_image_t*)image);
	(*env)->SetByteArrayRegion(env, result, 0, sizeof(temp), (unsigned char*)&temp);
}
示例#8
0
int
cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,
                   const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        dict_t                  *dict = NULL;
        int                     sent = 0;
        int                     parse_error = 0;

        if (!(wordcount == 3)) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROBE];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict)
                goto out;

        ret = dict_set_str (dict, "hostname", (char *)words[2]);
        if (ret)
                goto out;

        ret = valid_internet_address ((char *) words[2], _gf_false);
        if (ret == 1) {
                ret = 0;
        } else {
                cli_out ("%s is an invalid address", words[2]);
                cli_usage_out (word->pattern);
                parse_error = 1;
                ret = -1;
                goto out;
        }
/*        if (words[3]) {
                ret = dict_set_str (dict, "port", (char *)words[3]);
                if (ret)
                        goto out;
        }
*/
        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Peer probe failed");
        }

        CLI_STACK_DESTROY (frame);

        return ret;
}
示例#9
0
void 
shelm_entry_dialog(const char *window_title, const char *window_text, int window_width, int window_height, const char *window_background, const char *entry_text, Eina_Bool entry_hide_text)
{
  Evas_Object *window, *background, *frame, *box, *scroller, *entry, *buttonbar, *button_cancel, *button_ok;
  char buf[PATH_MAX];

  if (window_title)
    window = create_window("shellementary-entrydialog", window_title, cancel_callback);
  else
    window = create_window("shellementary-entrydialog", _("Enter something here"), cancel_callback);

  background = create_background(window, window_background, EINA_TRUE);
  elm_win_resize_object_add(window, background);
  evas_object_show(background);

  frame = create_frame(window, EINA_TRUE);
  elm_win_resize_object_add(window, frame);
  evas_object_show(frame);

  box = create_box(window, EINA_FALSE);
  elm_object_content_set(frame, box);
  evas_object_show(box);

  if (window_text)
    {
      Evas_Object *label;
      label = create_label(window, window_text);
      elm_box_pack_end(box, label);
      evas_object_show(label);
    }

  scroller = create_scroller(window, EINA_TRUE);
  elm_box_pack_end(box, scroller);
  evas_object_show(scroller);

  entry = create_entry(window, EINA_TRUE, entry_text, entry_hide_text, EINA_FALSE, EINA_TRUE);
  elm_object_content_set(scroller, entry);
  evas_object_show(entry);

  buttonbar = create_box(window, EINA_TRUE);
  elm_box_pack_end(box, buttonbar);
  evas_object_show(buttonbar);

  snprintf(buf, sizeof(buf), "%s/icon-cancel.png", PACKAGE_DATA_DIR);
  button_cancel = create_button(window, buf, _("Cancel"));
  evas_object_smart_callback_add(button_cancel, "clicked", cancel_callback, NULL);
  elm_box_pack_start(buttonbar, button_cancel);
  evas_object_show(button_cancel);

  snprintf(buf, sizeof(buf), "%s/icon-ok.png", PACKAGE_DATA_DIR);
  button_ok = create_button(window, buf, _("OK"));
  evas_object_smart_callback_add(button_ok, "clicked", entry_callback, entry);
  elm_box_pack_end(buttonbar, button_ok);
  evas_object_show(button_ok);

  if (!window_width)
    evas_object_geometry_get(window, NULL, NULL, &window_width, NULL);
  if (!window_height)
    evas_object_geometry_get(window, NULL, NULL, NULL, &window_height);

  evas_object_resize(window, window_width, window_height);

  evas_object_show(window);
}
示例#10
0
文件: tiling.c 项目: gwash/ion-3plus
static WRegion *create_frame_tiling(WWindow *parent, const WFitParams *fp)
{
    return (WRegion*)create_frame(parent, fp, FRAME_MODE_TILED);
}
示例#11
0
// Codigo para procesar los comandos recibidos a traves del canal USB
static portTASK_FUNCTION( CommandProcessingTask, pvParameters ){



	unsigned char frame[MAX_FRAME_SIZE];	//Ojo, esto hace que esta tarea necesite bastante pila
	int numdatos;
	unsigned int errors=0;
	unsigned char command;
	EventBits_t bits;



	/* The parameters are not used. */
	( void ) pvParameters;


	for(;;)
	{
		numdatos=receive_frame(frame,MAX_FRAME_SIZE);
		if (numdatos>0)
		{	//Si no hay error, proceso la trama que ha llegado.
			numdatos=destuff_and_check_checksum(frame,numdatos);
			if (numdatos<0)
			{
				//Error de checksum (PROT_ERROR_BAD_CHECKSUM), ignorar el paquete
				errors++;
				// Procesamiento del error (TODO)
			}
			else
			{
				//El paquete esta bien, luego procedo a tratarlo.
				command=decode_command_type(frame,0);
				bits=xEventGroupGetBits(xEventGroup);
				switch(command)
				{
				case COMANDO_PING :

					if(bits & TrazaBit == TrazaBit){
						UARTprintf("Comando PING\n ");
					}

					//A un comando de ping se responde con el propio comando
					numdatos=create_frame(frame,command,0,0,MAX_FRAME_SIZE);
					if (numdatos>=0)
					{
						send_frame(frame,numdatos);
					}else{
						//Error de creacion de trama: determinar el error y abortar operacion
						errors++;
						logError(numdatos);

					}
					break;
				case COMANDO_START:         // Comando de ejemplo: eliminar en la aplicacion final
				{

					if(bits & TrazaBit == TrazaBit){
						UARTprintf("Comando START\n ");
					}


					if(sensorTaskHandle == NULL){

						inicializarVariables();

						if((xTaskCreate(ConsumoTask, (signed portCHAR *)"Consumo", LED1TASKSTACKSIZE,NULL,tskIDLE_PRIORITY + 1, &consumoTaskHandle)!= pdTRUE))
						{
							while(1);
						}

						if((xTaskCreate(SensorTask, (signed portCHAR *)"Sensor", LED1TASKSTACKSIZE,NULL,tskIDLE_PRIORITY + 1, &sensorTaskHandle) != pdTRUE))
						{
							while(1);
						}
						if((xTaskCreate(HighTask, (signed portCHAR *)"Altitud", LED1TASKSTACKSIZE,NULL,tskIDLE_PRIORITY + 1, &altitudTaskHandle) != pdTRUE))
						{
							while(1);
						}

						if((xTaskCreate(turbulenciasTask, (signed portCHAR *)"Turbulencias", LED1TASKSTACKSIZE,NULL,tskIDLE_PRIORITY + 1, &turbulenciasTaskHandle) != pdTRUE))
						{
							while(1);
						}
					}

				}
				break;
				case COMANDO_STOP:
				{
					if(bits & TrazaBit == TrazaBit){
						UARTprintf("Comando STOP\n ");
					}
					if(combustible>0){ //Eliminamos las tareas en el STOP
						vTaskDelete(sensorTaskHandle);
						vTaskDelete( consumoTaskHandle );
						vTaskDelete(altitudTaskHandle);
						vTaskDelete( turbulenciasTaskHandle );

					}

				}
				break;
				case COMANDO_SPEED:
				{

					if(bits & TrazaBit == TrazaBit){
						UARTprintf("Comando SPEED\n ");
					}
					float  velocidad;

					//Recibimos y enviamos por la cola la velocidad
					extract_packet_command_param(frame,sizeof(velocidad),&velocidad);
					xQueueSend( velocidadQueue,&velocidad,portMAX_DELAY);

				}
				break;
				case COMANDO_TIME:
				{

					if(bits & TrazaBit == TrazaBit){
						UARTprintf("Comando TIME\n ");
					}

					uint32_t hora;
					extract_packet_command_param(frame,sizeof(hora),&hora);
					//recibimos y actualizamos el valor de Hora
					setHora(hora);
					//Creamos la tarea Time
					if(xTaskCreate(TimeTask, (portCHAR *)"Time",LED1TASKSTACKSIZE, NULL, tskIDLE_PRIORITY + 1, NULL) != pdTRUE)
					{
						while(1);
					}

				}
				break;
				default:
				{
					PARAM_COMANDO_NO_IMPLEMENTADO parametro;
					parametro.command=command;
					//El comando esta bien pero no esta implementado
					numdatos=create_frame(frame,COMANDO_NO_IMPLEMENTADO,&parametro,sizeof(parametro),MAX_FRAME_SIZE);
					if (numdatos>=0)
					{
						send_frame(frame,numdatos);
					}
					break;
				}
				}
			}
		}else{ // if (numdatos >0)
			//Error de recepcion de trama(PROT_ERROR_RX_FRAME_TOO_LONG), ignorar el paquete
			errors++;

		}
	}
}
示例#12
0
static portTASK_FUNCTION(ConsumoTask,pvParameters)
{

	double consumo=0.0374*exp(0.02*((velocidad*100)/240)); //actualizamos el consumo


	TickType_t tiempo_ant =xTaskGetTickCount(  ); //obtenemos los tick transcurridos


	unsigned char frame[MAX_FRAME_SIZE];
	int num_datos;

	double combustible;
	int16_t ejes[3];
	double  altitud;

	while(1)
	{

		if(xQueueReceive(velocidadQueue,&velocidad, configTICK_RATE_HZ)){
			//Si recibimos un nuevo valor de velocidad cambiamos brillo del led azul
			color[BLUE]=0xFFFF;
			RGBSet(color,((float)velocidad)/241);
		}

		if((xTaskGetTickCount(  )-tiempo_ant)>=configTICK_RATE_HZ*(60/tiempoSim) && combustible!=0){
			//Cada minuto real (1 hora simulada)
			combustible=getCombustible();
			//Modificamos el combustible segun el consumo
			combustible -= 0.5*exp(0.02*(velocidad*100/240)) ;


			if(combustible<=20){ //Encendemos el Led Verde si el combustible es menor que 20
				color[GREEN]=0xFFFF;
				RGBColorSet(color);
			}

			if(combustible<=0){ //Si el combustible es cero desactivamos el ADC
				combustible=0;
				velocidad=0;
				color[BLUE]=0x0;

				xEventGroupClearBits( xEventGroup, PilotoAutomaticoBit );
				ADCSequenceDisable(ADC0_BASE,0);

			}

			//Enviamos el combustible
			setCombustible(combustible);
			num_datos=create_frame(frame, COMANDO_FUEL, &combustible, sizeof(combustible), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}

			tiempo_ant =xTaskGetTickCount(  );
		}


		getEjes(ejes);
		altitud=getAltitud();
		if(ejes[PITCH]>-45 && combustible==0 && altitud>0){ //si el combustible es cero ponemos PITCH =45 poco a poco

			ejes[PITCH]--;

			setEjes(ejes[PITCH],ejes[ROLL],ejes[YAW]);

			num_datos=create_frame(frame, COMANDO_EJES, ejes, sizeof(ejes), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}
		}



	}
}
示例#13
0
static portTASK_FUNCTION(SensorTask,pvParameters)
		{

	uint32_t potenciometros[3];

	int16_t lastEjes[3]={0,0,0};

	unsigned char frame[MAX_FRAME_SIZE];
	int num_datos;

	int16_t ejes[3];

	getEjes(ejes);

	// Enviamos incialmente el estado de los ejes
	num_datos=create_frame(frame, COMANDO_EJES, ejes, sizeof(ejes), MAX_FRAME_SIZE);
	if (num_datos>=0){
	send_frame(frame, num_datos);
	}else{

		logError(num_datos);

	}

	while(1)
	{
		xQueueReceive(potQueue,potenciometros,portMAX_DELAY); //Esperamos a que llegue información del ADC

		getEjes(ejes); //Obtenemos como están actualmente los ejes

		/* Para el PITCH y ROLL los potenciometros tendran cinco zonas donde la central no modificará los ejes y
		 * las laterales aumentaran o disminuiran los valores de uno en uno o dos en dos.
		 */
		if(potenciometros[PITCH]<819){
			ejes[PITCH]-=2;
		}else if(potenciometros[PITCH]>=819 && potenciometros[PITCH]<1638){
			ejes[PITCH]-=1;
		}else if(potenciometros[PITCH]>=2458 && potenciometros[PITCH]<3276){
			ejes[PITCH]+=1;
		}else if(potenciometros[PITCH]>=3276 && potenciometros[PITCH]<4095){
			ejes[PITCH]+=2;
		}

		if( potenciometros[ROLL]<819){
			ejes[ROLL]-=2;
		}else if(potenciometros[ROLL]>=819 && potenciometros[ROLL]<1638){
			ejes[ROLL]-=1;
		}else if(potenciometros[ROLL]>=2458 && potenciometros[ROLL]<3276){
			ejes[ROLL]+=1;
		}else if(potenciometros[ROLL]>=3276 && potenciometros[ROLL]<4095){
			ejes[ROLL]+=2;
		}

		//Vemos si ha llegado al máximo
		if (ejes[PITCH]>45){
			ejes[PITCH]=45;
		}else if (ejes[PITCH]<-45){
			ejes[PITCH]=-45;
		}

		if (ejes[ROLL]>30){
			ejes[ROLL]=30;
		}else if (ejes[ROLL]<-30){
			ejes[ROLL]=-30;
		}


		ejes[YAW]=(potenciometros[YAW]*360)/4095; //Obtenemos el valor del yaw entre 0 y 360

		setEjes(ejes[PITCH], ejes[ROLL], ejes[YAW]); //Modificamos los ejes

		if(ejes[PITCH]!=lastEjes[PITCH] || ejes[ROLL]!=lastEjes[ROLL] || ejes[YAW]!=lastEjes[YAW]){
			//Solo enviamos los ejes si se han modificado
			num_datos=create_frame(frame, COMANDO_EJES, ejes, sizeof(ejes), MAX_FRAME_SIZE);
			if (num_datos>=0){
			send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}
			lastEjes[PITCH]=ejes[PITCH];
			lastEjes[ROLL]=ejes[ROLL];
			lastEjes[YAW]=ejes[YAW];
		}
	}

}
示例#14
0
static portTASK_FUNCTION(HighTask,pvParameters)
{

	unsigned char frame[MAX_FRAME_SIZE];
	int num_datos;

	double altitud;
	int16_t ejes[3];
	double combustible;
	float velocidad;
	int tiempoSim;

	while(1)
	{
		vTaskDelay(configTICK_RATE_HZ); //Cada seg

		//Obtenemos las variables
		altitud=getAltitud();
		velocidad=getVelocidad();
		tiempoSim=getTiempoSim();

		if(altitud>0){ //Si la altitud es mayor que cero cambiamos la altitud

			getEjes(ejes);
			altitud += sin((ejes[PITCH]*3.14f)/180) *(velocidad*(1000/(60/tiempoSim)));

			if(altitud>99999){ //99999 es el maximo del panel QT
				altitud=99999;
			}

			//Enviamos la trama con la altitud
			setAltitud(altitud);

			num_datos=create_frame(frame, COMANDO_HIGH, &altitud, sizeof(altitud), MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}

			//Obtenemos el combustible
			combustible=getCombustible();
			if(combustible==0){//Si ya estamos sin combustible hacemos parpadear los led con la altitud
				color[BLUE]=0xFFFF;
				if(altitud<=800){
					color[RED]=0xFFFF;
					color[GREEN]=0x0;
				}
				RGBColorSet(color);
				if(altitud<2000){
					RGBBlinkRateSet((float)(1000/(altitud+1)));
				}
				tiempoSim=getTiempoSim();

				//Aumentamos la velocidad a 9,8m/s^2
				velocidad+=9.8*(60*tiempoSim)/1000;
				setVelocidad(velocidad);
				//Enviamos la nueva velocidad
				num_datos=create_frame(frame, COMANDO_SPEED, &velocidad, sizeof(velocidad), MAX_FRAME_SIZE);
				if (num_datos>=0){
					send_frame(frame, num_datos);
				}else{

					logError(num_datos);

				}
			}

		}else{ //Si la altitud es menor o igual a 0

			//Variables a cero
			velocidad=0;
			altitud=0;

			setVelocidad(velocidad);
			setAltitud(altitud);

			//Enviamos comando colision
			if(combustible!=0) ADCSequenceDisable(ADC0_BASE,0);
			num_datos=create_frame(frame, COMANDO_COLISION,NULL, 0, MAX_FRAME_SIZE);
			if (num_datos>=0){
				send_frame(frame, num_datos);
			}else{

				logError(num_datos);

			}



			//BLOQUEAMOS LA TIVA
			vTaskDelete(sensorTaskHandle);
			vTaskDelete( consumoTaskHandle );
			vTaskDelete(altitudTaskHandle);
			vTaskDelete( turbulenciasTaskHandle );
			vTaskEndScheduler(  );

			while(1);

		}




	}
}
示例#15
0
error_code_t ls_remote(receiver_param *rp, const char *command)
{
    struct frame_t frame_info;
    struct frame_t recv_frame_info;
    char *recv_frame;
    char *frame;
    char buffer[32];
    int done;
    error_code_t e = OK;
    int timeout_count = 0;
    
    int sequence = 0;
    
    if (command[2] != ' ' && command[2] != '\0')
        return INV_CMD;
    
    frame_info.size = strlen(&command[3]);
    frame_info.sequence = 0;
    frame_info.type = 'L';
    frame_info.data = malloc(frame_info.size);
    strcpy(frame_info.data, &command[3]); 
    frame = create_frame(&frame_info);
    
    done = 0;
    while (!done)
    {
        if (timeout_count == 0)
        {
            if (send(rp->source_sd, frame, FRAME_MAX_SIZE, 0) <= 0)
                perror("WARNING");
        }
        pthread_mutex_lock(&receive_queue_mutex);
        recv_frame = list_dequeue(rp->queue);
        pthread_mutex_unlock(&receive_queue_mutex);
        
        if (recv_frame)
        {
            if (decode_frame(recv_frame, &recv_frame_info))
            {
                if (sequence == recv_frame_info.sequence)
                {
                    if (recv_frame_info.type == 'X' || recv_frame_info.type == 'Z')
                    {
                        send_ack(rp->source_sd, sequence);
                        sequence = (sequence+1) % (FRAME_SEQ_MAX+1);
                        memcpy(buffer, recv_frame_info.data, recv_frame_info.size);
                        buffer[recv_frame_info.size] = '\0';
                        printf("%s", buffer);
                        if (recv_frame_info.type == 'Z') done = 1;
                    }
                    else if (recv_frame_info.type == 'N')
                        timeout_count = 0;
                }
                else if (abs((frame_info.sequence-sequence) % (FRAME_SEQ_MAX+1)) < WINDOW_SIZE)
                {
                    send_nack(rp->source_sd, frame_info.sequence);
                }
                else
                {
                    send_ack(rp->source_sd, frame_info.sequence);
                }
                free(recv_frame_info.data);
            }
            else
            {
                send_nack(rp->source_sd, sequence);
            }
            free(recv_frame);
        }
        else
        {
            usleep(2);
            timeout_count = (timeout_count + 1) % (TIMEOUT_LIMIT + 1);
        }
    }
    free(frame);
    free(frame_info.data);
    
    return e;
}
示例#16
0
static void
create_calendar(void)
{
  static CalendarData calendar_data;

  GtkWidget *window, *hpaned, *vbox, *rpane, *hbox;
  GtkWidget *calendar, *toggle, *scroller, *button;
  GtkWidget *frame, *label, *bbox, *details;

  GtkSizeGroup *size;
  GtkStyleContext *context;
  PangoFontDescription *font_desc;
  gchar *font;
  gint i;
  
  struct {
    gboolean init;
    char *label;
  } flags[] =
    {
      { TRUE,  "Show _Heading" },
      { TRUE,  "Show Day _Names" },
      { FALSE, "No Month _Change" },
      { TRUE,  "Show _Week Numbers" },
      { FALSE, "Week Start _Monday" },
      { TRUE,  "Show De_tails" },
    };

  calendar_data.window = NULL;
  calendar_data.font_dialog = NULL;
  calendar_data.details_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    calendar_data.settings[i] = 0;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
  gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example");
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

  /* Calendar widget */

  calendar = gtk_calendar_new ();
  calendar_data.calendar_widget = calendar;
  frame = create_frame ("<b>Calendar</b>", calendar, GTK_ALIGN_CENTER, GTK_ALIGN_CENTER);
  gtk_paned_pack1 (GTK_PANED (hpaned), frame, TRUE, FALSE);

  calendar_data.window = calendar;
  calendar_set_flags(&calendar_data);
  gtk_calendar_mark_day (GTK_CALENDAR (calendar), 19);	

  g_signal_connect (calendar, "month_changed", 
		    G_CALLBACK (calendar_month_changed),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected", 
		    G_CALLBACK (calendar_day_selected),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected_double_click", 
		    G_CALLBACK (calendar_day_selected_double_click),
		    &calendar_data);
  g_signal_connect (calendar, "prev_month", 
		    G_CALLBACK (calendar_prev_month),
		    &calendar_data);
  g_signal_connect (calendar, "next_month", 
		    G_CALLBACK (calendar_next_month),
		    &calendar_data);
  g_signal_connect (calendar, "prev_year", 
		    G_CALLBACK (calendar_prev_year),
		    &calendar_data);
  g_signal_connect (calendar, "next_year", 
		    G_CALLBACK (calendar_next_year),
		    &calendar_data);

  rpane = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  gtk_paned_pack2 (GTK_PANED (hpaned), rpane, FALSE, FALSE);

  /* Build the right font-button */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  frame = create_frame ("<b>Options</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (rpane), frame);
  size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  context = gtk_widget_get_style_context (calendar);
  gtk_style_context_get (context, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
  font = pango_font_description_to_string (font_desc);
  button = gtk_font_button_new_with_font (font);
  g_free (font);
  pango_font_description_free (font_desc);

  g_signal_connect (button, "font-set",
                    G_CALLBACK(calendar_select_font),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("_Font:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the width entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_width_chars (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_width_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details W_idth:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the height entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_height_rows (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_height_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details H_eight:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the right details frame */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  frame = create_frame ("<b>Details</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_FILL);
  gtk_box_pack_start (GTK_BOX (rpane), frame);

  details = gtk_text_view_new();
  calendar_data.details_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (details));

  calendar_data.details_changed = g_signal_connect (calendar_data.details_buffer, "changed",
                                                    G_CALLBACK (calendar_details_changed),
                                                    &calendar_data);

  scroller = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scroller), details);

  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroller),
                                       GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_box_pack_start (GTK_BOX (vbox), scroller);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_widget_set_halign (hbox, GTK_ALIGN_START);
  gtk_widget_set_valign (hbox, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  button = gtk_button_new_with_mnemonic ("Demonstrate _Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (demonstrate_details),
                            &calendar_data);

  gtk_box_pack_start (GTK_BOX (hbox), button);

  button = gtk_button_new_with_mnemonic ("_Reset Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (reset_details),
                            &calendar_data);

  gtk_box_pack_start (GTK_BOX (hbox), button);

  toggle = gtk_check_button_new_with_mnemonic ("_Use Details");
  g_signal_connect (toggle, "toggled",
                    G_CALLBACK(calendar_toggle_details),
                    &calendar_data);
  gtk_box_pack_start (GTK_BOX (vbox), toggle);

  /* Build the Right frame with the flags in */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  frame = create_expander ("<b>Flags</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (rpane), frame);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    {
      toggle = gtk_check_button_new_with_mnemonic(flags[i].label);
      gtk_box_pack_start (GTK_BOX (vbox), toggle);
      calendar_data.flag_checkboxes[i] = toggle;

      g_signal_connect (toggle, "toggled",
                        G_CALLBACK (calendar_toggle_flag),
			&calendar_data);

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), flags[i].init);
    }

  /*
   *  Build the Signal-event part.
   */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
  frame = create_frame ("<b>Signal Events</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.last_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.prev_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Second previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.prev2_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev2_sig);

  /*
   *  Glue everything together
   */

  bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);

  button = gtk_button_new_with_label ("Close");
  g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);

  gtk_box_pack_start (GTK_BOX (vbox), hpaned);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_box_pack_start (GTK_BOX (vbox), frame);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_box_pack_start (GTK_BOX (vbox), bbox);

  gtk_container_add (GTK_CONTAINER (window), vbox);

  gtk_widget_set_can_default (button, TRUE);
  gtk_widget_grab_default (button);

  gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
  gtk_widget_show (window);
}
示例#17
0
int main(int argc, char **args)
{
    init_win();
    int i = 0,flag = 0, x = 0;
    bug_msg_t *p = (bug_msg_t *)malloc(sizeof(bug_msg_t));
    if(p == NULL) {
        return -1;
    } 
    user_msg_t *p_1 = (user_msg_t *)malloc(sizeof(user_msg_t));
    if(p_1 == NULL) {
        return -1;
    } 
    head.next = &head;
    head.prev = &head;
    head_user.next = &head_user;
    head_user.prev = &head_user;
    overload_bugList();
joggle: 
	overload_userList();
    i = boot_screen();
    switch(i){
        case 0:
            create_frame();
            create_msg_zone();
            create_title_window("User Login");
			x = user_login();
            if(x == 1) {
                 show_message("No user\nPlease register");
                 sleep(2);
                 goto joggle;
            }            
            if(x == 0) {
            core:
                flag = core_func();
                switch(flag){
                    case 0:
                       p = &head;
                        if( Add_Bug() == 0) {
                            File_bugList(p);
                            goto core;
                        }else {
                             return 0;
                        }
                    case 1:
                        if(Selection_Show_Bug() == -1){
                           goto core;
                        }else {
                             p = &head;
                             File_bugList(p);
                        }
                        break;
                    default:
                         exit_win();
                         return 0;
                }
            }
            break;
        case 1:
            create_frame();
            create_msg_zone();
            create_title_window("User Register");
       	    if(User_register() == 0) {
                 p_1 = &head_user;
                 File_userList(p_1);
                 goto joggle;
                 break;
            }
            break;
        default:
            exit_win();
            return 0;
    }
     exit_win();
     return 0;
}
示例#18
0
/**
@brief    Adds a frame to a workspace, creating the workspace if required.
          Indirectly creates workspaces and frames.  Gets the program name from the frame using the class hints (load_program_name).
          If the program name doesn't match the name of any workspace, creates a new workspace.
          If the workspace is new, switch to the workspace.  Try and tile the frame if its mode is tiling.
          Decide whether to show the frame and whether to focus it.
@return   the index of the workspace the frame was inserted into or -1 if an error occurred.
**/
int
add_frame_to_workspace(Display *display, struct Workspace_list *workspaces, Window framed_window, int *current_workspace, struct Workspace **frames
, struct Popup_menu *window_menu
, struct Separators *seps
, const struct Workarea *workarea
, struct Themes *themes, struct Cursors *cursors, struct Atoms *atoms) {

  int home_w;  //index of the home workspace of the frame
  int true_frame_index; //index of the frame in the global frame list in workspaces

  Bool new_workspace = False;  //boolean indicator to check if a workspace was just created.
  char *program_name = load_program_name(display, framed_window);

  if(program_name == NULL) {
    #ifdef SHOW_MAP_REQUEST_EVENT
    printf("Warning, could not load program name for window %lu. ", framed_window);
    printf("Creating default workspace\n");
    #endif
    make_default_program_name(display, framed_window, "Other Programs");
    program_name = load_program_name(display, framed_window);
  }
  if(program_name == NULL) {perror("Error: out of memory"); return -1;} //probably out of memory

  for(home_w = 0; home_w < workspaces->used_workspaces; home_w++) {
    if(strcmp(program_name, workspaces->list[home_w].workspace_name) == 0) {
      XFree(program_name);
      break;
    }
  }
  if(home_w == workspaces->used_workspaces) { //create_statup workspaces only creates a workspace if there is at least one
    home_w = create_workspace(display, workspaces, program_name, themes);
    if(home_w < 0) { perror("Error: could not create new workspace\n"); return -1; }
    new_workspace = True;
  }

  if(ensure_empty_frame_slots(workspaces) == False) return -1;
  if(ensure_empty_frame_reference_slots(&workspaces->list[home_w]) == False) return -1;

  true_frame_index = workspaces->used_frames;
  if(!create_frame(display, &workspaces->frame_list[true_frame_index], framed_window, window_menu, seps, workarea, themes, cursors, atoms)) {
    //if the window wasn't created, and the workspace is now empty, remove the workspace
    if(new_workspace) { remove_workspace(display, workspaces, home_w);  }
    return -1;
  }

  workspaces->used_frames++;
  #ifdef SHOW_MAP_REQUEST_EVENT
  printf("Workspace %d, real frame index %d, frame_name %s, window %lu, workspace_name %s\n", home_w, true_frame_index
  , workspaces->frame_list[true_frame_index].window_name, framed_window, workspaces->list[home_w].workspace_name);
  #endif

  check_and_set_new_frame_focus (display, &workspaces->frame_list[true_frame_index], &workspaces->list[home_w]);

  //check if it's neutral
  Bool show_in_other_workspaces = suitable_for_foreign_workspaces(&workspaces->frame_list[true_frame_index]);
  enum Window_state original_state = workspaces->frame_list[true_frame_index].state; //in case it is fullscreen

  { //save state of window in home workspace and other workspaces if it's meant to be shown in other workspaces.
    //Otherwise the saved state entry will simply zero'd.
    int workspace_index = 0;

    do {
      if(!show_in_other_workspaces) workspace_index = home_w; //only do one pass if we don't want to make it available

      workspaces->list[workspace_index].states[true_frame_index].need_to_tile = 0; //reset

      if(workspace_index == home_w) {
        workspaces->list[workspace_index].states[true_frame_index].available = 1;
        if(workspaces->frame_list[true_frame_index].mode == tiling  &&  home_w != *current_workspace) {
          workspaces->list[workspace_index].states[true_frame_index].need_to_tile = 1;
        }
        change_frame_state(display, &workspaces->frame_list[true_frame_index], original_state, seps, workarea, themes, atoms);
        save_frame_state(&workspaces->list[workspace_index].states[true_frame_index], &workspaces->frame_list[true_frame_index]);
      }
      else if (show_in_other_workspaces) {
        workspaces->list[workspace_index].states[true_frame_index].available = 2;
        change_frame_state(display, &workspaces->frame_list[true_frame_index], minimized, seps, workarea, themes, atoms);
        save_frame_state(&workspaces->list[workspace_index].states[true_frame_index], &workspaces->frame_list[true_frame_index]);
      }

      workspace_index++;
    }
    while(show_in_other_workspaces  &&  workspace_index < workspaces->used_workspaces);
  }

  if(home_w == *current_workspace  &&  *current_workspace != -1) { //new window is in the current workspace
     //save the reference
    struct Workspace *workspace = &workspaces->list[*current_workspace];
    int frame_ref_index = workspace->used;
    workspace->list[frame_ref_index] = &workspaces->frame_list[true_frame_index];
    workspace->used++;

    change_frame_state(display, &workspaces->frame_list[true_frame_index], original_state, seps, workarea, themes, atoms);
    if(workspace->list[frame_ref_index]->mode == tiling  &&  workspace->list[frame_ref_index]->state != fullscreen) {
      if(!redrop_frame(display, workspace, frame_ref_index, workarea, themes)) {
        change_frame_state(display, workspace->list[frame_ref_index], minimized, seps, workarea, themes, atoms);
      }
    }
    #ifdef SHOW_MAP_REQUEST_EVENT
    printf("Created and mapped window in workspace %d\n", *current_workspace);
    #endif
    if(workspaces->frame_list[true_frame_index].state != minimized) XMapWindow(display, workspace->list[frame_ref_index]->widgets[frame_parent].widget);
    XMapWindow(display, workspace->list[frame_ref_index]->menu.item);
    if(workspace->list[frame_ref_index]->focussed) {
      recover_focus(display, &workspaces->list[*current_workspace], atoms);
    }

    update_client_list(display, &workspaces->list[*current_workspace], atoms);
  }

  if(home_w != *current_workspace) {
    change_to_workspace(display, workspaces, current_workspace, frames, home_w, seps, workarea, themes, atoms);
  }

  XFlush(display);
  return home_w;
}
示例#19
0
/*---------------------------------------------------------------------------*/
static int
hdr_length(struct net_buf *buf)
{
  return create_frame(buf, 0);
}
示例#20
0
void check_null_frame(char *data, int size)
{
	CHECK_EQUAL((stomp_frame *)NULL, create_frame(data, size));                 
}
示例#21
0
/*---------------------------------------------------------------------------*/
static int
create(struct net_buf *buf)
{
  return create_frame(buf, 1);
}
示例#22
0
int
rpc_clnt_mgmt_pmap_signout (glusterfs_ctx_t *ctx, char *brickname)
{
        int               ret = 0;
        pmap_signout_req  req = {0, };
        call_frame_t     *frame = NULL;
        cmd_args_t       *cmd_args = NULL;
        char              brick_name[PATH_MAX]  = {0,};
        struct iovec      iov = {0, };
        struct iobuf     *iobuf = NULL;
        struct iobref    *iobref = NULL;
        ssize_t           xdr_size = 0;

        frame = create_frame (THIS, ctx->pool);
        cmd_args = &ctx->cmd_args;

        if (!cmd_args->brick_port && (!cmd_args->brick_name || !brickname)) {
                gf_log ("fsd-mgmt", GF_LOG_DEBUG,
                        "portmapper signout arguments not given");
                goto out;
        }

        if (cmd_args->volfile_server_transport &&
            !strcmp(cmd_args->volfile_server_transport, "rdma")) {
                snprintf (brick_name, sizeof(brick_name), "%s.rdma",
                          cmd_args->brick_name);
                req.brick = brick_name;
        } else {
                if (brickname)
                        req.brick = brickname;
                else
                        req.brick = cmd_args->brick_name;
        }

        req.port  = cmd_args->brick_port;
        req.rdma_port = cmd_args->brick_port2;

        /* mgmt_submit_request is not available in libglusterfs.
         * Need to serialize and submit manually.
         */
        iobref = iobref_new ();
        if (!iobref) {
                goto out;
        }

        xdr_size = xdr_sizeof ((xdrproc_t)xdr_pmap_signout_req, &req);
        iobuf = iobuf_get2 (ctx->iobuf_pool, xdr_size);
        if (!iobuf) {
                goto out;
        };

        iobref_add (iobref, iobuf);

        iov.iov_base = iobuf->ptr;
        iov.iov_len  = iobuf_pagesize (iobuf);

        /* Create the xdr payload */
        ret = xdr_serialize_generic (iov, &req,
                                     (xdrproc_t)xdr_pmap_signout_req);
        if (ret == -1) {
                gf_log (THIS->name, GF_LOG_WARNING,
                        "failed to create XDR payload");
                goto out;
        }
        iov.iov_len = ret;

        ret = rpc_clnt_submit (ctx->mgmt, &clnt_pmap_signout_prog,
                               GF_PMAP_SIGNOUT, mgmt_pmap_signout_cbk,
                               &iov, 1,
                               NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL);
out:
        if (iobref)
                iobref_unref (iobref);

        if (iobuf)
                iobuf_unref (iobuf);
        return ret;
}
int
cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
                           const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        int                     flags   = 0;
        gf1_cli_stop_vol_req    req = {0,};
        gf_answer_t             answer = GF_ANSWER_NO;
        int                     sent = 0;
        int                     parse_error = 0;

        const char *question = "Stopping volume will make its data inaccessible. "
                               "Do you want to continue?";

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        if (wordcount < 3 || wordcount > 4) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        req.volname = (char *)words[2];
        if (!req.volname)
                goto out;

        if (wordcount == 4) {
                if (!strcmp("force", words[3])) {
                        flags |= GF_CLI_FLAG_OP_FORCE;
                } else {
                        ret = -1;
                        cli_usage_out (word->pattern);
                        parse_error = 1;
                        goto out;
                }
        }

        answer = cli_cmd_get_confirmation (state, question);

        if (GF_ANSWER_NO == answer) {
                ret = 0;
                goto out;
        }

        req.flags = flags;
        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STOP_VOLUME];

        if (proc->fn) {
                ret = proc->fn (frame, THIS, &req);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Volume stop on '%s' failed", req.volname);
        }

        return ret;
}
示例#24
0
int
cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word,
                      const char **words, int wordcount)
{
        char                   cmd_arg_name[PATH_MAX] = "";
        char                  *command                = NULL;
        char                  *saveptr                = NULL;
        char                  *tmp                    = NULL;
        int                    ret                    = -1;
        int                    i                      = -1;
        int                    cmd_args_count         = 0;
        int                    in_cmd_args_count      = 0;
        rpc_clnt_procedure_t  *proc                   = NULL;
        call_frame_t          *frame                  = NULL;
        dict_t                *dict                   = NULL;
        cli_local_t           *local                  = NULL;

        if (wordcount < 3) {
                cli_usage_out (word->pattern);
                goto out;
        }

        dict = dict_new ();
        if (!dict)
                goto out;

        command = strtok_r ((char *)words[2], " ", &saveptr);
        do {
                tmp = strtok_r (NULL, " ", &saveptr);
                if (tmp) {
                        in_cmd_args_count++;
                        memset (cmd_arg_name, '\0', sizeof(cmd_arg_name));
                        snprintf (cmd_arg_name, sizeof(cmd_arg_name),
                                  "cmd_arg_%d", in_cmd_args_count);
                        ret = dict_set_str (dict, cmd_arg_name, tmp);
                        if (ret) {
                                gf_log ("", GF_LOG_ERROR, "Unable to set "
                                        "%s in dict", cmd_arg_name);
                                goto out;
                        }
                }
        } while (tmp);

        cmd_args_count = wordcount - 3;

        ret = dict_set_str (dict, "command", command);
        if (ret) {
                gf_log ("", GF_LOG_ERROR, "Unable to set command in dict");
                goto out;
        }

        for (i=1; i <= cmd_args_count; i++) {
                in_cmd_args_count++;
                memset (cmd_arg_name, '\0', sizeof(cmd_arg_name));
                snprintf (cmd_arg_name, sizeof(cmd_arg_name),
                          "cmd_arg_%d", in_cmd_args_count);
                ret = dict_set_str (dict, cmd_arg_name,
                                    (char *)words[2+i]);
                if (ret) {
                        gf_log ("", GF_LOG_ERROR, "Unable to set %s in dict",
                               cmd_arg_name);
                        goto out;
                }
        }

        ret = dict_set_int32 (dict, "cmd_args_count", in_cmd_args_count);
        if (ret) {
                gf_log ("", GF_LOG_ERROR,
                        "Unable to set cmd_args_count in dict");
                goto out;
        }

        ret = dict_set_str (dict, "volname", "N/A");
        if (ret) {
                gf_log ("", GF_LOG_ERROR, "Unable to set volname in dict");
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYS_EXEC];
        if (proc && proc->fn) {
                frame = create_frame (THIS, THIS->ctx->pool);
                if (!frame)
                        goto out;
                CLI_LOCAL_INIT (local, words, frame, dict);
                ret = proc->fn (frame, THIS, (void*)dict);
        }
out:
        return ret;
}
int
cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
                         const char **words, int wordcount)
{
        int                             ret = -1;
        rpc_clnt_procedure_t            *proc = NULL;
        call_frame_t                    *frame = NULL;
        cli_cmd_volume_get_ctx_t        ctx = {0,};
        cli_local_t                     *local = NULL;
        int                             sent = 0;
        int                             parse_error = 0;

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOLUME];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        if ((wordcount == 2)  || (wordcount == 3 &&
                                  !strcmp (words[2], "all"))) {
                ctx.flags = GF_CLI_GET_NEXT_VOLUME;
                proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_NEXT_VOLUME];
        } else if (wordcount == 3) {
                ctx.flags = GF_CLI_GET_VOLUME;
                ctx.volname = (char *)words[2];
                if (strlen (ctx.volname) > 1024) {
                        cli_out ("Invalid volume name");
                        goto out;
                }
                proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOLUME];
        } else {
                cli_usage_out (word->pattern);
                parse_error = 1;
                return -1;
        }

        local = cli_local_get ();

        if (!local)
                goto out;

        local->u.get_vol.flags = ctx.flags;
        if (ctx.volname)
                local->u.get_vol.volname = gf_strdup (ctx.volname);

        frame->local = local;

        if (proc->fn) {
                ret = proc->fn (frame, THIS, &ctx);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Getting Volume information failed!");
        }

        return ret;

}
示例#26
0
int
cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word,
                          const char **words, int wordcount)
{
        int                   ret   = -1;
        rpc_clnt_procedure_t *proc  = NULL;
        call_frame_t         *frame = NULL;
        dict_t               *dict  = NULL;
        int                  flags = 0;
        int                  sent = 0;
        int                  parse_error = 0;

        if ((wordcount < 3) || (wordcount > 4)) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEPROBE];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();

        ret = dict_set_str (dict, "hostname", (char *)words[2]);
        if (ret)
                goto out;

/*        if (words[3]) {
                ret = dict_set_str (dict, "port", (char *)words[3]);
                if (ret)
                        goto out;
        }
*/
        if (wordcount == 4) {
                if (!strcmp("force", words[3]))
                        flags |= GF_CLI_FLAG_OP_FORCE;
                else {
                        ret = -1;
                        cli_usage_out (word->pattern);
                        parse_error = 1;
                        goto out;
                }
        }
        ret = dict_set_int32 (dict, "flags", flags);
        if (ret)
                goto out;

        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Peer detach failed");
        }

        return ret;
}
int
cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
                           const char **words, int wordcount)
{
        int                   ret     = -1;
        rpc_clnt_procedure_t *proc    = NULL;
        call_frame_t         *frame   = NULL;
        dict_t               *dict = NULL;
        int                     sent = 0;
        int                     parse_error = 0;
        int                     index = 0;
#ifdef GF_SOLARIS_HOST_OS
        cli_out ("Command not supported on Solaris");
        goto out;
#endif

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict)
                goto out;

        if (!((wordcount == 4) || (wordcount == 5))) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        if (wordcount == 4) {
                index = 3;
        } else {
                if (strcmp (words[3], "fix-layout") && 
                    strcmp (words[3], "migrate-data")) {
                        cli_usage_out (word->pattern);
                        parse_error = 1;
                        goto out;
                }
                index = 4;
        }

	if (strcmp (words[index], "start") && strcmp (words[index], "stop") && 
            strcmp (words[index], "status")) {
	        cli_usage_out (word->pattern);
		parse_error = 1;
		goto out;
	}

        ret = dict_set_str (dict, "volname", (char *)words[2]);
        if (ret)
                goto out;

        if (wordcount == 4) {
                ret = dict_set_str (dict, "command", (char *)words[3]);
                if (ret)
                        goto out;
        }
        if (wordcount == 5) {
                ret = dict_set_str (dict, "start-type", (char *)words[3]);
                if (ret)
                        goto out;
                ret = dict_set_str (dict, "command", (char *)words[4]);
                if (ret)
                        goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEFRAG_VOLUME];

        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (dict)
                dict_destroy (dict);

        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Volume rebalance failed");
        }

        return ret;
}
示例#28
0
/*---------------------------------------------------------------------------*/
static int
create(void)
{
  return create_frame(FRAME802154_DATAFRAME, 1);
}
示例#29
0
void *g_html_special(struct g_part *p, int c, ...)
{
	va_list l;
	unsigned char *t;
	struct form_control *fc;
	struct frameset_param *fsp;
	struct frame_param *fp;
	struct image_description *im;
	struct g_object_tag *tag;
	struct refresh_param *rp;
	struct hr_param *hr;
	va_start(l, c);
	switch (c) {
		case SP_TAG:
			t = va_arg(l, unsigned char *);
			va_end(l);
			/*html_tag(p->data, t, X(p->cx), Y(p->cy));*/
			tag = mem_calloc(sizeof(struct g_object_tag) + strlen(t) + 1);
			tag->mouse_event = g_dummy_mouse;
			tag->draw = g_dummy_draw;
			tag->destruct = g_tag_destruct;
			strcpy(tag->name, t);
			flush_pending_text_to_line(p);
			add_object_to_line(p, &p->line, (struct g_object *)tag);
			break;
		case SP_CONTROL:
			fc = va_arg(l, struct form_control *);
			va_end(l);
			g_html_form_control(p, fc);
			break;
		case SP_TABLE:
			va_end(l);
			return convert_table;
		case SP_USED:
			va_end(l);
			return (void *)(my_intptr_t)!!p->data;
		case SP_FRAMESET:
			fsp = va_arg(l, struct frameset_param *);
			va_end(l);
			return create_frameset(p->data, fsp);
		case SP_FRAME:
			fp = va_arg(l, struct frame_param *);
			va_end(l);
			create_frame(fp);
			break;
		case SP_SCRIPT:
			t = va_arg(l, unsigned char *);
			va_end(l);
			if (p->data) process_script(p->data, t);
			break;
		case SP_IMAGE:
			im = va_arg(l, struct image_description *);
			va_end(l);
			do_image(p, im);
			break;
		case SP_NOWRAP:
			va_end(l);
			break;
		case SP_REFRESH:
			rp = va_arg(l, struct refresh_param *);
			va_end(l);
			html_process_refresh(p->data, rp->url, rp->time);
			break;
		case SP_SET_BASE:
			t = va_arg(l, unsigned char *);
			va_end(l);
			if (p->data) set_base(p->data, t);
			break;
		case SP_HR:
			hr = va_arg(l, struct hr_param *);
			va_end(l);
			g_hr(p, hr);
			break;
		default:
			va_end(l);
			internal("html_special: unknown code %d", c);
	}
	return NULL;
}