httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drew Bertola <>
Subject splitting a string...
Date Sun, 31 Dec 2006 02:55:04 GMT
Happy New Year, everyone.

I need some quick help with handling my content in an output filter.

I'd like to know how I can get the portion of client content before the
<head> tag (if it exists), and the portion after it.  That way, I can
insert something just after the <head> tag (adult content warnings, etc).

I seem to get stuck right after finding the position of the head tag.  I
can send on the tail end, but don't know how to capture the beginning

      apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ);

      if ( ( position = strcasestr(str, search_tag) ) == NULL )
           * If we didn't find the <head> tag, just pass along
           * everything to the next filter and we're done.
          ap_fputs(f->next, ctx->bb, str);
           * so, we have a <head> tag.  So, lets find and process it
           * and insert our notice.

          tail = position + 6;

          head = ???  <<<<<<<<< Here's where I'm stuck...
          ap_fputs(f->next, ctx->bb, "<!-- start test -->\n");

            ap_fputs(f->next, ctx->bb, head);
          ap_fputs(f->next, ctx->bb, "<html>\n<head>\n<meta />\n");
          ap_fputs(f->next, ctx->bb, "<!-- after head, before tail -->\n");
          ap_fputs(f->next, ctx->bb, tail);
          ap_fputs(f->next, ctx->bb, "<!-- end test -->\n");

  return APR_SUCCESS;

There's much more to code to make this thing work right, but this is my
first hurdle.
Please point out any other major idiotic mistakes I'm making.


View raw message