Example #1
0
/* (re-)initialize a XDGMenuEntry storage
 */
static void init_xdg_storage(XDGMenuEntry **xdg)
{

	if ((*xdg)->Name)
		wfree((*xdg)->Name);
	if ((*xdg)->TryExec)
		wfree((*xdg)->TryExec);
	if ((*xdg)->Exec)
		wfree((*xdg)->Exec);
	if ((*xdg)->Category)
		wfree((*xdg)->Category);
	if ((*xdg)->Path)
		wfree((*xdg)->Path);

	(*xdg)->Name = NULL;
	(*xdg)->TryExec = NULL;
	(*xdg)->Exec = NULL;
	(*xdg)->Category = NULL;
	(*xdg)->Path = NULL;
	(*xdg)->Flags = 0;
	(*xdg)->MatchLevel = -1;
}
Example #2
0
PUBLIC int websSetUserRoles(char *username, char *roles)
{
    WebsUser    *user;

    assert(username &&*username);
    if ((user = websLookupUser(username)) == 0) {
        return -1;
    }
    wfree(user->roles);
    user->roles = sclone(roles);
    computeUserAbilities(user);
    return 0;
}
*/
Wilddog_Conn_T* WD_SYSTEM _wilddog_conn_deinit(Wilddog_Repo_T*p_repo)
{
    if( !p_repo || !p_repo->p_rp_conn )
        return NULL;

    /* destory list.*/
    _wilddog_cm_ioctl(CM_CMD_DEINIT,p_repo->p_rp_conn->p_cm_l,0);
    
    wfree( p_repo->p_rp_conn);
    p_repo->p_rp_conn = NULL;
    
    return NULL;
Example #4
0
static void paintCursor(TextField * tPtr)
{
	int cx;
	WMScreen *screen = tPtr->view->screen;
	int textWidth;
	char *text;

	if (tPtr->flags.secure)
		text = makeHiddenString(strlen(tPtr->text));
	else
		text = tPtr->text;

	cx = WMWidthOfString(tPtr->font, &(text[tPtr->viewPosition]), tPtr->cursorPosition - tPtr->viewPosition);

	switch (tPtr->flags.alignment) {
	case WARight:
		textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen);
		if (textWidth < tPtr->usableWidth)
			cx += tPtr->offsetWidth + tPtr->usableWidth - textWidth + 1;
		else
			cx += tPtr->offsetWidth + 1;
		break;
	case WALeft:
		cx += tPtr->offsetWidth + 1;
		break;
	case WAJustified:
		/* not supported */
	case WACenter:
		textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen);
		if (textWidth < tPtr->usableWidth)
			cx += tPtr->offsetWidth + (tPtr->usableWidth - textWidth) / 2;
		else
			cx += tPtr->offsetWidth;
		break;
	}
	/*
	   XDrawRectangle(screen->display, tPtr->view->window, screen->xorGC,
	   cx, tPtr->offsetWidth, 1,
	   tPtr->view->size.height - 2*tPtr->offsetWidth - 1);
	   printf("%d %d\n",cx,tPtr->cursorPosition);
	 */

	XDrawLine(screen->display, tPtr->view->window, screen->xorGC,
		  cx, tPtr->offsetWidth, cx, tPtr->view->size.height - tPtr->offsetWidth - 1);

	W_SetPreeditPositon(tPtr->view, cx, 0);

	if (tPtr->flags.secure) {
		wfree(text);
	}
}
Example #5
0
WMTextField *WMCreateTextField(WMWidget * parent)
{
	TextField *tPtr;

	tPtr = wmalloc(sizeof(TextField));
	tPtr->widgetClass = WC_TextField;

	tPtr->view = W_CreateView(W_VIEW(parent));
	if (!tPtr->view) {
		wfree(tPtr);
		return NULL;
	}
	tPtr->view->self = tPtr;

	tPtr->view->delegate = &_TextFieldViewDelegate;

	tPtr->view->attribFlags |= CWCursor;
	tPtr->view->attribs.cursor = tPtr->view->screen->textCursor;

	W_SetViewBackgroundColor(tPtr->view, tPtr->view->screen->white);

	tPtr->text = wmalloc(MIN_TEXT_BUFFER);
	tPtr->textLen = 0;
	tPtr->bufferSize = MIN_TEXT_BUFFER;

	tPtr->flags.enabled = 1;

	WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | FocusChangeMask, handleEvents, tPtr);

	tPtr->font = WMRetainFont(tPtr->view->screen->normalFont);

	tPtr->flags.bordered = DEFAULT_BORDERED;
	tPtr->flags.beveled = True;
	tPtr->flags.alignment = DEFAULT_ALIGNMENT;
	tPtr->offsetWidth = WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font)) / 2, 1);

	W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);

	WMCreateEventHandler(tPtr->view, EnterWindowMask | LeaveWindowMask
			     | ButtonReleaseMask | ButtonPressMask | KeyPressMask | Button1MotionMask,
			     handleTextFieldActionEvents, tPtr);

	WMAddNotificationObserver(selectionNotification, tPtr->view,
				  WMSelectionOwnerDidChangeNotification, (void *)XA_PRIMARY);

	WMAddNotificationObserver(realizeObserver, tPtr, WMViewRealizedNotification, tPtr->view);

	tPtr->flags.cursorOn = 1;

	return tPtr;
}
Example #6
0
char *GetShortcutString(const char *shortcut)
{
	char *buffer = NULL;
	char *k;
	int control = 0;
	char *tmp, *text;

	tmp = text = wstrdup(shortcut);

	/* get modifiers */
	while ((k = strchr(text, '+')) != NULL) {
		int mod;

		*k = 0;
		mod = wXModifierFromKey(text);
		if (mod < 0) {
			return wstrdup("bug");
		}

		if (strcasecmp(text, "Meta") == 0) {
			buffer = wstrappend(buffer, "M+");
		} else if (strcasecmp(text, "Alt") == 0) {
			buffer = wstrappend(buffer, "A+");
		} else if (strcasecmp(text, "Shift") == 0) {
			buffer = wstrappend(buffer, "Sh+");
		} else if (strcasecmp(text, "Mod1") == 0) {
			buffer = wstrappend(buffer, "M1+");
		} else if (strcasecmp(text, "Mod2") == 0) {
			buffer = wstrappend(buffer, "M2+");
		} else if (strcasecmp(text, "Mod3") == 0) {
			buffer = wstrappend(buffer, "M3+");
		} else if (strcasecmp(text, "Mod4") == 0) {
			buffer = wstrappend(buffer, "M4+");
		} else if (strcasecmp(text, "Mod5") == 0) {
			buffer = wstrappend(buffer, "M5+");
		} else if (strcasecmp(text, "Control") == 0) {
			control = 1;
		} else {
			buffer = wstrappend(buffer, text);
		}
		text = k + 1;
	}

	if (control) {
		buffer = wstrappend(buffer, "^");
	}
	buffer = wstrappend(buffer, text);
	wfree(tmp);

	return buffer;
}
Example #7
0
static void
setIconCallback(WMenu *menu, WMenuEntry *entry)
{
    WAppIcon *icon = ((WApplication*)entry->clientdata)->app_icon;
    char *file=NULL;
    WScreen *scr;
    int result;

    assert(icon!=NULL);

    if (icon->editing)
        return;
    icon->editing = 1;
    scr = icon->icon->core->screen_ptr;

    wretain(icon);

    result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class);

    if (result && !icon->destroyed) {
        if (file && *file==0) {
            wfree(file);
            file = NULL;
        }
        if (!wIconChangeImageFile(icon->icon, file)) {
            wMessageDialog(scr, _("Error"),
                           _("Could not open specified icon file"),
                           _("OK"), NULL, NULL);
        } else {
            wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
            wAppIconPaint(icon);
        }
        if (file)
            wfree(file);
    }
    icon->editing = 0;
    wrelease(icon);
}
Example #8
0
/*
    Free a socket structure
 */
