Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (C) 2010, Linaro |
| 3 | * Copyright (C) 2010, IBM Corporation |
| 4 | * |
| 5 | * This file is part of PowerDebug. |
| 6 | * |
| 7 | * All rights reserved. This program and the accompanying materials |
| 8 | * are made available under the terms of the Eclipse Public License v1.0 |
| 9 | * which accompanies this distribution, and is available at |
| 10 | * http://www.eclipse.org/legal/epl-v10.html |
| 11 | * |
| 12 | * Contributors: |
| 13 | * Amit Arora <amit.arora@linaro.org> (IBM Corporation) |
| 14 | * - initial API and implementation |
| 15 | *******************************************************************************/ |
| 16 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 17 | #include <getopt.h> |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 18 | #include "powerdebug.h" |
| 19 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 20 | int numregulators; |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 21 | int dump; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 22 | int highlighted_row; |
| 23 | double ticktime = 10.0; /* in seconds */ |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 24 | |
| 25 | int init_regulator_ds(void) |
| 26 | { |
| 27 | DIR *regdir; |
| 28 | struct dirent *item; |
| 29 | |
| 30 | regdir = opendir("/sys/class/regulator"); |
| 31 | if (!regdir) |
| 32 | return(1); |
| 33 | while((item = readdir(regdir))) { |
| 34 | if (strncmp(item->d_name, "regulator", 9)) |
| 35 | continue; |
| 36 | |
| 37 | numregulators++; |
| 38 | } |
| 39 | closedir(regdir); |
| 40 | |
| 41 | regulators_info = (struct regulator_info *)malloc(numregulators* |
| 42 | sizeof(struct regulator_info)); |
| 43 | if (!regulators_info) { |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 44 | fprintf(stderr, "init_regulator_ds: Not enough memory to " |
| 45 | "read information for %d regulators!\n", numregulators); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 46 | return(1); |
| 47 | } |
| 48 | |
| 49 | return(0); |
| 50 | } |
| 51 | |
| 52 | int read_and_print_sensor_info(int verbose) |
| 53 | { |
| 54 | DIR *dir, *subdir; |
Amit Arora | 1c03789 | 2010-08-05 13:46:10 +0530 | [diff] [blame] | 55 | int len, found = 0; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 56 | char filename[PATH_MAX], devpath[PATH_MAX]; |
| 57 | char device[PATH_MAX]; |
| 58 | struct dirent *item, *subitem; |
| 59 | |
| 60 | /* |
| 61 | 1. readdir /sys/class/hwmon |
| 62 | 2. foreach subdir in above, do following |
| 63 | a) check if its virtual or physical (check for device) |
| 64 | b) for each *type* (in, temp, pwm, fan, curr, power, energy) |
| 65 | i> search for "_" (strrchr... check for last) |
| 66 | ii> check the *item* depending on type |
| 67 | i.e for "in" type items=min, max, input, label |
| 68 | for "fan" type items=min,max,input,div,target,label |
| 69 | for "pwm" type items=enable, mode, freq |
| 70 | for "temp" type items=type, max, min,input,crit,offset,label,lowest,highest, |
| 71 | for "curr" type items=max,min,input |
| 72 | for "power" type items=average,average_interval,average_min/max, average_highest/lowest, input, input_highest/lowest, accuracy,alarm, cap, cap_min/max |
| 73 | for "energy" type items=input |
| 74 | for "intrusion" type items=alarm,beep |
| 75 | */ |
| 76 | |
| 77 | sprintf(filename, "%s", "/sys/class/hwmon"); |
| 78 | |
| 79 | dir = opendir(filename); |
| 80 | if (!dir) |
| 81 | return errno; |
| 82 | |
| 83 | while ((item = readdir(dir))) { |
| 84 | if (item->d_name[0] == '.') /* skip the hidden files */ |
| 85 | continue; |
| 86 | |
Amit Arora | 1c03789 | 2010-08-05 13:46:10 +0530 | [diff] [blame] | 87 | found = 1; |
| 88 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 89 | sprintf(filename, "/sys/class/hwmon/%s", item->d_name); |
| 90 | sprintf(devpath, "%s/device", filename); |
| 91 | |
| 92 | len = readlink(devpath, device, PATH_MAX - 1); |
| 93 | |
| 94 | if (len < 0) |
| 95 | strcpy(devpath, filename); |
| 96 | else |
| 97 | device[len] = '\0'; |
| 98 | |
| 99 | subdir = opendir(devpath); |
| 100 | |
| 101 | printf("\nSensor Information for %s :\n", item->d_name); |
| 102 | fflush(stdin); |
| 103 | while ((subitem = readdir(subdir))) { |
| 104 | if (subitem->d_name[0] == '.') /* skip hidden files */ |
| 105 | continue; |
| 106 | |
| 107 | if(!strncmp(subitem->d_name, "in", 2)) |
| 108 | get_sensor_info(devpath, subitem->d_name, "in", |
| 109 | verbose); |
| 110 | else if (!strncmp(subitem->d_name, "temp", 4)) |
| 111 | get_sensor_info(devpath, subitem->d_name, |
| 112 | "temp", verbose); |
| 113 | else if (!strncmp(subitem->d_name, "fan", 4)) |
| 114 | get_sensor_info(devpath, subitem->d_name, |
| 115 | "fan", verbose); |
| 116 | else if (!strncmp(subitem->d_name, "pwm", 4)) |
| 117 | get_sensor_info(devpath, subitem->d_name, |
| 118 | "pwm", verbose); |
| 119 | |
| 120 | } |
| 121 | |
| 122 | closedir(subdir); |
| 123 | } |
| 124 | closedir(dir); |
| 125 | |
Amit Arora | 1c03789 | 2010-08-05 13:46:10 +0530 | [diff] [blame] | 126 | if(!found && verbose) { |
| 127 | printf("Could not find sensor information!"); |
| 128 | printf(" Looks like /sys/class/hwmon is empty.\n"); |
| 129 | } |
| 130 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 131 | return 0; |
| 132 | } |
| 133 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 134 | void read_info_from_dirent(struct dirent *ritem, char *str, int idx) |
| 135 | { |
| 136 | if (!strcmp(ritem->d_name, "name")) |
| 137 | strcpy(regulators_info[idx].name, str); |
| 138 | if (!strcmp(ritem->d_name, "state")) |
| 139 | strcpy(regulators_info[idx].state, str); |
| 140 | if (!strcmp(ritem->d_name, "status")) |
| 141 | strcpy(regulators_info[idx].status, str); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 142 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 143 | if (!strcmp(ritem->d_name, "type")) |
| 144 | strcpy(regulators_info[idx].type, str); |
| 145 | if (!strcmp(ritem->d_name, "opmode")) |
| 146 | strcpy(regulators_info[idx].opmode, str); |
| 147 | |
| 148 | if (!strcmp(ritem->d_name, "microvolts")) |
| 149 | regulators_info[idx].microvolts = atoi(str); |
| 150 | if (!strcmp(ritem->d_name, "min_microvolts")) |
| 151 | regulators_info[idx].min_microvolts = atoi(str); |
| 152 | if (!strcmp(ritem->d_name, "max_microvolts")) |
| 153 | regulators_info[idx].max_microvolts = atoi(str); |
| 154 | |
| 155 | if (!strcmp(ritem->d_name, "microamps")) |
| 156 | regulators_info[idx].microamps = atoi(str); |
| 157 | if (!strcmp(ritem->d_name, "min_microamps")) |
| 158 | regulators_info[idx].min_microamps = atoi(str); |
| 159 | if (!strcmp(ritem->d_name, "max_microamps")) |
| 160 | regulators_info[idx].max_microamps = atoi(str); |
| 161 | if (!strcmp(ritem->d_name, "requested_microamps")) |
| 162 | regulators_info[idx].requested_microamps = atoi(str); |
| 163 | |
| 164 | if (!strcmp(ritem->d_name, "num_users")) |
| 165 | regulators_info[idx].num_users = atoi(str); |
| 166 | } |
| 167 | |
| 168 | int read_regulator_info(void) |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 169 | { |
| 170 | FILE *file = NULL; |
| 171 | DIR *regdir, *dir; |
| 172 | int len, count = 0, ret = 0; |
| 173 | char line[1024], filename[1024], *fptr; |
| 174 | struct dirent *item, *ritem; |
| 175 | |
| 176 | regdir = opendir("/sys/class/regulator"); |
| 177 | if (!regdir) |
| 178 | return(1); |
| 179 | while((item = readdir(regdir))) { |
| 180 | if (strlen(item->d_name) < 3) |
| 181 | continue; |
| 182 | |
| 183 | if (strncmp(item->d_name, "regulator", 9)) |
| 184 | continue; |
| 185 | |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 186 | len = sprintf(filename, "/sys/class/regulator/%s", |
| 187 | item->d_name); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 188 | |
| 189 | dir = opendir(filename); |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 190 | if (!dir) |
Amit Arora | 7ef178c | 2010-08-03 15:57:21 +0530 | [diff] [blame] | 191 | continue; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 192 | |
| 193 | count++; |
| 194 | if (count > numregulators) { |
| 195 | ret = 1; |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 196 | goto exit; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 197 | } |
| 198 | |
Amit Arora | fccac91 | 2010-08-03 16:15:09 +0530 | [diff] [blame] | 199 | strcpy(regulators_info[count-1].name, item->d_name); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 200 | while((ritem = readdir(dir))) { |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 201 | if (strlen(ritem->d_name) < 3) |
| 202 | continue; |
| 203 | |
| 204 | sprintf(filename + len, "/%s", ritem->d_name); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 205 | |
| 206 | file = fopen(filename, "r"); |
| 207 | if (!file) |
| 208 | continue; |
| 209 | |
| 210 | memset(line, 0, 1024); |
| 211 | fptr = fgets(line, 1024, file); |
| 212 | fclose(file); |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 213 | if (!fptr) |
Amit Arora | 7ef178c | 2010-08-03 15:57:21 +0530 | [diff] [blame] | 214 | continue; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 215 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 216 | read_info_from_dirent(ritem, fptr, count - 1); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 217 | } |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 218 | exit: |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 219 | closedir(dir); |
| 220 | if (ret) |
| 221 | break; |
| 222 | } |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 223 | closedir(regdir); |
| 224 | |
| 225 | return ret; |
| 226 | } |
| 227 | |
| 228 | |
| 229 | int main(int argc, char **argv) |
| 230 | { |
| 231 | int c; |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 232 | int firsttime = 1; |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 233 | int enter_hit = 0; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 234 | int regulators = 0, sensors = 0, clocks = 0, verbose = 0; |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 235 | int r_share = 0, s_share = 0, c_share = 0; //%age share of the win size |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 236 | |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 237 | /* |
| 238 | * Options: |
| 239 | * -r, --regulator : regulator |
| 240 | * -s, --sensor : sensors |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 241 | * -c, --clock : clocks |
| 242 | * -t, --time : ticktime |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 243 | * -d, --dump : dump |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 244 | * -v, --verbose : verbose |
| 245 | * -V, --version : version |
| 246 | * -h, --help : help |
| 247 | * no option / default : show usage! |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 248 | */ |
| 249 | |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 250 | while (1) { |
| 251 | int optindex = 0; |
| 252 | static struct option long_options[] = { |
| 253 | {"regulator", 0, 0, 'r'}, |
| 254 | {"sensor", 0, 0, 's'}, |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 255 | {"clock", 0, 0, 'c'}, |
| 256 | {"time", 0, 0, 't'}, |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 257 | {"dump", 0, 0, 'd'}, |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 258 | {"verbose", 0, 0, 'v'}, |
| 259 | {"version", 0, 0, 'V'}, |
| 260 | {"help", 0, 0, 'h'}, |
| 261 | {0, 0, 0, 0} |
| 262 | }; |
| 263 | |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 264 | c = getopt_long(argc, argv, "rsct:dvVh", long_options, &optindex); |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 265 | if (c == -1) |
| 266 | break; |
| 267 | |
| 268 | switch (c) { |
| 269 | case 'r': |
| 270 | regulators = 1; |
| 271 | break; |
| 272 | case 's': |
| 273 | sensors = 1; |
| 274 | break; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 275 | case 'c': |
| 276 | clocks = 1; |
| 277 | break; |
| 278 | case 't': |
| 279 | ticktime = strtod(optarg, NULL); |
| 280 | break; |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 281 | case 'd': |
| 282 | dump = 1; |
| 283 | break; |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 284 | case 'v': |
| 285 | verbose = 1; |
| 286 | break; |
| 287 | case 'V': |
| 288 | version(); |
| 289 | break; |
| 290 | case 'h': |
| 291 | usage(argv); |
| 292 | break; |
| 293 | case '?': |
| 294 | fprintf (stderr, "%s: Unknown option %c'.\n", |
| 295 | argv[0], optopt); |
| 296 | exit(1); |
| 297 | default: |
| 298 | usage(argv); |
| 299 | break; |
| 300 | } |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 301 | } |
| 302 | |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 303 | |
| 304 | /* Need atleast one option specified */ |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 305 | if (!regulators && !sensors && !clocks) { |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 306 | usage(argv); |
| 307 | } |
| 308 | |
| 309 | init_regulator_ds(); |
| 310 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 311 | while(1) { |
| 312 | int key = 0; |
| 313 | struct timeval tval; |
| 314 | fd_set readfds; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 315 | int row = 1; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 316 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 317 | if (!dump) { |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 318 | if(firsttime) |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 319 | init_curses(); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 320 | create_windows(); |
| 321 | show_header(); |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 322 | if (sensors) |
| 323 | s_share = 20; |
| 324 | if (regulators) { |
| 325 | if (!sensors && clocks) |
| 326 | r_share = 50; |
| 327 | else if (clocks) |
| 328 | r_share = 40; |
| 329 | else |
| 330 | r_share = 80; |
| 331 | } |
| 332 | c_share = 100 - (r_share + s_share); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | if (regulators) { |
| 336 | read_regulator_info(); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 337 | if (!dump) { |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 338 | int orig_r_share = r_share; |
| 339 | |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 340 | row = create_regulator_win(row, |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 341 | numregulators + 2, |
| 342 | &r_share); |
| 343 | c_share += (orig_r_share - r_share); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 344 | show_regulator_info(verbose); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 345 | } |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 346 | else |
| 347 | print_regulator_info(verbose); |
| 348 | } |
| 349 | |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 350 | if (clocks) { |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 351 | if (firsttime) |
| 352 | init_clock_details(); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 353 | if (!dump) { |
| 354 | int hrow; |
| 355 | |
| 356 | //giv big no. in second arg as of now |
| 357 | row = create_clock_win(row, 100, &c_share); |
| 358 | hrow = read_and_print_clock_info(verbose, |
| 359 | highlighted_row, |
| 360 | enter_hit); |
| 361 | highlighted_row = hrow; |
| 362 | enter_hit = 0; |
| 363 | } else |
| 364 | dump_clock_info(verbose); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 365 | } |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 366 | |
| 367 | if (sensors) { |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 368 | if (!dump) { |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 369 | row = create_sensor_win(row, 100, &s_share);//big no. as of now |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 370 | print_sensor_header(); |
| 371 | } |
| 372 | else |
| 373 | read_and_print_sensor_info(verbose); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | if (dump) |
| 377 | break; |
| 378 | |
| 379 | FD_ZERO(&readfds); |
| 380 | FD_SET(0, &readfds); |
| 381 | tval.tv_sec = ticktime; |
| 382 | tval.tv_usec = (ticktime - tval.tv_sec) * 1000000; |
| 383 | |
| 384 | key = select(1, &readfds, NULL, NULL, &tval); |
| 385 | |
| 386 | if (key) { |
| 387 | char keychar; |
| 388 | |
| 389 | int keystroke = fgetc(stdin); |
| 390 | if (keystroke == EOF) |
| 391 | exit(0); |
| 392 | |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 393 | if (keystroke == 9) |
| 394 | highlighted_row++; |
| 395 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 396 | keychar = toupper(keystroke); |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 397 | if (keystroke == 13) |
| 398 | enter_hit = 1; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 399 | |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 400 | if (keychar == 'Q') |
| 401 | exit(0); |
| 402 | if (keychar == 'R') |
| 403 | ticktime = 3; |
| 404 | } |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 405 | if (firsttime) |
| 406 | firsttime = 0; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 407 | } |
| 408 | |
Amit Arora | 85fd495 | 2010-08-05 14:04:50 +0530 | [diff] [blame] | 409 | exit(0); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 410 | } |