Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c743c8d

Browse files
committed
Modified for GUSI
1 parent b852b74 commit c743c8d

5 files changed

Lines changed: 76 additions & 6 deletions

File tree

Mac/Include/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,21 @@
1313
#define HAVE_FOPENRF
1414
#endif
1515
#ifdef __MWERKS__
16+
#ifndef USE_GUSI
1617
#define HAVE_FOPENRF
1718
#endif
19+
#endif
20+
21+
#ifdef USE_GUSI
22+
/* GUSI provides a lot of unixisms */
23+
#define HAVE_SELECT
24+
#define DIRENT
25+
#define HAVE_GETPEERNAME
26+
#define HAVE_SELECT
27+
#define HAVE_FCNTL_H
28+
#define HAVE_SYS_TIME_H
29+
#define HAVE_UNISTD_H
30+
#endif
1831

1932
#ifdef SYMANTEC__CFM68K__
2033
#define atof Py_AtoF

Mac/Modules/config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ extern void initimgop();
122122
#ifdef USE_TK
123123
extern void init_tkinter();
124124
#endif
125+
#ifdef USE_GUSI
126+
extern void initsocket();
127+
extern void initselect();
128+
#endif
125129
/* -- ADDMODULE MARKER 1 -- */
126130

127131
extern void PyMarshal_Init();
@@ -204,6 +208,10 @@ struct {
204208
#ifdef USE_TK
205209
{"_tkinter", init_tkinter},
206210
#endif
211+
#ifdef USE_GUSI
212+
{"socket", initsocket},
213+
{"select", initselect},
214+
#endif
207215

208216
/* -- ADDMODULE MARKER 2 -- */
209217

Mac/Modules/macmodule.c

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4343
#undef S_ISREG
4444
#endif
4545

46+
#ifdef USE_GUSI
47+
#include <sys/types.h>
48+
#include <stat.h>
49+
#define macstat stat
50+
#else
4651
#include "macstat.h"
52+
#endif
4753

4854
#ifdef __MWERKS__
4955
/* For CodeWarrior 4 also define CW4 */
@@ -57,7 +63,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5763
#endif
5864

5965
#include "macdefs.h"
66+
#ifdef USE_GUSI
67+
#include <dirent.h>
68+
#else
6069
#include "dirent.h"
70+
#endif
6171

6272
#ifndef MAXPATHLEN
6373
#define MAXPATHLEN 1024
@@ -68,13 +78,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6878
int chdir PROTO((const char *path));
6979
char *getbootvol PROTO((void));
7080
char *getwd PROTO((char *));
81+
#ifdef USE_GUSI
82+
int mkdir PROTO((const char *path));
83+
DIR * opendir PROTO((const char *));
84+
int closedir PROTO((DIR *));
85+
#else
7186
int mkdir PROTO((const char *path, int mode));
7287
DIR * opendir PROTO((char *));
7388
void closedir PROTO((DIR *));
89+
#endif
7490
struct dirent * readdir PROTO((DIR *));
7591
int rmdir PROTO((const char *path));
7692
int sync PROTO((void));
77-
#if defined(THINK_C) || defined(__SC__)
93+
#if defined(THINK_C) || defined(__SC__) || defined(USE_GUSI)
7894
int unlink PROTO((char *));
7995
#else
8096
int unlink PROTO((const char *));
@@ -315,12 +331,26 @@ mac_lseek(self, args)
315331
}
316332
#endif /* !CW4 */
317333

334+
#ifdef USE_GUSI
335+
/* GUSI mkdir doesn't accept the (dummy) mode. Grrr. */
336+
int _gusi_mkdir(name, mode)
337+
char *name;
338+
int mode;
339+
{
340+
return mkdir(name);
341+
}
342+
#endif /* USE_GUSI */
343+
318344
static object *
319345
mac_mkdir(self, args)
320346
object *self;
321347
object *args;
322348
{
349+
#ifdef USE_GUSI
350+
return mac_strint(args, _gusi_mkdir);
351+
#else
323352
return mac_strint(args, mkdir);
353+
#endif
324354
}
325355

326356
#ifndef CW4
@@ -425,6 +455,19 @@ mac_xstat(self, args)
425455
END_SAVE
426456
if (res != 0)
427457
return mac_error();
458+
#ifdef USE_GUSI
459+
return mkvalue("(llllllllll)",
460+
(long)st.st_mode,
461+
(long)st.st_ino,
462+
(long)st.st_dev,
463+
(long)st.st_nlink,
464+
(long)st.st_uid,
465+
(long)st.st_gid,
466+
(long)st.st_size,
467+
(long)st.st_atime,
468+
(long)st.st_mtime,
469+
(long)st.st_ctime);
470+
#else
428471
return mkvalue("(llllllllllls#s#)",
429472
(long)st.st_mode,
430473
(long)st.st_ino,
@@ -439,6 +482,7 @@ mac_xstat(self, args)
439482
(long)st.st_rsize,
440483
st.st_creator, 4,
441484
st.st_type, 4);
485+
#endif
442486
}
443487

444488
static object *

Mac/Python/macapplication.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
extern void PyMac_InitApplication();
3232

3333
main() {
34-
#if defined(__MWERKS__) && defined(USE_TK)
35-
PyTk_InitGUSI();
34+
#if defined(USE_GUSI)
35+
GUSIDefaultSetup();
3636
#endif
3737
#if defined(__MWERKS__) && defined(__CFM68K__)
3838
printf("Hello, world!\n");

Mac/Python/macgetcompiler.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
#endif
66

77
#ifdef __MWERKS__
8+
#ifdef USE_GUSI
9+
#define HASGUSI " w/GUSI"
10+
#else
11+
#define HASGUSI ""
12+
#endif
813
#ifdef __powerc
9-
#define COMPILER " [CW PPC]"
14+
#define COMPILER " [CW PPC" HASGUSI "]"
1015
#else
1116
#ifdef __CFM68K__
12-
#define COMPILER " [CW CFM68K]"
17+
#define COMPILER " [CW CFM68K" HASGUSI "]"
1318
#else
14-
#define COMPILER " [CW 68K]"
19+
#define COMPILER " [CW 68K" HASGUSI "]"
1520
#endif
1621
#endif
1722
#endif

0 commit comments

Comments
 (0)