PUBLIC void socketFree(int sid)
{
    WebsSocket  *sp;
    char        buf[256];
    int         i;

    if ((sp = socketPtr(sid)) == NULL) {
        return;
    }
    /*
        To close a socket, remove any registered interests, set it to non-blocking so that the recv which follows won't
        block, do a shutdown on it so peers on the other end will receive a FIN, then read any data not yet retrieved
        from the receive buffer, and finally close it.  If these steps are not all performed RESETs may be sent to the
        other end causing problems.
     */
    socketRegisterInterest(sid, 0);
    if (sp->sock >= 0) {
        socketSetBlock(sid, 0);
        while (recv(sp->sock, buf, sizeof(buf), 0) > 0) {}
        if (shutdown(sp->sock, SHUT_RDWR) >= 0) {
            while (recv(sp->sock, buf, sizeof(buf), 0) > 0) {}
        }
        closesocket(sp->sock);
    }
    wfree(sp->ip);
    wfree(sp);
    socketMax = wfreeHandle(&socketList, sid);
    /*
        Calculate the new highest socket number
     */
    socketHighestFd = -1;
    for (i = 0; i < socketMax; i++) {
        if ((sp = socketList[i]) == NULL) {
            continue;
        } 
        socketHighestFd = max(socketHighestFd, sp->sock);
    }
}
Example #9
0
static void findCopyFile(const char *dir, const char *file)
{
	char *fullPath;

	fullPath = wfindfileinarray(PixmapPath, file);
	if (!fullPath) {
		wwarning("Could not find file %s", file);
		if (ThemePath)
			(void)wrmdirhier(ThemePath);
		return;
	}
	wcopy_file(dir, fullPath, file);
	wfree(fullPath);
}
Example #10
0
void
socket_buffer_delete(struct socket_buffer *b) {
	if (b->head.msg != NULL) {
		weenet_message_unref(b->head.msg);
		for (size_t i=0, n=b->tail.num; i<n; ++i) {
			weenet_message_unref(b->tail.slots[i]);
		}
	}
	if (b->tail.slots != NULL) {
		wfree(b->tail.slots);
	}
	weenet_event_monitor(b->self, 0, b->fd, WEVENT_DELETE, WEVENT_READ);
	weenet_event_monitor(b->self, 0, b->fd, WEVENT_DELETE, WEVENT_WRITE);
}
Example #11
0
void WMReleasePixmap(WMPixmap * pixmap)
{
	wassertr(pixmap != NULL);

	pixmap->refCount--;

	if (pixmap->refCount < 1) {
		if (pixmap->pixmap)
			XFreePixmap(pixmap->screen->display, pixmap->pixmap);
		if (pixmap->mask)
			XFreePixmap(pixmap->screen->display, pixmap->mask);
		wfree(pixmap);
	}
}
Example #12
0
void WMSetBrowserColumnTitle(WMBrowser * bPtr, int column, const char *title)
{
	assert(column >= 0);
	assert(column < bPtr->usedColumnCount);

	if (bPtr->titles[column])
		wfree(bPtr->titles[column]);

	bPtr->titles[column] = wstrdup(title);

	if (COLUMN_IS_VISIBLE(bPtr, column) && bPtr->flags.isTitled) {
		drawTitleOfColumn(bPtr, column);
	}
}
Example #13
0
void
WMSetTabViewItemLabel(WMTabViewItem *item, char *label)
{
    if (item->label)
        wfree(item->label);

    if (label)
        item->label = wstrdup(label);
    else
        item->label = NULL;

    if (item->tabView)
        recalcTabWidth(item->tabView);
}
Example #14
0
/**
 * Map iterator to free cached entries.
 */
