| 107 | |
| 108 | |
| 109 | int |
| 110 | in_ltm(const login_time_t *ltm, struct tm *tt, time_t *ends) |
| 111 | { |
| 112 | int rc = 0; |
| 113 | |
| 114 | if (tt != NULL) { |
| 115 | /* First, examine the day of the week */ |
| 116 | if ((u_char)(0x01 << tt->tm_wday) & ltm->lt_dow) { |
| 117 | /* Convert `current' time to minute of the day */ |
| 118 | u_short now = (u_short)((tt->tm_hour * 60) + tt->tm_min); |
| 119 | |
| 120 | if (tt->tm_sec > 30) |
| 121 | ++now; |
| 122 | if (now >= ltm->lt_start && now < ltm->lt_end) { |
| 123 | rc = 2; |
| 124 | if (ends != NULL) { |
| 125 | /* If requested, return ending time for this period */ |
| 126 | tt->tm_hour = (int)(ltm->lt_end / 60); |
| 127 | tt->tm_min = (int)(ltm->lt_end % 60); |
| 128 | *ends = mktime(tt); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | return (rc); |
| 134 | } |
| 135 | |
| 136 | |
| 137 | int |