| | @@ -39,10 +39,11 @@ |
| 39 | 39 | #define URL_REMEMBER 0x002 /* Remember the url for later reuse */ |
| 40 | 40 | #define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */ |
| 41 | 41 | #define URL_REMEMBER_PW 0x008 /* Should remember pw */ |
| 42 | 42 | #define URL_PROMPTED 0x010 /* Prompted for PW already */ |
| 43 | 43 | #define URL_OMIT_USER 0x020 /* Omit the user name from URL */ |
| 44 | +#define URL_USE_CONFIG 0x040 /* Use remembered URLs from CONFIG table */ |
| 44 | 45 | |
| 45 | 46 | /* |
| 46 | 47 | ** The URL related data used with this subsystem. |
| 47 | 48 | */ |
| 48 | 49 | struct UrlData { |
| | @@ -68,14 +69,12 @@ |
| 68 | 69 | }; |
| 69 | 70 | #endif /* INTERFACE */ |
| 70 | 71 | |
| 71 | 72 | |
| 72 | 73 | /* |
| 73 | | -** Parse the given URL. Or if zUrl is NULL, parse the URL in the |
| 74 | | -** last-sync-url setting using last-sync-pw as the password. Store |
| 75 | | -** the parser results in the pUrlData object. Populate members of pUrlData |
| 76 | | -** as follows: |
| 74 | +** Parse the URL in the zUrl argument. Store results in the pUrlData object. |
| 75 | +** Populate members of pUrlData as follows: |
| 77 | 76 | ** |
| 78 | 77 | ** isFile True if FILE: |
| 79 | 78 | ** isHttps True if HTTPS: |
| 80 | 79 | ** isSsh True if SSH: |
| 81 | 80 | ** protocol "http" or "https" or "file" or "ssh" |
| | @@ -86,10 +85,15 @@ |
| 86 | 85 | ** user Userid. |
| 87 | 86 | ** passwd Password. |
| 88 | 87 | ** hostname HOST:PORT or just HOST if port is the default. |
| 89 | 88 | ** canonical The URL in canonical form, omitting the password |
| 90 | 89 | ** |
| 90 | +** If zUrl==0, then parse the URL store in last-sync-url and last-sync-pw |
| 91 | +** of the CONFIG table. Or if zUrl is a symbolic name, look up the URL |
| 92 | +** in sync-url:%Q and sync-pw:%Q elements of the CONFIG table. But only |
| 93 | +** use the CONFIG table alternatives if the URL_FROM_CONFIG flag is set. |
| 94 | +** |
| 91 | 95 | ** This routine differs from url_parse() in that this routine stores the |
| 92 | 96 | ** results in pUrlData and does not change the values of global variables. |
| 93 | 97 | ** The url_parse() routine puts its result in g.url. |
| 94 | 98 | */ |
| 95 | 99 | void url_parse_local( |
| | @@ -98,31 +102,35 @@ |
| 98 | 102 | UrlData *pUrlData |
| 99 | 103 | ){ |
| 100 | 104 | int i, j, c; |
| 101 | 105 | char *zFile = 0; |
| 102 | 106 | |
| 103 | | - if( zUrl==0 || strcmp(zUrl,"default")==0 ){ |
| 104 | | - zUrl = db_get("last-sync-url", 0); |
| 105 | | - if( zUrl==0 ) return; |
| 106 | | - if( pUrlData->passwd==0 ){ |
| 107 | | - pUrlData->passwd = unobscure(db_get("last-sync-pw", 0)); |
| 108 | | - } |
| 109 | | - pUrlData->isAlias = 1; |
| 110 | | - }else{ |
| 111 | | - char *zKey = sqlite3_mprintf("sync-url:%q", zUrl); |
| 112 | | - char *zAlt = db_get(zKey, 0); |
| 113 | | - sqlite3_free(zKey); |
| 114 | | - if( zAlt ){ |
| 115 | | - pUrlData->passwd = unobscure( |
| 116 | | - db_text(0, "SELECT value FROM config WHERE name='sync-pw:%q'",zUrl) |
| 117 | | - ); |
| 118 | | - zUrl = zAlt; |
| 119 | | - urlFlags |= URL_REMEMBER_PW; |
| 120 | | - pUrlData->isAlias = 1; |
| 121 | | - }else{ |
| 122 | | - pUrlData->isAlias = 0; |
| 123 | | - } |
| 107 | + if( urlFlags & URL_USE_CONFIG ){ |
| 108 | + if( zUrl==0 || strcmp(zUrl,"default")==0 ){ |
| 109 | + zUrl = db_get("last-sync-url", 0); |
| 110 | + if( zUrl==0 ) return; |
| 111 | + if( pUrlData->passwd==0 ){ |
| 112 | + pUrlData->passwd = unobscure(db_get("last-sync-pw", 0)); |
| 113 | + } |
| 114 | + pUrlData->isAlias = 1; |
| 115 | + }else{ |
| 116 | + char *zKey = sqlite3_mprintf("sync-url:%q", zUrl); |
| 117 | + char *zAlt = db_get(zKey, 0); |
| 118 | + sqlite3_free(zKey); |
| 119 | + if( zAlt ){ |
| 120 | + pUrlData->passwd = unobscure( |
| 121 | + db_text(0, "SELECT value FROM config WHERE name='sync-pw:%q'",zUrl) |
| 122 | + ); |
| 123 | + zUrl = zAlt; |
| 124 | + urlFlags |= URL_REMEMBER_PW; |
| 125 | + pUrlData->isAlias = 1; |
| 126 | + }else{ |
| 127 | + pUrlData->isAlias = 0; |
| 128 | + } |
| 129 | + } |
| 130 | + }else{ |
| 131 | + if( zUrl==0 ) return; |
| 124 | 132 | } |
| 125 | 133 | |
| 126 | 134 | if( strncmp(zUrl, "http://", 7)==0 |
| 127 | 135 | || strncmp(zUrl, "https://", 8)==0 |
| 128 | 136 | || strncmp(zUrl, "ssh://", 6)==0 |
| 129 | 137 | |