* specific language governing permissions and limitations under the License.
*/
-
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
static void *ngx_http_office_hours_create_conf(ngx_conf_t * cf);
static char *ngx_http_office_hours_merge_conf(ngx_conf_t * cf,
- void *parent, void *child);
+ void *parent, void *child);
static ngx_int_t ngx_http_office_hours_init(ngx_conf_t * cf);
/* Configuration Handler */
ngx_null_command
};
-
/* Module Context */
static ngx_http_module_t ngx_http_office_hours_filter_module_ctx = {
ngx_http_office_hours_merge_conf /* Merge location configuration */
};
-
/* Module Definition */
ngx_module_t ngx_http_office_hours_filter_module = {
NGX_MODULE_V1_PADDING
};
-
/*
* Main Header Filter
* If the current time is within office hours, it goes to the next
ngx_http_get_module_loc_conf(r,
ngx_http_office_hours_filter_module);
-
if (conf->office_hours == NULL) {
ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0,
"Office hours disabled");
ngx_http_get_module_loc_conf(r,
ngx_http_office_hours_filter_module);
-
if (conf->office_hours == NULL) {
ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0,
"Office hours disabled");
return NGX_CONF_OK;
}
-
/*
* Config Creator
* Initializes the configuration structure
*/
static char *ngx_http_office_hours_merge_conf(ngx_conf_t * cf,
- void *parent, void *child)
+ void *parent, void *child)
{
ngx_http_office_hours_conf_t *prev = parent;
ngx_uint_t i, seconds_of_day;
ngx_uint_t ** parsed_office_hours;
-
output_buffer = malloc(1024 * sizeof(char));
parsed_office_hours = parse_office_hours(conf->office_hours);
now = ngx_time();
char * padding;
padding = "";
- output_string = malloc(3 * sizeof(char));
+ output_string = malloc(4 * sizeof(char));
if (number < 10) {
padding = "0";
}
- sprintf(output_string, "%s%u", padding, number);
+ snprintf(output_string, 4, "%s%u", padding, number);
return output_string;
}