~arivigo/schain

94771e7c770296c0b3c11b0a049073099fe4f00d — Ariadna Vigo a month ago ec1b576
schain.c: refactored code
1 files changed, 8 insertions(+), 5 deletions(-)

M schain.c
M schain.c => schain.c +8 -5
@@ 105,13 105,17 @@ main(int argc, char *argv[])
	int opt, mode, out_fmt, num;
	const char *filepath;
	char *datearg, *odate;
	char adate[DATE_SIZE], fdate[DATE_SIZE];
	char adate[DATE_SIZE], fdate[DATE_SIZE], today[DATE_SIZE], 
	     yest[DATE_SIZE];

	num = 0;
	datearg = NULL;
	mode = DEF_MODE;
	out_fmt = LONG_OUT;

	strlcpy(today, date_str(time(NULL)), DATE_SIZE);
	strlcpy(yest, date_str(time(NULL) - 86400), DATE_SIZE);

	while ((opt = getopt(argc, argv, ":ksvc:w:")) != -1) {
		switch (opt) {
		case 'k':


@@ 148,11 152,11 @@ main(int argc, char *argv[])

	if (datearg != NULL) {
		if (strncmp(datearg, "y", DATE_SIZE) == 0)
			strlcpy(adate, date_str(time(NULL) - 86400), DATE_SIZE);
			strlcpy(adate, yest, DATE_SIZE);
		else
			strlcpy(adate, datearg, DATE_SIZE);
	} else {
		strlcpy(adate, date_str(time(NULL)), DATE_SIZE);
		strlcpy(adate, today, DATE_SIZE);
	}

	if (is_date(adate) < 0)


@@ 166,8 170,7 @@ main(int argc, char *argv[])
	case CHECKIN_MODE:
		read_file(fdate, &num, filepath);

		if (strncmp(fdate, date_str(time(NULL)), DATE_SIZE) == 0
		    && num > 0)
		if (strncmp(fdate, today, DATE_SIZE) == 0 && num > 0)
			die("Check-in error: last check-in was today.");

		if (num + 1 < 0)