Пример #1
0
void mplEnd(void)
{
    plItem *next;

    if (!mplGotoTheNext && guiIntfStruct.Playing) {
        mplGotoTheNext = 1;
        return;
    }

    if (guiIntfStruct.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) {
        plLastPlayed = next;
        guiSetDF(guiIntfStruct.Filename, next->path, next->name);
        guiIntfStruct.StreamType      = STREAMTYPE_FILE;
        guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1;
        gfree((void **)&guiIntfStruct.AudioFile);
        gfree((void **)&guiIntfStruct.Subtitlename);
    } else {
        if (guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay)
            return;

        guiIntfStruct.TimeSec   = 0;
        guiIntfStruct.Position  = 0;
        guiIntfStruct.AudioType = 0;
        guiIntfStruct.NoWindow  = False;

#ifdef CONFIG_DVDREAD
        guiIntfStruct.DVD.current_title   = 1;
        guiIntfStruct.DVD.current_chapter = 1;
        guiIntfStruct.DVD.current_angle   = 1;
#endif

        if (!appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow) {
            wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height);
            wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y);
        } else
            wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow);

        guiGetEvent(guiCEvent, guiSetStop);
        mplSubRender = 1;
        wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B);
        wsClearWindow(appMPlayer.subWindow);
        wsPostRedisplay(&appMPlayer.subWindow);
    }
}
Пример #2
0
SplashState::~SplashState() {
  delete strokePattern;
  delete fillPattern;
  delete screen;
  gfree(lineDash);
  delete clip;
  if (deleteSoftMask && softMask) {
    delete softMask;
  }
}
Пример #3
0
static int		ft_no_new_line(char **line, char *buf, int j)
{
	char			*tmp;

	if (!(tmp = (char *)gmalloc(sizeof(*tmp) * BUFF_SIZE * j + 1)))
		return (-1);
	ft_strclr(tmp);
	ft_strcpy(tmp, *line);
	gfree((void *)*line);
	j++;
	if (!(*line = (char *)gmalloc(sizeof(**line) * BUFF_SIZE * j + 1)))
		return (-1);
	ft_strclr(*line);
	ft_strcpy(*line, tmp);
	gfree((void *)tmp);
	ft_strcat(*line, buf);
	buf[0] = '\0';
	return (j);
}
Пример #4
0
/* Destruction de la tâche */
int comSunSpotTaskClose() {
	/* close task */
	int ret;
	ret = pthread_cancel(comSunSpotThread);
	if (sock != 0)
		close(sock);
	if (message != NULL)
		gfree(message);
	return (ret);
}
Пример #5
0
static t_env	*ft_actualize(t_env *e, char *oldpwd, char **tab, int i)
{
	char	*pwd;

	pwd = (char *)gmalloc(sizeof(char) * 20000);
	getcwd(pwd, 20000);
	if (!i && tab[1] && !tab[2])
	{
		ft_putstr_fd("cd: not a directory or permission denied: ", 2);
		ft_putendl_fd(tab[1], 2);
	}
	else if (!i && tab[1] && tab[2])
		ft_putendl_fd("cd: too args", 2);
	else
		e = ft_good_env(e, pwd, oldpwd);
	ft_free_char2(tab);
	gfree(oldpwd);
	gfree(pwd);
	return (e);
}
Пример #6
0
static void freeptrtab(unsigned char **ptrtab,int tot) {
    int i,j;

    for ( i=0; i<tot; ++i )
	if ( ptrtab[i]!=NULL ) {
	    for ( j=i+1; j<tot; ++j )
		if ( ptrtab[j]==ptrtab[i] )
		    ptrtab[j] = NULL;
	    gfree(ptrtab[i]);
	}
}
Пример #7
0
int StopSimulationSensor() {
	SimuThreadList* p_simuThreadCurrent, *p_simuThreadDelete;
	p_simuThreadCurrent = p_simuThreadList;
	p_simuThreadDelete = p_simuThreadList;
	while (p_simuThreadCurrent != NULL) {
		p_simuThreadCurrent = p_simuThreadDelete->next;
		gfree(p_simuThreadDelete);
		p_simuThreadDelete = p_simuThreadCurrent;
	}
	return 0;
}
Пример #8
0
OutlineItem::~OutlineItem() {
  close();
  if (title) {
    gfree(title);
  }
  if (action) {
    delete action;
  }
  firstRef.free();
  lastRef.free();
  nextRef.free();
}
Пример #9
0
void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
			      SplashCoord lineDashPhaseA) {
  gfree(lineDash);
  lineDashLength = lineDashLengthA;
  if (lineDashLength > 0) {
    lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
    memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord));
  } else {
    lineDash = NULL;
  }
  lineDashPhase = lineDashPhaseA;
}
Пример #10
0
void	*c_calls(char *str, char *s1)
{
	void		*s2;

	if (!ft_strcmp(str, "trim"))
		s2 = ft_strtrim(s1);
	else if (!(ft_strcmp(str, "dup")))
		s2 = ft_strdup(s1);
	else if (!(ft_strcmp(str, "plim")))
		s2 = ft_strsplim(s1);
	gfree(s1);
	return (s2);
}
Пример #11
0
static void		ft_delete_plist_elem(t_p **p, t_p **move)
{
	t_p		*tmp;

	tmp = *move;
	if (*move && (*move)->next)
	{
		*move = (*move)->next;
		if (*p == (*move)->prev)
			*p = (*p)->next;
		if (tmp->prev)
		{
			tmp->prev->next = tmp->next;
			tmp->next->prev = tmp->prev;
		}
		else
			tmp->next->prev = NULL;
		gfree((void *)tmp->tok);
		gfree((void *)tmp);
	}
	else
		ft_delete_plist_last_elem(p, move);
}
Пример #12
0
void gmem_test2()
{	
	int *table2 = 0, *table3 = 0;
	int size2 = 8, size3 = 16;
	unsigned mem2 = sizeof(int)*size2;
	unsigned mem3 = sizeof(int)*size3;
	unsigned initialAvailableMem = gmem_availableMem();
	
	printf("Test 2 : running.\n");
	
	table2 = (int*) gmalloc(mem2);
	assert(table2 != NULL);
	assert(gmem_availableMem() == __HEAP_SIZE - 2*hdrSize - mem2);
	
	table3 = (int*) gmalloc(mem3);
	assert(table3 != NULL);
	assert(gmem_availableMem() == __HEAP_SIZE - 3*hdrSize - mem3 -mem2);
	
	gmem_fill_tab(table2, size2);
	gmem_fill_tab(table3, size3);
	
	gfree(table2);
	assert(gmem_availableMem() == __HEAP_SIZE - 3*hdrSize - mem3);
	
	gfree(table3);
	assert(gmem_availableMem() == __HEAP_SIZE - hdrSize);
	
	assert(gmem_availableMem() == initialAvailableMem);
	assert(gmem_sizeFreeBlockList() == 1);
	
	assert((void*)((unsigned)heap + __HEAP_SIZE - 1U)
		== (void*)((unsigned)firstHdr->blockNode.mem 
					+ firstHdr->blockNode.size - 1U));
		
	printf("Test 2 : OK.\n");
}
Пример #13
0
GImage *GImageRead_Jpeg(FILE *infile) {
    GImage *ret;
    struct _GImage *base;
    struct jpeg_decompress_struct cinfo;
    struct my_error_mgr jerr;
    JSAMPLE *rows[1];
    struct jpegState js;
    int ypos;

    if ( libjpeg==NULL )
	if ( !loadjpeg())
return( NULL );

  cinfo.err = _jpeg_std_error(&jerr.pub);
  jerr.pub.error_exit = my_error_exit;
  if (setjmp(jerr.setjmp_buffer)) {
    _jpeg_destroy_decompress(&cinfo);
return( NULL );
  }
  
  _jpeg_create_decompress(&cinfo,JPEG_LIB_VERSION,(size_t) sizeof(struct jpeg_decompress_struct));
  _jpeg_stdio_src(&cinfo, infile);
  (void) _jpeg_read_header(&cinfo, TRUE);

    if ( cinfo.jpeg_color_space == JCS_GRAYSCALE )
	cinfo.out_color_space = JCS_RGB;
    ret = GImageCreate(it_true,cinfo.image_width, cinfo.image_height);
    if ( ret==NULL ) {
	_jpeg_destroy_decompress(&cinfo);
return( NULL );
    }
    base = ret->u.image;

    (void) _jpeg_start_decompress(&cinfo);
    rows[0] = galloc(3*cinfo.image_width);
    js.cinfo = &cinfo; js.base = base; js.buffer = rows[0];
    while (cinfo.output_scanline < cinfo.output_height) {
	ypos = cinfo.output_scanline;
	(void) _jpeg_read_scanlines(&cinfo, rows, 1);
	transferBufferToImage(&js,ypos);
    }

  (void) _jpeg_finish_decompress(&cinfo);
  _jpeg_destroy_decompress(&cinfo);
  gfree(rows[0]);

return( ret );
}
Пример #14
0
void fs_PersistantHistory( char * subject )
{
 int i;

 if ( fsType != fsVideoSelector ) return;

 for ( i=0;i < fsPersistant_MaxPos;i++ )
  if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) )
   {
    char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp;
    return;
   }
 gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] );
 for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1];
 fsHistory[0]=gstrdup( subject );
}
Пример #15
0
static void checkResource(HWND hwnd, LPWORD lpBase, LPSTR lpText,...)
{
    LPSTR lpBuff=gmalloc(1024);
    int nOffset=0;
    int nCheck;

    if (!lpBuff) {
	alert(hwnd, "gmalloc() failed in checkResource!");
	return;
    }

    do {
	va_list args;
	LPSTR lpPtr;
	int nPtr;

	va_start(args, lpText);
	lpPtr=lpBuff+wvsprintf(lpBuff, lpText, args)+4;
	va_end(args);
	lstrcat(lpBuff, "\r\n\r\n");

	for (nPtr=0; nPtr<15; nPtr++) {
	    int nIndex=nPtr+nOffset;
	    UCHAR c1=lpBase[nIndex]>>8;
	    UCHAR c2=lpBase[nIndex]&0xff;

	    if (c1<32 || 126<c1)
		c1=' ';

	    if (c2<32 || 126<c2)
		c2=' ';

	    lpPtr+=wsprintf(lpPtr, "%04d: %04x %c%c\r\n", nIndex, lpBase[nIndex], c1, c2);
	}

	nCheck=query(hwnd, MB_YESNOCANCEL, lpBuff);

	switch (nCheck) {

	case IDYES:		nOffset+=16;	break;
	case IDNO:		nOffset-=16;	break;

	}
    } while (nCheck!=IDCANCEL);

    gfree(lpBuff);	lpBuff = NULL;
}
Пример #16
0
void guiLoadFont(void)
{
#ifdef CONFIG_FREETYPE
    load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
#else
    if (vo_font) {
        int i;

        free(vo_font->name);
        free(vo_font->fpath);

        for (i = 0; i < 16; i++) {
            if (vo_font->pic_a[i]) {
                free(vo_font->pic_a[i]->bmp);
                free(vo_font->pic_a[i]->pal);
            }
        }

        for (i = 0; i < 16; i++) {
            if (vo_font->pic_b[i]) {
                free(vo_font->pic_b[i]->bmp);
                free(vo_font->pic_b[i]->pal);
            }
        }

        free(vo_font);
        vo_font = NULL;
    }

    if (font_name) {
        vo_font = read_font_desc(font_name, font_factor, 0);

        if (!vo_font)
            gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
    } else {
        font_name = gstrdup(get_path("font/font.desc"));
        vo_font   = read_font_desc(font_name, font_factor, 0);

        if (!vo_font) {
            gfree((void **)&font_name);
            font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc");
            vo_font   = read_font_desc(font_name, font_factor, 0);
        }
    }
#endif
}
Пример #17
0
GooList *OutlineItem::readItemList(Object *firstItemRef, Object *lastItemRef,
				 XRef *xrefA) {
  GooList *items;
  char* alreadyRead;
  OutlineItem *item;
  Object obj;
  Object *p;

  if (!lastItemRef->isRef())
    return NULL;

  items = new GooList();

  alreadyRead = (char *)gmalloc(xrefA->getNumObjects());
  memset(alreadyRead, 0, xrefA->getNumObjects());

  p = firstItemRef;
  while (p->isRef() && 
	 (p->getRefNum() >= 0) && 
         (p->getRefNum() < xrefA->getNumObjects()) && 
         !alreadyRead[p->getRefNum()]) {
    if (!p->fetch(xrefA, &obj)->isDict()) {
      obj.free();
      break;
    }
    alreadyRead[p->getRefNum()] = 1;
    item = new OutlineItem(obj.getDict(), xrefA);
    obj.free();
    items->append(item);
    if (p->getRef().num == lastItemRef->getRef().num &&
	p->getRef().gen == lastItemRef->getRef().gen) {
      break;
    }
    p = &item->nextRef;
  }

  gfree(alreadyRead);

  if (!items->getLength()) {
    delete items;
    items = NULL;
  }

  return items;
}
Пример #18
0
llist effacerListe(llist liste)
{
    element* tmp = liste;
    element* tmpnxt;
 
    
    while(tmp != NULL)
    {
        
        tmpnxt = tmp->nxt;
        
        gfree(tmp);
        
        tmp = tmpnxt;
    }
    
    return NULL;
}
Пример #19
0
/* Tâche simulant un capteur de contact, de l'ajout de celui-ci jusqu'à l'envoi de trames à partir de ces capteurs.
 * p_argSensor : Structure argument contenant les informations ID et EEP du capteur.
 */
