src/lib/udc.c 1.30
1.30 2009/11/20 17:45:32 angie
Added udcParseUrlFull, which returns http auth portion instead of silently skipping it.
Index: src/lib/udc.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/udc.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -b -B -U 4 -r1.29 -r1.30
--- src/lib/udc.c 19 Nov 2009 19:11:18 -0000 1.29
+++ src/lib/udc.c 20 Nov 2009 17:45:32 -0000 1.30
@@ -633,12 +633,13 @@
}
return output;
}
-void udcParseUrl(char *url, char **retProtocol, char **retAfterProtocol, char **retColon)
+void udcParseUrlFull(char *url, char **retProtocol, char **retAfterProtocol, char **retColon,
+ char **retAuth)
/* Parse the URL into components that udc treats separately.
* *retAfterProtocol is Q-encoded to keep special chars out of filenames.
- * Free *retProtocol and *retAfterProtocol but not *retColon when done. */
+ * Free all *ret's except *retColon when done. */
{
char *protocol, *afterProtocol;
char *colon = strchr(url, ':');
if (!colon)
@@ -653,22 +654,38 @@
afterProtocol += 1;
char *userPwd = strchr(afterProtocol, '@');
if (userPwd)
{
+ if (retAuth)
+ {
+ char auth[1024];
+ safencpy(auth, sizeof(auth), afterProtocol, userPwd+1-afterProtocol);
+ *retAuth = qEncode(auth);
+ }
char *afterHost = strchr(afterProtocol, '/');
if (!afterHost)
{
afterHost = afterProtocol+strlen(afterProtocol);
}
if (userPwd < afterHost)
afterProtocol = userPwd + 1;
}
+else if (retAuth)
+ *retAuth = NULL;
afterProtocol = qEncode(afterProtocol);
*retProtocol = protocol;
*retAfterProtocol = afterProtocol;
*retColon = colon;
}
+void udcParseUrl(char *url, char **retProtocol, char **retAfterProtocol, char **retColon)
+/* Parse the URL into components that udc treats separately.
+ * *retAfterProtocol is Q-encoded to keep special chars out of filenames.
+ * Free *retProtocol and *retAfterProtocol but not *retColon when done. */
+{
+udcParseUrlFull(url, retProtocol, retAfterProtocol, retColon, NULL);
+}
+
void udcPathAndFileNames(struct udcFile *file, char *cacheDir, char *protocol, char *afterProtocol)
/* Initialize udcFile path and names */
{
int len = strlen(cacheDir) + 1 + strlen(protocol) + 1 + strlen(afterProtocol) + 1;