Пример #1
0
void
maketablehdr() {
	int ibin;
	printf("              ");
	for (ibin = from; ibin < to; ibin++)
		printf(" %5s", sec2str(ibin * bin));
}
Пример #2
0
void proc_pretty_printer(struct all_types proc) {
	printf("%-8d", proc.flex_types.p.n_req);
	printf("%-12s", sec2str(proc.flex_types.p.max_time));
	printf("%-10u", proc.flex_types.p.n_proc);
	// TODO: Update the line below to print current time.
	printf("%-12s", sec2str(proc.flex_types.p.start_sec?(time(NULL) - proc.flex_types.p.start_sec):0));
	printf("%-12s", proc.flex_types.p.status ? "PENDING" : "RUNNING");
	printf("%-s", strcat(strcat(proc.flex_types.p.exec_name, " "), proc.flex_types.p.argv));
	printf("\n");

	// printf("Process: \n");
	// printf("exec_path: %s\n", proc.flex_types.p.exec_path);
	// printf("max_time: %lu\n", proc.flex_types.p.max_time);
	// printf("n_proc: %u\n", proc.flex_types.p.n_proc);
	// printf("argv: %s\n", proc.flex_types.p.argv);
	// printf("prev_index: %d\n", proc.prev_index);
	// printf("next_index: %d\n", proc.next_index);
	// printf("status: %s\n", proc.flex_types.p.status?"pending":"running");
	// printf("\n");
}
Пример #3
0
void
numtable(const int day, const int ibin, const int label) {
	const unsigned int time = data[IDX(day, ibin, label)];
	if (time)
		if (options.flags & F_PRINT_TIME)
			printf(" %5s", sec2str(time));
		else
			printf(" %5.1f", (float) time * 100.0 / bin);
	else
		printf("      ");
}
Пример #4
0
static void
dump_interface_status(void)
{
    struct ifinfo *ifinfo;
    struct timeval now;

    gettimeofday(&now, NULL);

    for (ifinfo = iflist; ifinfo; ifinfo = ifinfo->next) {
        fprintf(fp, "Interface %s\n", ifinfo->ifname);
        fprintf(fp, "  probe interval: ");
        if (ifinfo->probeinterval) {
            fprintf(fp, "%d\n", ifinfo->probeinterval);
            fprintf(fp, "  probe timer: %d\n", ifinfo->probetimer);
        } else {
            fprintf(fp, "infinity\n");
            fprintf(fp, "  no probe timer\n");
        }
        fprintf(fp, "  interface status: %s\n",
                ifinfo->active > 0 ? "active" : "inactive");
#ifndef SMALL
        fprintf(fp, "  other config: %s\n",
                ifinfo->otherconfig ? "on" : "off");
#endif
        fprintf(fp, "  rtsold status: %s\n", ifstatstr[ifinfo->state]);
        fprintf(fp, "  carrier detection: %s\n",
                ifinfo->mediareqok ? "available" : "unavailable");
        fprintf(fp, "  probes: %d, dadcount = %d\n",
                ifinfo->probes, ifinfo->dadcount);
        if (ifinfo->stoptimer)
            fprintf(fp, "  no timer\n");
        else {
            fprintf(fp, "  timer: interval=%lld:%ld, expire=%s\n",
                    (long long)ifinfo->timer.tv_sec,
                    ifinfo->timer.tv_usec,
                    (ifinfo->expire.tv_sec < now.tv_sec) ? "expired"
                    : sec2str(ifinfo->expire.tv_sec - now.tv_sec));
        }
        fprintf(fp, "  number of valid RAs: %d\n", ifinfo->racnt);
    }
}
Пример #5
0
int
main(int argc, char *argv[]) {
	FILE *fp = stdin;
	static char *buf = NULL;
	static size_t size = 0;
	int label, workingtime = 0;
	const unsigned int procrastination = getlabelid("!*");
	const unsigned int work = getlabelid("+");
	unsigned int payed = getlabelid("");

	ARGBEGIN {
	case 'c':
		columns = atoi(EARGF(usage()));
		if (columns > LENGTH(convert))
			columns = LENGTH(convert);
		break;
	case 'e':
		options.efc = atoi(EARGF(usage()));
		break;
	case 'd':
		options.flags |= F_DAY_STAT;
		break;
	case 'm':
		options.flags |= F_MONTH_STAT;
		break;
	case 'M':
		options.mph = atoi(EARGF(usage()));
		break;
	case 't':
		options.flags |= F_PRINT_TASK;
		break;
	case 'w':
		options.flags |= F_WEEK_STAT;
		break;
	case 'W':
		payed = getlabelid(EARGF(usage()));
		break;
	default:
		usage();
	} ARGEND;

	initdata();

	while (getline(&buf, &size, fp) > 0) {
		char * time;
		struct interval interval;
		if ((time = istask(buf, &interval))) {
			const int timeint = interval.stop - interval.start;
			label = getlabelid(buf);
			char * tmp = strchr(time, ')');
			if (!tmp)
				continue;
			tmp[0] = '\0';
			if (options.flags & F_PRINT_TASK) {
				printf("%-2s(%s", buf, time);
				if (tmp[-1] == '-')
					printf("%s", sec2str(interval.stop));
				printf(") %.2f:%s", (timeint) / 3600.0, tmp + 1);
			}
			set(timeint, label);
			set(timeint, 0);
			if (strchr(buf, '!'))
				set(timeint, procrastination);
			if (convert[label].mark == '+')
				set(timeint, work);
			if (label == payed)
				workingtime += timeint;
			continue;
		}
		int rd;
		if ((rd = getdayid(buf)) >= 0) {
			if (options.flags & F_DAY_STAT)
				printdaystat();
			if (options.flags & F_PRINT_TASK)
				printf("%s", buf);
			memset(data.day, 0, LENGTH(convert) * sizeof(int));
			continue;
		}
		if (strstr(buf, WEEK)) {
			if (options.flags & F_WEEK_STAT)
				printweekstat();
			memset(data.week, 0, LENGTH(convert) * sizeof(int));
			continue;
		}
		if (isnewmonth(buf)) {
			if (options.flags & F_MONTH_STAT)
				printmonthstat();
			memset(data.month, 0, LENGTH(convert) * sizeof(int));
			continue;
		}
		if (!strncmp(buf, PAY_MARK, strlen(PAY_MARK))) {
			printtopay(workingtime / 3600.0);
			workingtime = 0;
		}
	}

	printdaystat();
	printf("\n");
	printweekstat();
	printf("\n");
	printmonthstat();
	printf("\n");
	printyearstat();
	printf("\n");
	printtopay(workingtime / 3600.0);

	freedata();
	free(buf);
	return EXIT_SUCCESS;
}