static bool
free_cached(void *key, void *value, void *data)
{
	dbmw_t *dw = data;
	struct cached *entry = value;

	dbmw_check(dw);
	g_assert(!entry->len == !entry->data);

	free_value(dw, entry, TRUE);
	wfree(key, dbmw_keylen(dw, key));
	WFREE(entry);
	return TRUE;
}
Example #15
0
PUBLIC bool websLoginUser(Webs *wp, char *username, char *password)
{
    assert(wp);
    assert(wp->route);
    assert(username);
    assert(password);

    if (!wp->route || !wp->route->verify) {
        return 0;
    }
    wfree(wp->username);
    wp->username = sclone(username);
    wfree(wp->password);
    wp->password = sclone(password);

    if (!(wp->route->verify)(wp)) {
        trace(2, "Password does not match");
        return 0;
    }
    trace(2, "Login successful for %s", username);
    websSetSessionVar(wp, WEBS_SESSION_USERNAME, wp->username);                                
    return 1;
}
/*
 * Function:    wrealloc
 * Description: Realloc the souce pointer's length.
 * Input:       ptr: old pointer.
 *              size: new length you want.
 * Output:      N/A
 * Return:      New pointer.
*/
void * WD_SYSTEM wrealloc(void *ptr, size_t oldSize, size_t newSize)
{
#if defined(WILDDOG_PORT_TYPE_QUCETEL) || defined(WILDDOG_PORT_TYPE_ESP)
    void* tmpPtr = NULL;
#endif

    if(!ptr)
        return wmalloc(newSize);
#if defined(WILDDOG_PORT_TYPE_QUCETEL) || defined(WILDDOG_PORT_TYPE_ESP)

    tmpPtr = (void*)wmalloc(newSize);
    if(!tmpPtr)
    {
        wfree(ptr);
        return NULL;
    }
    memcpy(tmpPtr, ptr, oldSize > newSize? (newSize):(oldSize));
    wfree(ptr);
    return tmpPtr;
#else
    return realloc( ptr, newSize);
#endif
}
Example #17
0
static void endDragProcess(WMDraggingInfo * info, Bool deposited)
{
	WMView *view = XDND_SOURCE_VIEW(info);
	WMScreen *scr = W_VIEW_SCREEN(XDND_SOURCE_VIEW(info));

	/* free selection handler while view exists */
	WMDeleteSelectionHandler(view, scr->xdndSelectionAtom, CurrentTime);
	wfree(XDND_SELECTION_PROCS(info));

	if (XDND_DRAG_CURSOR(info) != None) {
		XFreeCursor(scr->display, XDND_DRAG_CURSOR(info));
		XDND_DRAG_CURSOR(info) = None;
	}

	if (view->dragSourceProcs->endedDrag != NULL) {
		/* this can destroy source view (with a "move" action for example) */
		view->dragSourceProcs->endedDrag(view, &XDND_DRAG_ICON_POS(info), deposited);
	}

	/* clear remaining draggging infos */
	wfree(XDND_SOURCE_INFO(info));
	XDND_SOURCE_INFO(info) = NULL;
}
Example #18
0
void WMSetLabelText(WMLabel * lPtr, const char *text)
{
	if (lPtr->caption)
		wfree(lPtr->caption);

	if (text != NULL) {
		lPtr->caption = wstrdup(text);
	} else {
		lPtr->caption = NULL;
	}
	if (lPtr->view->flags.realized) {
		paintLabel(lPtr);
	}
}
Example #19
0
/**
 * Map iterator to free cached entries.
 */