void * SimulationSensorContact(void * p_argSensor) {
	char message[29];
	int contact, sleepingTime;
	char contactHexa[3];
	char id[9];

	sleepingTime = ((struct ArgSensor*) p_argSensor)->sleepingTime;
	strcpy(id, ((struct ArgSensor*) p_argSensor)->id);
	gfree(p_argSensor);

	/*AddSensor(((struct ArgSensor*)p_argSensor)->id, str_sub(((struct ArgSensor*)p_argSensor)->eep, 0, 1), str_sub(((struct ArgSensor*)p_argSensor)->eep, 2, 3), str_sub(((struct ArgSensor*)p_argSensor)->eep, 4, 5));*/
	while (1) {
		sleep(sleepingTime);
		contact = rand() % 2;
		sprintf(contactHexa, "%X", contact);
		contactHexa[1] = contactHexa[0];
		contactHexa[0] = '0';
		contactHexa[2] = '\0';

		/******* HEADER *******/
		strcpy(message, "A55A"); /* Début d'un message */
		strcat(message, "0B"); /* SYNC_BYTE */
		strcat(message, "07"); /* LENGTH_BYTE */
		/***** FIN HEADER *****/

		/******* DATA BYTE *******/
		strcat(message, "000000"); /* BYTE 3 à 1 */
		strcat(message, contactHexa); /* BYTE 0 */
		/***** FIN DATA BYTE *****/

		/******* ID *******/
		strcat(message, id); /* 4 octets */
		/***** FIN ID *****/

		strcat(message, "00"); /* STATUS BYTE */
		strcat(message, "00"); /* CHECKSUM */

		/*printf("Message du capteur de contact : %s\n",message);*/

		mq_send(smq, message, MAX_MQ_SIZE, 0);
	}
	return (void*) NULL;
}
Пример #20
0
static void ecButtonReleased( GtkButton * button,gpointer user_data )
{
 if ( (int)user_data )
 { // if you pressed Ok
  gfree( (void **)&gtkEquChannel1 ); gtkEquChannel1=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel1 ) ) );
  gfree( (void **)&gtkEquChannel2 ); gtkEquChannel2=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel2 ) ) );
  gfree( (void **)&gtkEquChannel3 ); gtkEquChannel3=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel3 ) ) );
  gfree( (void **)&gtkEquChannel4 ); gtkEquChannel4=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel4 ) ) );
  gfree( (void **)&gtkEquChannel5 ); gtkEquChannel5=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel5 ) ) );
  gfree( (void **)&gtkEquChannel6 ); gtkEquChannel6=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel6 ) ) );
  eqSetChannelNames();
 }
 HideEquConfig();
}
Пример #21
0
/* Tâche simulant un capteur de présence, de l'ajout de celui-ci jusqu'à l'envoi de trames à partir de ces capteurs.
 * p_argSensor : Structure argument contenant les informations ID du capteur.
 */
