0

I'm trying to create a downloader/update tool for my C application.

My updater PDL:

  1. Download update.xml from webserver
  2. Check update version by using fscanf and storing floating point to a variable
  3. Check variable with an if statement if the version is greater than release version defined in application
  4. Download update if true
  5. Display up to date if false

Does C have any built in functions to do this? Is this possible in C?

Kyle
  • 3,004
  • 15
  • 52
  • 79
  • 2
    No, not possible. C can do everything except display up to date if false. – Nikolai Fetissov Nov 13 '10 at 07:45
  • I was just going to use a simple printf("Up to date"); – Kyle Nov 13 '10 at 07:45
  • You should simplify this question to just the part that you do not know how to do. I suggest that is just parts 1 and 4. – Clifford Nov 13 '10 at 08:42
  • 2
    Oh yes! There's an ANSI C function called 'DownloadUpdateXmlCheckMyVerIfTrueDownloadMeToSpecificDir'. I just don't remember exactly which languages are supported when it prints "up to date" – valdo Nov 13 '10 at 09:00

3 Answers3

4

cURL (libcurl) would be the easy option:
Download file using libcurl in C/C++
Downloading all files in directory using libcurl
http://curl.haxx.se/

If your software is based on Microsoft Windows, then you can also use Wininet APIs:
http://msdn.microsoft.com/en-us/library/aa385473.aspx

Community
  • 1
  • 1
swatkat
  • 4,785
  • 1
  • 23
  • 17
1

Not with ANSI C, but for Win have a look at:

#include <Urlmon.h>
HRESULT URLDownloadToFile();
user411313
  • 3,930
  • 19
  • 16
  • Rather "not in the ISO C standard library". Using a third-party library does not make the code non-compliant with the language standard. – Clifford Nov 13 '10 at 08:39
1

C has no "built in functions" at all, they are all provided by libraries. Networking is not supported in the standard library; you need a networking library of which there are many, some of which are standard for particular operating systems, but tend to be low level, such as BSD Sockets or the similar WinSock API.

I strongly suggest however that you do not us a floating point value to represent version number, and simply compare the version string. This avoids fp precision and conversion issues, and allows flexible version number formatting such as "1.0.1" or "1.0a" or whatever.

Clifford
  • 88,407
  • 13
  • 85
  • 165