static gboolean
free_cached(gpointer key, gpointer value, gpointer data)
{
	dbmw_t *dw = data;
	struct cached *entry = value;

	dbmw_check(dw);
	g_assert(!entry->len == !entry->data);

	free_value(dw, entry, TRUE);
	wfree(key, dbmw_keylen(dw, key));
	WFREE(entry);
	return TRUE;
}
Example #20
0
PUBLIC void sslFree(Webs *wp)
{
    Nano        *np;
    
    if (wp->ssl) {
        np = wp->ssl;
        if (np->handle) {
            SSL_closeConnection(np->handle);
            np->handle = 0;
        }
        wfree(np);
        wp->ssl = 0;
    }
}
Example #21
0
static int init_mode(int new_mode, const char *paletname) {
    Uint32 mode_flags;
    const SDL_VideoInfo *vi;
    int las, las2;
    int w = (new_mode == SVGA_MODE) ? 800 : 320;
    int h = (new_mode == SVGA_MODE) ? 600 : 200;

    init_video();

    mode_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWPALETTE;

    if (!draw_with_vircr_mode)
        mode_flags |= SDL_ANYFORMAT;
    //if (wantfullscreen)
     //   mode_flags |= SDL_FULLSCREEN;

    if (draw_with_vircr_mode && pixel_multiplier > 1)
        wfree(vircr);

    pixel_multiplier = (new_mode == SVGA_MODE) ? pixel_multiplier_svga : pixel_multiplier_vga;

    video_state.surface = SDL_SetVideoMode(w * pixel_multiplier, h * pixel_multiplier, 8, mode_flags);
    assert(video_state.surface);

    if (draw_with_vircr_mode) {
        if (pixel_multiplier > 1) {
            vircr = (uint8_t *) walloc(w * h);
        } else {
            vircr = (uint8_t *) video_state.surface->pixels;
        }
    }
    /* else vircr is preallocated in init_video */
    vi = SDL_GetVideoInfo();
    video_state.haverealpalette = (vi->vfmt->palette != NULL);

    dksopen(paletname);

    dksread(ruutu.normaalipaletti, sizeof(ruutu.normaalipaletti));
    for (las = 0; las < 256; las++)
        for (las2 = 0; las2 < 3; las2++)
            ruutu.paletti[las][las2] = ruutu.normaalipaletti[las][las2];

    dksclose();

    setpal_range(ruutu.paletti, 0, 256);
    all_bitmaps_refresh();

    current_mode = new_mode;
    return 1;
}
Example #22
0
WMRuler *WMCreateRuler(WMWidget * parent)
{
	Ruler *rPtr = wmalloc(sizeof(Ruler));
	unsigned int w = WMWidgetWidth(parent);

	rPtr->widgetClass = WC_Ruler;

	rPtr->view = W_CreateView(W_VIEW(parent));

	if (!rPtr->view) {
		wfree(rPtr);
		return NULL;
	}

	rPtr->view->self = rPtr;

	rPtr->drawBuffer = (Pixmap) NULL;

	W_ResizeView(rPtr->view, w, 40);

	WMCreateEventHandler(rPtr->view, ExposureMask | StructureNotifyMask
			     | EnterWindowMask | LeaveWindowMask | FocusChangeMask
			     | ButtonReleaseMask | ButtonPressMask | KeyReleaseMask
			     | KeyPressMask | Button1MotionMask, handleEvents, rPtr);

	rPtr->view->delegate = &_RulerViewDelegate;

	rPtr->fg = WMBlackColor(rPtr->view->screen);
	rPtr->fgGC = WMColorGC(rPtr->fg);
	rPtr->bgGC = WMColorGC(WMGrayColor(rPtr->view->screen));
	rPtr->font = WMSystemFontOfSize(rPtr->view->screen, 8);

	rPtr->offset = 22;
	rPtr->margins.left = 22;
	rPtr->margins.body = 22;
	rPtr->margins.first = 42;
	rPtr->margins.right = (w < 502 ? w : 502);
	rPtr->margins.tabs = NULL;

	rPtr->flags.whichMarker = 0;	/* none */
	rPtr->flags.buttonPressed = False;
	rPtr->flags.redraw = True;

	rPtr->moveAction = NULL;
	rPtr->releaseAction = NULL;

	rPtr->pview = W_VIEW(parent);

	return rPtr;
}
Example #23
0
// free the data item by using empty string
// Item = the item to free
void FreeDataItem(WIDATAITEM *Item)
{
	wfree(&Item->Name);
	wfree(&Item->Start);
	wfree(&Item->End);
	wfree(&Item->Unit);
	wfree(&Item->Url);
	wfree(&Item->Break);
}
Example #24
0
int wWorkspaceNew(WScreen *scr)
{
	WWorkspace *wspace, **list;
	int i;

	if (w_global.workspace.count < MAX_WORKSPACES) {
		w_global.workspace.count++;

		wspace = wmalloc(sizeof(WWorkspace));
		wspace->name = NULL;
		wspace->clip = NULL;

		if (!wspace->name) {
			static const char *new_name = NULL;
			static size_t name_length;

			if (new_name == NULL) {
				new_name = _("Workspace %i");
				name_length = strlen(new_name) + 8;
			}
			wspace->name = wmalloc(name_length);
			snprintf(wspace->name, name_length, new_name, w_global.workspace.count);
		}

		if (!wPreferences.flags.noclip)
			wspace->clip = wDockCreate(scr, WM_CLIP, NULL);

		list = wmalloc(sizeof(WWorkspace *) * w_global.workspace.count);

		for (i = 0; i < w_global.workspace.count - 1; i++)
			list[i] = w_global.workspace.array[i];

		list[i] = wspace;
		if (w_global.workspace.array)
			wfree(w_global.workspace.array);

		w_global.workspace.array = list;

		wWorkspaceMenuUpdate(w_global.workspace.menu);
		wWorkspaceMenuUpdate(w_global.clip.ws_menu);
		wNETWMUpdateDesktop(scr);
		WMPostNotificationName(WMNWorkspaceCreated, scr, (void *)(uintptr_t) (w_global.workspace.count - 1));
		XFlush(dpy);

		return w_global.workspace.count - 1;
	}

	return -1;
}
Example #25
0
void PropSetIconTileHint(virtual_screen *vscr, RImage *image)
{
	static Atom imageAtom = 0;
	unsigned char *tmp;
	int x, y;

	if (vscr->screen_ptr->info_window == None)
		return;

	if (!imageAtom) {
		/*
		 * WIDTH, HEIGHT (16 bits, MSB First)
		 * array of R,G,B,A bytes
		 */
		imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False);
	}

	tmp = malloc(image->width * image->height * 4 + 4);
	if (!tmp) {
		wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint");
		return;
	}

	tmp[0] = image->width >> 8;
	tmp[1] = image->width & 0xff;
	tmp[2] = image->height >> 8;
	tmp[3] = image->height & 0xff;

	if (image->format == RRGBAFormat) {
		memcpy(&tmp[4], image->data, image->width * image->height * 4);
	} else {
		char *ptr = (char *)(tmp + 4);
		char *src = (char *)image->data;

		for (y = 0; y < image->height; y++) {
			for (x = 0; x < image->width; x++) {
				*ptr++ = *src++;
				*ptr++ = *src++;
				*ptr++ = *src++;
				*ptr++ = 255;
			}
		}
	}

	XChangeProperty(dpy, vscr->screen_ptr->info_window, w_global.atom.wmaker.icon_tile,
			imageAtom, 8, PropModeReplace, tmp, image->width * image->height * 4 + 4);
	wfree(tmp);

}
Example #26
0
File: iso.c Project: DesignD/rufus
char* MountISO(const char* path)
{
	VIRTUAL_STORAGE_TYPE vtype = { 1, VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT };
	ATTACH_VIRTUAL_DISK_PARAMETERS vparams = {0};
	DWORD r;
	wchar_t wtmp[128];
	ULONG size = ARRAYSIZE(wtmp);
	wconvert(path);
	char* ret = NULL;

	PF_INIT_OR_OUT(OpenVirtualDisk, VirtDisk);
	PF_INIT_OR_OUT(AttachVirtualDisk, VirtDisk);
	PF_INIT_OR_OUT(GetVirtualDiskPhysicalPath, VirtDisk);

	if ((mounted_handle != NULL) && (mounted_handle != INVALID_HANDLE_VALUE))
		UnMountISO();

	r = pfOpenVirtualDisk(&vtype, wpath, VIRTUAL_DISK_ACCESS_READ | VIRTUAL_DISK_ACCESS_GET_INFO,
		OPEN_VIRTUAL_DISK_FLAG_NONE, NULL, &mounted_handle);
	if (r != ERROR_SUCCESS) {
		SetLastError(r);
		uprintf("Could not open ISO '%s': %s", path, WindowsErrorString());
		goto out;
	}

	vparams.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
	r = pfAttachVirtualDisk(mounted_handle, NULL, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY |
		ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER, 0, &vparams, NULL);
	if (r != ERROR_SUCCESS) {
		SetLastError(r);
		uprintf("Could not mount ISO '%s': %s", path, WindowsErrorString());
		goto out;
	}

	r = pfGetVirtualDiskPhysicalPath(mounted_handle, &size, wtmp);
	if (r != ERROR_SUCCESS) {
		SetLastError(r);
		uprintf("Could not obtain physical path for mounted ISO '%s': %s", path, WindowsErrorString());
		goto out;
	}
	wchar_to_utf8_no_alloc(wtmp, physical_path, sizeof(physical_path));
	ret = physical_path;

out:
	if (ret == NULL)
		UnMountISO();
	wfree(path);
	return ret;
}
Example #27
0
File: process.c Project: wavs/ocre
/**
 * This function executes the extraction process.
 *
 * @param infos Informations about the launch process.
 */
