diff options
author | Daniel Borca <dborca@users.sourceforge.net> | 2005-01-14 08:37:20 +0000 |
---|---|---|
committer | Daniel Borca <dborca@users.sourceforge.net> | 2005-01-14 08:37:20 +0000 |
commit | 7da875d55f6dc9f18e23dd8af9ae7f5782cd3a72 (patch) | |
tree | f14744a4eb497de9045a20726dbf2fdbf474d87b /src/glut/dos/PC_HW/pc_hw.c | |
parent | f4bff83c3211297159e498c1115b993a5cba9b4b (diff) |
changed coding style
Diffstat (limited to 'src/glut/dos/PC_HW/pc_hw.c')
-rw-r--r-- | src/glut/dos/PC_HW/pc_hw.c | 178 |
1 files changed, 98 insertions, 80 deletions
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c index b1fd84bdb6..100b372165 100644 --- a/src/glut/dos/PC_HW/pc_hw.c +++ b/src/glut/dos/PC_HW/pc_hw.c @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.3 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -16,6 +16,7 @@ #include "pc_hw.h" + /* * atexit */ @@ -24,52 +25,61 @@ static volatile int atexitcnt; static VFUNC atexittbl[MAX_ATEXIT]; -static void __attribute__((destructor)) doexit (void) + +static void __attribute__((destructor)) +doexit (void) { - while (atexitcnt) atexittbl[--atexitcnt](); + while (atexitcnt) atexittbl[--atexitcnt](); } -int pc_clexit (VFUNC f) + +int +pc_clexit (VFUNC f) { - int i; - - for (i=0;i<atexitcnt;i++) { - if (atexittbl[i]==f) { - for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1]; - atexittbl[i] = 0; - return 0; - } - } - return -1; + int i; + + for (i = 0; i < atexitcnt; i++) { + if (atexittbl[i] == f) { + for (atexitcnt--; i < atexitcnt; i++) atexittbl[i] = atexittbl[i+1]; + atexittbl[i] = 0; + return 0; + } + } + return -1; } -int pc_atexit (VFUNC f) + +int +pc_atexit (VFUNC f) { - pc_clexit(f); - if (atexitcnt<MAX_ATEXIT) { - atexittbl[atexitcnt++] = f; - return 0; - } - return -1; + pc_clexit(f); + if (atexitcnt < MAX_ATEXIT) { + atexittbl[atexitcnt++] = f; + return 0; + } + return -1; } + /* * locked memory allocation */ -void *pc_malloc (size_t size) +void * +pc_malloc (size_t size) { - void *p = malloc(size); + void *p = malloc(size); - if (p) { - if (_go32_dpmi_lock_data(p, size)) { - free(p); - return NULL; - } - } + if (p) { + if (_go32_dpmi_lock_data(p, size)) { + free(p); + return NULL; + } + } - return p; + return p; } + /* * standard redirection */ @@ -78,68 +88,76 @@ static int h_out, h_outbak; static char errname[L_tmpnam]; static int h_err, h_errbak; -int pc_open_stdout (void) + +int +pc_open_stdout (void) { - tmpnam(outname); + tmpnam(outname); - if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { - h_outbak = dup(STDOUT_FILENO); - fflush(stdout); - dup2(h_out, STDOUT_FILENO); - } + if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { + h_outbak = dup(STDOUT_FILENO); + fflush(stdout); + dup2(h_out, STDOUT_FILENO); + } - return h_out; + return h_out; } -void pc_close_stdout (void) + +void +pc_close_stdout (void) { - FILE *f; - char *line = alloca(512); - - if (h_out > 0) { - dup2(h_outbak, STDOUT_FILENO); - close(h_out); - close(h_outbak); - - f = fopen(outname, "rt"); - while (fgets(line, 512, f)) { - fputs(line, stdout); - } - fclose(f); - - remove(outname); - } + FILE *f; + char *line = alloca(512); + + if (h_out > 0) { + dup2(h_outbak, STDOUT_FILENO); + close(h_out); + close(h_outbak); + + f = fopen(outname, "rt"); + while (fgets(line, 512, f)) { + fputs(line, stdout); + } + fclose(f); + + remove(outname); + } } -int pc_open_stderr (void) + +int +pc_open_stderr (void) { - tmpnam(errname); + tmpnam(errname); - if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { - h_errbak = dup(STDERR_FILENO); - fflush(stderr); - dup2(h_err, STDERR_FILENO); - } + if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { + h_errbak = dup(STDERR_FILENO); + fflush(stderr); + dup2(h_err, STDERR_FILENO); + } - return h_err; + return h_err; } -void pc_close_stderr (void) + +void +pc_close_stderr (void) { - FILE *f; - char *line = alloca(512); - - if (h_err > 0) { - dup2(h_errbak, STDERR_FILENO); - close(h_err); - close(h_errbak); - - f = fopen(errname, "rt"); - while (fgets(line, 512, f)) { - fputs(line, stderr); - } - fclose(f); - - remove(errname); - } + FILE *f; + char *line = alloca(512); + + if (h_err > 0) { + dup2(h_errbak, STDERR_FILENO); + close(h_err); + close(h_errbak); + + f = fopen(errname, "rt"); + while (fgets(line, 512, f)) { + fputs(line, stderr); + } + fclose(f); + + remove(errname); + } } |