- Scriptcontext debugged to be working

- Added a drivable adapter to scriptcontext nodes
- Added subsampling to simulated histograms (and as a general option) in
  order to support Gumtree testing.
This commit is contained in:
koennecke
2008-06-09 08:57:53 +00:00
parent 3cb901b437
commit 0915491925
33 changed files with 1938 additions and 247 deletions

View File

@@ -18,51 +18,91 @@ int ErrEqual(char *str1, char *str2) {
if (str1 == NULL || str2 == NULL) {
return str1 == str2;
}
str1++;
str2++;
} else {
str1++;
str2++;
}
str1++;
str2++;
}
return 1;
}
ErrMsg *ErrPutMsg(ErrMsg *dump, char *fmt, ...) {
ErrMsg *m;
ErrMsg **last;
va_list ap;
char buf[256];
char *text;
int l;
va_start(ap, fmt);
l = vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
if (l < sizeof buf) {
text = buf;
} else {
/* assuming we have a C99 conforming snprintf and need a larger buffer */
text = calloc(l, 1);
va_start(ap, fmt);
vsnprintf(text, l, fmt, ap);
va_end(ap);
}
last = &dump;
for (m = dump; m != NULL; m = m->next) {
ErrMsg *ErrFind(ErrMsg *dump, char *message){
ErrMsg *cur = dump;
while(cur != NULL){
if(ErrEqual(message,cur->text)){
break;
}
cur = cur->next;
}
return cur;
}
ErrMsg *ErrPutMsg(ErrMsg *dump, ErrMsg **current, char *fmt, ...){
ErrMsg *m = NULL;
va_list ap;
char buf[1024];
/* format message */
va_start(ap, fmt);
memset(buf,0,1024*sizeof(char));
vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
m = ErrFind(dump, buf);
if(m == NULL){
m = calloc(1, sizeof(*m));
m->text = strdup(buf);
m->cnt = 1;
m->next = dump;
*current = m;
return m;
} else {
*current = m;
return dump;
}
}
ErrMsg *ErrOldPutMsg(ErrMsg *dump, char *fmt, ...) {
ErrMsg *m = NULL;
ErrMsg **last = NULL;
va_list ap;
char buf[256];
char *text = NULL;
int l;
va_start(ap, fmt);
l = vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
if (l < sizeof buf) {
text = buf;
} else {
/* assuming we have a C99 conforming snprintf and need a larger buffer */
text = calloc(l, 1);
va_start(ap, fmt);
vsnprintf(text, l, fmt, ap);
va_end(ap);
}
for (last = &dump; *last != NULL; last = &m->next) {
m = *last;
if (ErrEqual(text, m->text)) {
*last = m->next; /* remove found item from the list */
*last = m->next;
break;
}
last = &m->next;
}
if (m == NULL) { /* make a fresh list item m */
if (m == NULL) {
if (text == buf) text = strdup(buf);
m = calloc(1, sizeof(*m));
m->text = text;
m->cnt = 1;
} else { /* take the found item m */
} else {
if (text != buf) free(text);
m->cnt++;
}
m->next = dump; /* add the new item to the head of the list */
if(m != dump){
m->next = dump;
}
time(&m->last);
return m;
}