void * SimulationSensorOccupancy(void * p_argSensor) {
	char message[29];
	int occupancy, sleepingTime;
	char occupancyHexa[3];
	char id[9];

	sleepingTime = ((struct ArgSensor*) p_argSensor)->sleepingTime;
	strcpy(id, ((struct ArgSensor*) p_argSensor)->id);
	gfree(p_argSensor);

	while (1) {
		sleep(sleepingTime);
		occupancy = (rand() % 2) << 1;
		sprintf(occupancyHexa, "%X", occupancy);
		occupancyHexa[1] = occupancyHexa[0];
		occupancyHexa[0] = '0';
			occupancyHexa[2] = '\0';

			/******* HEADER *******/
			strcpy(message, "A55A"); /* Début d'un message */
			strcat(message, "0B"); /* SYNC_BYTE */
			strcat(message, "07"); /* LENGTH_BYTE */
			/***** FIN HEADER *****/

			/******* DATA BYTE *******/
			strcat(message, "000000"); /* BYTE 3 à 1 */
			strcat(message, occupancyHexa); /* BYTE 0 */
			/***** FIN DATA BYTE *****/

			/******* ID *******/
			strcat(message, id); /* 4 octets */
			/***** FIN ID *****/

			strcat(message, "00"); /* STATUS BYTE */
			strcat(message, "00"); /* CHECKSUM */

			/*printf("Message du capteur de présence : %s\n",message);*/

			mq_send(smq, message, MAX_MQ_SIZE, 0);
	}
	return (void*) NULL;
}
Пример #22
0
void help(char *file) {
    if(file){
	char*  p_file  = copy(file);
	char*  p_uri   = p_file;
	char*  p_param = strrchr(p_file,'#');

	if(p_param){
	    *p_param = '\0';
	}
	if(! GFileIsAbsolute(p_file)){
	    p_uri = (char*) galloc( 256 + strlen(GResourceProgramDir) + strlen(p_file) );

	    strcpy(p_uri, GResourceProgramDir); /*  doc/fontforge/ja/file  */
	    strcat(p_uri, "/doc/fontforge/");
	    AppendSupportedLocale(p_uri);
	    strcat(p_uri, p_file);

	    if(!GFileReadable(p_uri)){
		strcpy(p_uri, GResourceProgramDir);/*  doc/fontforge/file  */
		strcat(p_uri, "/doc/fontforge/");
		strcat(p_uri, p_file);

		if(!GFileReadable(p_uri)){
		    strcpy(p_uri, "http://fontforge.sourceforge.net/"); /*  http://host/ja/file  */
		    AppendSupportedLocale(p_uri);
		    strcat(p_uri, p_file);
		}
	    }
	}
	if(p_param){
	    if(p_uri != p_file)
		strcat(p_uri, p_param);
	    else
		*p_param = '#';
	}

	/* using default browser */
	ShellExecute(NULL, "open", p_uri, NULL, NULL, SW_SHOWDEFAULT);

	if(p_uri != p_file) gfree(p_uri);
    }
}
Пример #23
0
/* Tâche simulant un interrupteur à 4 etats, de l'ajout de celui-ci jusqu'à l'envoi de trames à partir de ces capteurs.
 * p_argSensor : Structure argument contenant les informations ID du capteur.
 */
