ftp.nice.ch/pub/next/tools/system/power.N.bs.tar.gz#/power/setpwr.c

This is setpwr.c in view mode; [Download] [Up]

/* setpwr.c
 *
 * Usage: setpwr [-on|-off] t_time
 *
 * set NVRAM alarm to t_time (epoch-time) and/or enable/disable
 * the next power-on time
 *
 */

#include <sys/types.h>
#include <stdio.h>
#include <strings.h>



int set_nvram_power_on_alarm_enabled (int argflag); 
char *progname;

extern int optind;
extern char *optarg;
			   

main (argc, argv)
	int argc;
	char *argv[];
 
{
		time_t	tmval;
		register int errflg = 0;
	   	int c;
	   	progname = argv[0];

		while ((c = getopt(argc, argv, "o:")) != EOF)
		switch (c) {
			case 'o':
				if (strcmp(optarg, "n"))  
					set_nvram_power_on_alarm_enabled(0);
				else if (strcmp(optarg, "ff"))  
				 	set_nvram_power_on_alarm_enabled(16);											
				else
					errflg++;	
                    		break;
			default:
				errflg++;
				break;

				}
		
		if ((optind<argc) && (!errflg)) {
			tmval = atoi( argv[optind] );
			if ( ! set_nvram_power_on_alarm(tmval) ) 
  				fputs ("You don't have the permission to change the power-on time!\n", stderr) ;
			}
		else
			if ((errflg) || (optind == 1)) {
				fprintf(stderr, "Usage: %s [-on|-off] t_time\n", progname);
			exit(2);
			}

}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.