예제 #1
0
void toggle_buttgui_on_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;
  static char toggle_exit=0;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data^=1;
           redraw_object(o);
           toggle_exit=1;
           }
        else if (toggle_exit)
              {
              set_change();
              toggle_exit=0;
              }
        }
        }

  if ((msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)&&toggle_exit)
     {
     *(char *)o->data^=1;
     redraw_object(o);
     toggle_exit=0;
     }
  }
예제 #2
0
void check_box_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data|=0x80;
           redraw_object(o);
           }
        else if (*(char *)o->data)
              {
               *(char *)o->data^=0x1;
               *(char *)o->data&=0x1;
               redraw_object(o);
               set_change();
              }
        }
        }

  if (msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)
     {
     *(char *)o->data&=0x1;
     redraw_object(o);
     }
  }
예제 #3
0
void buttgui_on_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data=1;
           redraw_object(o);
           }
        else if (*(char *)o->data)
              {
               *(char *)o->data=0;
               redraw_object(o);
               set_change();
              }
        }
        }

  if (msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)
     {
     *(char *)o->data=0;
     redraw_object(o);
     }
  }
예제 #4
0
inline void IAtelier_summer::set_rect(RECT& rect)
{
    if (RectEqulas(rect, _abs_rect))
		return;

    CriticalLock::Scoped scope(_lockChange);
    set_change(GLYPH_CHANGED_ATELIER_RESIZE);

    _abs_rect = rect, _rect.left = _rect.top = 0, _rect.right = RectWidth(rect), _rect.bottom = RectHeight(rect);

    _pHwndRT->Resize(D2D1::SizeU(_rect.right, _rect.bottom));
	_appbmp.SetSize(_pHwndRT, _rect);
    _artist->ResizeRenderTarget(_rect.right, _rect.bottom);

    disposal(_abs_rect);
}
예제 #5
0
inline HRESULT IAtelier_summer::Draw()
{
    HRESULT hr = S_OK;
    CriticalLock::Scoped scope(_lockChange);
    bool bkgchanged = bkg_is_changed(_changed);
    //redraw all back-ground bitmap
    if (bkgchanged)
    {
        //draw backup graph using default bitmap render target
#ifdef  _DEBUG
        //MYTRACE(L"draw backup graph\n");
#endif  //_DEBUG
        _artist->BeginBmpDraw(true);
        _artist->SetTransform(&idmatrix);

        hr = draw_graph(true, IGlyph_summer::GLYPH_TYPE_BKG);

        if (SUCCEEDED(hr))
            hr = _artist->EndBmpDraw();
    }

    //if (SUCCEEDED(hr)) {
    //    if (bkgchanged || graph_is_changed(_changed))
    //    {
            _artist->BeginDraw(true);
            _artist->SetTransform(&idmatrix);

            //draw background first
            _artist->DrawBitmap(_artist->GetDefaultBmp(), _rect, _rect);

            //draw all graph
            hr = draw_graph(bkgchanged);
            //copy to screen-bitmap
            if (SUCCEEDED(hr))
                hr = CopyFromRenderTarget(_pHwndRT, _appbmp._screen, pntZero, _rect);

            if (SUCCEEDED(hr))
                hr = _artist->EndDraw();
    //    } else
    //        hr = draw_screen_bitmap();
    //}

    if (SUCCEEDED(hr))
        set_change(GLYPH_CHANGED_NONE);

    return hr;
}
예제 #6
0
void radio_butts_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;
  int sel;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x02)
        {
        sel=(ms->y-o->locy)/(o->ys/(*((long *)o->userptr+1)));
        if (sel>=*((long *)o->userptr+1)) sel=*((long *)o->userptr+1)-1;
        *(long *)o->data=sel;
        *(long *)o->userptr=0;
        redraw_object(o);
        *(long *)o->userptr=1;
        set_change();
        }
     }

  }
