Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Wake100.c
// |
// |
// © Copyright 1991 Apple Computer, Inc. All Rights Reserved |
// |
// By Ricardo Batista |
// |
// This is an INIT which reads the wake up time in the PowerBook 100 and |
// old Portable, if the wake up date has elapsed then we add a day to it |
// so that the machine wakes up at the same time every day. |
// By request of Neal Macklin. Maybe we can make something useful from |
// this later on. |
// |
// This file is a code resource that gets added to the sleep queue. |
#include <Types.h> |
#include <Power.h> |
#include <OSUtils.h> |
typedef unsigned long ulong; |
long main() |
{ |
DateTimeRec d; |
ulong wTime, now; |
Boolean wake = false; |
short err; |
short hour, minute; |
err = GetWUTime((long*) &wTime, (Byte*) &wake); |
if (err) |
return(0L); |
GetDateTime(&now); |
now += 2L; // add 2 secs to make sure we just woke up |
if (now > wTime) { |
Secs2Date(wTime, &d); // get day time they wanted |
hour = d.hour; |
minute = d.minute; |
Secs2Date(now, &d); // get current date |
if (hour < d.hour) |
d.day++; // next day |
if ((hour == d.hour) && (minute <= d.minute)) |
d.day++; |
d.hour = hour; |
d.minute = minute; |
Date2Secs(&d, &wTime); |
err = SetWUTime((long) &wTime); // interfaces have a bug ! |
} |
return(0L); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14