Пример #1
0
void tellMonitors(int clientSocket, char * str, int len) {
	clientNode * node =	NULL;
	char * message = NULL;
	void ** holder;
	
	node = monitorList(0, 1, TRUE);
	if (node == NULL || len == 0)
		return;
	
	message =	malloc(sizeof(char) * (7 + 7 + len + 1));
	sprintf(message, "update %06d %s", clientSocket, str);
	
	while (node != NULL) {
		holder = createISIHolder(getSocket(*getClient(node)), message, strlen(message));
		doFunction("sendMessage", holder);
		destroyHolder(holder, 3);
		node =	node->next;
	}//END WHILE LOOP
	
	memset(&message, '\0', sizeof(message));
	free(message);
	message =	NULL;
	
	return;
}//END FUNCTION
void ofxClickDownMenu::mousePressed(ofMouseEventArgs &mouse){
	hl = hilight;
	if (haveChild) return;
	if (haveFChild)return;
	if (phase == PHASE_SELECT) return;
	if ((phase == PHASE_WAIT)&&(Enable)){
		if (((mouse.button == 2)&&(OnlyRightClick))||(!OnlyRightClick)) {
			openMenu(mouse.x,mouse.y);
		}
	}else if (phase == PHASE_CLICK){
		if (menu_focused != -1){
			doFunction();
		}else{
			menu_focused = menus.size()-1;
			doFunction();
		}
	}
	
	
}
Пример #3
0
int main(){
    int cont = 1;
    int w,d,a,k;
    int *p1,*p2;
    int *q1,*q2;
    buffer = (char*)malloc(sizeof(char)*BUF_SIZE);
    int size;
    while (fgets(buffer,BUF_SIZE,stdin) != NULL){
        if (cont == 1){
            sscanf(buffer,"%d %d %d %d",&w,&d,&a,&k);
            k = k + 1;
            p1 = (int*)malloc(sizeof(int)*k);
            q1 = (int*)malloc(sizeof(int)*k);
            p2 = (int*)malloc(sizeof(int)*k);
            q2 = (int*)malloc(sizeof(int)*k);
        }
        else if (cont == 2){
            loopLer(k,&p1);
        }
        else if (cont == 3){
            loopLer(k,&q1);
        }
        else if (cont == 4){
            loopLer(k,&p2);
        }
        else if (cont == 5){
            loopLer(k,&q2);
            cont = 0;
            printf("%f\n",doFunction(p1,q1,k,2));
            free(p1);
            free(p2);
            free(q1);
            free(q2);
        }
        //buffer[0]='\0';
        cont++;
    }
    return 0;
}
Пример #4
0
void processChar(char c)
{  extern int  interuption;
   static char buffer[2048];
   static int  bp = 0;
   static int  escape = 0;
   static int  saw_escape = 0;
   static int  escape_num = 0;
#ifdef VNMRJ
   static int  show_hourglass = 0;
#endif 

   TPRINT2(1,"processChar: got %c (\\0%o)\n",
              (' ' <= c && c <= '~') ? c : ' ',c);
   if (escape && c != NEWLINE && c != CRRETURN)
   {

/*  Escape sequences must include a carriage return, so the Master
    recognizes the Child is busy, and will queue input from the
    Acqproc until the Child completes its current command.

    Thus the operation implied by the Escape Sequence is postponed
    until the Child receives a Carriage Return or New Line character.	*/

      saw_escape = 131071;
      escape_num = 10*escape_num + c-'0';
   }
   else
      switch (c)
      { case NEWLINE:
	case CRRETURN:    
			TPRINT0(1,"processChar: ...carriage return\n");
			if (saw_escape)
			{
			   saw_escape = 0;
                           escape = 0;
			   set_hourglass_cursor();
#ifdef VNMRJ
                           set_batch_function(1); // turn on graphics batch
                           setExecLevel(0);
                           newLogCmd("buttonFunc", 10);
#endif 
			   doFunction( escape_num+'0' );
#ifdef VNMRJ
                           set_batch_function(0); // turn off graphics batch
                           saveLogCmd("buttonFunc", 10);
#endif 
			   restore_original_cursor();
                           bp = 0;
			   sendReadyToMaster();
			   return;
			}
			else if (escape) {
				Werrprintf( "error in input from keyboard" );
				escape = 0;
			        saw_escape = 0;
                                bp = 0;
				sendReadyToMaster();
				return;
			}
			buffer[bp++] = '\n';
			buffer[bp++] = '\0';
			TPRINT0(2,"processChar:    saving environment\n");
			working = 1;

#ifdef VNMRJ
			if ((show_hourglass = get_hourglass(buffer)) != 0)
			   set_hourglass_cursor();
                        set_batch_function(1);
#else 
			show_hourglass = 1;
			set_hourglass_cursor();
#endif 
                        if (c == CRRETURN)
                           skipErrClear();

			/* save command history */
#ifdef VNMRJ
                        setExecLevel(0);
                        if (bp < 512) {
			    p11_writeCmdHistory(buffer); 
                            newLogCmd(buffer, bp);
                        }
		// if(okExec(buffer)) {	
                        doThisCmdHistory = doCmdHistory;
			loadAndExec(buffer);
                        if (doThisCmdHistory)
                        {
                           saveCmdHistory(buffer);
                        }
/*
if ( strncmp(buffer,"jMove",5) && strncmp(buffer,"jFunc",5) )
 */

                        set_batch_function(0);
                        if (bp < 512) {
                            saveLogCmd(buffer, bp - 2);
                        }
			
			p11_updateParamChanged();
		// }
#else 
			loadAndExec(buffer);

#endif 

                        if (show_hourglass != 0)
			    restore_original_cursor();
			Buttons_off();

			working     = 0;
			if (interuption)
			{
			   TPRINT0(2,"processChar:    Back at square one!\n");
			   interuption = 0;
			}
			else
			{
			   TPRINT0(2,"processChar:    Back again (normally)\n");
			}
			bp = 0;
			sendReadyToMaster();
			break;
	case ESC:       
			TPRINT0(1,"processChar: ...escape\n");
			escape = 1;
			escape_num = 0;
			break;
	case BACKSPACE:
	case DELETE:    
			TPRINT0(1,"processChar: ...delete\n");
			if (bp > 0)
			{  bp--;
			   putchar(BACKSPACE);
			   putchar(' ');
			   putchar(BACKSPACE);
			}
			break;
	case CONTROL_U: 
			TPRINT0(1,"processChar: ...^U\n");
			bp = 0;
			break;
	case EOF:
	case CONTROL_D: 
			TPRINT0(1,"processChar: ...end of file\n");
			nmr_exit(vnMode);
			break;
	default:	
			TPRINT1(2,"terminal_mail_loop: got %c\n",c);
			buffer[bp++] = c;
                        if (bp > 2044) {
			    buffer[bp++] = '\n';
			    buffer[bp++] = '\0';
		  	    Werrprintf( "%s", buffer);
		  	    Werrprintf( "command was too long, abort!\n" );
                            bp = 0;
                        }
			break;
      }
}