[maemo-commits] [maemo-commits] r15149 - projects/haf/trunk/apt-https
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Feb 6 18:26:07 EET 2008
- Previous message: [maemo-commits] r15148 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r15150 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2008-02-06 18:26:06 +0200 (Wed, 06 Feb 2008)
New Revision: 15149
Modified:
projects/haf/trunk/apt-https/https.cc
Log:
* https.cc (get_osso_product_hardware): New.
(maybe_add_device_id): Use it instead of $OSSO_PRODUCT_HARDWARE.
Modified: projects/haf/trunk/apt-https/https.cc
===================================================================
--- projects/haf/trunk/apt-https/https.cc 2008-02-06 15:50:24 UTC (rev 15148)
+++ projects/haf/trunk/apt-https/https.cc 2008-02-06 16:26:06 UTC (rev 15149)
@@ -139,7 +139,7 @@
GError *error = NULL;
GPid child_pid;
-#if 0
+#if 0
fprintf (stderr, "[");
for (int i = 0; argv[i]; i++)
fprintf (stderr, " %s", argv[i]);
@@ -176,14 +176,51 @@
return success;
}
+static const char *
+get_osso_product_hardware ()
+{
+ static char *product_hardware = NULL;
+
+ if (product_hardware)
+ return product_hardware;
+
+ /* XXX - There is a library in maemo somewhere to do this, but it is
+ not included in the maemo SDK, so we have to do it
+ ourselves. Ridiculous, I know.
+ */
+
+ product_hardware = "";
+ FILE *f = fopen ("/proc/component_version", "r");
+ if (f)
+ {
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t n;
+
+ while ((n = getline (&line, &len, f)) != -1)
+ {
+ if (n > 0 && line[n-1] == '\n')
+ line[n-1] = '\0';
+
+ if (sscanf (line, "product %as", &product_hardware) == 1)
+ break;
+ }
+
+ free (line);
+ fclose (f);
+ }
+
+ return product_hardware;
+}
+
char *
maybe_add_device_id (const char *uri)
{
- const char *product_hardware = getenv ("OSSO_PRODUCT_HARDWARE");
+ const char *product_hardware = get_osso_product_hardware ();
const char *host_part, *host_end, *at_pos;
char *result;
- if (product_hardware == NULL)
+ if (product_hardware == NULL || product_hardware[0] == '\0')
{
dont_add_device_id:
return strdup (uri);
- Previous message: [maemo-commits] r15148 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r15150 - in projects/haf/trunk/apt-https: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