예제 #7
0
	int main(void){

		char *path = "/etc/proyecto_so_1/proy1.ini";
		char *line = NULL;
		size_t len = 0;
		ssize_t reading;
		openlog("ALERT_DAEMON", LOG_PID, LOG_DAEMON);

	 	FILE *fp;

	 	fp = fopen(path,"r");

	 	if (fp == NULL){
			syslog(LOG_ERR,"Fallo en la lectura del archivo de conf proy1.ini");
			closelog();
	    	exit(EXIT_FAILURE);
	      	//notificar por medio de syslog que no se encontro el proy1.ini
	 	}else{
			 	while(!feof(fp)){

	            	while ((reading = getline(&line, &len, fp)) != -1) {

	                	if(line[0] != ';'){

	                  		if(line[0] != '[' && line != NULL){
	                  			//printf("Linea %s\n",line);
	                  			char *buf;
	                  			buf = strsep(&line,"=");

	                  			if((strcmp(buf,"log_tag"))==0){
	                    			tag = strsep(&line,"\0");
	                  	
	                  			}

	                  			if((strcmp(buf,"interval"))==0){
	                    			buf = strsep(&line,"\0");
	                    			interval = atoi(buf);
	                  			
	                  			}
	                		}
	         			}
	       			}
	     		}
		}

		openlog(tag, LOG_PID, LOG_DAEMON);

		if ((lista = (Lista *) malloc (sizeof (Lista))) == NULL){
			syslog(LOG_ERR,"Error, no se pudo inicializar la lista");
	    	exit(EXIT_FAILURE);
	   	}

	   	incializacion(lista);




		while(1==1){

	  		sleep(interval);
	  		char *dir="/var/log";
	  		struct dirent *dp;
	  		DIR *fd;
	  		char  *val,**paragraph;
	  		paragraph = (char**)malloc(1*sizeof(char*));
	  		int position=0;

	  		if ((fd = opendir(dir)) == NULL) {
				
				syslog(LOG_INFO,"Error, no se pudo abrir el directorio /var/log");
	    		closelog();
	    		return;
	  		}

	  		while ((dp = readdir(fd)) != NULL) {

	 			if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
	    		continue;    /* skip self and parent */

	 			char *aux = get_filename_ext(dp->d_name);
	  			// printf("Val--------> %d type dir  %d  type file regular  %d\n ",dp->d_type,DT_DIR,DT_REG);
	   			if(dp->d_type == DT_REG){

	       			if(strcmp(aux,"gz")!=0){
						//agregar a la lista
	        			paragraph = ObtenerPalabras(dp->d_name,paragraph,position);
	        			position++;
	       			}
	   			}
	 		}


					(void) signal(SIGUSR1,manejadorDeSenales);
					int pos=0;

					//printf("Num pal %d\n",position);
					for(pos; pos < position; pos++){

						int i, fds[2];

						if (pipe(fds) == -1) {
							syslog(LOG_ERR,"Error, no se pudo crear la tuberia anonima");
							exit(EXIT_FAILURE);
						}

					 

							pmd5sum = fork();
							if (pmd5sum == 0) {

								hijo(fds,paragraph[pos]);
								kill(pmd5sum,SIGKILL);

							} else if (pmd5sum > 0) {
								/* tratamiento del padre */

					            papa(fds);
					            close(fds[0]);
						        close(fds[1]);
								kill(pmd5sum,SIGKILL);

							} else if (pmd5sum == -1) {

								syslog(LOG_ERR,"Error, fallo en la llamada fork");
								exit(EXIT_FAILURE);

							}

					    	/* tratamiento del padre una vez lanzado su hijo. */
					    	pmd5sum = wait(NULL);

							while (pmd5sum > 0) {
								pmd5sum = wait(NULL);
							}

							if (pmd5sum == -1 && errno != ECHILD) {
								syslog(LOG_ERR,"Error, fallo en la llamada wait");
								exit(EXIT_FAILURE);
							}

					}//fin for que crea hijos
                     // libero el paragragh
                     memset(paragraph,0,sizeof(char*)*position);
					 // visualizacion(lista);
					 // verifico si algun archivo cambio llamando a cambio ?
					char *namepak;
					int cambio = file_change(lista);

					if(cambio==1){//algun archivo cambio
						//procesar .pak
						namepak  = (char*)proccesingPak(lista);
					  	set_change(lista);

					  	pgzip = fork();
					    if (pgzip == 0) {

					          comprimir(namepak);
					          kill(pgzip,SIGKILL);

					    } else if (pgzip > 0) {
					      /* tratamiento del padre */

					    pgzip = wait(NULL);

					    while (pgzip > 0) {
					    	pgzip = wait(NULL);
					 	}


					    }else if (pgzip == -1) {
					    	syslog(LOG_ERR,"Error, fallo en fork");
					      	exit(EXIT_FAILURE);
					    }

					  	if (pgzip == -1 && errno != ECHILD) {
					    	syslog(LOG_ERR,"Error, fallo en wait");
					   		exit(EXIT_FAILURE);
					  	}

					}//FIN IF CAMBIO

	  	}//FIN WHILE TRUE
	}//FIN MAIN