void processAll(t_launch_infos *infos)
{
  t_binary_image *pic;
  SDL_Surface *image;
  t_cc_list *cc_list;
  
  pic = NULL;
  image = NULL;
  image = SDL_LoadBMP(infos->inFile);
  if (image != NULL)
    { 
      if (infos->verbose)
	printf("\n >> Image %s loaded.\n", infos->inFile);
      pic = bitmap_to_binaryimage(image,infos->inFile);
      if (pic != NULL)
	{ 
	  if (infos->verbose)
	    printf(" >> Binarization done.\n");
	  cc_list = findCC(pic->matrix);
	  if (cc_list != NULL)
	    {
	      checkIfCharacter(cc_list, pic->height, pic->width);

	      if (infos->verbose)
		printf(" >> Extraction of %d characters done.\n", cc_list->nbcc);

	      updateCC(cc_list);
	      exportCC(cc_list, pic);
	      
	      /*traceCC(image, cc_list); */

	      if (SDL_SaveBMP(image, infos->outFile) < 0)
		fprintf(stderr," > SDL BMP saving error <\n");
	      else
		if (infos->verbose)
		  printf(" >> Image %s saved.\n\n", infos->outFile);
	      /* free_listCC(cc_list) */
	      free_pic(pic);
	    }
	}
      SDL_FreeSurface(image);
    }
  else
    {
      fprintf(stderr, " > SDL BMP Loader error <\n");
      wfree(infos);
      exit(EXIT_FAILURE);
    }
}
Example #28
0
/*
    Any entry in the cgiList need to be checked to see if it has completed, and if so, process its output and clean up.
    Return time till next poll.
 */
