Commit a5afc764 authored by Andrey Filippov's avatar Andrey Filippov

set up Eclkipse/CDT project

parent 703d73a8
html/*
attic/*
/.project
/.cproject
/.pydevproject
/.externalToolBuilders
/.settings
.directory
generated*
sysroots
bitbake-logs
/temp
*.o
*.cgi
# 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)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.629709185">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.629709185" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="0.629709185" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.629709185." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.347398953" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.347398953.196635379" name=""/>
<builder arguments="apps-editconf" command="${workspace_loc:/elphel-apps-editconf/run_bitbake.sh}" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.2015202574" incrementalBuildTarget="-c compile -f -v" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1905439854" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.528335744" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1593907887" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-editconf/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1046189248" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;size_t=unsigned long long&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.2076071186" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.12324268" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.158887608" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-editconf/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1360212747" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;size_t=unsigned long long&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1115999536" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1277713790" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.418963330" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-editconf/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.2098006010" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;size_t=unsigned long long&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.202835438" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1999073205" name="LLVM bytecode assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1697066798" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-editconf/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.321760471" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;size_t=unsigned long long&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.2096553053" languageId="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssembly" languageName="LLVM bytecode assembly" sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblySource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1025932579" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1021276505" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-editconf/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.2096085107" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;size_t=unsigned long long&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1803057684" languageId="org.eclipse.cdt.core.parser.upc.upc" languageName="UPC" sourceContentType="org.eclipse.cdt.core.parser.upc.upcSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="elphel-apps-editconf.null.314879186" name="elphel-apps-editconf"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.629709185">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/elphel-apps-editconf"/>
</configuration>
</storageModule>
</cproject>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/elphel-apps-editconf/run_bitbake.sh}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="apps-editconf -c target_scp -f"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>elphel-apps-editconf</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/SCP apps-editconf to target.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder (2).launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
#!/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
#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
/*
** -----------------------------------------------------------------------------**
** 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 <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#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("<?xml version=\"1.0\" ?>\n<editconf>\n");
// printf("<argc>%d</argc>\n",argc);
/*
if (fileName[0]) printf("<fileName>%s</fileName>\n",fileName);
if (confKey[0]) printf("<confKey>%s</confKey>\n",confKey);
if (confValue[0]) printf("<confValue>%s</confValue>\n",confValue);
printf("<useEQ>%d</useEQ>\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("<file>%s</file>\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<fileSize; i++) if (confFile[i]==0) confFile[i]=' ';
confFileCopy= strdup(confFile);
confFile[fileSize]=0;
fclose (cfile);
ep=confFile+fileSize;
valueStart=ep;
for (lineStart=confFile;(lineStart-confFile)<fileSize; lineStart=ep+1) {
cp=lineStart;
ep=strchr(cp,'\n'); if (!ep) ep=confFile+fileSize;
ep[0]=0;
// now - just output everything as xml
for (lineEnd=cp;(lineEnd<ep) && !strchr("#\n\r",lineEnd[0]);lineEnd++);
lineEnd[0]=0;
// now the line is truncated by any end of line or "#"
// still left white spaces before "#"
lineEnd--;
while ((lineEnd>=cp) && strchr(" \t",lineEnd[0])) {
lineEnd[0]=0;
lineEnd--;
}
lineEnd++;
for (;(strchr(" \t",cp[0])) && (cp<lineEnd);cp++);
keyStart=cp;
for (;!(strchr(" \t=",cp[0])) && (cp<lineEnd);cp++);
cp[0]=0;
valueStart=cp; // will point on empty string
if (cp<lineEnd) {
cp++;
for (;(strchr(" \t",cp[0])) && (cp<lineEnd);cp++);
valueStart=cp;
}
if (confKey[0]) { // key specified
if (strncmp(confKey,keyStart, sizeof(confKey))==0) break;
} else if(keyStart[0] && valueStart[0]) { // no jey specified - output all lines
if (method == NULL) printf ("%s\n",valueStart); // will never be used
else printf ("<%s>%s</%s>\n",keyStart,valueStart,keyStart);
}
} // end of for (lineStart=confFile;(lineStart-confFile)<fileSize; lineStart=ep+1) // may break;
//printf ("<fileEnd>%d</fileEnd>\n",fileSize);
//printf ("<lineStart>%d</lineStart>\n",(lineStart-confFile));
//printf ("<lineEnd>%d</lineEnd>\n",(lineEnd-confFile));
//printf ("<keyStart>%d</keyStart>\n",(keyStart-confFile));
//printf ("<valueStart>%d</valueStart>\n",(keyStart-confFile));
if (!confValue[0]) { // read value]
if (method == NULL) {
if ((lineStart-confFile)<fileSize) printf ("%s\n",valueStart);
}else {
if ((lineStart-confFile)<fileSize) printf ("<value>%s</value>\n",valueStart);
else if (confKey[0]) printf ("<error>%d</error>\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("<error>0</error>\n");
if (confFile) free (confFile);
if (confFileCopy) free (confFileCopy);
if (thisError) printf("<error>%d</error>\n",thisError);
printf("</editconf>\n");
}
return 0;
}
int unescape (char * s, int l) {
int i=0;
int j=0;
while ((i<l) && s[i]) {
if ((s[i]=='%') && (i<(l-2)) && s[i+1]){ // behavior from Mozilla
s[j++]=(hexdigit(s[i+1])<<4) | hexdigit(s[i+2]);
i+=3;
} else s[j++]=s[i++];
}
if (i<l) s[j]=0;
return j;
}
int hexdigit (char c) {
int i;
i=c-'0';
if ((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<QRY_MAXPARAMS) && (params[i].key)) {
if (strcmp(skey,params[i].key)==0) return params[i].value;
i++;
}
return NULL;
}
int parseQuery(struct key_value * params, char * qry) {
char * cp;
int l=0;
cp=strtok(qry,"=");
while ((cp) && (l<QRY_MAXPARAMS)) {
params[l].key=cp;
cp=strtok(NULL,"&");
params[l++].value=cp;
if (cp) cp=strtok(NULL,"=");
}
params[l].key=NULL;
return l;
}
<?php
/*!*******************************************************************************
*! FILE NAME : editconf.php
*! DESCRIPTION: simple (not optimal) replacement of editconf.cgi
*! to write/read internal parameters instead of the files
*! to minimize camvc changes
*! Copyright (C) 2008 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 <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $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("<?xml version='1.0'?><editconf/>");
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
?>
#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
#include <string>
#include <map>
#include <fstream>
using namespace std;
void load(string fn, map<string, string> &c) {
int i;
char *z;
string s;
ifstream ifile(fn.c_str());
while(!ifile.eof()) {
ifile >> s;
z = const_cast<char *>(s.c_str());
for(i = 0; z[i]; i++)
if(z[i] == '=') {
z[i] = '\0';
c[&z[0]] = &z[i + 1];
break;
}
}
ifile.close();
/*
for(map<string, string>::iterator it = c.begin(); it != c.end(); it++)
syslog(LOG_ALERT, "|%s|==|%s|\r\n", (*it).first.c_str(), (*it).second.c_str());
syslog(LOG_ALERT, "//||\\\\--------------------------- %s\r\n", fn.c_str());
*/
}
void save(string fn, map<string, string> &c) {
string s;
ofstream of(fn.c_str());
/*
for(map<string, string>::iterator it = c.begin(); it != c.end(); it++)
syslog(LOG_ALERT, "|%s|==|%s|\r\n", (*it).first.c_str(), (*it).second.c_str());
*/
for(map<string, string>::iterator it = c.begin(); it != c.end(); it++) {
s = (*it).first;
s += "=";
s += (*it).second;
of << s;
of << endl;
}
of.close();
}
int main() {
const char *uri;
const char *method;
const char *query;
// map<string, string> in
// string in;
// string out;
map<string, string> params;
map<string, string> in;
map<string, string> out;
method = getenv("REQUEST_METHOD");
query = getenv("QUERY_STRING");
uri = getenv("REQUEST_URI");
/*
syslog(LOG_ALERT, "REQUEST_METHOD=|%s|\r\n", method);
syslog(LOG_ALERT, "REQUEST_STRING=|%s|\r\n", query);
syslog(LOG_ALERT, "REQUEST_URI=|%s|\r\n", uri);
syslog(LOG_ALERT, "strconf!\r\n");
*/
// parse GET params
string p_s = query;
char *p = const_cast<char *>(p_s.c_str());
//syslog(LOG_ALERT, "string: |%s|\r\n", p);
int i, j, k;
k = 0;
bool f = false, to_break = false;
for(i = 0; ; i++) {
if(p[i] == '\'')
f = !f;
if((p[i] == '&' || p[i] == '\0') && !f) {
if(p[i] == '\0')
to_break = true;
else
p[i] = '\0';
for(j = k; p[j]; j++) {
if(p[j] == '=') {
p[j] = '\0';
params[&p[k]] = &p[j + 1];
break;
}
}
k = i + 1;
f = false;
}
if(to_break)
break;
}
// load 'in' and 'out' file;
load(params["in"], in);
load(params["out"], out);
///*
in["init_1"] = out["init_1"];
in["init_2"] = out["init_2"];
///*
if(params["init_1"] != "''")
in["init_1"] = params["init_1"];
if(params["init_2"] != "''")
in["init_2"] = params["init_2"];
//*/
save(params["out"], in);
//*/
// for(map<string, string>::iterator it = params.begin(); it != params.end(); it++) {
// syslog(LOG_ALERT, "param: |%s|==|%s|\r\n", (*it).first.c_str(), (*it).second.c_str());
// }
return 0;
}
File added
/*
** -----------------------------------------------------------------------------**
** 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 <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
*/
#include <stdlib.h>
#include <stdio.h>
int hexdigit (char c) {
int i;
i=c-'0';
if ((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??
}
int main(argc, argv)
int argc;
char *argv[];
{
if (argc<2) {printf("unescape returnes unescaped string (argument) to stdout\n"); return 0; }
int i=0;
while (argv[1][i]) {
if ((argv[1][i]=='%') && argv[1][i+1]) { // behavior from Mozilla
printf("%c", (char) (hexdigit(argv[1][i+1])<<4) | hexdigit(argv[1][i+2]));
i+=3;
} else printf("%c",argv[1][i++]);
}
return 0;
}
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division
from __future__ import print_function
"""
# @file used_files.py
# @brief Extract file access data after build, modify CDT project configuration
# (.cproject) accordingly
# @copyright Copyright (C) 2016, Elphel.inc.
# @param <b>License</b>
# 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 <http:#www.gnu.org/licenses/>.
@author: Andrey Filippov
@license: GPLv3.0+
@contact: andrey@elphel.coml
@deffield updated: Updated
"""
__author__ = "Andrey Filippov"
__copyright__ = "Copyright 2016, Elphel, Inc."
__license__ = "GPL"
__version__ = "3.0+"
__maintainer__ = "Andrey Filippov"
__email__ = "andrey@elphel.com"
__status__ = "Development"
import sys
import os
import time
import xml.etree.ElementTree as ET
'''
TODO:Automate, find out why separate touch commands are needed
Run this program twice:
1-st run ./used_files.py linux -1
and save shown timestamp
Then run (some mystery here)
touch src/drivers/ata/ahci_elphel.c
touch src/drivers/elphel/sensor_common.c
Wait 5 seconds and run (in a different console with appropriate sourcing)
bitbake linux-xlnx -c compile -f
Then again
./used_files.py linux <timestamp_from_the_first_run>
If somethong went wrong you will need to resore .cproject from eclipse_project_setup directory
For php:
bitbake php -c cleansstate
bitbake php -c unpack -f
bitbake php -c configure -f
./used_files.py php -1
bitbake php -c compile -f
./used_files.py php 1471044836.8
Doing:
bitbake php -c compile -f
./used_files.py php -1
bitbake php -c compile -f
./used_files.py php 1471044836.8
Corrupts make process
'''
def file_tree(flist): # Each file in list is a file, no directories
ftree={}
for p in flist:
node = ftree
seg_list=p.split(os.sep)
last_i=len(seg_list)-1
for i,segm in enumerate(seg_list):
if not segm in node:
if i == last_i:
node[segm] = None
else:
node[segm] = {}
node=node[segm]
return ftree
def exclude_list(ftree, flist):
mark = "*" # no file/dir name can be "*"
def list_tree_recursive(root):
rslt = []
if not mark in root:
return [[""]] # convert to trailing "/" for directories
for n in root:
if not n == mark:
if root[n] is None:
rslt.append([n])
else:
for l in list_tree_recursive(root[n]):
rslt.append([n]+l)
return rslt
ftree[mark]=None # mark top level dir
for p in flist:
node = ftree
for segm in p.split(os.sep)[:-1]:
node=node[segm]
node[mark]=None # [mark] means used in flist
del node[p.split(os.sep)[-1]]
#print (ftree)
# for k in ftree:
# print(k)
#Now prune unused directories
#prune_recursive(ftree) # (assuming root is used)
# now create list
files_list_list = list_tree_recursive(ftree)
# print (files_list_list)
#converrt to file paths
pl = []
for l in files_list_list:
pl.append(os.path.join(*(l[1:])))
pl = sorted (pl)
return pl
def proc_tree():
DEBUG = True
extensions = [".h",".c",".cpp"]
exclude_start = ["linux"+os.sep+"scripts"+os.sep,"linux"+os.sep+"source"+os.sep+"scripts"+os.sep]
delta_t = 3 # seconds
try:
root_path = sys.argv[1]
except:
print ("Calling %s <root directory path> [timestamp]"%(os.path.basename(sys.argv[0])))
try:
start_time = float(sys.argv[2])
except:
start_time = 0.0
touch_files= start_time < 0.0
print ("root_path = %s"%(root_path))
# root_path = "/home/eyesis/git/poky/linux-elphel/linux/"
lstFiles = []
# Append files to a list
for path, _, files in os.walk(root_path, followlinks = True):
for f in files:
for ext in extensions:
if f.endswith(ext):
lstFiles.append(os.path.join(path, f))
break
all_tree= file_tree(sorted(lstFiles))
include_lst=[]
lst_a = []
latest_at=0
for p in lstFiles:
if touch_files:
if os.path.islink(p):
try:
os.utime(os.path.realpath(p), None)
except:
print("missing linked file: %s"%(os.path.realpath(p)))
else:
os.utime(p, None)
else:
# at = time.ctime(os.stat(p).st_atime)
try:
at = os.stat(p).st_atime
l = None
except:
at = 0
if os.path.islink(p):
try:
l = os.path.realpath(p)
at = os.stat(l).st_atime
except:
at = 0 # missing file
latest_at = max((latest_at,at))
if at > (start_time + delta_t):
#Scripts/lexers result in problems
exclude=False
for exStr in exclude_start:
if p.startswith(exStr):
exclude=True
break
if exclude:
break
#exclude_start
lst_a.append([p,at,l])
include_lst.append(p)
if touch_files:
print (len(lstFiles), "last time = ", time.time())
return
excluding = exclude_list(all_tree, include_lst)
# print (all_tree)
# print (sorted(include_lst))
# print ("|".join(excluding))
if DEBUG:
with open("all_sources.lst","w" ) as f:
for p in sorted(lstFiles):
try:
at = os.stat(p).st_atime
except:
at = 0
lnk=""
if os.path.islink(p):
try:
at = os.stat(os.path.realpath(p)).st_atime
except:
at = 0
lnk = os.path.realpath(p)
print (p,at,lnk, file=f)
with open("excluding.lst","w" ) as f:
for p in excluding:
print (p, file=f)
with open("including.lst","w" ) as f:
for p in include_lst:
print (p, file=f)
# include_tree= file_tree(sorted(include_lst))
# print(include_tree)
root_dir=include_lst[0].split(os.sep)[0]
print ("root_dir=",root_dir)
xml= ET.parse(".cproject")
root=xml.getroot()
# for child in root:
# print(child.tag, child.attrib)
for child in root.iter('sourceEntries'):
for gchild in child:
print(gchild.tag)
for child in root.iter('sourceEntries'):
for gchild in child:
if gchild.tag == 'entry':
attr = gchild.attrib
try:
if (attr['kind'] == 'sourcePath') and (attr['name'] == root_dir):
child.remove (gchild)
print ("Removed existing entry ",gchild.tag)
break
except:
print ("error matching attributes for ",gchild.tag)
pass
break #after first 'sourceEntries' - should be just one?
ET.SubElement(child, 'entry', {"flags":"VALUE_WORKSPACE_PATH", "kind":"sourcePath", "name":root_dir, "excluding":"|".join(excluding)})
for child in root.iter('sourceEntries'):
for gchild in child:
print(gchild.tag)
oneliner= ET.tostring(root)
#overwrites original .cproject, may change to somethong different
with open(".cproject", "wr") as f:
f.write("""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>""")
f.write(oneliner)
print (len(lstFiles), len(lst_a), "last access time = ",latest_at)
if __name__ == '__main__':
proc_tree()
"""
Usage for new applications:
1) add src to sources, remove root folder
2) Do not add sysroots to sources, just add include directory (sysroots/elphel393/usr/include-uapi) - sysroot created with 'bitbake -c unpack'
3) run following steps - they will add sysroots to .cproject, together with the exclude filter
make clean # otherwise compiled files are preserved
bitbake apps-editconf -c cleansstate
bitbake apps-editconf -c unpack -f
bitbake apps-editconf -c configure -f
./used_files.py sysroots -1
bitbake apps-editconf -c compile -f
./used_files.py sysroots 1473297567.42 # result of previous run
4)Add SCP <name> to target in "builders" "new" "program".
5) remove "configuration builder' in 2 steps - remove it from .externalToolBuilders, run Eclipse again and then remove from builders.
6) copy .externalToolBuilders (just 1 entry), .project and .cproject to eclipse_project_setup
7) make sure .gitignore ignores all what it should
"""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment