Skip to content
Snippets Groups Projects
Commit 8790df6a authored by rswindell's avatar rswindell
Browse files

Now tests SLEEP, and more dirwrap functions.

parent 432d96be
Branches
Tags
No related merge requests found
...@@ -9,26 +9,55 @@ ...@@ -9,26 +9,55 @@
#include "sockwrap.h" #include "sockwrap.h"
#include "threadwrap.h" #include "threadwrap.h"
static void getkey(void)
{
printf("Hit any key...");
while(getch()==0);
printf("\r%20s\r","");
}
int main() int main()
{ {
char compiler[128]; char compiler[128];
char fname[MAX_PATH+1];
char* glob_pattern = "*wrap*"; char* glob_pattern = "*wrap*";
int i; int i;
int ch;
uint u; uint u;
time_t t; time_t t;
glob_t g; glob_t g;
DIR* dir; DIR* dir;
DIRENT* dirent; DIRENT* dirent;
COMPILER_DESC(compiler); /* Show platform details */
DESCRIBE_COMPILER(compiler);
printf("Platform: %s\n",PLATFORM_DESC); printf("Platform: %s\n",PLATFORM_DESC);
printf("Compiler: %s\n",compiler); printf("Compiler: %s\n",compiler);
xp_beep(500,500); printf("\ngetch() test (ESC to continue)\n");
do {
ch=getch();
printf("getch() returned %d\n",ch);
} while(ch!=ESC);
/* GLOB TEST */ #if 0
printf("glob() test\n"); /* BEEP test */
printf("\nBEEP() test\n");
getkey();
for(i=750;i>250;i-=5)
BEEP(i,10);
for(;i<1000;i+=5)
BEEP(i,10);
#endif
/* SLEEP test */
printf("\nSLEEP() test\n");
getkey();
t=time(NULL);
SLEEP(5000);
printf("slept %d seconds\n",time(NULL)-t);
/* glob test */
printf("\nglob() test\n");
getkey();
i=glob(glob_pattern,GLOB_MARK,NULL,&g); i=glob(glob_pattern,GLOB_MARK,NULL,&g);
if(i==0) { if(i==0) {
for(u=0;u<g.gl_pathc;u++) for(u=0;u<g.gl_pathc;u++)
...@@ -37,29 +66,22 @@ int main() ...@@ -37,29 +66,22 @@ int main()
} else } else
printf("glob(%s) returned %d\n",glob_pattern,i); printf("glob(%s) returned %d\n",glob_pattern,i);
printf("Hit any key..."); /* opendir (and other directory functions) test */
printf("\ngetch() returned %d\n",getch()); printf("\nopendir() test\n");
getkey();
/* OPENDIR TEST */
printf("opendir() test\n");
dir=opendir("."); dir=opendir(".");
while(dir!=NULL && (dirent=readdir(dir))!=NULL) { while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
t=fdate(dirent->d_name); t=fdate(dirent->d_name);
sprintf(fname,"%.*s%c" printf("%.24s %10lu %04o %s%c\n"
,sizeof(fname)-2
,dirent->d_name
,isdir(dirent->d_name) ? '/':0);
printf("%-25s %10lu %.24s\n"
,fname
,flength(dirent->d_name)
,ctime(&t) ,ctime(&t)
,flength(dirent->d_name)
,getfattr(dirent->d_name)
,dirent->d_name
,isdir(dirent->d_name) ? '/':0
); );
} }
if(dir!=NULL) if(dir!=NULL)
closedir(dir); closedir(dir);
printf("Hit any key...");
printf("\ngetch() returned %d\n",getch());
return 0; return 0;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment