38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#define URL_PROMPT_PW 0x001 /* Prompt for password if needed */
#define URL_REMEMBER 0x002 /* Remember the url for later reuse */
#define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */
#define URL_REMEMBER_PW 0x008 /* Should remember pw */
#define URL_PROMPTED 0x010 /* Prompted for PW already */
#define URL_OMIT_USER 0x020 /* Omit the user name from URL */
#define URL_USE_CONFIG 0x040 /* Use remembered URLs from CONFIG table */
/*
** The URL related data used with this subsystem.
*/
struct UrlData {
int isFile; /* True if a "file:" url */
int isHttps; /* True if a "https:" url */
|
>
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#define URL_PROMPT_PW 0x001 /* Prompt for password if needed */
#define URL_REMEMBER 0x002 /* Remember the url for later reuse */
#define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */
#define URL_REMEMBER_PW 0x008 /* Should remember pw */
#define URL_PROMPTED 0x010 /* Prompted for PW already */
#define URL_OMIT_USER 0x020 /* Omit the user name from URL */
#define URL_USE_CONFIG 0x040 /* Use remembered URLs from CONFIG table */
#define URL_USE_PARENT 0x080 /* Use the URL of the parent project */
/*
** The URL related data used with this subsystem.
*/
struct UrlData {
int isFile; /* True if a "file:" url */
int isHttps; /* True if a "https:" url */
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
** dfltPort Default TCP port number (80 or 443).
** path Path name for HTTP or HTTPS.
** user Userid.
** passwd Password.
** hostname HOST:PORT or just HOST if port is the default.
** canonical The URL in canonical form, omitting the password
**
** If zUrl==0, then parse the URL store in last-sync-url and last-sync-pw
** of the CONFIG table. Or if zUrl is a symbolic name, look up the URL
** in sync-url:%Q and sync-pw:%Q elements of the CONFIG table. But only
** use the CONFIG table alternatives if the URL_FROM_CONFIG flag is set.
**
** This routine differs from url_parse() in that this routine stores the
** results in pUrlData and does not change the values of global variables.
** The url_parse() routine puts its result in g.url.
*/
void url_parse_local(
const char *zUrl,
unsigned int urlFlags,
UrlData *pUrlData
){
int i, j, c;
char *zFile = 0;
if( urlFlags & URL_USE_CONFIG ){
if( zUrl==0 || strcmp(zUrl,"default")==0 ){
zUrl = db_get("last-sync-url", 0);
if( zUrl==0 ) return;
if( pUrlData->passwd==0 ){
pUrlData->passwd = unobscure(db_get("last-sync-pw", 0));
}
pUrlData->isAlias = 1;
}else{
char *zKey = sqlite3_mprintf("sync-url:%q", zUrl);
char *zAlt = db_get(zKey, 0);
sqlite3_free(zKey);
if( zAlt ){
|
>
|
>
>
>
>
|
|
<
>
>
>
>
>
>
>
>
>
>
|
>
|
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
** dfltPort Default TCP port number (80 or 443).
** path Path name for HTTP or HTTPS.
** user Userid.
** passwd Password.
** hostname HOST:PORT or just HOST if port is the default.
** canonical The URL in canonical form, omitting the password
**
** If zUrl==0 and URL_USE_CONFIG is set, then parse the URL stored
** in last-sync-url and last-sync-pw of the CONFIG table. Or if
** URL_USE_PARENT is also set, then use parent-project-url and
** parent-project-pw from the CONFIG table instead of last-sync-url
** and last-sync-pw.
**
** If zUrl is a symbolic name and URL_USE_CONFIG is true, then look up
** the URL in sync-url:%Q and sync-pw:%Q elements of the CONFIG table where
** %Q is the symbolic name.
**
** This routine differs from url_parse() in that this routine stores the
** results in pUrlData and does not change the values of global variables.
** The url_parse() routine puts its result in g.url.
*/
void url_parse_local(
const char *zUrl,
unsigned int urlFlags,
UrlData *pUrlData
){
int i, j, c;
char *zFile = 0;
if( urlFlags & URL_USE_CONFIG ){
if( zUrl==0 || strcmp(zUrl,"default")==0 ){
const char *zPwConfig = "last-sync-pw";
if( urlFlags & URL_USE_PARENT ){
zUrl = db_get("parent-project-url", 0);
if( zUrl==0 ){
zUrl = db_get("last-sync-url",0);
}else{
zPwConfig = "parent-project-pw";
}
}else{
zUrl = db_get("last-sync-url", 0);
}
if( zUrl==0 ) return;
if( pUrlData->passwd==0 ){
pUrlData->passwd = unobscure(db_get(zPwConfig, 0));
}
pUrlData->isAlias = 1;
}else{
char *zKey = sqlite3_mprintf("sync-url:%q", zUrl);
char *zAlt = db_get(zKey, 0);
sqlite3_free(zKey);
if( zAlt ){
|
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
|
}
/*
** Remember the URL and password if requested.
*/
void url_remember(void){
if( g.url.flags & URL_REMEMBER ){
db_set("last-sync-url", g.url.canonical, 0);
if( g.url.user!=0 && g.url.passwd!=0 && ( g.url.flags & URL_REMEMBER_PW ) ){
db_set("last-sync-pw", obscure(g.url.passwd), 0);
}
}
}
/* Preemptively prompt for a password if a username is given in the
** URL but no password.
*/
|
>
>
>
|
>
>
>
>
|
>
|
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
|
}
/*
** Remember the URL and password if requested.
*/
void url_remember(void){
if( g.url.flags & URL_REMEMBER ){
if( g.url.flags & URL_USE_PARENT ){
db_set("parent-project-url", g.url.canonical, 0);
}else{
db_set("last-sync-url", g.url.canonical, 0);
}
if( g.url.user!=0 && g.url.passwd!=0 && ( g.url.flags & URL_REMEMBER_PW ) ){
if( g.url.flags & URL_USE_PARENT ){
db_set("parent-project-pw", obscure(g.url.passwd), 0);
}else{
db_set("last-sync-pw", obscure(g.url.passwd), 0);
}
}
}
}
/* Preemptively prompt for a password if a username is given in the
** URL but no password.
*/
|