diff options
Diffstat (limited to 'PC/os2emx/pythonpm.c')
-rw-r--r-- | PC/os2emx/pythonpm.c | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/PC/os2emx/pythonpm.c b/PC/os2emx/pythonpm.c index 5accbbd..ba47f4b 100644 --- a/PC/os2emx/pythonpm.c +++ b/PC/os2emx/pythonpm.c @@ -27,10 +27,10 @@ /* use structure to pass command line to Python thread */ typedef struct { - int argc; - char **argv; - HWND Frame; - int running; + int argc; + char **argv; + HWND Frame; + int running; } arglist; /* make this a global to simplify access. @@ -45,80 +45,80 @@ void PythonThread(void *); int main(int argc, char **argv) { - ULONG FrameFlags = FCF_TITLEBAR | - FCF_SYSMENU | - FCF_SIZEBORDER | - FCF_HIDEBUTTON | - FCF_SHELLPOSITION | - FCF_TASKLIST; - HAB hab; - HMQ hmq; - HWND Client; - QMSG qmsg; - arglist args; - int python_tid; - - /* init PM and create message queue */ - hab = WinInitialize(0); - hmq = WinCreateMsgQueue(hab, 0); - - /* create a (hidden) Window to house the window procedure */ - args.Frame = WinCreateStdWindow(HWND_DESKTOP, - 0, - &FrameFlags, - NULL, - "PythonPM", - 0L, - 0, - 0, - &Client); - - /* run Python interpreter in a thread */ - args.argc = argc; - args.argv = argv; - args.running = 0; - if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) - { - /* couldn't start thread */ - WinAlarm(HWND_DESKTOP, WA_ERROR); - PythonRC = 1; - } - else - { - /* process PM messages, until Python exits */ - while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) - WinDispatchMsg(hab, &qmsg); - if (args.running > 0) - DosKillThread(python_tid); - } - - /* destroy window, shutdown message queue and PM */ - WinDestroyWindow(args.Frame); - WinDestroyMsgQueue(hmq); - WinTerminate(hab); - - return PythonRC; + ULONG FrameFlags = FCF_TITLEBAR | + FCF_SYSMENU | + FCF_SIZEBORDER | + FCF_HIDEBUTTON | + FCF_SHELLPOSITION | + FCF_TASKLIST; + HAB hab; + HMQ hmq; + HWND Client; + QMSG qmsg; + arglist args; + int python_tid; + + /* init PM and create message queue */ + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); + + /* create a (hidden) Window to house the window procedure */ + args.Frame = WinCreateStdWindow(HWND_DESKTOP, + 0, + &FrameFlags, + NULL, + "PythonPM", + 0L, + 0, + 0, + &Client); + + /* run Python interpreter in a thread */ + args.argc = argc; + args.argv = argv; + args.running = 0; + if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) + { + /* couldn't start thread */ + WinAlarm(HWND_DESKTOP, WA_ERROR); + PythonRC = 1; + } + else + { + /* process PM messages, until Python exits */ + while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) + WinDispatchMsg(hab, &qmsg); + if (args.running > 0) + DosKillThread(python_tid); + } + + /* destroy window, shutdown message queue and PM */ + WinDestroyWindow(args.Frame); + WinDestroyMsgQueue(hmq); + WinTerminate(hab); + + return PythonRC; } void PythonThread(void *argl) { - HAB hab; - arglist *args; + HAB hab; + arglist *args; - /* PM initialisation */ - hab = WinInitialize(0); + /* PM initialisation */ + hab = WinInitialize(0); - /* start Python */ - args = (arglist *)argl; - args->running = 1; - PythonRC = Py_Main(args->argc, args->argv); + /* start Python */ + args = (arglist *)argl; + args->running = 1; + PythonRC = Py_Main(args->argc, args->argv); - /* enter a critical section and send the termination message */ - DosEnterCritSec(); - args->running = 0; - WinPostMsg(args->Frame, WM_QUIT, NULL, NULL); + /* enter a critical section and send the termination message */ + DosEnterCritSec(); + args->running = 0; + WinPostMsg(args->Frame, WM_QUIT, NULL, NULL); - /* shutdown PM and terminate thread */ - WinTerminate(hab); - _endthread(); + /* shutdown PM and terminate thread */ + WinTerminate(hab); + _endthread(); } |