void * SimulationSensorSwitch(void * p_argSensor) {
	char message[29];
	int i_switch, sleepingTime;
	char switchHexa[3];
	char id[9];

	sleepingTime = ((struct ArgSensor*) p_argSensor)->sleepingTime;
	strcpy(id, ((struct ArgSensor*) p_argSensor)->id);
	gfree(p_argSensor);

	/*	AddSensor(((struct ArgSensor*)p_argSensor)->id, str_sub(((struct ArgSensor*)p_argSensor)->eep, 0, 1), str_sub(((struct ArgSensor*)p_argSensor)->eep, 2, 3), str_sub(((struct ArgSensor*)p_argSensor)->eep, 4, 5));*/
	while (1) {
		sleep(sleepingTime);
		i_switch = (rand() % 4) << 1;
		sprintf(switchHexa, "%X", i_switch);
		switchHexa[1] = '0';
		switchHexa[2] = '\0';

		/******* HEADER *******/
		strcpy(message, "A55A"); /* Début d'un message */
		strcat(message, "0B"); /* SYNC_BYTE */
		strcat(message, "07"); /* LENGTH_BYTE */
		/***** FIN HEADER *****/

		/******* DATA BYTE *******/
		strcat(message, switchHexa); /* BYTE 3 */
		strcat(message, "000000"); /* BYTE 2 à 0 */
		/***** FIN DATA BYTE *****/

		/******* ID *******/
		strcat(message, id); /* 4 octets */
		/***** FIN ID *****/

		strcat(message, "30"); /* STATUS BYTE */
		strcat(message, "00"); /* CHECKSUM */

		/*	printf("Message du capteur d'interrupteur : %s\n",message);*/

		mq_send(smq, message, MAX_MQ_SIZE, 0);
	}
	return (void*) NULL;
}
Пример #24
0
void NameToCharCode::add(char *name, CharCode c) {
  NameToCharCodeEntry *oldTab;
  int h, i, oldSize;

  // expand the table if necessary
  if (len >= size / 2) {
    oldSize = size;
    oldTab = tab;
    size = 2*size + 1;
    tab = (NameToCharCodeEntry *)gmallocn(size, sizeof(NameToCharCodeEntry));
    for (h = 0; h < size; ++h) {
      tab[h].name = NULL;
    }
    for (i = 0; i < oldSize; ++i) {
      if (oldTab[i].name) {
	h = hash(oldTab[i].name);
	while (tab[h].name) {
	  if (++h == size) {
	    h = 0;
	  }
	}
	tab[h] = oldTab[i];
      }
    }
    gfree(oldTab);
  }

  // add the new name
  h = hash(name);
  while (tab[h].name && strcmp(tab[h].name, name)) {
    if (++h == size) {
      h = 0;
    }
  }
  if (!tab[h].name) {
    tab[h].name = copyString(name);
  }
  tab[h].c = c;

  ++len;
}
Пример #25
0
GImage *GImageReadTiff(char *filename) {
    TIFF* tif;
    uint32 w, h, i,j;
    uint32 *ipt, *fpt;
    size_t npixels;
    uint32* raster;
    GImage *ret=NULL;
    struct _GImage *base;

    if ( libtiff==NULL )
	if ( !loadtiff())
return( NULL );

    tif = _TIFFOpen(filename, "r");

    if (tif==NULL )
return( ret );

    _TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
    _TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
    npixels = w * h;
    raster = (uint32*) galloc(npixels * sizeof (uint32));
    if (raster != NULL) {
	if (_TIFFReadRGBAImage(tif, w, h, raster, 0)) {
	    ret = GImageCreate(it_true,w,h);
	    if ( ret!=NULL ) {
		base = ret->u.image;
		for ( i=0; i<h; ++i ) {
		    ipt = (uint32 *) (base->data+i*base->bytes_per_line);
		    fpt = raster+(h-1-i)*w;
		    for ( j=0; j<w; ++j )
			*ipt++ = COLOR_CREATE(
				TIFFGetR(fpt[j]), TIFFGetG(fpt[j]), TIFFGetB(fpt[j]));
		}
	    }
	} 
	gfree(raster);
    }
    _TIFFClose(tif);
return( ret );
}
Пример #26
0
/* Lance une action sur un actionneur de courant
 * Le courant est coupé si value = 7, et est en marche quand value = 5
 */