WebsTime websCgiPoll()
{
    Webs    *wp;
    Cgi     *cgip;
    char    **ep;
    int     cid, nTries;

    for (cid = 0; cid < cgiMax; cid++) {
        if ((cgip = cgiList[cid]) != NULL) {
            wp = cgip->wp;
            websCgiGatherOutput(cgip);
            if (checkCgi(cgip->handle) == 0) {
                /*
                    We get here if the CGI process has terminated. Clean up.
                 */
                for (nTries = 0; (cgip->fplacemark == 0) && (nTries < 100); nTries++) {
                    websCgiGatherOutput(cgip);
                    /*                  
                         There are some cases when we detect app exit before the file is ready. 
                     */
                    if (cgip->fplacemark == 0) {
#if WINDOWS
                        Sleep(10);
#endif
                    }
                }
                if (cgip->fplacemark == 0) {
                    websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "CGI generated no output");
                } else {
                    trace(5, "cgi: Request complete - calling websDone");
                    websDone(wp);
                }
                /*
                    Remove the temporary re-direction files
                 */
                unlink(cgip->stdIn);
                unlink(cgip->stdOut);
                /*
                    Free all the memory buffers pointed to by cgip. The stdin file name (wp->cgiStdin) gets freed as
                    part of websFree().
                 */
                cgiMax = wfreeHandle(&cgiList, cid);
                for (ep = cgip->envp; ep != NULL && *ep != NULL; ep++) {
                    wfree(*ep);
                }
                wfree(cgip->cgiPath);
                wfree(cgip->argp);
                wfree(cgip->envp);
                wfree(cgip->stdOut);
                wfree(cgip);
                websPump(wp);
            }
        }
    }
    return cgiMax ? 10 : MAXINT;
}
Example #29
0
void freeMemcacheData(void *d)
{
    struct memcacheProcData *data = d;
    if (data->command)
        wstrFree(data->command);
    if (data->key)
        wstrFree(data->key);
    if (data->keys) {
        arrayEach(data->keys, freeKey);
        arrayDealloc(data->keys);
    }
    if (data->vals)
        arrayDealloc(data->vals);
    wfree(d);
}
Example #30
0
int op_exec_fi(operation* o, lwx * lx, int** ovec, int* ovec_len, void ** udata)
{
  if(o->argsl == 0)
  {
    lwx_setflags(lx, INTERPOLATE_DELIM_WS);
  }
  else if(o->argsl == 1)
  {
    lwx_setflags(lx, INTERPOLATE_DELIM_CUST);
    wfree(lwx_getptr(lx));
    lwx_setptr(lx, strdup(o->args[0]->s));
  }

  finally : coda;
}