diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..fffb27eaefcd145ca2750b7f62135e27fe4e7693
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+html/*
+attic/*
+/.project
+/.cproject
+/.pydevproject
+/.externalToolBuilders
+/.settings
+.directory
+generated*
+sysroots
+bitbake-logs
+/temp
+*.o
+*.cgi
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..923969ef34ddf94b39ecf66738ec868708fc431f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,27 @@
+# Runs 'make', 'make install', and 'make clean' in specified subdirectories
+SUBDIRS := src
+INSTALLDIRS = $(SUBDIRS:%=install-%)
+CLEANDIRS = $(SUBDIRS:%=clean-%)
+
+#TARGETDIR=$(DESTDIR)/www/pages
+
+all: $(SUBDIRS)
+ @echo "make all top"
+
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+install: $(INSTALLDIRS)
+ @echo "make install top"
+
+$(INSTALLDIRS):
+ $(MAKE) -C $(@:install-%=%) install
+
+clean: $(CLEANDIRS)
+ @echo "make clean top"
+
+$(CLEANDIRS):
+ $(MAKE) -C $(@:clean-%=%) clean
+
+.PHONY: all install clean $(SUBDIRS) $(INSTALLDIRS) $(CLEANDIRS)
+
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..631b9b56c69f107f284d11ebb45fb58cae76aaad
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.0
diff --git a/eclipse_project_setup/.cproject b/eclipse_project_setup/.cproject
new file mode 100644
index 0000000000000000000000000000000000000000..c122aa7d8d22f41acbc5e04eea31ba0e81278de5
--- /dev/null
+++ b/eclipse_project_setup/.cproject
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/eclipse_project_setup/.externalToolBuilders/SCP apps-editconf to target.launch b/eclipse_project_setup/.externalToolBuilders/SCP apps-editconf to target.launch
new file mode 100644
index 0000000000000000000000000000000000000000..dda8b619ba7eeac00ee7c50184d881f3b576d24b
--- /dev/null
+++ b/eclipse_project_setup/.externalToolBuilders/SCP apps-editconf to target.launch
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/eclipse_project_setup/.project b/eclipse_project_setup/.project
new file mode 100644
index 0000000000000000000000000000000000000000..172fafdfcf28cc1174d76fffd65b4a2148b8f056
--- /dev/null
+++ b/eclipse_project_setup/.project
@@ -0,0 +1,41 @@
+
+
+ elphel-apps-editconf
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ full,incremental,
+
+
+
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+ full,incremental,
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/SCP apps-editconf to target.launch
+
+
+
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+ full,incremental,
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder (2).launch
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/run_bitbake.sh b/run_bitbake.sh
new file mode 100755
index 0000000000000000000000000000000000000000..8e63ac07d7557338735aef7ef7e5a520b62e3ee7
--- /dev/null
+++ b/run_bitbake.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+args="$@"
+while (( "$#" )); do
+ shift
+done
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+echo "Launching bitbake $args"
+cd $DIR/../../poky
+. ./oe-init-build-env
+bitbake $args | sed -u 's@| @@'
+exit 0
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..fff5f02a075ee52545acc13050bc65834a4e631d
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,42 @@
+
+#INSTDIR = $(prefix)/usr/local/bin/
+CGIDIR = /www/pages
+BINDIR = /usr/bin/
+INSTMODE = 0755
+INSTOWNER = root
+INSTGROUP = root
+
+PROGS = editconf.cgi unescape strconf.cgi
+SRCS = editconf.c unescape.c strconf.cpp
+OBJS = editconf.o unescape.o
+
+OBJS += $(SOURCES:.cpp=.o)
+
+CFLAGS += -Wall -I$(STAGING_DIR_HOST)/usr/include-uapi
+
+all: $(PROGS)
+
+strconf.cgi: strconf.o
+ $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
+editconf.cgi: editconf.o
+ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+unescape: unescape.o
+ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+
+install: $(PROGS)
+ $(INSTALL) $(OWN) -d $(DESTDIR)
+ $(INSTALL) $(OWN) -d $(DESTDIR)$(CGIDIR)
+ $(INSTALL) $(OWN) -d $(DESTDIR)$(BINDIR)
+ $(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) strconf.cgi $(DESTDIR)$(CGIDIR)
+ $(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) editconf.cgi $(DESTDIR)$(CGIDIR)
+ $(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) unescape $(DESTDIR)$(BINDIR)
+ $(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) xmlxmt.cgi $(DESTDIR)$(CGIDIR)
+ $(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) editconf.php $(DESTDIR)$(CGIDIR)
+clean:
+ rm -rf $(PROGS) *.o core
+#dependency:
+# make depend
+#depend:
+# makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
+# touch dependency
+# DO NOT DELETE
diff --git a/src/editconf.c b/src/editconf.c
new file mode 100644
index 0000000000000000000000000000000000000000..a4e230b40e774f1afb4b04a63b7df987cbcf7718
--- /dev/null
+++ b/src/editconf.c
@@ -0,0 +1,271 @@
+/*
+** -----------------------------------------------------------------------------**
+** editconf.c
+**
+** Copyright (C) 2006 Elphel, Inc.
+**
+** -----------------------------------------------------------------------------**
+** 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, either version 3 of the License, or
+** (at your option) any later version.
+**
+** 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 .
+** -----------------------------------------------------------------------------**
+*/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+#define THIS_DEBUG 1
+#define QRY_MAXPARAMS 64
+
+char copyQuery [4096];
+const char *uri;
+const char *method;
+const char *query;
+
+struct key_value {
+ char *key;
+ char *value;
+};
+
+struct key_value gparams[QRY_MAXPARAMS+1];
+
+int unescape(char *, int);
+int hexdigit(char);
+char * paramValue(struct key_value *, char *);
+int parseQuery(struct key_value *, char *);
+
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int i; //,j,k,a,l;
+ char fileName[256];
+ char confKey[256];
+// char confSection[256];
+ char confValue[1024];
+ char *confFile=NULL;
+ char *confFileCopy=NULL;
+ char * v;
+ int useEQ=1;
+ FILE * cfile;
+ int thisError=0;
+ size_t fileSize;
+ char * cp;
+ char * ep;
+ char * lineEnd;
+ char * lineStart;
+ char * keyStart;
+ char * valueStart;
+
+
+ fileName[0]=0; fileName[sizeof(fileName)-1]=0;
+ confKey[0]=0; confKey[sizeof(confKey)-1]=0;
+ confValue[0]=0; confValue[sizeof(confValue)-1]=0;
+// short int hsz[2];
+
+// struct stat buf;
+
+ method = getenv("REQUEST_METHOD");
+ query = getenv("QUERY_STRING");
+ uri = getenv("REQUEST_URI");
+ if (argc > 1) method = NULL; // to fix a bug when a script is called as CGI and uses editconf as a command line app.
+ if (method == NULL) {
+ if (argc<3) {printf("This program should be run as a CGI from the web server or:\n" \
+ "editconf filename key - will return a key value if any\n" \
+ "editconf filename key value - will set a value to a key (using '=' as separator)" \
+ "editconf filename key value 0 - will set a value to a key (using ' ' as separator)");
+ exit (0);}
+ strncpy(fileName,argv[1], sizeof(fileName));
+ strncpy(confKey, argv[2], sizeof(confKey));
+ if (argc>3) strncpy(confValue,argv[3], sizeof(confValue));
+ if (argc>4) useEQ =atoi(argv[4]);
+
+ /* Not a CGI! */
+// printf("This program should be run as a CGI from the web server!\n");
+// exit(1);
+ } else {
+
+ i= (query)? strlen (query):0;
+// fprintf(stderr,"querry length=%d\n", i);
+
+ if (i>(sizeof(copyQuery)-1)) i= sizeof(copyQuery)-1;
+ if (i>0) strncpy(copyQuery,query, i);
+ copyQuery[i]=0;
+ unescape(copyQuery,sizeof(copyQuery));
+
+ parseQuery(gparams, copyQuery);
+
+ if((v = paramValue(gparams, "file")) != NULL) strncpy(fileName,v, sizeof(fileName));
+ if((v = paramValue(gparams, "key")) != NULL) strncpy(confKey,v, sizeof(confKey));
+ if((v = paramValue(gparams, "value")) != NULL) strncpy(confValue,v, sizeof(confValue));
+ if((v = paramValue(gparams, "eq")) != NULL) useEQ=atoi (v);
+
+// int keyFound=0;
+ printf("Content-Type: text/xml\n");
+ printf("Pragma: no-cache\n\n"); // 2 new lines!
+ printf("\n\n");
+// printf("%d\n",argc);
+/*
+ if (fileName[0]) printf("%s\n",fileName);
+ if (confKey[0]) printf("%s\n",confKey);
+ if (confValue[0]) printf("%s\n",confValue);
+ printf("%d\n",useEQ);
+*/
+ } // end of METHOD==NULL/else
+#ifdef THIS_DEBUG
+ fprintf (stderr,"editconf(file='%s'\n",fileName);
+ fflush(stderr);
+#endif
+
+ unescape (confValue, sizeof(confValue));
+
+
+// printf("%s\n",fileName);
+ if ((cfile = fopen(fileName, "r"))==NULL) {thisError=-1;}
+ else {
+ fseek(cfile, 0L, SEEK_END);
+ fileSize= ftell(cfile);
+ confFile= (char*) malloc(fileSize+1);
+ fseek(cfile, 0L, SEEK_SET);
+ i=fread(confFile, 1, fileSize, cfile);
+ for (i=0; i=cp) && strchr(" \t",lineEnd[0])) {
+ lineEnd[0]=0;
+ lineEnd--;
+ }
+ lineEnd++;
+ for (;(strchr(" \t",cp[0])) && (cp%s%s>\n",keyStart,valueStart,keyStart);
+ }
+ } // end of for (lineStart=confFile;(lineStart-confFile)%d\n",fileSize);
+//printf ("%d\n",(lineStart-confFile));
+//printf ("%d\n",(lineEnd-confFile));
+//printf ("%d\n",(keyStart-confFile));
+//printf ("%d\n",(keyStart-confFile));
+
+ if (!confValue[0]) { // read value]
+ if (method == NULL) {
+ if ((lineStart-confFile)%s\n",valueStart);
+ else if (confKey[0]) printf ("%d\n",-3); // key not found
+ }
+ } else { // modify value
+ if ((cfile = fopen(fileName, "w"))==NULL) {thisError=-2;}
+ else { // file opened OK
+ fwrite(confFileCopy, 1, (lineStart-confFile), cfile); // write everything before the line with a key (if any)
+ if (confValue[0]!='#') { // replace the key
+ if ((lineStart>confFile) && (confFileCopy[lineStart-confFile-1] != '\n')) fprintf(cfile,"\n");
+ if (useEQ) fprintf(cfile,"%s=%s\n",confKey,confValue);
+ else fprintf(cfile,"%s %s\n",confKey,confValue);
+ }
+ if ((ep-confFile) < fileSize) fwrite(confFileCopy+(ep+1-confFile), 1, (confFile+ fileSize - ep-1), cfile); // write everything after the line with a key (if any)
+ }
+ }
+ }
+ if (method != NULL) {
+ if ((confValue[0])&& !thisError) printf("0\n");
+ if (confFile) free (confFile);
+ if (confFileCopy) free (confFileCopy);
+ if (thisError) printf("%d\n",thisError);
+ printf("\n");
+ }
+ return 0;
+}
+
+int unescape (char * s, int l) {
+ int i=0;
+ int j=0;
+ while ((i=0) && (i<10)) return i;
+ i=c-'a'+10;
+ if ((i>=10) && (i<16)) return i;
+ i=c-'A'+10;
+ if ((i>=10) && (i<16)) return i;
+ return 0; // could be -1??
+}
+
+char * paramValue(struct key_value * params, char * skey) { // returns pointer to parameter value, NULL if not defined
+ int i=0;
+ if (skey)
+ while ((i.
+*! -----------------------------------------------------------------------------**
+*! $Log: editconf.php,v $
+*! Revision 1.1 2008/12/09 07:49:32 elphel
+*! added editconf.php - supplements editconf.cgi to deal with internal parameters, has the same interface to simplify interfacing from camvc
+*!
+*!
+*/
+ $sensor_port=0;
+ $key=$_GET['key'];
+ $value=$_GET['key'];
+ $param=array();
+ $param[$_GET['key']]=myval($_GET['value']);
+ $xml = new SimpleXMLElement("");
+ if (array_key_exists('sensor_port',$_GET)) {
+ $sensor_port = myval($_GET['sensor_port']);
+ }
+ if (array_key_exists('key',$_GET)) {
+ if ($key=='ftp_left_time') {
+ $param=elphel_get_P_arr($sensor_port,array('FTP_NEXT_TIME'=>0));
+ $xml->addChild ('value',$param['FTP_NEXT_TIME']-time());
+ } else if (array_key_exists('value',$_GET)) {
+ $frame=elphel_set_P_arr($sensor_port,$param);
+ $xml->addChild ('error',$frame?0:-3);
+ } else {
+ $param=elphel_get_P_arr($sensor_port,$param);
+ $xml->addChild ('value',$param[$_GET['key']]);
+ }
+ } else {
+ $xml->addChild ('error',0);
+ }
+ if (array_key_exists('sync',$_GET)) {
+ exec ('sync');
+ $xml->addChild ('sync','OK');
+ }
+ $rslt=$xml->asXML();
+ header("Content-Type: text/xml");
+ header("Content-Length: ".strlen($rslt)."\n");
+ header("Pragma: no-cache\n");
+ printf($rslt);
+
+ exit (0);
+function myval ($s) {
+ $s=trim($s,"\" ");
+ if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
+ else return intval($s);
+}
+//http://192.168.0.7/editconf.php?&key=DAEMON_EN_CCAMFTP&value=1&eq=1&_time=1228790213230
+?>
diff --git a/src/strconf.cpp b/src/strconf.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c021a63681af1cfc85a3a51ff236fd75900c84ed
--- /dev/null
+++ b/src/strconf.cpp
@@ -0,0 +1,118 @@
+#include
+#include
+#include
+#include
+#include