summaryrefslogtreecommitdiffstats
path: root/src/glut
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-11-05 20:52:07 +0000
committerBrian Paul <[email protected]>2002-11-05 20:52:07 +0000
commitaa3029bce1bc5bb59e91373d15035653f75d6818 (patch)
treef44d6fd995f715d83b792439a1eb148678c03395 /src/glut
parent8a738db519a3cfb7a0a87a3c97090709bbbd6024 (diff)
Updates for DOS driver from Daniel Borca.
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/dos/PC_HW/pc_hw.c97
-rw-r--r--src/glut/dos/PC_HW/pc_hw.h6
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c4
-rw-r--r--src/glut/dos/window.c5
4 files changed, 60 insertions, 52 deletions
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c
index 09ab4614049..9b30c5808c1 100644
--- a/src/glut/dos/PC_HW/pc_hw.c
+++ b/src/glut/dos/PC_HW/pc_hw.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.0 for DOS/DJGPP
+ * PC/HW routine collection v1.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -12,7 +12,6 @@
#include <sys/stat.h> /* for mode definitions */
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "pc_hw.h"
@@ -74,68 +73,76 @@ void *pc_malloc (size_t size)
/*
* standard redirection
*/
-static char errname[L_tmpnam];
-static char outname[L_tmpnam];
+static int h_out, h_outbak, h_err, h_errbak;
-static int h_out, h_outbak;
-static int h_err, h_errbak;
-
-void pc_open_stderr (void)
+int pc_open_stdout (void)
{
- if (tmpnam(errname)) {
- h_err = open(errname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
- S_IREAD | S_IWRITE);
- h_errbak = dup(2);
- fflush(stderr);
- dup2(h_err, 2);
+ if ((h_out=open(tmpnam(NULL), O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_TEMPORARY, S_IRUSR | S_IWUSR)) >= 0) {
+ if ((h_outbak=dup(1)) != -1) {
+ fflush(stdout);
+ if (dup2(h_out, 1) != -1) {
+ return 0;
+ }
+ close(h_outbak);
+ }
+ close(h_out);
}
+ return (h_out = -1);
}
-void pc_close_stderr (void)
+void pc_close_stdout (void)
{
FILE *f;
char *line = alloca(512);
-
- dup2(h_errbak, 2);
- close(h_err);
- close(h_errbak);
-
- if ((f=fopen(errname, "r"))!=NULL) {
- while (fgets(line, 512, f)) {
- fputs(line, stderr);
+
+ if (h_out >= 0) {
+ dup2(h_outbak, 1);
+ close(h_outbak);
+
+ if ((f=fdopen(h_out, "r")) != NULL) {
+ fseek(f, 0, SEEK_SET);
+ while (fgets(line, 512, f)) {
+ fputs(line, stdout);
+ }
+ fclose(f);
+ } else {
+ close(h_out);
}
- fclose(f);
}
-
- remove(errname);
}
-void pc_open_stdout (void)
+int pc_open_stderr (void)
{
- if (tmpnam(outname)) {
- h_out = open(outname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
- S_IREAD | S_IWRITE);
- h_outbak = dup(1);
- fflush(stdout);
- dup2(h_out, 1);
+ if ((h_err=open(tmpnam(NULL), O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_TEMPORARY, S_IRUSR | S_IWUSR)) >= 0) {
+ if ((h_errbak=dup(2)) != -1) {
+ fflush(stderr);
+ if (dup2(h_err, 2) != -1) {
+ return 0;
+ }
+ close(h_errbak);
+ }
+ close(h_err);
}
+ return (h_err = -1);
}
-void pc_close_stdout (void)
+void pc_close_stderr (void)
{
FILE *f;
char *line = alloca(512);
-
- dup2(h_outbak, 1);
- close(h_out);
- close(h_outbak);
-
- if ((f=fopen(outname, "r"))!=NULL) {
- while (fgets(line, 512, f)) {
- fputs(line, stdout);
+
+ if (h_err >= 0) {
+ dup2(h_errbak, 2);
+ close(h_errbak);
+
+ if ((f=fdopen(h_err, "r")) != NULL) {
+ fseek(f, 0, SEEK_SET);
+ while (fgets(line, 512, f)) {
+ fputs(line, stderr);
+ }
+ fclose(f);
+ } else {
+ close(h_err);
}
- fclose(f);
}
-
- remove(outname);
}
diff --git a/src/glut/dos/PC_HW/pc_hw.h b/src/glut/dos/PC_HW/pc_hw.h
index fd0e777953d..77572e64414 100644
--- a/src/glut/dos/PC_HW/pc_hw.h
+++ b/src/glut/dos/PC_HW/pc_hw.h
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.1 for DOS/DJGPP
+ * PC/HW routine collection v1.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -217,8 +217,8 @@ void pc_unscare_mouse (void);
/*
* standard redirection
*/
-void pc_open_stdout (void);
-void pc_open_stderr (void);
+int pc_open_stdout (void);
+int pc_open_stderr (void);
void pc_close_stdout (void);
void pc_close_stderr (void);
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
index 5a04cf21913..01e9502dd0c 100644
--- a/src/glut/dos/PC_HW/pc_mouse.c
+++ b/src/glut/dos/PC_HW/pc_mouse.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.1 for DOS/DJGPP
+ * PC/HW routine collection v1.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -226,6 +226,7 @@ void pc_unscare_mouse (void)
}
__asm("\n\
+ .text \n\
.balign 4 \n\
.global _mouse_wrapper \n\
_mouse_wrapper: \n\
@@ -252,7 +253,6 @@ _mouse_wrapper: \n\
movl %esi, %esp \n\
popl %es \n\
iret \n\
- \n\
.balign 4 \n\
.global _mouse_wrapper_end \n\
_mouse_wrapper_end:");
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index 384e10a03b8..ba0f5acee5c 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 4.0
+ * Version: 4.1
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v1.2 for Mesa 4.1
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -113,6 +113,7 @@ int APIENTRY glutCreateWindow (const char *title)
if ((context=fxMesaCreateBestContext(-1, screen_w, screen_h, fx_attrib))==NULL) {
return 0;
}
+ visual = context;
#endif
pc_open_stdout();