Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have some code working now (mod_auth_mysql) and just want to add one tiny thing to it.
Something that should be super easy, but I've been messing with it for a couple of hours and can't figure it out as I'm not worth a flip in C++.
The code currently supports passing parameters to it like %a for IP address and other stuff...
I Just want to add a new parameter called %t to compare what I pass to the current UNIX time.
Here are what I think is the important parts of the code and the areas I believe it would be easy to insert what I want.
Somewhere in these areas I just need to get a time(NULL) to compare the %t I want to pass to it. I just don't know how to add it...
So below is how the code is now. I just need to know how to add the new %t parameter and make it match again the current time(NULL).
*****SNIP*****
static char * format_remote_ip(request_rec * r, char ** parm);
*****SNIP*****
typedef struct { /* User formatting patterns */
char pattern; /* Pattern to match */
char * (*func)(request_rec * r, char ** parm);
} format;format formats[] = {{'h', format_remote_host},
{'a', format_remote_ip},*****SNIP*****
static char * format_remote_ip(request_rec * r, char ** parm) {
return r->connection->remote_ip;
}*****SNIP*****

In case somebody is ever interested. I had some help and got
it working. Here is the code:******* SNIP *******
static char * format_the_time(request_rec * r, char ** parm);
******* SNIP *******
typedef struct { /* User formatting patterns */
char pattern; /* Pattern to match */
char * (*func)(request_rec * r, char ** parm);
} format;format formats[] = {{'h', format_remote_host},
{'a', format_remote_ip},
{'t', format_the_time},******* SNIP *******
static char * format_the_time(request_rec * r, char ** parm) {
static char buffer[ 64 ];
unsigned int now = (unsigned int)time(NULL);
sprintf(buffer, "%u", now);
return buffer;
}******* SNIP *******

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |