#include #include #include #define STARTFILE "/var/run/ppp.linkstart" int main() { int fd = open(STARTFILE, O_RDONLY); char buf[128]; time_t start, end; unsigned int diff; if(fd<0) { perror("could not open ppp.linkstart"); exit(1); } read(fd, buf, sizeof(buf)); if(buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; start = atoi(buf); end = start+7200; diff = end-time(NULL); printf("Connection started at %s", ctime(&start)); printf("Connection will end at %s", ctime(&end)); printf("%d seconds remaining\n", diff); }