diff options
Diffstat (limited to 'libcsoap/csoapurl.c')
-rw-r--r-- | libcsoap/csoapurl.c | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/libcsoap/csoapurl.c b/libcsoap/csoapurl.c deleted file mode 100644 index 6a305e1..0000000 --- a/libcsoap/csoapurl.c +++ /dev/null @@ -1,190 +0,0 @@ -/****************************************************************** - * $Id: csoapurl.c,v 1.2 2003/11/13 10:44:10 snowdrop Exp $ - * - * CSOAP Project: A SOAP client/server library in C - * Copyright (C) 2003 Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Email: ayaz@jprogrammer.net - ******************************************************************/ -#include "libcsoap/csoapurl.h" -#include "libcsoap/csoaplog.h" - -#include <stdio.h> -#include <string.h> - - -static -HSOAPURL CreateUrlFromIndex(const char* urlstr, int iprotocol, int ihost, int iport) -{ - const char *FUNC = "CreateUrlFromIndex"; - int len, size; - char tmp[8]; - HSOAPURL url; - - SoapTraceEnter(FUNC, "Entering"); - - url = (HSOAPURL)malloc(sizeof(struct SOAPURL)); - - url->m_protocol = (char*)malloc(sizeof(char)*iprotocol+1); - strncpy(url->m_protocol, urlstr, iprotocol); - - size = ihost - iprotocol - 3; - url->m_host = (char*)malloc(sizeof(char)*size); - strncpy(url->m_host, &urlstr[iprotocol+3], size); - - if (iport > ihost) - { - size = iport - ihost; - strncpy(tmp, &urlstr[ihost+1], size); - url->m_port = atoi(tmp); - } else { - url->m_port = 80; - } - - len = strlen(urlstr); - if (len > iport ) - { - size = len - iport; - url->m_context = (char*)malloc(sizeof(char)*size+1); - strncpy(url->m_context, &urlstr[iport], size); - url->m_context[size]='\0'; - } else { - url->m_context = NULL; - } - - SoapUrlDump(url); - - SoapTraceLeave(FUNC, "Leaving url(%p)", url); - return url; -}; - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlCreate -/-----------------------------------------------------------------*/ - -HSOAPURL SoapUrlCreate(const char* urlstr) -{ - const char *FUNC = "SoapUrlCreate"; - int iprotocol; - int ihost; - int iport; - int len; - HSOAPURL url = NULL; - - SoapTraceEnter(FUNC, "Entering. URL = %s", urlstr?urlstr:"null"); - - iprotocol = 0; - len = strlen(urlstr); - - /* find protocol */ - while (urlstr[iprotocol] != ':' && urlstr[iprotocol] != '\0') - { -/* printf("protocol: urlstr[%d] = %c\n",iprotocol, urlstr[iprotocol] );*/ - iprotocol++; - } - - if (iprotocol == 0) { - SoapTraceLeaveWithError(FUNC, "no protocol"); - return NULL; - } - - if (iprotocol + 3 >= len) { - SoapTraceLeaveWithError(FUNC, "no host"); - return NULL; - } - - if ( urlstr[iprotocol] != ':' - && urlstr[iprotocol+1] != '/' - && urlstr[iprotocol+2] != '/') - { - SoapTraceLeaveWithError(FUNC, "no protocol"); - return NULL; - } - - /* find host */ - ihost = iprotocol + 3; - while (urlstr[ihost] != ':' - && urlstr[ihost] != '/' - && urlstr[ihost] != '\0') - { -/* printf("host: urlstr[%d] = %c\n",ihost, urlstr[ihost] );*/ - ihost++; - } - - if (ihost == iprotocol + 1) { - SoapTraceLeaveWithError(FUNC, "no host"); - return NULL; - } - - /* find port */ - iport = ihost; - if (ihost + 1 < len) { - if (urlstr[ihost] == ':') { - while (urlstr[iport] != '/' && urlstr[iport] != '\0') { -/* printf("port: urlstr[%d] = %c\n", iport, urlstr[iport] );*/ - iport++; - } - } - } - -/* - printf("iprotocol = %d\nihost = %d\niport = %d\nlen = %d\n", - iprotocol, ihost, iport, len); -*/ - url = CreateUrlFromIndex(urlstr, iprotocol, ihost, iport); - SoapTraceLeave(FUNC, "Leaving url (%p)", url); - return url; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlFree -/-----------------------------------------------------------------*/ - -void SoapUrlFree(HSOAPURL url) -{ - if (url != NULL) { - if (url->m_protocol) free(url->m_protocol); - if (url->m_host) free(url->m_host); - if (url->m_context) free(url->m_context); - - free(url); - } -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlDump -/-----------------------------------------------------------------*/ - -void SoapUrlDump(HSOAPURL url) -{ - const char *FUNC = "SoapUrlDump"; - - if (url == NULL) { - printf("(null)\n"); - return ; - } - - SoapLog(LOG_DEBUG, FUNC, "PROTOCOL : %s\n", url->m_protocol?url->m_protocol:"(null)"); - SoapLog(LOG_DEBUG, FUNC, " HOST : %s\n", url->m_host?url->m_host:"(null)"); - SoapLog(LOG_DEBUG, FUNC, " PORT : %d\n", url->m_port); - SoapLog(LOG_DEBUG, FUNC, " CONTEXT : %s\n", url->m_context?url->m_context:"(null)"); - -} |