1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
7 * The contents of this file are subject to the SciTech MGL Public
8 * License Version 1.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.scitechsoft.com/mgl-license.txt
12 * Software distributed under the License is distributed on an
13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
25 * Environment: Linux/QNX
27 * Description: Program to save the console state state so that it can
28 * be later restored if the program crashed while the console
29 * was in graphics mode.
31 ****************************************************************************/
44 /* Allocate a buffer to save console state and save the state */
45 hwndConsole = PM_openConsole(0,0,0,0,0,true);
46 stateSize = PM_getConsoleStateSize();
47 if ((stateBuf = PM_malloc(stateSize)) == NULL) {
48 PM_closeConsole(hwndConsole);
49 printf("Unable to allocate console state buffer!\n");
52 PM_saveConsoleState(stateBuf,0);
54 /* Restore the console state on exit */
55 PM_restoreConsoleState(stateBuf,0);
56 PM_closeConsole(hwndConsole);
58 /* Write the saved console state buffer to disk */
59 if ((f = fopen("/etc/pmsave.dat","wb")) == NULL)
60 printf("Unable to open /etc/pmsave/dat for writing!\n");
62 fwrite(&stateSize,1,sizeof(stateSize),f);
63 fwrite(stateBuf,1,stateSize,f);
65 printf("Console state successfully saved to /etc/pmsave.dat\n");