003 File Manager
Current Path:
/usr/src/contrib/ntp/sntp/tests
usr
/
src
/
contrib
/
ntp
/
sntp
/
tests
/
📁
..
📄
Makefile.am
(5.33 KB)
📄
Makefile.in
(59.77 KB)
📄
crypto.c
(5.93 KB)
📁
data
📄
fileHandlingTest.c
(1.48 KB)
📄
fileHandlingTest.h.in
(582 B)
📄
keyFile.c
(4.23 KB)
📄
kodDatabase.c
(2.98 KB)
📄
kodFile.c
(3.76 KB)
📄
networking.c
(88 B)
📄
packetHandling.c
(6.98 KB)
📄
packetProcessing.c
(11.55 KB)
📄
run-crypto.c
(1.75 KB)
📄
run-keyFile.c
(1.6 KB)
📄
run-kodDatabase.c
(1.65 KB)
📄
run-kodFile.c
(1.71 KB)
📄
run-networking.c
(1.15 KB)
📄
run-packetHandling.c
(2.22 KB)
📄
run-packetProcessing.c
(2.91 KB)
📄
run-t-log.c
(1.37 KB)
📄
run-utilities.c
(1.73 KB)
📄
sntptest.c
(505 B)
📄
sntptest.h
(222 B)
📄
t-log.c
(2.24 KB)
📄
testconf.yml
(278 B)
📄
tests-runner
(331 B)
📄
utilities.c
(4.44 KB)
Editing: fileHandlingTest.c
#include "config.h" #include "stdlib.h" #include "sntptest.h" #include "fileHandlingTest.h" /* required because of the h.in thingy */ #include <string.h> #include <unistd.h> const char * CreatePath( const char * filename, enum DirectoryType argument ) { const char srcdir[] = SRCDIR_DEF;//"@abs_srcdir@/data/"; size_t plen = sizeof(srcdir) + strlen(filename) + 1; char * path = emalloc(plen); ssize_t retc; UNUSED_ARG(argument); retc = snprintf(path, plen, "%s%s", srcdir, filename); if (retc <= 0 || (size_t)retc >= plen) exit(1); return path; } void DestroyPath( const char * pathname ) { /* use a union to get terminally rid of the 'const' attribute */ union { const char *ccp; void *vp; } any; any.ccp = pathname; free(any.vp); } int GetFileSize( FILE * file ) { fseek(file, 0L, SEEK_END); int length = ftell(file); fseek(file, 0L, SEEK_SET); return length; } bool CompareFileContent( FILE * expected, FILE * actual ) { int currentLine = 1; char actualLine[1024]; char expectedLine[1024]; size_t lenAct = sizeof actualLine; size_t lenExp = sizeof expectedLine; while ( ( (fgets(actualLine, lenAct, actual)) != NULL) && ( (fgets(expectedLine, lenExp, expected)) != NULL ) ) { if( strcmp(actualLine,expectedLine) !=0 ){ printf("Comparision failed on line %d",currentLine); return FALSE; } currentLine++; } return TRUE; } void ClearFile( const char * filename ) { if (!truncate(filename, 0)) exit(1); }
Upload File
Create Folder