예제 #8
0
void string_list_event(EVENT_MSG *msg,OBJREC *o)
  {
  STRING_LIST_DATA *p;
  int y;
  int znh,i;
  TSTR_LIST ls;
  MS_EVENT *ms;
  static char clicked=0;

  p=o->userptr;
  ls=p->list;
  y=o->locy;

  switch (msg->msg)
     {
     case E_MOUSE:
        i=get_to_topline(ls,p->topline,NULL);
        ms=get_mouse(msg);
        curfont=o->font;
        if (ms->tl1 && clicked || ms->event_type & 0x2)
           {
		   if (ls)
              do
              {
              char *c;

              clicked=1;
              c=ls[i];
              if (i>=p->maxitems) return;
              if (c!=NULL) znh=text_height(c); else znh=0;
              if (y+znh>o->locy+o->ys) return;
              if (ms->y>=y && ms->y<y+znh)
                 {
                 if (ls[i]!=NULL) c_set_value(0,o->id,i);else clicked=0;
                 return;
                 }
              i++;
              y+=znh;
              }
           while (1);
           }
        if (ms->event_type & 0x4 && clicked)
           {
            clicked=0;set_change();
           }
        return;
	 case E_KEYBOARD:
	   {
		 int pos=*(int *)(o->data);
		 int  key=(*(int *)msg->data) & 0xff;
		 if (!key)
		 {
		   int save;
		   int curLine;
		   key=*(int *)msg->data >> 8;
		   {
			 do
			 {
			   save=pos;
			   switch (key)
			   {
			   case 'H':pos--;break;
			   case 'P':pos++;break;
			   case 'I':pos-=p->maxview;break;
			   case 'Q':pos+=p->maxview;break;
			   }
			   if (pos<0) pos=0;
			   if (pos>=p->maxitems) pos=p->maxitems-1;
			   curLine=set_line_back(p->list,pos);
			   if (curLine>=p->topline+p->maxview) p->topline=curLine-p->maxview+1;
			   if (curLine<p->topline) p->topline=curLine;
			 }
			 while (save!=pos && p->list[pos]==NULL);
			 c_set_value(0,o->id,pos);
		   }
		 }
		break;
	   }
	   
     case E_CONTROL:
        {
        int *q;

        q=msg->data;
        switch (*q++)
           {
           case 1:p->list=(TSTR_LIST)*q;
                  redraw_object(o);
                  break;
           case 0:*(void **)*q=p->list;
                  break;
           case 2:
                  i=get_to_topline(ls,p->topline,NULL);
                  if (*(int *)o->data<i) p->topline=set_line_back(ls,*(int *)o->data);
                  if (*(int *)o->data>=i+p->maxview) p->topline=set_line_back(ls,*(int *)o->data);
                  break;
           }
        }
     case E_LOST_FOCUS:clicked=0;
     }