opkg: add downloading, configuring and installing state changes
[oweals/opkg-lede.git] / opkg_state.c
index ded9683c6b9ac48c6b0d1f02e79f7fbfabc594e1..3dbd6c6b6a701066351258bc609d58097c364728 100644 (file)
 */
 
 #include "libopkg.h"
+#include "opkg_state.h"
+
+
+static char *state_strings[] =
+{
+  "None",
+  "Downloading Package",
+  "Installing Package",
+  "Configuring Package",
+  "Upgrading Package",
+  "Removing Package",
+  "Downloading Repository",
+  "Verifying Repository Signature"
+};
+
+
 
 opkg_state_changed_callback opkg_cb_state;
 
@@ -27,10 +43,19 @@ opkg_set_current_state (opkg_state_t state, const char *data)
 {
   if (opkg_state_data)
     free (opkg_state_data);
-  opkg_state_data = malloc (strlen (data));
-  strcpy (opkg_state_data, data);
+  if (data)
+  {
+    opkg_state_data = malloc (strlen (data));
+    strcpy (opkg_state_data, data);
+  }
+  else
+  {
+    opkg_state_data = NULL;
+  }
 
   opkg_state = state;
+
+  printf ("opkg state set to %s: %s\n", state_strings[state], data);
 }
 
 void