int actionCurrent(float value, struct Actuator * p_actuator, mqd_t smq) {
	char message[29];
	char valueHexa[3];
	char *actuatorRealID;

	sprintf(valueHexa,"%02X",(int)value);

	actuatorRealID = str_sub(p_actuator->id, strlen(p_actuator->id)-2, strlen(p_actuator->id)-1);

	/******* HEADER *******/
	strcpy(message, "A55A"); /* Début d'un message */
	strcat(message, "6B"); /* SYNC_BYTE */
	strcat(message, "05"); /* LENGTH_BYTE */
	/***** FIN HEADER *****/

	/******* DATA BYTE *******/
	strcat(message, valueHexa); /* BYTE 3 */
	strcat(message, "000000"); /* BYTE 2 à 0 */
	/***** FIN DATA BYTE *****/

	/******* ID *******/
	strcat(message, idReceptorEnOcean); /* 3 octets */
	strcat(message, actuatorRealID); /* 1 octet */
	/***** FIN ID *****/

	strcat(message, "30"); /* STATUS BYTE */
	strcat(message, "00\0"); /* CHECKSUM */
	
	p_actuator->status = value;
	if (value == (float) CURRENT_TURN_ON) {
		printf("[Actuator] Action sur l'actionneur de courant : Mise en marche.\n");
	} else {
		printf("[Actuator] Action sur l'actionneur de courant : Extinction.\n");
	}
	mq_send(smq, message, MAX_MQ_SIZE, 0);
	gLogsLog(p_actuator->id, p_actuator->status);
	gfree(actuatorRealID);
	return 0;
}
Пример #27
0
static bool manager_destroy_vnic(VNIC* vnic) {
	for(int i = 0; i < MAX_VNIC_COUNT; i++) {
		if(manager.vnics[i] != vnic)
			continue;

		manager.vnics[i] = NULL;
		manager.vnic_count--;
		__nics[i] = NULL;
		__nic_count++;
		break;
	}

	NICDevice* nic_dev = nicdev_get(vnic->parent);
	if(!nic_dev)
		return false;

	if(!nicdev_unregister_vnic(nic_dev, vnic->id))
		return false;

	bfree(vnic->nic);
	gfree(vnic);

	return true;
}
Пример #28
0
int32
/* Start of GurumNetworks modification
TFFS_mount( IN  FileSystemDriver* driver, OUT tffs_handle_t * phtffs)
End of GurumNetworks modification*/
TFFS_mount( IN  FileSystemDriver* driver, int first_lba)
{
	int32 ret;
	tffs_t * tffs;
	boot_sector_t * pbs = NULL;
	DiskDriver* disk_driver = driver->driver;
	tdir_t * proot_dir = NULL;
	tdir_t * pcur_dir = NULL;
	tfat_t * pfat = NULL;
	uint32 rootdir_clus;
	void* read_buf = NULL;
	void* fat = NULL;

	/* Start of GurumNetworks modification
	tdev_handle_t hdev;
	tcache_t * pcache = NULL;
	End of GurumNetworks modification */

	/* Start of GurumNetworks modification	
	if (!dev || !phtffs)
		return ERR_TFFS_INVALID_PARAM;
	End of GurumNetworks modification */

	ret = TFFS_OK;
	tffs = (tffs_t *)malloc(sizeof(tffs_t));
	memset(tffs, 0, sizeof(tffs_t));
	pbs = (boot_sector_t *)gmalloc(sizeof(boot_sector_t));
	memset(pbs, 0, sizeof(boot_sector_t));

#ifdef _KERNEL_	
	ASSERT(sizeof(boot_sector_t) == 512);
#endif

	/* Start of GurumNetworks modification	
	hdev = HAI_initdevice(dev, 512);
	if (hdev == NULL) {
		ret = ERR_TFFS_DEVICE_FAIL;
		goto _release;
	}
	tffs->hdev = hdev;

	if (HAI_readsector(hdev, 0, (ubyte *)pbs) != HAI_OK) {
		ret = ERR_TFFS_DEVICE_FAIL;
		goto _release;
	}

	End of GurumNetworks modification */
	tffs->driver = driver;
	tffs->first_lba = first_lba;

	if(disk_driver->read(disk_driver, tffs->first_lba, 1, (void*)pbs) < 0)
		goto _release;

	tffs->pbs = pbs;
	
	if (!_validate_bs(pbs)) {
		ret = ERR_TFFS_BAD_BOOTSECTOR;
		goto _release;
	}

	_parse_boot_sector(pbs, tffs);
	DBG("tffs->fat_type:%d\n", tffs->fat_type);
	DBG("tffs->sec_fat:%d\n", tffs->sec_fat);
	DBG("tffs->sec_root_dir:%d\n", tffs->sec_root_dir);
	DBG("tffs->sec_first_data:%d\n", tffs->sec_first_data);

	if ((pfat = fat_init(tffs)) == NULL) {
		ret = ERR_TFFS_BAD_FAT;
		goto _release;
	}

	tffs->pfat = pfat;

	/* Start of GurumNetworks modification
	if ((pcache = cache_init(hdev, 32, tffs->pbs->byts_per_sec)) == NULL) {
		WARN("TFFS: cache is disable.\n");
		pcache = cache_init(hdev, 0, tffs->pbs->byts_per_sec);
	}
	tffs->pcache = pcache;
	End of GurumNetworks modification */

	rootdir_clus = tffs->fat_type == FT_FAT32 ? tffs->pbs->bh32.root_clus : ROOT_DIR_CLUS_FAT16;

	if (dir_init_by_clus(tffs, rootdir_clus, &proot_dir) != DIR_OK ||
		dir_init_by_clus(tffs, rootdir_clus, &pcur_dir) != DIR_OK) {
		ret = ERR_TFFS_DEVICE_FAIL;
		goto _release;
	}

	tffs->root_dir = proot_dir;
	tffs->cur_dir = pcur_dir;

	/* Start of GurumNetworks modification
	*phtffs = (tffs_handle_t)tffs;
	End of GurumNetworks modification */

	int i = 0;
	size_t read_size = 0;
	size_t fat_size = tffs->fatsz * pbs->byts_per_sec;
	read_buf = gmalloc(FS_BLOCK_SIZE);
	fat = bmalloc();

	while(read_size < fat_size) {
	#define MIN(x, y) (((x) < (y)) ? (x) : (y))
		if(disk_driver->read(disk_driver, tffs->sec_fat + i * FS_SECTOR_PER_BLOCK, FS_SECTOR_PER_BLOCK, read_buf) < 0) {
			ret = -99; // TODO: errno for fat error
			goto _release;
		}

		size_t copy_size = MIN(fat_size - read_size, FS_BLOCK_SIZE);
		memcpy((uint8_t*)fat + read_size, read_buf, copy_size);

		read_size += copy_size;
		i++;
	}

	tffs->fat = fat;
	DBG("tffs->fat:%p\n", tffs->fat);
	DBG("tffs->fat size:%d\n", tffs->fatsz);
	DBG("Tiny FAT file system mount OK.\n");
	driver->priv = tffs;

	gfree(read_buf);
	return ret;

_release:
	if (pfat)
		fat_destroy(pfat);
	if (proot_dir)
		dir_destroy(proot_dir);
	if (pcur_dir)
		dir_destroy(pcur_dir);
	if (HAI_closedevice(tffs->hdev) != HAI_OK)
		ret = ERR_TFFS_DEVICE_FAIL;

	if(read_buf)
		gfree(read_buf);
	if(fat)
		free(fat);

	free(pbs);
	free(tffs);

	return ret;
}
Пример #29
0
static int		ft_test_ok(char **path, int i)
{
	while (path[++i])
		gfree((void *)path[i]);
	return (gfree((void *)path));
}
Пример #30
0
void dma_free_coherent(struct device *dev, size_t size, void *kvaddr, dma_addr_t dma_handle) {
	void* ptr = *((void**)((uint64_t)kvaddr - sizeof(void*)));

	if(ptr)
		gfree(ptr);
}