From ea5bff2d6a80e3d1630e3d09b27eeb8626c7df62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kou=C5=99il?= Date: Thu, 2 Jul 2009 14:48:39 +0000 Subject: [PATCH] Added edg_wll_gss_unread() to unget already received data back to the buffer so it could be read again by next caller --- org.glite.security.gss/interface/glite_gss.h | 5 +++++ org.glite.security.gss/src/glite_gss.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/org.glite.security.gss/interface/glite_gss.h b/org.glite.security.gss/interface/glite_gss.h index ae3971c..4a41cfa 100644 --- a/org.glite.security.gss/interface/glite_gss.h +++ b/org.glite.security.gss/interface/glite_gss.h @@ -155,6 +155,11 @@ int edg_wll_gss_equal_subj(const char *a, const char *b); +int +edg_wll_gss_unread(edg_wll_GssConnection *connection, + void *data, + size_t len); + #ifdef __cplusplus } diff --git a/org.glite.security.gss/src/glite_gss.c b/org.glite.security.gss/src/glite_gss.c index 61ce138..5474767 100644 --- a/org.glite.security.gss/src/glite_gss.c +++ b/org.glite.security.gss/src/glite_gss.c @@ -1459,3 +1459,26 @@ edg_wll_gss_equal_subj(const char *a, const char *b) free(an); free(bn); return res; } + +int +edg_wll_gss_unread(edg_wll_GssConnection *con, void *data, size_t len) +{ + char *tmp; + + if (len == 0) + return 0; + + tmp = malloc(len + con->bufsize); + if (tmp == NULL) + return ENOMEM; + + memcpy(tmp, data, len); + if (con->bufsize > 0) + memcpy(tmp + len, con->buffer, con->bufsize); + + free(con->buffer); + con->buffer = tmp; + con->bufsize += len; + + return 0; +} -- 1.8.2.3