boot.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of openSDK.
00003  *
00004  * Copyright (C) 2006-2007 openSDK team
00005  *
00006  * openSDK is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; version 2.
00009  *
00010  * openSDK is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with openSDK; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *     $Id: boot.cc,v 1.5 2007/03/02 21:43:48 nuno-lopes Exp $
00020  */
00021 
00022 #include <cstdlib> // for exit()
00023 #include <unistd.h>
00024 #include <signal.h>
00025 #include <OPENR/OPower.h>
00026 #include <opensdkAPI.h>
00027 #include "boot.h"
00028 
00029 void shutdown(void)
00030 {
00031         if (!__in_shutdown) {
00032                 exit(0);
00033         }
00034 }
00035 /*
00036 void timer_signal_handler(int)
00037 {
00038         alarm(0); // cancel delivery of further alarms
00039         shutdown();
00040 }
00041 
00042 OStatus set_shutdown_timer(time_t time, longword timeType)
00043 {
00044         if (timeType == obcbttABSOLUTE) {
00045                 OTime timer(time, 0);
00046                 OTime sysTime;
00047 
00048                 // check if we are looking for a time in the past
00049                 if (timer < sysTime) {
00050                         return oFAIL;
00051                 }
00052 
00053                 time -= sysTime.GetClock();
00054         }
00055 
00056         if (time == 0) {
00057                 shutdown();
00058         } else {
00059                 // TODO move the signal() call to the main initialization function
00060                 if (alarm(time) == 0 || signal(SIGALRM, timer_signal_handler) == SIG_ERR) {
00061                         return oFAIL;
00062                 }
00063         }
00064 
00065         return oSUCCESS;
00066 }
00067 */

Generated on Sun Dec 2 23:04:28 2007 for openSDK by  doxygen 1.3.9.1