[Mod-auth-commit] mod_authn_cache/src mod_authn_cache.c,1.5,1.6
Brought to you by:
firechipmunk,
honx
From: <fir...@us...> - 2004-01-02 23:51:07
|
Update of /cvsroot/mod-auth/mod_authn_cache/src In directory sc8-pr-cvs1:/tmp/cvs-serv22469 Modified Files: mod_authn_cache.c Log Message: does basic connects. need to write parsing code for memcached. this is why the world invented high level languages. string manipulation still sucks in c :) Index: mod_authn_cache.c =================================================================== RCS file: /cvsroot/mod-auth/mod_authn_cache/src/mod_authn_cache.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mod_authn_cache.c 2 Jan 2004 22:59:41 -0000 1.5 --- mod_authn_cache.c 2 Jan 2004 23:51:02 -0000 1.6 *************** *** 157,161 **** #define RECVLEN 512 ! static apr_status_t getLine(request_rec * r, mcd_res_t* mcd, char *str, apr_size_t count) { apr_status_t rv = APR_SUCCESS; apr_size_t recvlen; --- 157,161 ---- #define RECVLEN 512 ! static apr_status_t getLine(request_rec * r, mcd_res_t* mcd, char **str, apr_size_t count) { apr_status_t rv = APR_SUCCESS; apr_size_t recvlen; *************** *** 180,191 **** if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "getLine: apr_socket_recv"); return rv; } recv[recvlen] = 0; if(recvlen+recv_total > count) { // line is too big. recv[(recvlen+recv_total) - count] = 0; ! str = apr_pstrcat(r->pool, mcd->line_buff, recv, NULL); break; --- 180,199 ---- if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "getLine: apr_socket_recv"); + if(mcd->line_buff_size > 0) { + *str = apr_pstrcat(r->pool, mcd->line_buff, NULL); + } + else { + *str = NULL; + } + return rv; } recv[recvlen] = 0; + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "getline: read-> '%s'", recv); if(recvlen+recv_total > count) { // line is too big. recv[(recvlen+recv_total) - count] = 0; ! *str = apr_pstrcat(r->pool, mcd->line_buff, recv, NULL); break; *************** *** 204,208 **** *s++; // \r *s = 0; // terminate on the \n ! str = apr_pstrcat(r->pool, mcd->line_buff, recv, NULL); // do we have an extra string left over? if( (recvlen-2) > strlen(recv) ) { --- 212,216 ---- *s++; // \r *s = 0; // terminate on the \n ! *str = apr_pstrcat(r->pool, mcd->line_buff, recv, NULL); // do we have an extra string left over? if( (recvlen-2) > strlen(recv) ) { *************** *** 224,231 **** } ! static apr_status_t mcd_get(request_rec * r, mcd_res_t* mcd, const char* key, char* value) { apr_status_t rv = APR_SUCCESS; apr_size_t sendlen; char *command; command = apr_psprintf(r->pool, "get %s\r\n", key); --- 232,241 ---- } ! static apr_status_t mcd_get(request_rec * r, mcd_res_t* mcd, const char* key, char** value) { apr_status_t rv = APR_SUCCESS; apr_size_t sendlen; + apr_size_t recvlen; char *command; + char *s = NULL; command = apr_psprintf(r->pool, "get %s\r\n", key); *************** *** 237,241 **** return rv; } ! getLine(r, mcd, command, 5000); return rv; --- 247,272 ---- return rv; } ! getLine(r, mcd, &command, 5000); ! ! s = strstr("VALUE", command); ! if (*s != NULL) { ! // VALUE foo 0 5 ! char *pstr; ! char *tok_cntx; ! pstr = command; ! pstr = apr_strtok(pstr, " ", &tok_cntx); // value ! pstr = apr_strtok(pstr, " ", &tok_cntx); // key ! pstr = apr_strtok(pstr, " ", &tok_cntx); // flags ! pstr = apr_strtok(pstr, " ", &tok_cntx); // len ! // recvlen = ! } ! else { ! s = strstr("END", command); ! if (*s != NULL) { ! *value = NULL; ! } ! } ! ! ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "mcd_get: got line: '%s'", command); return rv; *************** *** 255,259 **** return rv; } ! getLine(r, mcd, command, 5000); return rv; --- 286,290 ---- return rv; } ! getLine(r, mcd, &command, 5000); return rv; *************** *** 356,360 **** apr_reslist_acquire(reslist_pool, (void **) &mcd); ! mcd_get(r, mcd, "foo", foo); do { --- 387,391 ---- apr_reslist_acquire(reslist_pool, (void **) &mcd); ! mcd_get(r, mcd, "foo", &foo); do { *************** *** 401,404 **** --- 432,438 ---- "NOT adding user(but auth good?): %s to cache for realm: %s!",user,ap_auth_name(r)); } + + mcd->line_buff_size = 0; + apr_reslist_release(reslist_pool, (void **) mcd); return auth_result; |