apm.c (3259) | apm.c (4062) |
---|---|
1/* 2 * LP (Laptop Package) 3 * 4 * Copyright (C) 1994 by HOSOKAWA Tatasumi <hosokawa@mt.cs.keio.ac.jp> 5 * 6 * This software may be used, modified, copied, distributed, and sold, 7 * in both source and binary form provided that the above copyright and 8 * these terms are retained. Under no circumstances is the author 9 * responsible for the proper functioning of this software, nor does 10 * the author assume any responsibility for damages incurred with its 11 * use. 12 * 13 * Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) 14 */ 15 16#include <stdio.h> 17#include <string.h> 18#include <sys/file.h> 19#include <sys/ioctl.h> | 1/* 2 * LP (Laptop Package) 3 * 4 * Copyright (C) 1994 by HOSOKAWA Tatasumi <hosokawa@mt.cs.keio.ac.jp> 5 * 6 * This software may be used, modified, copied, distributed, and sold, 7 * in both source and binary form provided that the above copyright and 8 * these terms are retained. Under no circumstances is the author 9 * responsible for the proper functioning of this software, nor does 10 * the author assume any responsibility for damages incurred with its 11 * use. 12 * 13 * Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) 14 */ 15 16#include <stdio.h> 17#include <string.h> 18#include <sys/file.h> 19#include <sys/ioctl.h> |
20#include <machine/apm_bios.h> | 20#include |
21 | 21 |
22#define APMDEV "/dev/apm" | 22#define APMDEV "/dev/apm0" |
23 24int main_argc; 25char **main_argv; 26 27void apm_suspend(int fd) 28{ 29 if (ioctl(fd, APMIO_SUSPEND, NULL) == -1) { 30 fprintf(stderr, "%s: ioctl APMIO_SUSPEND failed.\n", main_argv[0]); --- 67 unchanged lines hidden (view full) --- 98 if (strcmp(cmdname, "zzz") == 0) { 99 sleep = 1; 100 all_info = 0; 101 goto finish_option; 102 } 103 104 for (i = argc - 1; i >= 1; i--) { 105 if (argv[i][0] != '-') { | 23 24int main_argc; 25char **main_argv; 26 27void apm_suspend(int fd) 28{ 29 if (ioctl(fd, APMIO_SUSPEND, NULL) == -1) { 30 fprintf(stderr, "%s: ioctl APMIO_SUSPEND failed.\n", main_argv[0]); --- 67 unchanged lines hidden (view full) --- 98 if (strcmp(cmdname, "zzz") == 0) { 99 sleep = 1; 100 all_info = 0; 101 goto finish_option; 102 } 103 104 for (i = argc - 1; i >= 1; i--) { 105 if (argv[i][0] != '-') { |
106 fprintf(stderr, "%s: Unknown option '%s'.", argv[0], argv[i]); | 106 fprintf(stderr, "%s: Unknown option '%s'.\n", argv[0], argv[i]); 107 exit(1); |
107 } 108 for (j = 1; argv[i][j]; j++) { 109 switch (argv[i][j]) { 110 case 'z': 111 sleep = 1; 112 all_info = 0; 113 break; 114 case 'b': 115 batt_status = 1; 116 all_info = 0; 117 break; 118 case 'a': 119 ac_status = 1; 120 all_info = 0; 121 break; 122 case 'l': 123 batt_life = 1; 124 all_info = 0; 125 break; | 108 } 109 for (j = 1; argv[i][j]; j++) { 110 switch (argv[i][j]) { 111 case 'z': 112 sleep = 1; 113 all_info = 0; 114 break; 115 case 'b': 116 batt_status = 1; 117 all_info = 0; 118 break; 119 case 'a': 120 ac_status = 1; 121 all_info = 0; 122 break; 123 case 'l': 124 batt_life = 1; 125 all_info = 0; 126 break; |
127 default: 128 fprintf(stderr, "%s Unknown option '%s'.\n", argv[0], argv[i]); 129 exit(1); |
|
126 } 127 } 128 } 129finish_option: 130 fd = open(APMDEV, O_RDWR); 131 if (fd == -1) { 132 fprintf(stderr, "%s: Can't open %s.\n", argv[0], APMDEV); 133 return 1; --- 24 unchanged lines hidden --- | 130 } 131 } 132 } 133finish_option: 134 fd = open(APMDEV, O_RDWR); 135 if (fd == -1) { 136 fprintf(stderr, "%s: Can't open %s.\n", argv[0], APMDEV); 137 return 1; --- 24 unchanged lines hidden --- |