added makefile and eclipse cdt project files

This commit is contained in:
Marcel M. Otte 2013-12-25 16:27:41 +00:00
parent e5f80ed5d9
commit 7adbcbd8b6
5 changed files with 149 additions and 27 deletions

45
c/.cproject Normal file
View File

@ -0,0 +1,45 @@
<?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="cdt.managedbuild.toolchain.gnu.base.2063448201">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2063448201" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" 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.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.2063448201" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.2063448201.1202991045" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.base.198603313" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1008203517" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder id="cdt.managedbuild.target.gnu.builder.base.843414349" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.302168232" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1312703866" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.87826736" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.687205595" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.154508414" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.13897115" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.1886071166">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="cmdlineoptions-c.null.1936447817" name="cmdlineoptions-c"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

26
c/.project Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cmdlineoptions-c</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

16
c/Makefile Normal file
View File

@ -0,0 +1,16 @@
all: build lib static
build:
gcc -c cmdlineoptions.c
lib:
rm -f libcmdlineoptions.a
ar cq libcmdlineoptions.a cmdlineoptions.o
static:
rm -f cmdlineoptions-static.o libcmdlineoptions.so
gcc -c -fPIC -o cmdlineoptions-static.o cmdlineoptions.c
ld -G cmdlineoptions-static.o -o libcmdlineoptions.so

View File

@ -1,5 +1,6 @@
#include "cmdlineoptions.h"
#include <string.h>
#include <stdlib.h>
CmdOptions cmdoptions;
@ -15,6 +16,37 @@ void CmdOptions_Init(){
}
}
int CmdOptions_Create(char* name) {
if (CmdOptions_NodeGet(name) == 0) {
CONode* newnode = 0;
newnode = malloc(sizeof(CONode));
if (cmdoptions.options == 0) {
cmdoptions.options = newnode;
} else {
CONode* last = cmdoptions.options;
while (last->next != 0)
last = last->next;
last->next = newnode;
}
newnode->next = 0;
newnode->option = malloc(sizeof(Option));
newnode->option->name = name;
}
}
CONode* CmdOptions_NodeGet(char* name) {
if (cmdoptions.options != 0) {
CONode* node = cmdoptions.options;
while (node != 0) {
if (strcmp(name, node->option->name) == 0) {
return node;
}
node = node->next;
}
}
return 0;
}
int CmdOptions_Parse(int argc, char** argv) {
}
@ -35,7 +67,7 @@ int CmdOptions_AddDescription(char* name, char* description) {
}
bool CmdOptions_IsSet(char* name) {
int CmdOptions_IsSet(char* name) {
}

View File

@ -1,7 +1,7 @@
#ifndef CMDLINEOPTIONS_H
#define CMDLINEOPTIONS_H
struct Option {
typedef struct {
char* name; // the name of this option
char** options; //dashed option name and alternatives
unsigned int optionscount; // count of option alternatives
@ -13,19 +13,20 @@ struct Option {
char** values; // values
unsigned int valuecount; // size of the values, if more than one...
bool set; // boolean if this option has been set
};
char set; // boolean if this option has been set
} Option;
struct CONode {
CONode* prev;
CONode* next;
typedef struct _CONode {
//CONode* prev;
struct _CONode* next;
Option* option;
};
} CONode;
struct CmdOptions {
bool init;
typedef struct {
char init;
CONode* options;
};
} CmdOptions;
/*
* Main structure
@ -62,7 +63,7 @@ int CmdOptions_AddDescription(char* name, char* description);
/**
* Check if the option specified by name is set.
*/
bool CmdOptions_IsSet(char* name);
int CmdOptions_IsSet(char* name);
/**
* Get first parameter of the option specified by name.
*/
@ -85,5 +86,7 @@ double CmdOptions_GetDouble(char* name);
*/
int CmdOptions_GetAll(char* name, char** values, unsigned int* count);
int CmdOptions_Create(char* name);
CONode* CmdOptions_NodeGet(char* name);
#endif