register int a, b, resc = 0;
for (a = 0; a < kod_db_cnt; a++)
- if (!strcmp(kod_db[a]->hostname, hostname))
+ if (!strcmp(kod_db[a]->hostname, hostname))
resc++;
if (!resc)
}
-void
+void
add_entry(
char *hostname,
char *type /* 4 bytes not \0 terminated */
}
-void
+void
delete_entry(
char *hostname,
char *type
kod_db_cnt--;
if (a < kod_db_cnt)
- memmove(&kod_db[a], &kod_db[a + 1],
+ memmove(&kod_db[a], &kod_db[a + 1],
(kod_db_cnt - a) * sizeof(kod_db[0]));
}
-void
+void
write_kod_db(void)
{
FILE *db_s;
*pch = DIR_SEP;
pch = strchr(pch + 1, DIR_SEP);
}
+ db_s = fopen(kod_db_file, "w");
}
-
- db_s = fopen(kod_db_file, "w");
if (NULL == db_s) {
char msg[80];
- snprintf(msg, sizeof(msg),
+ snprintf(msg, sizeof(msg),
"Can't open KOD db file %s for writing!",
kod_db_file);
#ifdef DEBUG
return;
}
-
+
for (a = 0; a < kod_db_cnt; a++) {
fprintf(db_s, "%16.16llx %s %s\n", (unsigned long long)
kod_db[a]->timestamp, kod_db[a]->type,
}
-void
+void
kod_init_kod_db(
const char *db_file
)
* Max. of 254 characters for hostname, 10 for timestamp, 4 for
* kisscode, 2 for spaces, 1 for \n, and 1 for \0
*/
- char fbuf[272];
+ char fbuf[254+10+4+2+1+1];
FILE *db_s;
int a, b, sepc;
unsigned long long ull;
return;
}
- if(ENABLED_OPT(NORMALVERBOSE))
+ if(ENABLED_OPT(NORMALVERBOSE))
printf("Starting to read KoD file %s...\n", db_file);
/* First let's see how many entries there are and check for right syntax */
/* ignore blank lines */
if ('\n' == fbuf[0])
continue;
-
+
sepc = 0;
for(a=0; a<strlen(fbuf); a++) {
- if (' ' == fbuf[a])
+ if (' ' == fbuf[a])
sepc++;
-
+
if ('\n' == fbuf[a]) {
if (sepc != 2) {
if (strcmp(db_file, "/dev/null")) {
log_msg(msg, 1);
}
- return;
+ return;
}
sepc = 0;
b--;
continue;
}
-
+
kod_db[b] = emalloc(sizeof(*kod_db[b]));
if (3 != sscanf(fbuf, "%llx %4s %254s", &ull,