cdev-1.7.2n

This commit is contained in:
2022-12-13 12:44:04 +01:00
commit b3b88fc333
1357 changed files with 338883 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
ARCH = OS
SHOBJ = NO
include ../include/makeinclude/Makefile.$(ARCH)
APPNAME = "Context Map Source"
CXXINCLUDES = -I./
TARGETS = $(BASEBIN)/cdevContextMapTest
LIBS = $(CDEVLIBS) $(OSLIBS)
targets: $(TARGETS)
$(BASEBIN)/cdevContextMapTest: $(OBJDIR)/cdevContextMap.o $(OBJDIR)/cdevContextMapTest.o
$(LINK.cc) $^ -o $@ $(LIBS)

View File

@@ -0,0 +1,21 @@
.SUFFIXES: .cc .obj
APPNAME = Context Map Source
ARCH = WINNT-4.0
BINARIES = $(BASEBIN)\cdevContextMapTest.exe
include ..\include\makeinclude\Makefile.WINNT-4.0
CXXEXTRA = /D "GENERIC_SERVER_API= "
CXXINCLUDES = /I .\\
TARGETS = $(BASEBIN)\cdevContextMapTest.exe
targets : $(TARGETS)
$(BASEBIN)\cdevContextMapTest.exe : .exec\$(TARGETDIR)\cdevContextMap.obj .exec\$(TARGETDIR)\cdevContextMapTest.obj
-@if exist $@ erase $@
@echo ^ ^ ^ ^ ^ ^ =^> Linking $(@F)
$(LINK) $(CDEVLIB)\cdev.lib\
$(LINK_EXE_FLAGS) /out:$@ $?
@echo ^ ^ ^ ^ ^ ^ ^ ^ ^ Done...

View File

@@ -0,0 +1,123 @@
#include <cdevContextMap.h>
// *****************************************************************************
// * cdevContextMap::cdevContextMap :
// * This is the constructor for the class and it initializes all
// * data items to 0 or NULL...
// *****************************************************************************
cdevContextMap::cdevContextMap ( void )
: entries(NULL), maximum(0), cnt(0)
{}
// *****************************************************************************
// * cdevContextMap::~cdevContextMap :
// * This is the destructor for the class and it will delete any
// * cdevData objects that have been allocated using new and will
// * then free the array that was allocated using malloc or realloc.
// *****************************************************************************
cdevContextMap::~cdevContextMap ( void )
{
if(entries!=NULL)
{
for(int i=0; i<maximum; i++) if(entries[i]!=NULL) delete entries[i];
free(entries);
}
entries = NULL;
maximum = 0;
cnt = 0;
}
// *****************************************************************************
// * cdevContextMap::resize :
// * This method is called to double the number of pointers that
// * are available to store context items in...
// *****************************************************************************
void cdevContextMap::resize ( void )
{
if(maximum<=0)
{
maximum = 64;
entries = (cdevData **)malloc(maximum * sizeof(cdevData *));
memset(entries, 0, maximum*sizeof(cdevData *));
}
else {
entries = (cdevData **)realloc(entries, 2*maximum*sizeof(cdevData *));
memset(&entries[maximum], 0, maximum*sizeof(cdevData *));
maximum *= 2;
}
}
// *****************************************************************************
// * cdevContextMap::insert :
// * This method is used to add a new cdevData object to the
// * cdevContextMap table... If a matching cdevData object already
// * exists in the class, then its identifier will be returned...
// * otherwise, a new cdevData object will be added to the list and
// * the index of the new item will be returned...
// *****************************************************************************
int cdevContextMap::insert ( cdevData & context )
{
int i;
int found = 0;
for(i=0;
i<cnt && (entries[i]==NULL || !(found=(*entries[i]==context)));
i++);
if(!found)
{
if(i>=maximum) resize();
entries[i] = new cdevData(context);
cnt++;
}
return i;
}
// *****************************************************************************
// * cdevContextMap::find :
// * This method allows the caller to obtain the index of a context
// * cdevData object that matches the cdevData object he provides...
// * If a matching context object cannot be found, then -1 will be
// * returned.
// *****************************************************************************
int cdevContextMap::find ( cdevData & context )
{
int i;
int found;
for(i=0;
i<cnt && (entries[i]==NULL || !(found=(*entries[i]==context)));
i++);
return (i<cnt)?i:-1;
}
// *****************************************************************************
// * cdevContextMap::asciiDump :
// * This is a diagnostic method that allows the caller to dump the
// * contents of the cdevContextMap table to a file descriptor...
// *****************************************************************************
void cdevContextMap::asciiDump ( FILE * fp )
{
fprintf(fp, "----------------------------------------------------------\n");
fprintf(fp, " Diagnostic Dump of CDEV Context Map\n");
fprintf(fp, "----------------------------------------------------------\n");
fprintf(fp, "Number of Entries : %i\n", cnt);
fprintf(fp, "Allocated Maximum Entries : %i\n", maximum);
for(int i=0; i<cnt; i++)
{
fprintf(fp, "\n\t------------------------------------------------\n");
fprintf(fp, "\tContext at Entry Number %i\n", i);
fprintf(fp, "\t------------------------------------------------\n");
if(entries[i]==NULL) fprintf(fp, "\t(not specified)\n");
else entries[i]->asciiDump(fp);
fflush(fp);
}
fprintf(fp, "----------------------------------------------------------\n");
fprintf(fp, " End of Diagnostic Dump of CDEV Context Map\n");
fprintf(fp, "----------------------------------------------------------\n\n");
fflush(fp);
}

View File

@@ -0,0 +1,33 @@
#ifndef _CDEV_CONTEXT_MAP_H_
#define _CDEV_CONTEXT_MAP_H_ 1
#include <cdevPlatforms.h>
#include <cdevData.h>
// *****************************************************************************
// * class cdevContextMap :
// * The purpose of this class is to allow the user to store a list of
// * commonly used context cdevData items. This will allow the caller to
// * pass the context to maintain a list of contexts that are identifiable
// * by a unique integer identifier...
// *****************************************************************************
class GENERIC_SERVER_API cdevContextMap
{
protected:
cdevData ** entries;
size_t maximum;
size_t cnt;
void resize ( void );
public:
cdevContextMap ( void );
~cdevContextMap ( void );
int insert ( cdevData & context );
int find ( cdevData & context );
cdevData * find ( int idx ) { return (idx>cnt || idx<0)?(cdevData *)NULL:entries[idx]; }
void asciiDump ( FILE * fp = stdout );
};
#endif /* _CDEV_CONTEXT_MAP_H_ */

View File

@@ -0,0 +1,41 @@
#include "cdevContextMap.h"
cdevContextMap map;
int main()
{
int i=0;
cdevData data;
data.insert(1, "Test String 1");
data.insert(2, "Test String 2");
data.insert(3, "Test String 3");
data.insert(4, "Test String 4");
for(i=0; i<255; i++)
{
data.insert(5, i);
map.insert(data);
if(i%255==0) fprintf(stdout,"\n");
else if(i%100==0) fprintf(stdout,"*");
else if(i%10==0) fprintf(stdout,":");
else fprintf(stdout, ".");
fflush(stdout);
}
for(i=255; i>0; i--)
{
data.insert(5, i);
map.insert(data);
if(i%255==0) fprintf(stdout,"\n");
else if(i%100==0) fprintf(stdout,"*");
else if(i%10==0) fprintf(stdout,":");
else fprintf(stdout, ".");
fflush(stdout);
}
map.asciiDump();
return 0;
}