Ignore:
Timestamp:
Aug 31, 2001, 1:37:03 AM (24 years ago)
Author:
phaller
Message:

.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shlwapi/ordinal_odin.cpp

    r5749 r6609  
    1 /* $Id: ordinal_odin.cpp,v 1.2 2001-05-19 11:14:01 sandervl Exp $ */
     1/* $Id: ordinal_odin.cpp,v 1.3 2001-08-30 23:37:03 phaller Exp $ */
    22
    33/*
     
    9090 *****************************************************************************/
    9191
    92 ODINFUNCTION2(DWORD,SHLWAPI_1,
    93               DWORD,arg0,
    94               DWORD,arg1)
     92// return characters in protocol part
     93static INT extractProtocolFromURL(LPSTR  pszURL,
     94                                  LPSTR* ppszColon)
     95{
     96  int i = 0;  // number of characters scanned
     97  LPSTR s = pszURL;
     98
     99  *ppszColon = NULL;
     100
     101  if (*pszURL == 0)
     102    return 0;
     103
     104
     105  // scan through the string for the 1st colon
     106  while(*s)
     107  {
     108    // filter non-printable characters
     109    if (*s < ' ')
     110      return 0;
     111    else
     112      if (*s > 0x80)
     113        return 0;     
     114
     115    // Note: actually, the original code has a table with
     116    // "forbidden" characters, we don't reproduce this here yet.
     117
     118    if (*s == ':')
     119    {
     120       // yes, first colon found!
     121       if ( (pszURL[0] == 'U' || pszURL[0] == 'u') &&
     122            (pszURL[1] == 'R' || pszURL[1] == 'r') &&
     123            (pszURL[2] == 'L' || pszURL[2] == 'l') )
     124       {
     125         // restart scan!
     126         pszURL = s+1;
     127         i = 0;
     128       }
     129       else
     130       {
     131         // OK, protocol extracted
     132         *ppszColon = s;
     133         return i;
     134       }
     135    }
     136
     137    // skip to next character
     138    i++;
     139    s++;
     140  } 
     141
     142  return 0;
     143}
     144
     145typedef struct tabProtocolTableEntry
     146{
     147  LPSTR  pszName; // Note: original is unicode
     148  DWORD  ID;
     149  DWORD  dwNameLength;
     150  DWORD  dwCharacteristic;
     151} PROTOCOLTABLEENTRY, *LPPROTOCOLTABLEENTRY;
     152
     153
     154#define PROTOCOL_HTTP 2
     155#define PROTOCOL_FILE 9
     156
     157static PROTOCOLTABLEENTRY tabProtocolTable[] =
     158{
     159  { "http",        PROTOCOL_HTTP,  4, 0x0a },
     160  { "file",        PROTOCOL_FILE,  4, 0x08 },
     161  { "ftp",         1,  3, 0x0a },
     162  { "https",      11,  5, 0x0a },
     163  { "news",        5,  4, 0x0a },
     164  { "mailto",      0,  6, 0x01 },
     165  { "gopher",      3,  6, 0x0a },
     166  { "nntp",        6,  4, 0x0a },
     167  { "telnet",      7,  6, 0x0a },
     168  { "wais",        8,  4, 0x00 },
     169  { "mk",         10,  2, 0x04 },
     170  { "shell",      12,  5, 0x01 },
     171  { "local",      14,  5, 0x00 },
     172  { "javascript", 15, 10, 0x05 },
     173  { "vbscript",   16,  8, 0x05 },
     174  { "snews",      13,  5, 0x0a },
     175  { "about",      17,  5, 0x05 },
     176  { "res",        18,  3, 0x04 }
     177};
     178#define END_OF_PROTOCOLTABLE (tabProtocolTable + sizeof(tabProtocolTable))
     179
     180
     181
     182static DWORD getProtocolTableEntry(LPSTR pszProtocol, DWORD dwNameLength)
     183{
     184  LPPROTOCOLTABLEENTRY lpEntry = tabProtocolTable;
     185
     186  for(;;)
     187  {
     188    if (lpEntry->dwNameLength == dwNameLength)
     189      if (lstrncmpiA( lpEntry->pszName, pszProtocol, dwNameLength) == 0)
     190      {
     191        return lpEntry->ID;
     192      }
     193
     194    lpEntry++;
     195
     196    // if scanning beyond end of the table,
     197    // abort and return null
     198    if (lpEntry > END_OF_PROTOCOLTABLE)
     199      return 0;
     200  }
     201}
     202
     203typedef struct tagProtocolHandlerA
     204{
     205  DWORD  dwSize;
     206  DWORD  dwProtocolNameLength;
     207  LPSTR  lpszProtocolName;
     208  LPSTR  lpszURL;
     209  DWORD  dwURLNameLength;
     210  DWORD  ProtocolID;
     211} PROTOCOLHANDLERA, *LPPROTOCOLHANDLERA;
     212
     213typedef struct tagProtocolHandlerW
     214{
     215  DWORD  dwSize;
     216  DWORD  dwProtocolNameLength;
     217  LPWSTR lpszProtocolName;
     218  LPWSTR lpszURL;
     219  DWORD  dwURLNameLength;
     220  DWORD  ProtocolID;
     221} PROTOCOLHANDLERW, *LPPROTOCOLHANDLERW;
     222
     223
     224ODINFUNCTION2(DWORD,   SHLWAPI_1,
     225              LPSTR,   lpszURL,
     226              LPPROTOCOLHANDLERA, lpHandler)
    95227{
    96228  dprintf(("not implemented"));
    97229
    98   return 0;
    99 }
    100 
    101 
    102 /*****************************************************************************
    103  * Name      : ???
    104  * Purpose   : Unknown (used by explorer.exe)
    105  * Parameters: Unknown (wrong)
    106  * Variables :
    107  * Result    : Unknown
    108  * Remark    :
    109  * Status    : UNTESTED STUB
    110  *
    111  * Author    : Christoph Bratschi [Wed, 2000/03/29 19:47]
    112  *****************************************************************************/
    113 
    114 ODINFUNCTION2(DWORD,SHLWAPI_2,
    115               DWORD,arg0,
    116               DWORD,arg1)
    117 {
    118   dprintf(("not implemented"));
     230  if (NULL == lpszURL)
     231    return E_INVALIDARG;
     232
     233  if (NULL == lpHandler)
     234    return E_INVALIDARG;
     235
     236  if (lpHandler->dwSize != sizeof( PROTOCOLHANDLERA) )
     237    return E_INVALIDARG;
     238
     239  dprintf(("SHLWAPI-SHLWAPI1: URL=%s",
     240    lpszURL));
     241
     242  INT iProtocolLength = extractProtocolFromURL(lpszURL,
     243                                               &lpszURL);
     244  lpHandler->dwProtocolNameLength = iProtocolLength;
     245  if (0 == iProtocolLength)
     246    return 0x80041001; // unknown error constant
     247
     248  lpHandler->lpszProtocolName = lpszURL;
     249
     250  DWORD ID = getProtocolTableEntry(lpszURL,
     251                                                       iProtocolLength);
     252  lpHandler->ProtocolID = ID;
     253  lpHandler->lpszURL    = (LPSTR)(lpszURL + iProtocolLength + 1);
     254 
     255  if (ID == PROTOCOL_FILE)
     256  {
     257    // cut off leading slashes as required
     258    if (lpHandler->lpszURL[0] == '/' &&
     259        lpHandler->lpszURL[1] == '/')
     260      lpHandler->lpszURL = lpHandler->lpszURL + 2;
     261
     262    if (lpHandler->lpszURL[0] == '/')
     263      lpHandler->lpszURL = lpHandler->lpszURL + 1;
     264  }
     265
     266  lpHandler->dwURLNameLength = lstrlenA(lpHandler->lpszURL);
     267
     268  return NO_ERROR;
     269}
     270
     271
     272/*****************************************************************************
     273 * Name      : ParseURLIntoProtocolAndURI_W
     274 * Purpose   :
     275 * Parameters:
     276 * Variables :
     277 * Result    :
     278 * Remark    :
     279 * Status    : UNTESTED
     280 *
     281 * Author    : Patrick Haller [2001-08-30]
     282 *****************************************************************************/
     283
     284ODINFUNCTION2(DWORD,              SHLWAPI_2,
     285              LPWSTR,             lpszURL,
     286              LPPROTOCOLHANDLERW, lpHandler)
     287{
     288  dprintf(("not yet implemented"));
     289
     290  // PH: do unicode conversion, call SHLWAPI_1
    119291
    120292  return 0;
Note: See TracChangeset for help on using the changeset viewer.