CINXE.COM
glibcurl | Richard Atterer
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>glibcurl | Richard Atterer</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="/sites/all/themes/canvas_spring/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width; initial-scale=0.6666; maximum-scale=1.5; minimum-scale=0.25;" /> <link type="text/css" rel="stylesheet" media="all" href="/sites/atterer/files/css/css_20e2e973af54425b6c8758b72a0b4e9d.css" /> </head> <body class="not-front not-logged-in page-node node-type-page no-sidebars"> <div id="page"><div id="page-inner"> <a name="top" id="navigation-top"></a> <div id="skip-to-nav"><a href="#navigation">Skip to Navigation</a></div> <div id="header"><div id="header-inner" class="clear-block"> <div id="header-background"></div> <div id="logo-title"> <div id="logo"><a href="/" title="Home" rel="home"></a></div> </div> <!-- /#logo-title --> <div id="header-blocks" class="region region-header"> <div id="block-user-0" class="block block-user"> <h2>User login</h2> <div class="content"> <form action="/glibcurl?destination=node%2F21" accept-charset="UTF-8" method="post" id="user-login-form"> <div><div class="form-item" id="edit-name-wrapper"> <label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label> <input type="text" maxlength="60" name="name" id="edit-name" size="15" value="" class="form-text required" /> </div> <div class="form-item" id="edit-pass-wrapper"> <label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label> <input type="password" name="pass" id="edit-pass" maxlength="60" size="15" class="form-text required" /> </div> <input type="submit" name="op" id="edit-submit" value="Log in" class="form-submit" /> <div class="item-list"><ul><li class="first last"><a href="/user/password" title="Request new password via e-mail.">Request new password</a></li> </ul></div><input type="hidden" name="form_build_id" id="form-WAPkye40CUqxWvYvg-stmSHNlD5OFR4dQpngSKYknqo" value="form-WAPkye40CUqxWvYvg-stmSHNlD5OFR4dQpngSKYknqo" /> <input type="hidden" name="form_id" id="edit-user-login-block" value="user_login_block" /> </div></form> </div> </div> </div> <!-- /#header-blocks --> </div></div> <!-- /#header-inner, /#header --> <div id="main"><div id="main-inner" class="clear-block with-navbar"> <div id="content"><div id="content-inner"> <div id="content-header"> <div class="breadcrumb"><a href="/">Home</a> › <a href="/glibcurl" class="active">glibcurl</a></div> <h1 class="title">glibcurl</h1> </div> <!-- /#content-header --> <div id="content-area"> <div id="node-21" class="node clear-block"> <div class="meta"> <span class="submitted">Last update by Richard on 2010-04-26</span> <div class="terms terms-inline"><ul class="links inline"><li class="taxonomy_term_3 first last"><a href="/taxonomy/term/3" rel="tag" title="">software</a></li> </ul></div> </div> <div class="content"> <p>This page is for programmers who want to use <a href="http://curl.haxx.se/libcurl/">libcurl</a> (a library for performing HTTP/FTP downloads) in their glib program. glib is used by the <a href="http://www.gtk.org/">GTK+</a> library, and thus by all GTK applications.</p> <p>This is a by-product of my work on <a href="/jigdo">jigdo</a>. Currently, the code is tested and known to work under Linux and Windows.</p> <h2>What is glibcurl?</h2> <p>glibcurl consists of a small amount of C code which you can include in your program. It integrates the event loops of libcurl and glib. This means that a GTK+ program is able to wait for clicks, button presses etc. at the same time as waiting for data to arrive on the network sockets maintained by libcurl.</p> <p>glibcurl could be turned into a library, but for the time being I think it is much easier for people to include it directly in their own code. It is released under a very liberal MIT/BSD-style license which makes inclusion possible for GPL-licensed and even for commercial programs.</p> <h2>Why is glibcurl useful?</h2> <p>libcurl is a thread-safe library, allowing you to start several downloads in separate threads in your GTK+/Gnome application - so why should you use something like glibcurl instead?</p> <p>In my opinion, glibcurl is preferable over multiple curl-easy threads because then writing your GTK+ program will be a lot easier. With several threads, your code needs to include many additional calls to glib functions for synchronisation. For example, a mutex will be necessary if you want to display a progress bar while a download is performed.</p> <p>However, when using glibcurl, you can directly update the GTK+ widgets from the curl callback function, since glibcurl causes the call to <code>curl_multi_perform()</code> (and thus to your callback) to happen from within the libgtk main loop, in the same way that GTK+ callbacks for button presses etc. are called.</p> <p>(Under Windows, glibcurl internally uses a separate thread to wait for data arriving on network sockets, but this is hidden from the code using glibcurl - everything behaves identically under Linux and Windows.)</p> <p>By the way, the name "glibcurl" is inspired by "glibwww", which does much the same thing for the <a href="http://www.w3.org/Library/">libwww</a> library.</p> <h2>Documentation</h2> The glibcurl functions are documented in the <tt>glibcurl.h</tt> header file. Additionally, an <a href="/jigdo/api?page=glibcurl_8h.html">HTML version of the glibcurl API</a> is generated from the header file. <h2>Download</h2> <p>There are no "releases" for this piece of code, it only gets updated during my work on jigdo. It can be downloaded from the jigdo CVS repository:</p> <ul> <li><a href="http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jigdo/jigdo/src/glibcurl/" >Browse the CVS repository</a></li> <li>Download: <a href="http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jigdo/jigdo/src/glibcurl/Makefile?revision=HEAD">Makefile</a>, <a href="http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jigdo/jigdo/src/glibcurl/glibcurl-example.c?revision=HEAD">glibcurl-example.c</a>, <a href="http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jigdo/jigdo/src/glibcurl/glibcurl.c?revision=HEAD">glibcurl.c</a>, <a href="http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jigdo/jigdo/src/glibcurl/glibcurl.h?revision=HEAD">glibcurl.h</a> </li> </ul><div class="field field-type-filefield field-field-file"> <div class="field-label">Attachments: </div> <div class="field-items"> <div class="field-item odd"> <div class="filefield-file"><img class="filefield-icon field-icon-application-octet-stream" alt="application/octet-stream icon" src="http://atterer.org/sites/all/modules/filefield/icons/application-octet-stream.png" /><a href="http://atterer.org/sites/atterer/files/2009-09/glibcurl/glibcurl-050101.tar.gz" type="application/octet-stream; length=6600" title="glibcurl-050101.tar.gz">Snapshot of the glibcurl code, 2005-01-01</a></div> </div> </div> </div> </div> <ul class="links inline"><li class="comment_add first last"><a href="/comment/reply/21#comment-form" title="Share your thoughts and opinions related to this posting.">Add new comment</a></li> </ul></div> </div> </div></div> <!-- /#content-inner, /#content --> <div id="navbar"><div id="navbar-inner" class="clear-block region region-navbar"> <a name="navigation" id="navigation"></a> <div id="search-box"> <form action="/glibcurl" accept-charset="UTF-8" method="post" id="search-theme-form"> <div><div id="search" class="container-inline"> <div class="form-item" id="edit-search-theme-form-1-wrapper"> <input type="text" maxlength="128" name="search_theme_form" id="edit-search-theme-form-1" size="15" value="Search" title="Enter the terms you wish to search for." class="form-text" /> </div> <input type="hidden" name="form_build_id" id="form-1iwuEPVw2gT7vkF7FmL8ETY1i2hWWmN3ivr_L43PB8U" value="form-1iwuEPVw2gT7vkF7FmL8ETY1i2hWWmN3ivr_L43PB8U" /> <input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form" /> </div> </div></form> </div> <!-- /#search-box --> <div id="primary"> <ul class="links"><li class="menu-344 first"><a href="/photo" title="">Photography</a></li> <li class="menu-362"><a href="/software" title="">Software</a></li> <li class="menu-190"><a href="/jigdo" title="jigdo (Jigsaw Download) - a download manager for CD/DVD images">jigdo</a></li> <li class="menu-376"><a href="/research" title="">Research</a></li> <li class="menu-193 last"><a href="/about" title="About">About</a></li> </ul> </div> <!-- /#primary --> </div></div> <!-- /#navbar-inner, /#navbar --> </div></div> <!-- /#main-inner, /#main --> <div id="footer"><div id="footer-inner" class="region region-footer"> <div id="footer-message"><div class="aller"><i>漏 Copyright 2014 Richard Atterer</i></div> <div class="breadcrumb"> <a href="#page"> Top of page </a> • <a href="/"> Home </a> • <a href="/sitemap"> Sitemap </a> • <a href="/contact"> Contact </a> • <a href="/about"> About </a></div></div> </div></div> <!-- /#footer-inner, /#footer --> </div></div> <!-- /#page-inner, /#page --> <script type="text/javascript" src="/sites/atterer/files/js/js_b0b21dfadec5927599caf5b21dcf2041.js"></script> <script type="text/javascript"> <!--//--><![CDATA[//><!-- jQuery.extend(Drupal.settings, { "basePath": "/", "spamspan": { "m": "spamspan", "u": "u", "d": "d", "h": "h", "t": "t" } }); //--><!]]> </script> </body> </html>