Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Web update: patch pool update manager (untested)

  • Loading branch information...
commit fa0831ba77bce5671f11cecfd8a2e29026f7cb54 1 parent 68c15ad
@sbourdeauducq sbourdeauducq authored
Showing with 181 additions and 5 deletions.
  1. +1 −1  src/Makefile
  2. +2 −4 src/flash.c
  3. +141 −0 src/patchpool.c
  4. +37 −0 src/patchpool.h
View
2  src/Makefile
@@ -16,7 +16,7 @@ BINDIR=bin
OBJS=version.o shellext.o sysconfig.o config.o fb.o input.o keymap.o fbgrab.o shortcuts.o osc.o png.o flashvalid.o main.o
# GUI
-OBJS+=messagebox.o filedialog.o resmgr.o guirender.o performance.o cp.o keyboard.o ir.o audio.o midi.o oscsettings.o dmxspy.o dmxdesk.o dmx.o videoin.o rsswall.o patcheditor.o monitor.o firstpatch.o filemanager.o sysettings.o about.o flash.o shutdown.o
+OBJS+=messagebox.o filedialog.o resmgr.o guirender.o performance.o cp.o keyboard.o ir.o audio.o midi.o oscsettings.o dmxspy.o dmxdesk.o dmx.o videoin.o rsswall.o patcheditor.o monitor.o firstpatch.o filemanager.o sysettings.o about.o patchpool.o flash.o shutdown.o
# translations
OBJS+=french.o german.o
View
6 src/flash.c
@@ -101,7 +101,7 @@ static double *d_progress;
static int progress_callback(void *d_progress, double t, double d, double ultotal, double ulnow)
{
- flash_progress = (int) d/t*100;
+ flash_progress = (int)d/t*100;
return 0;
}
@@ -160,7 +160,7 @@ static size_t write_memory_callback(void *ptr, size_t size, size_t nmemb, void *
mem->memory = realloc(mem->memory, mem->size + realsize + 1);
if(mem->memory == NULL) {
- printf("not enough memory (realloc returned NULL)\n");
+ printf("flash.c: write_memory_callback: not enough memory (realloc returned NULL)\n");
return -1;
}
@@ -345,7 +345,6 @@ static void get_versions()
if(c != NULL)
*c = 0;
available_socbios = available_socbios_buf;
- printf("SoC: %s\n", available_socbios);
free(b);
b = download_mem(BASE_URL "version-app");
@@ -357,7 +356,6 @@ static void get_versions()
if(c != NULL)
*c = 0;
available_application = available_application_buf;
- printf("App: %s\n", available_application);
free(b);
}
View
141 src/patchpool.c
@@ -0,0 +1,141 @@
+/*
+ * Flickernoise
+ * Copyright (C) 2011 Sebastien Bourdeauducq
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "patchpool.h"
+
+void patchpool_init(struct patchpool *pp)
+{
+ pp->alloc_size = 0;
+ pp->names = NULL;
+}
+
+void patchpool_free(struct patchpool *pp)
+{
+ int i;
+
+ for(i=0;i<pp->alloc_size;i++)
+ free(pp->names[i]);
+ free(pp->names);
+}
+
+#define REALLOC_COUNT 16
+
+void patchpool_add(struct patchpool *pp, char *entry)
+{
+ int i;
+ int newsize;
+
+ for(i=0;i<pp->alloc_size;i++)
+ if(pp->names[i] == NULL) {
+ pp->names[i] = entry;
+ return;
+ }
+
+ newsize = pp->alloc_size + REALLOC_COUNT;
+ pp->names = realloc(pp->names, newsize*sizeof(char *));
+ if(pp->names == NULL) {
+ printf("realloc failed in patchpool\n");
+ pp->alloc_size = 0;
+ pp->names = 0;
+ }
+ memset(&pp->names[pp->alloc_size], 0, REALLOC_COUNT*sizeof(char *));
+ pp->names[pp->alloc_size] = entry;
+ pp->alloc_size = newsize;
+}
+
+void patchpool_del(struct patchpool *pp, const char *entry)
+{
+ int i;
+
+ for(i=0;i<pp->alloc_size;i++)
+ if((pp->names[i] != NULL) && (strcmp(entry, pp->names[i]) == 0)) {
+ free(pp->names[i]);
+ pp->names[i] = NULL;
+ return;
+ }
+}
+
+int patchpool_count(struct patchpool *pp)
+{
+ int i;
+ int count;
+
+ count = 0;
+ for(i=0;i<pp->alloc_size;i++) {
+ if(pp->names[i] != NULL)
+ count++;
+ }
+ return count;
+}
+
+void patchpool_diff(struct patchpool *pp, struct patchpool *to_delete)
+{
+ int i;
+
+ for(i=0;i<to_delete->alloc_size;i++)
+ if(to_delete->names[i] != NULL)
+ patchpool_del(pp, to_delete->names[i]);
+}
+
+void patchpool_add_multi(struct patchpool *pp, const char *entry)
+{
+ int offset;
+ char *e;
+
+ while(1) {
+ offset = 0;
+ while((entry[offset] != '\n') && (entry[offset] != 0))
+ offset++;
+ e = strndup(entry, offset);
+ patchpool_add(pp, e);
+ if(entry[offset] == 0)
+ break;
+ else
+ entry += offset + 1;
+ }
+}
+
+void patchpool_add_files(struct patchpool *pp, const char *folder, const char *extension)
+{
+ DIR *d;
+ struct dirent *entry;
+ struct stat s;
+ char fullname[384];
+ char *c;
+
+ d = opendir(folder);
+ if(!d) return;
+ while((entry = readdir(d))) {
+ if(entry->d_name[0] == '.') continue;
+ strncpy(fullname, folder, sizeof(fullname));
+ strncat(fullname, entry->d_name, sizeof(fullname));
+ lstat(fullname, &s);
+ if(!S_ISDIR(s.st_mode)) {
+ c = strrchr(entry->d_name, '.');
+ if((c != NULL) && (strcmp(extension, c+1) == 0))
+ patchpool_add(pp, entry->d_name);
+ }
+ }
+ closedir(d);
+}
View
37 src/patchpool.h
@@ -0,0 +1,37 @@
+/*
+ * Flickernoise
+ * Copyright (C) 2011 Sebastien Bourdeauducq
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __PATCHPOOL_H
+#define __PATCHPOOL_H
+
+struct patchpool {
+ int alloc_size;
+ char **names;
+};
+
+void patchpool_init(struct patchpool *pp);
+void patchpool_free(struct patchpool *pp);
+void patchpool_add(struct patchpool *pp, char *entry);
+void patchpool_del(struct patchpool *pp, const char *entry);
+int patchpool_count(struct patchpool *pp);
+
+void patchpool_diff(struct patchpool *pp, struct patchpool *to_delete);
+
+void patchpool_add_multi(struct patchpool *pp, const char *entry);
+void patchpool_add_files(struct patchpool *pp, const char *folder, const char *extension);
+
+#endif /* __PATCHPOOL_H */
Please sign in to comment.
Something went wrong with that request. Please try again.