]> granicus.if.org Git - apache/commitdiff
cleanup handle_flastmod function
authorAndré Malo <nd@apache.org>
Fri, 22 Aug 2003 21:16:14 +0000 (21:16 +0000)
committerAndré Malo <nd@apache.org>
Fri, 22 Aug 2003 21:16:14 +0000 (21:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101063 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_include.c

index 585c55df72e0177fbed9665e09af16a3cc4a25fb..dd287b315343806b823bb1abc9835813776a3240 100644 (file)
@@ -2054,41 +2054,59 @@ static apr_status_t handle_fsize(include_ctx_t *ctx, ap_filter_t *f,
     return APR_SUCCESS;
 }
 
+/*
+ * <!--#flastmod virtual|file="..." [virtual|file="..."] ... -->
+ */
 static apr_status_t handle_flastmod(include_ctx_t *ctx, ap_filter_t *f,
                                     apr_bucket_brigade *bb)
 {
-    char *tag     = NULL;
-    char *tag_val = NULL;
-    apr_finfo_t  finfo;
-    apr_size_t  t_len;
-    apr_bucket   *tmp_buck;
-    char *parsed_string;
     request_rec *r = f->r;
 
-    if (ctx->flags & SSI_FLAG_PRINTING) {
-        while (1) {
-            ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
-            if (!tag || !tag_val) {
-                return APR_SUCCESS;
-            }
-            else {
-                parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL, 
-                                                    MAX_STRING_LEN,
-                                                    SSI_EXPAND_DROP_NAME);
-                if (!find_file(r, "flastmod", tag, parsed_string, &finfo)) {
-                    char *t_val;
+    if (!ctx->argc) {
+        ap_log_rerror(APLOG_MARK,
+                      (ctx->flags & SSI_FLAG_PRINTING)
+                          ? APLOG_ERR : APLOG_WARNING,
+                      0, r, "missing argument for flastmod element in %s",
+                      r->filename);
+    }
 
-                    t_val = ap_ht_time(r->pool, finfo.mtime, ctx->time_str, 0);
-                    t_len = strlen(t_val);
+    if (!(ctx->flags & SSI_FLAG_PRINTING)) {
+        return APR_SUCCESS;
+    }
 
-                    tmp_buck = apr_bucket_pool_create(t_val, t_len, r->pool,
-                                                  r->connection->bucket_alloc);
-                    APR_BRIGADE_INSERT_TAIL(bb, tmp_buck);
-                }
-                else {
-                    SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
-                }
-            }
+    if (!ctx->argc) {
+        SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+        return APR_SUCCESS;
+    }
+
+    while (1) {
+        char *tag     = NULL;
+        char *tag_val = NULL;
+        apr_finfo_t  finfo;
+        char *parsed_string;
+
+        ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
+        if (!tag || !tag_val) {
+            break;
+        }
+
+        parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL,
+                                            MAX_STRING_LEN,
+                                            SSI_EXPAND_DROP_NAME);
+
+        if (!find_file(r, "flastmod", tag, parsed_string, &finfo)) {
+            char *t_val;
+            apr_size_t t_len;
+
+            t_val = ap_ht_time(ctx->pool, finfo.mtime, ctx->time_str, 0);
+            t_len = strlen(t_val);
+
+            APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(t_val, t_len,
+                                    ctx->pool, f->c->bucket_alloc));
+        }
+        else {
+            SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+            break;
         }
     }