示例#1
0
void
shoes_download(shoes_http_request *req)
{
    HANDLE file = INVALID_HANDLE_VALUE;
    INTERNET_PORT _port = req->port;
    LPWSTR _method = NULL, _body = NULL;
    LPWSTR _scheme = SHOE_ALLOC_N(WCHAR, MAX_PATH);
    LPWSTR _host = SHOE_ALLOC_N(WCHAR, MAX_PATH);
    LPWSTR _path = SHOE_ALLOC_N(WCHAR, MAX_PATH);
    DWORD _size;
    MultiByteToWideChar(CP_UTF8, 0, req->scheme, -1, _scheme, MAX_PATH);
    MultiByteToWideChar(CP_UTF8, 0, req->host, -1, _host, MAX_PATH);
    MultiByteToWideChar(CP_UTF8, 0, req->path, -1, _path, MAX_PATH);
    if (req->method != NULL)
    {
        _method = SHOE_ALLOC_N(WCHAR, MAX_PATH);
        MultiByteToWideChar(CP_UTF8, 0, req->method, -1, _method, MAX_PATH);
    }

    if (req->mem == NULL && req->filepath != NULL)
        file = CreateFile(req->filepath, GENERIC_READ | GENERIC_WRITE,
                          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    shoes_winhttp(_scheme, _host, _port, _path, _method, req->headers, (LPVOID)req->body, req->bodylen,
                  &req->mem, req->memlen, file, &_size, req->flags, req->handler, req->data);
    req->size = _size;
    SHOE_FREE(_scheme);
    SHOE_FREE(_host);
    SHOE_FREE(_path);
    if (_method != NULL) SHOE_FREE(_method);
}
示例#2
0
文件: app.c 项目: gensym/shoes
static void
shoes_app_free(shoes_app *app)
{
  SHOE_FREE(app->slot);
  cairo_destroy(app->scratch);
  RUBY_CRITICAL(free(app));
}
示例#3
0
文件: canvas.c 项目: AnthonBerg/shoes
void
shoes_transform_release(shoes_transform *st)
{
  if (st == NULL) return;
  if (--st->refs) return;
  SHOE_FREE(st);
}
示例#4
0
文件: curl.c 项目: Shoes3/shoes3
size_t
shoes_curl_header_funk(char *ptr, size_t size, size_t nmemb, void *user)
{
  shoes_curl_data *data = (shoes_curl_data *)user;
  size_t realsize = size * nmemb;
  if (data->status == 0 && data->handler != NULL)
  {
    curl_easy_getinfo(data->curl, CURLINFO_RESPONSE_CODE, (long *)&data->status);
    if (data->handler != NULL)
    {
      shoes_http_event *event = SHOE_ALLOC(shoes_http_event);
      SHOE_MEMZERO(event, shoes_http_event, 1);
      event->stage = SHOES_HTTP_STATUS;
      event->status = data->status;
      data->handler(event, data->data);
      SHOE_FREE(event);
    }
  }

  HTTP_HEADER(ptr, realsize, data->handler, data->data);
  if ((data->mem != NULL || data->fp != NULL) &&
      strncmp(ptr, content_len_str, strlen(content_len_str)) == 0)
  {
    data->total = strtoull(ptr + strlen(content_len_str), NULL, 10);
    if (data->mem != NULL && data->total > data->memlen)
    {
      data->memlen = data->total;
      SHOE_REALLOC_N(data->mem, char, data->memlen);
      if (data->mem == NULL) return -1;
    }
示例#5
0
文件: world.c 项目: Klokka/Lumi
void
lumi_world_free(lumi_world_t *world)
{
#ifdef VLC_0_9
  if (world->vlc != NULL) libvlc_release(world->vlc);
#endif
  lumi_native_cleanup(world);
  st_foreach(world->image_cache, CASTFOREACH(lumi_world_free_image_cache), 0);
  st_free_table(world->image_cache);
  SHOE_FREE(world->blank_cache);
  cairo_surface_destroy(world->blank_image);
  pango_font_description_free(world->default_font);
  rb_gc_unregister_address(&world->apps);
  rb_gc_unregister_address(&world->msgs);
  if (world != NULL)
    SHOE_FREE(world);
}
示例#6
0
文件: canvas.c 项目: AnthonBerg/shoes
static void
shoes_canvas_free(shoes_canvas *canvas)
{
  if (canvas->slot != NULL && canvas->slot->owner == canvas)
    SHOE_FREE(canvas->slot);
  shoes_canvas_reset_transform(canvas);
  RUBY_CRITICAL(free(canvas));
}
示例#7
0
文件: winhttp.c 项目: FiXato/shoes
void
shoes_download(shoes_download_request *req)
{
  HANDLE file = INVALID_HANDLE_VALUE;
  INTERNET_PORT _port = req->port;
  LPWSTR _host = SHOE_ALLOC_N(WCHAR, MAX_PATH);
  LPWSTR _path = SHOE_ALLOC_N(WCHAR, MAX_PATH);
  DWORD _size;
  MultiByteToWideChar(CP_UTF8, 0, req->host, -1, _host, MAX_PATH);
  MultiByteToWideChar(CP_UTF8, 0, req->path, -1, _path, MAX_PATH);

  if (req->mem == NULL && req->filepath != NULL)
    file = CreateFile(req->filepath, GENERIC_READ | GENERIC_WRITE,
      FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  shoes_winhttp(_host, _port, _path, &req->mem, req->memlen, file, &_size, req->handler, req->data);
  req->size = _size;
  SHOE_FREE(_host);
  SHOE_FREE(_path);
}
示例#8
0
文件: world.c 项目: danorine/shoes
void
shoes_world_free(shoes_world_t *world)
{
#ifdef SHOES_QUARTZ
  CFRelease(world->os.clip);
  TECDisposeConverter(world->os.converter);
#endif
  rb_gc_unregister_address(&world->apps);
  rb_gc_unregister_address(&world->msgs);
  if (world != NULL)
    SHOE_FREE(world);
}
示例#9
0
文件: canvas.c 项目: Shoes3/shoes3
static void shoes_canvas_reset_transform(shoes_canvas *canvas) {
    if (canvas->sts != NULL) {
        int i;
        for (i = 0; i < canvas->stl; i++)
            shoes_transform_release(canvas->sts[i]);
        SHOE_FREE(canvas->sts);
        canvas->sts = NULL;
    }
    canvas->stl = 0;
    canvas->stt = 0;

    if (canvas->st != NULL) {
        shoes_transform_release(canvas->st);
        canvas->st = NULL;
    }
}
示例#10
0
文件: systray.c 项目: Shoes3/shoes3
static void shoes_systray_free(shoes_systray *handle) {
    if (handle->icon_path) free(handle->icon_path);
    if (handle->title) free(handle->title);
    if (handle->message) free(handle->message);
    RUBY_CRITICAL(SHOE_FREE(handle));
}
示例#11
0
文件: menu.c 项目: Shoes3/shoes3
static void shoes_menu_free(shoes_menu *mn) {
	if (mn->title)
	  free(mn->title);
    RUBY_CRITICAL(SHOE_FREE(mn));
}
示例#12
0
void
shoes_http_headers_free(SHOES_DOWNLOAD_HEADERS headers)
{
    SHOE_FREE(headers);
}
示例#13
-1
文件: winhttp.c 项目: FiXato/shoes
void
shoes_winhttp_headers(HINTERNET req, shoes_download_handler handler, void *data)
{ 
  DWORD size;
  WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS,
    WINHTTP_HEADER_NAME_BY_INDEX, NULL, &size, WINHTTP_NO_HEADER_INDEX);

  if(GetLastError() == ERROR_INSUFFICIENT_BUFFER)
  {
    int whdrlen = 0, hdrlen = 0;
    LPCWSTR whdr;
    LPSTR hdr = SHOE_ALLOC_N(CHAR, MAX_PATH);
    LPCWSTR hdrs = SHOE_ALLOC_N(WCHAR, size/sizeof(WCHAR));
    BOOL res = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS,
      WINHTTP_HEADER_NAME_BY_INDEX, (LPVOID)hdrs, &size, WINHTTP_NO_HEADER_INDEX);
    if (res)
    {
      for (whdr = hdrs; whdr - hdrs < size / sizeof(WCHAR); whdr += whdrlen)
      {
        WideCharToMultiByte(CP_UTF8, 0, whdr, -1, hdr, MAX_PATH, NULL, NULL);
        hdrlen = strlen(hdr);
        HTTP_HEADER(hdr, hdrlen, handler, data);
        whdrlen = wcslen(whdr) + 1;
      }
    }
    SHOE_FREE(hdrs);
    SHOE_FREE(hdr);
  }
}