Fossil SCM
modified fix for [c8c0b78c84], which no longer causes "Usage" printouts to use the full fossil path, even though the command line didn't use the full path
Commit
dacc6946157383da12b3cf650eea6a3e671b3a64
Parent
1ef58e524675c7a…
8 files changed
+1
-1
+7
-7
+15
-15
+17
-17
+1
-1
+20
-20
+5
-9
+2
-2
+1
-1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -147,11 +147,11 @@ | ||
| 147 | 147 | }else{ |
| 148 | 148 | fossil_fatal("\"all\" subcommand should be one of: " |
| 149 | 149 | "changes ignore list ls push pull rebuild sync"); |
| 150 | 150 | } |
| 151 | 151 | verify_all_options(); |
| 152 | - zFossil = quoteFilename(fossil_nameofexe()); | |
| 152 | + zFossil = quoteFilename(g.nameOfExe); | |
| 153 | 153 | if( useCheckouts ){ |
| 154 | 154 | db_prepare(&q, |
| 155 | 155 | "SELECT substr(name, 7) COLLATE nocase, max(rowid)" |
| 156 | 156 | " FROM global_config" |
| 157 | 157 | " WHERE substr(name, 1, 6)=='ckout:'" |
| 158 | 158 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -147,11 +147,11 @@ | |
| 147 | }else{ |
| 148 | fossil_fatal("\"all\" subcommand should be one of: " |
| 149 | "changes ignore list ls push pull rebuild sync"); |
| 150 | } |
| 151 | verify_all_options(); |
| 152 | zFossil = quoteFilename(fossil_nameofexe()); |
| 153 | if( useCheckouts ){ |
| 154 | db_prepare(&q, |
| 155 | "SELECT substr(name, 7) COLLATE nocase, max(rowid)" |
| 156 | " FROM global_config" |
| 157 | " WHERE substr(name, 1, 6)=='ckout:'" |
| 158 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -147,11 +147,11 @@ | |
| 147 | }else{ |
| 148 | fossil_fatal("\"all\" subcommand should be one of: " |
| 149 | "changes ignore list ls push pull rebuild sync"); |
| 150 | } |
| 151 | verify_all_options(); |
| 152 | zFossil = quoteFilename(g.nameOfExe); |
| 153 | if( useCheckouts ){ |
| 154 | db_prepare(&q, |
| 155 | "SELECT substr(name, 7) COLLATE nocase, max(rowid)" |
| 156 | " FROM global_config" |
| 157 | " WHERE substr(name, 1, 6)=='ckout:'" |
| 158 |
+7
-7
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -40,23 +40,23 @@ | ||
| 40 | 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | 44 | int isPrivate = 0; /* True if the branch should be private */ |
| 45 | - | |
| 45 | + | |
| 46 | 46 | noSign = find_option("nosign","",0)!=0; |
| 47 | 47 | zColor = find_option("bgcolor","c",1); |
| 48 | 48 | isPrivate = find_option("private",0,0)!=0; |
| 49 | 49 | zDateOvrd = find_option("date-override",0,1); |
| 50 | 50 | zUserOvrd = find_option("user-override",0,1); |
| 51 | 51 | verify_all_options(); |
| 52 | 52 | if( g.argc<5 ){ |
| 53 | 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | 54 | } |
| 55 | - db_find_and_open_repository(0, 0); | |
| 55 | + db_find_and_open_repository(0, 0); | |
| 56 | 56 | noSign = db_get_int("omitsign", 0)|noSign; |
| 57 | - | |
| 57 | + | |
| 58 | 58 | /* fossil branch new name */ |
| 59 | 59 | zBranch = g.argv[3]; |
| 60 | 60 | if( zBranch==0 || zBranch[0]==0 ){ |
| 61 | 61 | fossil_panic("branch name cannot be empty"); |
| 62 | 62 | } |
| @@ -132,11 +132,11 @@ | ||
| 132 | 132 | while( db_step(&q)==SQLITE_ROW ){ |
| 133 | 133 | const char *zTag = db_column_text(&q, 0); |
| 134 | 134 | blob_appendf(&branch, "T -%F *\n", zTag); |
| 135 | 135 | } |
| 136 | 136 | db_finalize(&q); |
| 137 | - | |
| 137 | + | |
| 138 | 138 | blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 139 | 139 | md5sum_blob(&branch, &mcksum); |
| 140 | 140 | blob_appendf(&branch, "Z %b\n", &mcksum); |
| 141 | 141 | if( !noSign && clearsign(&branch, &branch) ){ |
| 142 | 142 | Blob ans; |
| @@ -165,18 +165,18 @@ | ||
| 165 | 165 | "\n" |
| 166 | 166 | "Note: the local check-out has not been updated to the new\n" |
| 167 | 167 | " branch. To begin working on the new branch, do this:\n" |
| 168 | 168 | "\n" |
| 169 | 169 | " %s update %s\n", |
| 170 | - fossil_nameofexe(), zBranch | |
| 170 | + g.argv[0], zBranch | |
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | /* Commit */ |
| 176 | 176 | db_end_transaction(0); |
| 177 | - | |
| 177 | + | |
| 178 | 178 | /* Do an autosync push, if requested */ |
| 179 | 179 | if( !isPrivate ) autosync(AUTOSYNC_PUSH); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /* |
| @@ -381,11 +381,11 @@ | ||
| 381 | 381 | ** to the end of the line. |
| 382 | 382 | */ |
| 383 | 383 | static void brtimeline_extra(int rid){ |
| 384 | 384 | Stmt q; |
| 385 | 385 | if( !g.perm.Hyperlink ) return; |
| 386 | - db_prepare(&q, | |
| 386 | + db_prepare(&q, | |
| 387 | 387 | "SELECT substr(tagname,5) FROM tagxref, tag" |
| 388 | 388 | " WHERE tagxref.rid=%d" |
| 389 | 389 | " AND tagxref.tagid=tag.tagid" |
| 390 | 390 | " AND tagxref.tagtype>0" |
| 391 | 391 | " AND tag.tagname GLOB 'sym-*'", |
| 392 | 392 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -40,23 +40,23 @@ | |
| 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | int isPrivate = 0; /* True if the branch should be private */ |
| 45 | |
| 46 | noSign = find_option("nosign","",0)!=0; |
| 47 | zColor = find_option("bgcolor","c",1); |
| 48 | isPrivate = find_option("private",0,0)!=0; |
| 49 | zDateOvrd = find_option("date-override",0,1); |
| 50 | zUserOvrd = find_option("user-override",0,1); |
| 51 | verify_all_options(); |
| 52 | if( g.argc<5 ){ |
| 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | } |
| 55 | db_find_and_open_repository(0, 0); |
| 56 | noSign = db_get_int("omitsign", 0)|noSign; |
| 57 | |
| 58 | /* fossil branch new name */ |
| 59 | zBranch = g.argv[3]; |
| 60 | if( zBranch==0 || zBranch[0]==0 ){ |
| 61 | fossil_panic("branch name cannot be empty"); |
| 62 | } |
| @@ -132,11 +132,11 @@ | |
| 132 | while( db_step(&q)==SQLITE_ROW ){ |
| 133 | const char *zTag = db_column_text(&q, 0); |
| 134 | blob_appendf(&branch, "T -%F *\n", zTag); |
| 135 | } |
| 136 | db_finalize(&q); |
| 137 | |
| 138 | blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 139 | md5sum_blob(&branch, &mcksum); |
| 140 | blob_appendf(&branch, "Z %b\n", &mcksum); |
| 141 | if( !noSign && clearsign(&branch, &branch) ){ |
| 142 | Blob ans; |
| @@ -165,18 +165,18 @@ | |
| 165 | "\n" |
| 166 | "Note: the local check-out has not been updated to the new\n" |
| 167 | " branch. To begin working on the new branch, do this:\n" |
| 168 | "\n" |
| 169 | " %s update %s\n", |
| 170 | fossil_nameofexe(), zBranch |
| 171 | ); |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* Commit */ |
| 176 | db_end_transaction(0); |
| 177 | |
| 178 | /* Do an autosync push, if requested */ |
| 179 | if( !isPrivate ) autosync(AUTOSYNC_PUSH); |
| 180 | } |
| 181 | |
| 182 | /* |
| @@ -381,11 +381,11 @@ | |
| 381 | ** to the end of the line. |
| 382 | */ |
| 383 | static void brtimeline_extra(int rid){ |
| 384 | Stmt q; |
| 385 | if( !g.perm.Hyperlink ) return; |
| 386 | db_prepare(&q, |
| 387 | "SELECT substr(tagname,5) FROM tagxref, tag" |
| 388 | " WHERE tagxref.rid=%d" |
| 389 | " AND tagxref.tagid=tag.tagid" |
| 390 | " AND tagxref.tagtype>0" |
| 391 | " AND tag.tagname GLOB 'sym-*'", |
| 392 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -40,23 +40,23 @@ | |
| 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | int isPrivate = 0; /* True if the branch should be private */ |
| 45 | |
| 46 | noSign = find_option("nosign","",0)!=0; |
| 47 | zColor = find_option("bgcolor","c",1); |
| 48 | isPrivate = find_option("private",0,0)!=0; |
| 49 | zDateOvrd = find_option("date-override",0,1); |
| 50 | zUserOvrd = find_option("user-override",0,1); |
| 51 | verify_all_options(); |
| 52 | if( g.argc<5 ){ |
| 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | } |
| 55 | db_find_and_open_repository(0, 0); |
| 56 | noSign = db_get_int("omitsign", 0)|noSign; |
| 57 | |
| 58 | /* fossil branch new name */ |
| 59 | zBranch = g.argv[3]; |
| 60 | if( zBranch==0 || zBranch[0]==0 ){ |
| 61 | fossil_panic("branch name cannot be empty"); |
| 62 | } |
| @@ -132,11 +132,11 @@ | |
| 132 | while( db_step(&q)==SQLITE_ROW ){ |
| 133 | const char *zTag = db_column_text(&q, 0); |
| 134 | blob_appendf(&branch, "T -%F *\n", zTag); |
| 135 | } |
| 136 | db_finalize(&q); |
| 137 | |
| 138 | blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 139 | md5sum_blob(&branch, &mcksum); |
| 140 | blob_appendf(&branch, "Z %b\n", &mcksum); |
| 141 | if( !noSign && clearsign(&branch, &branch) ){ |
| 142 | Blob ans; |
| @@ -165,18 +165,18 @@ | |
| 165 | "\n" |
| 166 | "Note: the local check-out has not been updated to the new\n" |
| 167 | " branch. To begin working on the new branch, do this:\n" |
| 168 | "\n" |
| 169 | " %s update %s\n", |
| 170 | g.argv[0], zBranch |
| 171 | ); |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* Commit */ |
| 176 | db_end_transaction(0); |
| 177 | |
| 178 | /* Do an autosync push, if requested */ |
| 179 | if( !isPrivate ) autosync(AUTOSYNC_PUSH); |
| 180 | } |
| 181 | |
| 182 | /* |
| @@ -381,11 +381,11 @@ | |
| 381 | ** to the end of the line. |
| 382 | */ |
| 383 | static void brtimeline_extra(int rid){ |
| 384 | Stmt q; |
| 385 | if( !g.perm.Hyperlink ) return; |
| 386 | db_prepare(&q, |
| 387 | "SELECT substr(tagname,5) FROM tagxref, tag" |
| 388 | " WHERE tagxref.rid=%d" |
| 389 | " AND tagxref.tagid=tag.tagid" |
| 390 | " AND tagxref.tagtype>0" |
| 391 | " AND tag.tagname GLOB 'sym-*'", |
| 392 |
+15
-15
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -66,11 +66,11 @@ | ||
| 66 | 66 | }; |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | 70 | ** The following is a list of settings that we are willing to |
| 71 | -** transfer. | |
| 71 | +** transfer. | |
| 72 | 72 | ** |
| 73 | 73 | ** Setting names that begin with an alphabetic characters refer to |
| 74 | 74 | ** single entries in the CONFIG table. Setting names that begin with |
| 75 | 75 | ** "@" are for special processing. |
| 76 | 76 | */ |
| @@ -222,28 +222,28 @@ | ||
| 222 | 222 | void configure_render_special_name(const char *zName, Blob *pOut){ |
| 223 | 223 | Stmt q; |
| 224 | 224 | if( fossil_strcmp(zName, "@shun")==0 ){ |
| 225 | 225 | db_prepare(&q, "SELECT uuid FROM shun"); |
| 226 | 226 | while( db_step(&q)==SQLITE_ROW ){ |
| 227 | - blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n", | |
| 227 | + blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n", | |
| 228 | 228 | db_column_text(&q, 0) |
| 229 | 229 | ); |
| 230 | 230 | } |
| 231 | 231 | db_finalize(&q); |
| 232 | 232 | }else if( fossil_strcmp(zName, "@reportfmt")==0 ){ |
| 233 | 233 | db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt"); |
| 234 | 234 | while( db_step(&q)==SQLITE_ROW ){ |
| 235 | 235 | blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)" |
| 236 | - " VALUES(%Q,%Q,%Q);\n", | |
| 236 | + " VALUES(%Q,%Q,%Q);\n", | |
| 237 | 237 | db_column_text(&q, 0), |
| 238 | 238 | db_column_text(&q, 1), |
| 239 | 239 | db_column_text(&q, 2) |
| 240 | 240 | ); |
| 241 | 241 | } |
| 242 | 242 | db_finalize(&q); |
| 243 | 243 | }else if( fossil_strcmp(zName, "@user")==0 ){ |
| 244 | - db_prepare(&q, | |
| 244 | + db_prepare(&q, | |
| 245 | 245 | "SELECT login, CASE WHEN length(pw)==40 THEN pw END," |
| 246 | 246 | " cap, info, quote(photo) FROM user"); |
| 247 | 247 | while( db_step(&q)==SQLITE_ROW ){ |
| 248 | 248 | blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)" |
| 249 | 249 | " VALUES(%Q,%Q,%Q,%Q,%s);\n", |
| @@ -274,11 +274,11 @@ | ||
| 274 | 274 | ** config_is_reset(int) |
| 275 | 275 | ** config_reset(int) |
| 276 | 276 | ** |
| 277 | 277 | ** The config_is_reset() function takes the integer valued argument and |
| 278 | 278 | ** ANDs it against the static variable "configHasBeenReset" below. The |
| 279 | -** function returns TRUE or FALSE depending on the result depending on | |
| 279 | +** function returns TRUE or FALSE depending on the result depending on | |
| 280 | 280 | ** whether or not the corresponding configuration table has been reset. The |
| 281 | 281 | ** config_reset() function adds the bits to "configHasBeenReset" that |
| 282 | 282 | ** are given in the argument. |
| 283 | 283 | ** |
| 284 | 284 | ** These functions are used below in the WHEN clause of a trigger to |
| @@ -337,11 +337,11 @@ | ||
| 337 | 337 | @ SELECT rn,owner,title,cols,sqlcode FROM reportfmt; |
| 338 | 338 | @ INSERT INTO _xfer_user |
| 339 | 339 | @ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user; |
| 340 | 340 | ; |
| 341 | 341 | db_multi_exec(zSQL1); |
| 342 | - | |
| 342 | + | |
| 343 | 343 | /* When the replace flag is set, add triggers that run the first time |
| 344 | 344 | ** that new data is seen. The triggers run only once and delete all the |
| 345 | 345 | ** existing data. |
| 346 | 346 | */ |
| 347 | 347 | if( replaceFlag ){ |
| @@ -441,11 +441,11 @@ | ||
| 441 | 441 | ** transferred. pContent is a string that consist of alternating Fossil |
| 442 | 442 | ** and SQL tokens. The First token is a timestamp in seconds since 1970. |
| 443 | 443 | ** The second token is a primary key for the table identified by zName. If |
| 444 | 444 | ** The entry with the corresponding primary key exists and has a more recent |
| 445 | 445 | ** mtime, then nothing happens. If the entry does not exist or if it has |
| 446 | -** an older mtime, then the content described by subsequent token pairs is | |
| 446 | +** an older mtime, then the content described by subsequent token pairs is | |
| 447 | 447 | ** inserted. The first element of each token pair is a column name and |
| 448 | 448 | ** the second is its value. |
| 449 | 449 | ** |
| 450 | 450 | ** In overview, we have: |
| 451 | 451 | ** |
| @@ -519,11 +519,11 @@ | ||
| 519 | 519 | thisMask = configure_is_exportable(azToken[1]); |
| 520 | 520 | }else{ |
| 521 | 521 | thisMask = configure_is_exportable(aType[ii].zName); |
| 522 | 522 | } |
| 523 | 523 | if( (thisMask & groupMask)==0 ) return; |
| 524 | - | |
| 524 | + | |
| 525 | 525 | blob_zero(&sql); |
| 526 | 526 | if( groupMask & CONFIGSET_OVERWRITE ){ |
| 527 | 527 | if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){ |
| 528 | 528 | db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]); |
| 529 | 529 | configHasBeenReset |= thisMask; |
| @@ -606,11 +606,11 @@ | ||
| 606 | 606 | blob_reset(&content); |
| 607 | 607 | blob_seek(pIn, 1, BLOB_SEEK_CUR); |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | - | |
| 611 | + | |
| 612 | 612 | |
| 613 | 613 | /* |
| 614 | 614 | ** Send "config" cards using the new format for all elements of a group |
| 615 | 615 | ** that have recently changed. |
| 616 | 616 | ** |
| @@ -756,11 +756,11 @@ | ||
| 756 | 756 | sqlite3_int64 iStart, /* Start date */ |
| 757 | 757 | const char *zFilename /* Write into this file */ |
| 758 | 758 | ){ |
| 759 | 759 | Blob out; |
| 760 | 760 | blob_zero(&out); |
| 761 | - blob_appendf(&out, | |
| 761 | + blob_appendf(&out, | |
| 762 | 762 | "# The \"%s\" configuration exported from\n" |
| 763 | 763 | "# repository \"%s\"\n" |
| 764 | 764 | "# on %s\n", |
| 765 | 765 | zMask, g.zRepositoryName, |
| 766 | 766 | db_text(0, "SELECT datetime('now')") |
| @@ -817,11 +817,11 @@ | ||
| 817 | 817 | ** Restore the configuration to the default. AREA as above. |
| 818 | 818 | ** |
| 819 | 819 | ** %fossil configuration sync AREA ?URL? |
| 820 | 820 | ** |
| 821 | 821 | ** Synchronize configuration changes in the local repository with |
| 822 | -** the remote repository at URL. | |
| 822 | +** the remote repository at URL. | |
| 823 | 823 | ** |
| 824 | 824 | ** Options: |
| 825 | 825 | ** -R|--repository FILE Extract info from repository FILE |
| 826 | 826 | ** |
| 827 | 827 | ** See also: settings, unset |
| @@ -852,11 +852,11 @@ | ||
| 852 | 852 | }else{ |
| 853 | 853 | iStart = 0; |
| 854 | 854 | } |
| 855 | 855 | export_config(mask, g.argv[3], iStart, g.argv[4]); |
| 856 | 856 | }else |
| 857 | - if( strncmp(zMethod, "import", n)==0 | |
| 857 | + if( strncmp(zMethod, "import", n)==0 | |
| 858 | 858 | || strncmp(zMethod, "merge", n)==0 ){ |
| 859 | 859 | Blob in; |
| 860 | 860 | int groupMask; |
| 861 | 861 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 862 | 862 | blob_read_from_file(&in, g.argv[3]); |
| @@ -915,11 +915,11 @@ | ||
| 915 | 915 | if( strncmp(zMethod, "reset", n)==0 ){ |
| 916 | 916 | int mask, i; |
| 917 | 917 | char *zBackup; |
| 918 | 918 | if( g.argc!=4 ) usage("reset AREA"); |
| 919 | 919 | mask = configure_name_to_mask(g.argv[3], 1); |
| 920 | - zBackup = db_text(0, | |
| 920 | + zBackup = db_text(0, | |
| 921 | 921 | "SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')"); |
| 922 | 922 | db_begin_transaction(); |
| 923 | 923 | export_config(mask, g.argv[3], 0, zBackup); |
| 924 | 924 | for(i=0; i<count(aConfig); i++){ |
| 925 | 925 | const char *zName = aConfig[i].zName; |
| @@ -937,13 +937,13 @@ | ||
| 937 | 937 | db_multi_exec("DELETE FROM reportfmt"); |
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | db_end_transaction(0); |
| 941 | 941 | fossil_print("Configuration reset to factory defaults.\n"); |
| 942 | - fossil_print("To recover, use: %s %s import %s\n", | |
| 943 | - fossil_nameofexe(), g.argv[1], zBackup); | |
| 942 | + fossil_print("To recover, use: %s %s import %s\n", | |
| 943 | + g.argv[0], g.argv[1], zBackup); | |
| 944 | 944 | }else |
| 945 | 945 | { |
| 946 | 946 | fossil_fatal("METHOD should be one of:" |
| 947 | 947 | " export import merge pull push reset"); |
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -66,11 +66,11 @@ | |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | ** The following is a list of settings that we are willing to |
| 71 | ** transfer. |
| 72 | ** |
| 73 | ** Setting names that begin with an alphabetic characters refer to |
| 74 | ** single entries in the CONFIG table. Setting names that begin with |
| 75 | ** "@" are for special processing. |
| 76 | */ |
| @@ -222,28 +222,28 @@ | |
| 222 | void configure_render_special_name(const char *zName, Blob *pOut){ |
| 223 | Stmt q; |
| 224 | if( fossil_strcmp(zName, "@shun")==0 ){ |
| 225 | db_prepare(&q, "SELECT uuid FROM shun"); |
| 226 | while( db_step(&q)==SQLITE_ROW ){ |
| 227 | blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n", |
| 228 | db_column_text(&q, 0) |
| 229 | ); |
| 230 | } |
| 231 | db_finalize(&q); |
| 232 | }else if( fossil_strcmp(zName, "@reportfmt")==0 ){ |
| 233 | db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt"); |
| 234 | while( db_step(&q)==SQLITE_ROW ){ |
| 235 | blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)" |
| 236 | " VALUES(%Q,%Q,%Q);\n", |
| 237 | db_column_text(&q, 0), |
| 238 | db_column_text(&q, 1), |
| 239 | db_column_text(&q, 2) |
| 240 | ); |
| 241 | } |
| 242 | db_finalize(&q); |
| 243 | }else if( fossil_strcmp(zName, "@user")==0 ){ |
| 244 | db_prepare(&q, |
| 245 | "SELECT login, CASE WHEN length(pw)==40 THEN pw END," |
| 246 | " cap, info, quote(photo) FROM user"); |
| 247 | while( db_step(&q)==SQLITE_ROW ){ |
| 248 | blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)" |
| 249 | " VALUES(%Q,%Q,%Q,%Q,%s);\n", |
| @@ -274,11 +274,11 @@ | |
| 274 | ** config_is_reset(int) |
| 275 | ** config_reset(int) |
| 276 | ** |
| 277 | ** The config_is_reset() function takes the integer valued argument and |
| 278 | ** ANDs it against the static variable "configHasBeenReset" below. The |
| 279 | ** function returns TRUE or FALSE depending on the result depending on |
| 280 | ** whether or not the corresponding configuration table has been reset. The |
| 281 | ** config_reset() function adds the bits to "configHasBeenReset" that |
| 282 | ** are given in the argument. |
| 283 | ** |
| 284 | ** These functions are used below in the WHEN clause of a trigger to |
| @@ -337,11 +337,11 @@ | |
| 337 | @ SELECT rn,owner,title,cols,sqlcode FROM reportfmt; |
| 338 | @ INSERT INTO _xfer_user |
| 339 | @ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user; |
| 340 | ; |
| 341 | db_multi_exec(zSQL1); |
| 342 | |
| 343 | /* When the replace flag is set, add triggers that run the first time |
| 344 | ** that new data is seen. The triggers run only once and delete all the |
| 345 | ** existing data. |
| 346 | */ |
| 347 | if( replaceFlag ){ |
| @@ -441,11 +441,11 @@ | |
| 441 | ** transferred. pContent is a string that consist of alternating Fossil |
| 442 | ** and SQL tokens. The First token is a timestamp in seconds since 1970. |
| 443 | ** The second token is a primary key for the table identified by zName. If |
| 444 | ** The entry with the corresponding primary key exists and has a more recent |
| 445 | ** mtime, then nothing happens. If the entry does not exist or if it has |
| 446 | ** an older mtime, then the content described by subsequent token pairs is |
| 447 | ** inserted. The first element of each token pair is a column name and |
| 448 | ** the second is its value. |
| 449 | ** |
| 450 | ** In overview, we have: |
| 451 | ** |
| @@ -519,11 +519,11 @@ | |
| 519 | thisMask = configure_is_exportable(azToken[1]); |
| 520 | }else{ |
| 521 | thisMask = configure_is_exportable(aType[ii].zName); |
| 522 | } |
| 523 | if( (thisMask & groupMask)==0 ) return; |
| 524 | |
| 525 | blob_zero(&sql); |
| 526 | if( groupMask & CONFIGSET_OVERWRITE ){ |
| 527 | if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){ |
| 528 | db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]); |
| 529 | configHasBeenReset |= thisMask; |
| @@ -606,11 +606,11 @@ | |
| 606 | blob_reset(&content); |
| 607 | blob_seek(pIn, 1, BLOB_SEEK_CUR); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | |
| 613 | /* |
| 614 | ** Send "config" cards using the new format for all elements of a group |
| 615 | ** that have recently changed. |
| 616 | ** |
| @@ -756,11 +756,11 @@ | |
| 756 | sqlite3_int64 iStart, /* Start date */ |
| 757 | const char *zFilename /* Write into this file */ |
| 758 | ){ |
| 759 | Blob out; |
| 760 | blob_zero(&out); |
| 761 | blob_appendf(&out, |
| 762 | "# The \"%s\" configuration exported from\n" |
| 763 | "# repository \"%s\"\n" |
| 764 | "# on %s\n", |
| 765 | zMask, g.zRepositoryName, |
| 766 | db_text(0, "SELECT datetime('now')") |
| @@ -817,11 +817,11 @@ | |
| 817 | ** Restore the configuration to the default. AREA as above. |
| 818 | ** |
| 819 | ** %fossil configuration sync AREA ?URL? |
| 820 | ** |
| 821 | ** Synchronize configuration changes in the local repository with |
| 822 | ** the remote repository at URL. |
| 823 | ** |
| 824 | ** Options: |
| 825 | ** -R|--repository FILE Extract info from repository FILE |
| 826 | ** |
| 827 | ** See also: settings, unset |
| @@ -852,11 +852,11 @@ | |
| 852 | }else{ |
| 853 | iStart = 0; |
| 854 | } |
| 855 | export_config(mask, g.argv[3], iStart, g.argv[4]); |
| 856 | }else |
| 857 | if( strncmp(zMethod, "import", n)==0 |
| 858 | || strncmp(zMethod, "merge", n)==0 ){ |
| 859 | Blob in; |
| 860 | int groupMask; |
| 861 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 862 | blob_read_from_file(&in, g.argv[3]); |
| @@ -915,11 +915,11 @@ | |
| 915 | if( strncmp(zMethod, "reset", n)==0 ){ |
| 916 | int mask, i; |
| 917 | char *zBackup; |
| 918 | if( g.argc!=4 ) usage("reset AREA"); |
| 919 | mask = configure_name_to_mask(g.argv[3], 1); |
| 920 | zBackup = db_text(0, |
| 921 | "SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')"); |
| 922 | db_begin_transaction(); |
| 923 | export_config(mask, g.argv[3], 0, zBackup); |
| 924 | for(i=0; i<count(aConfig); i++){ |
| 925 | const char *zName = aConfig[i].zName; |
| @@ -937,13 +937,13 @@ | |
| 937 | db_multi_exec("DELETE FROM reportfmt"); |
| 938 | } |
| 939 | } |
| 940 | db_end_transaction(0); |
| 941 | fossil_print("Configuration reset to factory defaults.\n"); |
| 942 | fossil_print("To recover, use: %s %s import %s\n", |
| 943 | fossil_nameofexe(), g.argv[1], zBackup); |
| 944 | }else |
| 945 | { |
| 946 | fossil_fatal("METHOD should be one of:" |
| 947 | " export import merge pull push reset"); |
| 948 | } |
| 949 | } |
| 950 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -66,11 +66,11 @@ | |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | ** The following is a list of settings that we are willing to |
| 71 | ** transfer. |
| 72 | ** |
| 73 | ** Setting names that begin with an alphabetic characters refer to |
| 74 | ** single entries in the CONFIG table. Setting names that begin with |
| 75 | ** "@" are for special processing. |
| 76 | */ |
| @@ -222,28 +222,28 @@ | |
| 222 | void configure_render_special_name(const char *zName, Blob *pOut){ |
| 223 | Stmt q; |
| 224 | if( fossil_strcmp(zName, "@shun")==0 ){ |
| 225 | db_prepare(&q, "SELECT uuid FROM shun"); |
| 226 | while( db_step(&q)==SQLITE_ROW ){ |
| 227 | blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n", |
| 228 | db_column_text(&q, 0) |
| 229 | ); |
| 230 | } |
| 231 | db_finalize(&q); |
| 232 | }else if( fossil_strcmp(zName, "@reportfmt")==0 ){ |
| 233 | db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt"); |
| 234 | while( db_step(&q)==SQLITE_ROW ){ |
| 235 | blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)" |
| 236 | " VALUES(%Q,%Q,%Q);\n", |
| 237 | db_column_text(&q, 0), |
| 238 | db_column_text(&q, 1), |
| 239 | db_column_text(&q, 2) |
| 240 | ); |
| 241 | } |
| 242 | db_finalize(&q); |
| 243 | }else if( fossil_strcmp(zName, "@user")==0 ){ |
| 244 | db_prepare(&q, |
| 245 | "SELECT login, CASE WHEN length(pw)==40 THEN pw END," |
| 246 | " cap, info, quote(photo) FROM user"); |
| 247 | while( db_step(&q)==SQLITE_ROW ){ |
| 248 | blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)" |
| 249 | " VALUES(%Q,%Q,%Q,%Q,%s);\n", |
| @@ -274,11 +274,11 @@ | |
| 274 | ** config_is_reset(int) |
| 275 | ** config_reset(int) |
| 276 | ** |
| 277 | ** The config_is_reset() function takes the integer valued argument and |
| 278 | ** ANDs it against the static variable "configHasBeenReset" below. The |
| 279 | ** function returns TRUE or FALSE depending on the result depending on |
| 280 | ** whether or not the corresponding configuration table has been reset. The |
| 281 | ** config_reset() function adds the bits to "configHasBeenReset" that |
| 282 | ** are given in the argument. |
| 283 | ** |
| 284 | ** These functions are used below in the WHEN clause of a trigger to |
| @@ -337,11 +337,11 @@ | |
| 337 | @ SELECT rn,owner,title,cols,sqlcode FROM reportfmt; |
| 338 | @ INSERT INTO _xfer_user |
| 339 | @ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user; |
| 340 | ; |
| 341 | db_multi_exec(zSQL1); |
| 342 | |
| 343 | /* When the replace flag is set, add triggers that run the first time |
| 344 | ** that new data is seen. The triggers run only once and delete all the |
| 345 | ** existing data. |
| 346 | */ |
| 347 | if( replaceFlag ){ |
| @@ -441,11 +441,11 @@ | |
| 441 | ** transferred. pContent is a string that consist of alternating Fossil |
| 442 | ** and SQL tokens. The First token is a timestamp in seconds since 1970. |
| 443 | ** The second token is a primary key for the table identified by zName. If |
| 444 | ** The entry with the corresponding primary key exists and has a more recent |
| 445 | ** mtime, then nothing happens. If the entry does not exist or if it has |
| 446 | ** an older mtime, then the content described by subsequent token pairs is |
| 447 | ** inserted. The first element of each token pair is a column name and |
| 448 | ** the second is its value. |
| 449 | ** |
| 450 | ** In overview, we have: |
| 451 | ** |
| @@ -519,11 +519,11 @@ | |
| 519 | thisMask = configure_is_exportable(azToken[1]); |
| 520 | }else{ |
| 521 | thisMask = configure_is_exportable(aType[ii].zName); |
| 522 | } |
| 523 | if( (thisMask & groupMask)==0 ) return; |
| 524 | |
| 525 | blob_zero(&sql); |
| 526 | if( groupMask & CONFIGSET_OVERWRITE ){ |
| 527 | if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){ |
| 528 | db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]); |
| 529 | configHasBeenReset |= thisMask; |
| @@ -606,11 +606,11 @@ | |
| 606 | blob_reset(&content); |
| 607 | blob_seek(pIn, 1, BLOB_SEEK_CUR); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | |
| 613 | /* |
| 614 | ** Send "config" cards using the new format for all elements of a group |
| 615 | ** that have recently changed. |
| 616 | ** |
| @@ -756,11 +756,11 @@ | |
| 756 | sqlite3_int64 iStart, /* Start date */ |
| 757 | const char *zFilename /* Write into this file */ |
| 758 | ){ |
| 759 | Blob out; |
| 760 | blob_zero(&out); |
| 761 | blob_appendf(&out, |
| 762 | "# The \"%s\" configuration exported from\n" |
| 763 | "# repository \"%s\"\n" |
| 764 | "# on %s\n", |
| 765 | zMask, g.zRepositoryName, |
| 766 | db_text(0, "SELECT datetime('now')") |
| @@ -817,11 +817,11 @@ | |
| 817 | ** Restore the configuration to the default. AREA as above. |
| 818 | ** |
| 819 | ** %fossil configuration sync AREA ?URL? |
| 820 | ** |
| 821 | ** Synchronize configuration changes in the local repository with |
| 822 | ** the remote repository at URL. |
| 823 | ** |
| 824 | ** Options: |
| 825 | ** -R|--repository FILE Extract info from repository FILE |
| 826 | ** |
| 827 | ** See also: settings, unset |
| @@ -852,11 +852,11 @@ | |
| 852 | }else{ |
| 853 | iStart = 0; |
| 854 | } |
| 855 | export_config(mask, g.argv[3], iStart, g.argv[4]); |
| 856 | }else |
| 857 | if( strncmp(zMethod, "import", n)==0 |
| 858 | || strncmp(zMethod, "merge", n)==0 ){ |
| 859 | Blob in; |
| 860 | int groupMask; |
| 861 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 862 | blob_read_from_file(&in, g.argv[3]); |
| @@ -915,11 +915,11 @@ | |
| 915 | if( strncmp(zMethod, "reset", n)==0 ){ |
| 916 | int mask, i; |
| 917 | char *zBackup; |
| 918 | if( g.argc!=4 ) usage("reset AREA"); |
| 919 | mask = configure_name_to_mask(g.argv[3], 1); |
| 920 | zBackup = db_text(0, |
| 921 | "SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')"); |
| 922 | db_begin_transaction(); |
| 923 | export_config(mask, g.argv[3], 0, zBackup); |
| 924 | for(i=0; i<count(aConfig); i++){ |
| 925 | const char *zName = aConfig[i].zName; |
| @@ -937,13 +937,13 @@ | |
| 937 | db_multi_exec("DELETE FROM reportfmt"); |
| 938 | } |
| 939 | } |
| 940 | db_end_transaction(0); |
| 941 | fossil_print("Configuration reset to factory defaults.\n"); |
| 942 | fossil_print("To recover, use: %s %s import %s\n", |
| 943 | g.argv[0], g.argv[1], zBackup); |
| 944 | }else |
| 945 | { |
| 946 | fossil_fatal("METHOD should be one of:" |
| 947 | " export import merge pull push reset"); |
| 948 | } |
| 949 | } |
| 950 |
M
src/db.c
+17
-17
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -65,11 +65,11 @@ | ||
| 65 | 65 | */ |
| 66 | 66 | static void db_err(const char *zFormat, ...){ |
| 67 | 67 | va_list ap; |
| 68 | 68 | char *z; |
| 69 | 69 | int rc = 1; |
| 70 | - static const char zRebuildMsg[] = | |
| 70 | + static const char zRebuildMsg[] = | |
| 71 | 71 | "If you have recently updated your fossil executable, you might\n" |
| 72 | 72 | "need to run \"fossil all rebuild\" to bring the repository\n" |
| 73 | 73 | "schemas up to date.\n"; |
| 74 | 74 | va_start(ap, zFormat); |
| 75 | 75 | z = vmprintf(zFormat, ap); |
| @@ -92,11 +92,11 @@ | ||
| 92 | 92 | g.cgiOutput = 0; |
| 93 | 93 | cgi_printf("<h1>Database Error</h1>\n" |
| 94 | 94 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 95 | 95 | cgi_reply(); |
| 96 | 96 | }else{ |
| 97 | - fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg); | |
| 97 | + fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); | |
| 98 | 98 | } |
| 99 | 99 | free(z); |
| 100 | 100 | db_force_rollback(); |
| 101 | 101 | fossil_exit(rc); |
| 102 | 102 | } |
| @@ -695,11 +695,11 @@ | ||
| 695 | 695 | zVfs |
| 696 | 696 | ); |
| 697 | 697 | if( rc!=SQLITE_OK ){ |
| 698 | 698 | db_err(sqlite3_errmsg(db)); |
| 699 | 699 | } |
| 700 | - sqlite3_busy_timeout(db, 5000); | |
| 700 | + sqlite3_busy_timeout(db, 5000); | |
| 701 | 701 | sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */ |
| 702 | 702 | sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0); |
| 703 | 703 | return db; |
| 704 | 704 | } |
| 705 | 705 | |
| @@ -832,34 +832,34 @@ | ||
| 832 | 832 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 833 | 833 | db_open_or_attach(zDbName, "localdb"); |
| 834 | 834 | |
| 835 | 835 | /* If the "isexe" column is missing from the vfile table, then |
| 836 | 836 | ** add it now. This code added on 2010-03-06. After all users have |
| 837 | - ** upgraded, this code can be safely deleted. | |
| 837 | + ** upgraded, this code can be safely deleted. | |
| 838 | 838 | */ |
| 839 | 839 | if( !db_local_column_exists("vfile", "isexe") ){ |
| 840 | 840 | db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0"); |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | /* If "islink"/"isLink" columns are missing from tables, then |
| 844 | 844 | ** add them now. This code added on 2011-01-17 and 2011-08-27. |
| 845 | - ** After all users have upgraded, this code can be safely deleted. | |
| 845 | + ** After all users have upgraded, this code can be safely deleted. | |
| 846 | 846 | */ |
| 847 | 847 | if( !db_local_column_exists("vfile", "islink") ){ |
| 848 | 848 | db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 849 | 849 | } |
| 850 | - | |
| 850 | + | |
| 851 | 851 | if( !db_local_column_exists("stashfile", "isLink") && |
| 852 | 852 | db_local_table_exists("stashfile") ){ |
| 853 | 853 | db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | if( !db_local_column_exists("undo", "isLink") && |
| 857 | 857 | db_local_table_exists("undo") ){ |
| 858 | 858 | db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 859 | 859 | } |
| 860 | - | |
| 860 | + | |
| 861 | 861 | if( !db_local_column_exists("undo_vfile", "islink") && |
| 862 | 862 | db_local_table_exists("undo_vfile") ){ |
| 863 | 863 | db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 864 | 864 | } |
| 865 | 865 | return 1; |
| @@ -871,11 +871,11 @@ | ||
| 871 | 871 | ** that contains a valid repository database. |
| 872 | 872 | ** |
| 873 | 873 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 874 | 874 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 875 | 875 | ** |
| 876 | -** If no valid _FOSSIL_ or .fos file is found, we move up one level and | |
| 876 | +** If no valid _FOSSIL_ or .fos file is found, we move up one level and | |
| 877 | 877 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 878 | 878 | ** to the root of the repository tree and this routine returns 1. If |
| 879 | 879 | ** no database is found, then this routine return 0. |
| 880 | 880 | ** |
| 881 | 881 | ** This routine always opens the user database regardless of whether or |
| @@ -883,12 +883,12 @@ | ||
| 883 | 883 | ** is found, it is attached to the open database connection too. |
| 884 | 884 | */ |
| 885 | 885 | int db_open_local(void){ |
| 886 | 886 | int i, n; |
| 887 | 887 | char zPwd[2000]; |
| 888 | - static const char *aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; | |
| 889 | - | |
| 888 | + static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; | |
| 889 | + | |
| 890 | 890 | if( g.localOpen) return 1; |
| 891 | 891 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 892 | 892 | n = strlen(zPwd); |
| 893 | 893 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 894 | 894 | while( n>0 ){ |
| @@ -1397,11 +1397,11 @@ | ||
| 1397 | 1397 | db_end_transaction(0); |
| 1398 | 1398 | if( zTemplate ) db_detach("settingSrc"); |
| 1399 | 1399 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 1400 | 1400 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 1401 | 1401 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1402 | - fossil_print("admin-user: %s (initial password is \"%s\")\n", | |
| 1402 | + fossil_print("admin-user: %s (initial password is \"%s\")\n", | |
| 1403 | 1403 | g.zLogin, zPassword); |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | /* |
| 1407 | 1407 | ** SQL functions for debugging. |
| @@ -1443,11 +1443,11 @@ | ||
| 1443 | 1443 | } |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | /* |
| 1447 | 1447 | ** Implement the cgi() SQL function. cgi() takes a an argument which is |
| 1448 | -** a name of CGI query parameter. The value of that parameter is returned, | |
| 1448 | +** a name of CGI query parameter. The value of that parameter is returned, | |
| 1449 | 1449 | ** if available. optional second argument will be returned if the first |
| 1450 | 1450 | ** doesn't exist as a CGI parameter. |
| 1451 | 1451 | */ |
| 1452 | 1452 | static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){ |
| 1453 | 1453 | const char* zP; |
| @@ -1638,11 +1638,11 @@ | ||
| 1638 | 1638 | struct _cacheEntry { |
| 1639 | 1639 | struct _cacheEntry *next; |
| 1640 | 1640 | const char *zName, *zValue; |
| 1641 | 1641 | } *cacheEntry = 0; |
| 1642 | 1642 | static struct _cacheEntry *cache = 0; |
| 1643 | - | |
| 1643 | + | |
| 1644 | 1644 | /* Look up name in cache */ |
| 1645 | 1645 | cacheEntry = cache; |
| 1646 | 1646 | while( cacheEntry!=0 ){ |
| 1647 | 1647 | if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ |
| 1648 | 1648 | zVersionedSetting = fossil_strdup(cacheEntry->zValue); |
| @@ -1865,11 +1865,11 @@ | ||
| 1865 | 1865 | "REPLACE INTO global_config(name, value)" |
| 1866 | 1866 | "VALUES('ckout:%q','%q');", |
| 1867 | 1867 | blob_str(&localRoot), blob_str(&full) |
| 1868 | 1868 | ); |
| 1869 | 1869 | db_swap_connections(); |
| 1870 | - db_optional_sql("repository", | |
| 1870 | + db_optional_sql("repository", | |
| 1871 | 1871 | "REPLACE INTO config(name,value,mtime)" |
| 1872 | 1872 | "VALUES('ckout:%q',1,now())", |
| 1873 | 1873 | blob_str(&localRoot) |
| 1874 | 1874 | ); |
| 1875 | 1875 | blob_reset(&localRoot); |
| @@ -2064,11 +2064,11 @@ | ||
| 2064 | 2064 | ** The "unset" command clears a property setting. |
| 2065 | 2065 | ** |
| 2066 | 2066 | ** |
| 2067 | 2067 | ** allow-symlinks If enabled, don't follow symlinks, and instead treat |
| 2068 | 2068 | ** (versionable) them as symlinks on Unix. Has no effect on Windows |
| 2069 | -** (existing links in repository created on Unix become | |
| 2069 | +** (existing links in repository created on Unix become | |
| 2070 | 2070 | ** plain-text files with link destination path inside). |
| 2071 | 2071 | ** Default: off |
| 2072 | 2072 | ** |
| 2073 | 2073 | ** auto-captcha If enabled, the Login page provides a button to |
| 2074 | 2074 | ** fill in the captcha password. Default: on |
| @@ -2212,11 +2212,11 @@ | ||
| 2212 | 2212 | ** and "firefox" on Unix. |
| 2213 | 2213 | ** |
| 2214 | 2214 | ** Options: |
| 2215 | 2215 | ** --global set or unset the given property globally instead of |
| 2216 | 2216 | ** setting or unsetting it for the open repository only. |
| 2217 | -** | |
| 2217 | +** | |
| 2218 | 2218 | ** See also: configuration |
| 2219 | 2219 | */ |
| 2220 | 2220 | void setting_cmd(void){ |
| 2221 | 2221 | int i; |
| 2222 | 2222 | int globalFlag = find_option("global","g",0)!=0; |
| @@ -2300,11 +2300,11 @@ | ||
| 2300 | 2300 | ** Print the approximate span of time from now to TIMESTAMP. |
| 2301 | 2301 | */ |
| 2302 | 2302 | void test_timespan_cmd(void){ |
| 2303 | 2303 | double rDiff; |
| 2304 | 2304 | if( g.argc!=3 ) usage("TIMESTAMP"); |
| 2305 | - sqlite3_open(":memory:", &g.db); | |
| 2305 | + sqlite3_open(":memory:", &g.db); | |
| 2306 | 2306 | rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]); |
| 2307 | 2307 | fossil_print("Time differences: %s\n", db_timespan_name(rDiff)); |
| 2308 | 2308 | sqlite3_close(g.db); |
| 2309 | 2309 | g.db = 0; |
| 2310 | 2310 | } |
| 2311 | 2311 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -65,11 +65,11 @@ | |
| 65 | */ |
| 66 | static void db_err(const char *zFormat, ...){ |
| 67 | va_list ap; |
| 68 | char *z; |
| 69 | int rc = 1; |
| 70 | static const char zRebuildMsg[] = |
| 71 | "If you have recently updated your fossil executable, you might\n" |
| 72 | "need to run \"fossil all rebuild\" to bring the repository\n" |
| 73 | "schemas up to date.\n"; |
| 74 | va_start(ap, zFormat); |
| 75 | z = vmprintf(zFormat, ap); |
| @@ -92,11 +92,11 @@ | |
| 92 | g.cgiOutput = 0; |
| 93 | cgi_printf("<h1>Database Error</h1>\n" |
| 94 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 95 | cgi_reply(); |
| 96 | }else{ |
| 97 | fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg); |
| 98 | } |
| 99 | free(z); |
| 100 | db_force_rollback(); |
| 101 | fossil_exit(rc); |
| 102 | } |
| @@ -695,11 +695,11 @@ | |
| 695 | zVfs |
| 696 | ); |
| 697 | if( rc!=SQLITE_OK ){ |
| 698 | db_err(sqlite3_errmsg(db)); |
| 699 | } |
| 700 | sqlite3_busy_timeout(db, 5000); |
| 701 | sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */ |
| 702 | sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0); |
| 703 | return db; |
| 704 | } |
| 705 | |
| @@ -832,34 +832,34 @@ | |
| 832 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 833 | db_open_or_attach(zDbName, "localdb"); |
| 834 | |
| 835 | /* If the "isexe" column is missing from the vfile table, then |
| 836 | ** add it now. This code added on 2010-03-06. After all users have |
| 837 | ** upgraded, this code can be safely deleted. |
| 838 | */ |
| 839 | if( !db_local_column_exists("vfile", "isexe") ){ |
| 840 | db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0"); |
| 841 | } |
| 842 | |
| 843 | /* If "islink"/"isLink" columns are missing from tables, then |
| 844 | ** add them now. This code added on 2011-01-17 and 2011-08-27. |
| 845 | ** After all users have upgraded, this code can be safely deleted. |
| 846 | */ |
| 847 | if( !db_local_column_exists("vfile", "islink") ){ |
| 848 | db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 849 | } |
| 850 | |
| 851 | if( !db_local_column_exists("stashfile", "isLink") && |
| 852 | db_local_table_exists("stashfile") ){ |
| 853 | db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 854 | } |
| 855 | |
| 856 | if( !db_local_column_exists("undo", "isLink") && |
| 857 | db_local_table_exists("undo") ){ |
| 858 | db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 859 | } |
| 860 | |
| 861 | if( !db_local_column_exists("undo_vfile", "islink") && |
| 862 | db_local_table_exists("undo_vfile") ){ |
| 863 | db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 864 | } |
| 865 | return 1; |
| @@ -871,11 +871,11 @@ | |
| 871 | ** that contains a valid repository database. |
| 872 | ** |
| 873 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 874 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 875 | ** |
| 876 | ** If no valid _FOSSIL_ or .fos file is found, we move up one level and |
| 877 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 878 | ** to the root of the repository tree and this routine returns 1. If |
| 879 | ** no database is found, then this routine return 0. |
| 880 | ** |
| 881 | ** This routine always opens the user database regardless of whether or |
| @@ -883,12 +883,12 @@ | |
| 883 | ** is found, it is attached to the open database connection too. |
| 884 | */ |
| 885 | int db_open_local(void){ |
| 886 | int i, n; |
| 887 | char zPwd[2000]; |
| 888 | static const char *aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; |
| 889 | |
| 890 | if( g.localOpen) return 1; |
| 891 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 892 | n = strlen(zPwd); |
| 893 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 894 | while( n>0 ){ |
| @@ -1397,11 +1397,11 @@ | |
| 1397 | db_end_transaction(0); |
| 1398 | if( zTemplate ) db_detach("settingSrc"); |
| 1399 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 1400 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 1401 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1402 | fossil_print("admin-user: %s (initial password is \"%s\")\n", |
| 1403 | g.zLogin, zPassword); |
| 1404 | } |
| 1405 | |
| 1406 | /* |
| 1407 | ** SQL functions for debugging. |
| @@ -1443,11 +1443,11 @@ | |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | /* |
| 1447 | ** Implement the cgi() SQL function. cgi() takes a an argument which is |
| 1448 | ** a name of CGI query parameter. The value of that parameter is returned, |
| 1449 | ** if available. optional second argument will be returned if the first |
| 1450 | ** doesn't exist as a CGI parameter. |
| 1451 | */ |
| 1452 | static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){ |
| 1453 | const char* zP; |
| @@ -1638,11 +1638,11 @@ | |
| 1638 | struct _cacheEntry { |
| 1639 | struct _cacheEntry *next; |
| 1640 | const char *zName, *zValue; |
| 1641 | } *cacheEntry = 0; |
| 1642 | static struct _cacheEntry *cache = 0; |
| 1643 | |
| 1644 | /* Look up name in cache */ |
| 1645 | cacheEntry = cache; |
| 1646 | while( cacheEntry!=0 ){ |
| 1647 | if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ |
| 1648 | zVersionedSetting = fossil_strdup(cacheEntry->zValue); |
| @@ -1865,11 +1865,11 @@ | |
| 1865 | "REPLACE INTO global_config(name, value)" |
| 1866 | "VALUES('ckout:%q','%q');", |
| 1867 | blob_str(&localRoot), blob_str(&full) |
| 1868 | ); |
| 1869 | db_swap_connections(); |
| 1870 | db_optional_sql("repository", |
| 1871 | "REPLACE INTO config(name,value,mtime)" |
| 1872 | "VALUES('ckout:%q',1,now())", |
| 1873 | blob_str(&localRoot) |
| 1874 | ); |
| 1875 | blob_reset(&localRoot); |
| @@ -2064,11 +2064,11 @@ | |
| 2064 | ** The "unset" command clears a property setting. |
| 2065 | ** |
| 2066 | ** |
| 2067 | ** allow-symlinks If enabled, don't follow symlinks, and instead treat |
| 2068 | ** (versionable) them as symlinks on Unix. Has no effect on Windows |
| 2069 | ** (existing links in repository created on Unix become |
| 2070 | ** plain-text files with link destination path inside). |
| 2071 | ** Default: off |
| 2072 | ** |
| 2073 | ** auto-captcha If enabled, the Login page provides a button to |
| 2074 | ** fill in the captcha password. Default: on |
| @@ -2212,11 +2212,11 @@ | |
| 2212 | ** and "firefox" on Unix. |
| 2213 | ** |
| 2214 | ** Options: |
| 2215 | ** --global set or unset the given property globally instead of |
| 2216 | ** setting or unsetting it for the open repository only. |
| 2217 | ** |
| 2218 | ** See also: configuration |
| 2219 | */ |
| 2220 | void setting_cmd(void){ |
| 2221 | int i; |
| 2222 | int globalFlag = find_option("global","g",0)!=0; |
| @@ -2300,11 +2300,11 @@ | |
| 2300 | ** Print the approximate span of time from now to TIMESTAMP. |
| 2301 | */ |
| 2302 | void test_timespan_cmd(void){ |
| 2303 | double rDiff; |
| 2304 | if( g.argc!=3 ) usage("TIMESTAMP"); |
| 2305 | sqlite3_open(":memory:", &g.db); |
| 2306 | rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]); |
| 2307 | fossil_print("Time differences: %s\n", db_timespan_name(rDiff)); |
| 2308 | sqlite3_close(g.db); |
| 2309 | g.db = 0; |
| 2310 | } |
| 2311 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -65,11 +65,11 @@ | |
| 65 | */ |
| 66 | static void db_err(const char *zFormat, ...){ |
| 67 | va_list ap; |
| 68 | char *z; |
| 69 | int rc = 1; |
| 70 | static const char zRebuildMsg[] = |
| 71 | "If you have recently updated your fossil executable, you might\n" |
| 72 | "need to run \"fossil all rebuild\" to bring the repository\n" |
| 73 | "schemas up to date.\n"; |
| 74 | va_start(ap, zFormat); |
| 75 | z = vmprintf(zFormat, ap); |
| @@ -92,11 +92,11 @@ | |
| 92 | g.cgiOutput = 0; |
| 93 | cgi_printf("<h1>Database Error</h1>\n" |
| 94 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 95 | cgi_reply(); |
| 96 | }else{ |
| 97 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 98 | } |
| 99 | free(z); |
| 100 | db_force_rollback(); |
| 101 | fossil_exit(rc); |
| 102 | } |
| @@ -695,11 +695,11 @@ | |
| 695 | zVfs |
| 696 | ); |
| 697 | if( rc!=SQLITE_OK ){ |
| 698 | db_err(sqlite3_errmsg(db)); |
| 699 | } |
| 700 | sqlite3_busy_timeout(db, 5000); |
| 701 | sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */ |
| 702 | sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0); |
| 703 | return db; |
| 704 | } |
| 705 | |
| @@ -832,34 +832,34 @@ | |
| 832 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 833 | db_open_or_attach(zDbName, "localdb"); |
| 834 | |
| 835 | /* If the "isexe" column is missing from the vfile table, then |
| 836 | ** add it now. This code added on 2010-03-06. After all users have |
| 837 | ** upgraded, this code can be safely deleted. |
| 838 | */ |
| 839 | if( !db_local_column_exists("vfile", "isexe") ){ |
| 840 | db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0"); |
| 841 | } |
| 842 | |
| 843 | /* If "islink"/"isLink" columns are missing from tables, then |
| 844 | ** add them now. This code added on 2011-01-17 and 2011-08-27. |
| 845 | ** After all users have upgraded, this code can be safely deleted. |
| 846 | */ |
| 847 | if( !db_local_column_exists("vfile", "islink") ){ |
| 848 | db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 849 | } |
| 850 | |
| 851 | if( !db_local_column_exists("stashfile", "isLink") && |
| 852 | db_local_table_exists("stashfile") ){ |
| 853 | db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 854 | } |
| 855 | |
| 856 | if( !db_local_column_exists("undo", "isLink") && |
| 857 | db_local_table_exists("undo") ){ |
| 858 | db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0"); |
| 859 | } |
| 860 | |
| 861 | if( !db_local_column_exists("undo_vfile", "islink") && |
| 862 | db_local_table_exists("undo_vfile") ){ |
| 863 | db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0"); |
| 864 | } |
| 865 | return 1; |
| @@ -871,11 +871,11 @@ | |
| 871 | ** that contains a valid repository database. |
| 872 | ** |
| 873 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 874 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 875 | ** |
| 876 | ** If no valid _FOSSIL_ or .fos file is found, we move up one level and |
| 877 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 878 | ** to the root of the repository tree and this routine returns 1. If |
| 879 | ** no database is found, then this routine return 0. |
| 880 | ** |
| 881 | ** This routine always opens the user database regardless of whether or |
| @@ -883,12 +883,12 @@ | |
| 883 | ** is found, it is attached to the open database connection too. |
| 884 | */ |
| 885 | int db_open_local(void){ |
| 886 | int i, n; |
| 887 | char zPwd[2000]; |
| 888 | static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; |
| 889 | |
| 890 | if( g.localOpen) return 1; |
| 891 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 892 | n = strlen(zPwd); |
| 893 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 894 | while( n>0 ){ |
| @@ -1397,11 +1397,11 @@ | |
| 1397 | db_end_transaction(0); |
| 1398 | if( zTemplate ) db_detach("settingSrc"); |
| 1399 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 1400 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 1401 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1402 | fossil_print("admin-user: %s (initial password is \"%s\")\n", |
| 1403 | g.zLogin, zPassword); |
| 1404 | } |
| 1405 | |
| 1406 | /* |
| 1407 | ** SQL functions for debugging. |
| @@ -1443,11 +1443,11 @@ | |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | /* |
| 1447 | ** Implement the cgi() SQL function. cgi() takes a an argument which is |
| 1448 | ** a name of CGI query parameter. The value of that parameter is returned, |
| 1449 | ** if available. optional second argument will be returned if the first |
| 1450 | ** doesn't exist as a CGI parameter. |
| 1451 | */ |
| 1452 | static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){ |
| 1453 | const char* zP; |
| @@ -1638,11 +1638,11 @@ | |
| 1638 | struct _cacheEntry { |
| 1639 | struct _cacheEntry *next; |
| 1640 | const char *zName, *zValue; |
| 1641 | } *cacheEntry = 0; |
| 1642 | static struct _cacheEntry *cache = 0; |
| 1643 | |
| 1644 | /* Look up name in cache */ |
| 1645 | cacheEntry = cache; |
| 1646 | while( cacheEntry!=0 ){ |
| 1647 | if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ |
| 1648 | zVersionedSetting = fossil_strdup(cacheEntry->zValue); |
| @@ -1865,11 +1865,11 @@ | |
| 1865 | "REPLACE INTO global_config(name, value)" |
| 1866 | "VALUES('ckout:%q','%q');", |
| 1867 | blob_str(&localRoot), blob_str(&full) |
| 1868 | ); |
| 1869 | db_swap_connections(); |
| 1870 | db_optional_sql("repository", |
| 1871 | "REPLACE INTO config(name,value,mtime)" |
| 1872 | "VALUES('ckout:%q',1,now())", |
| 1873 | blob_str(&localRoot) |
| 1874 | ); |
| 1875 | blob_reset(&localRoot); |
| @@ -2064,11 +2064,11 @@ | |
| 2064 | ** The "unset" command clears a property setting. |
| 2065 | ** |
| 2066 | ** |
| 2067 | ** allow-symlinks If enabled, don't follow symlinks, and instead treat |
| 2068 | ** (versionable) them as symlinks on Unix. Has no effect on Windows |
| 2069 | ** (existing links in repository created on Unix become |
| 2070 | ** plain-text files with link destination path inside). |
| 2071 | ** Default: off |
| 2072 | ** |
| 2073 | ** auto-captcha If enabled, the Login page provides a button to |
| 2074 | ** fill in the captcha password. Default: on |
| @@ -2212,11 +2212,11 @@ | |
| 2212 | ** and "firefox" on Unix. |
| 2213 | ** |
| 2214 | ** Options: |
| 2215 | ** --global set or unset the given property globally instead of |
| 2216 | ** setting or unsetting it for the open repository only. |
| 2217 | ** |
| 2218 | ** See also: configuration |
| 2219 | */ |
| 2220 | void setting_cmd(void){ |
| 2221 | int i; |
| 2222 | int globalFlag = find_option("global","g",0)!=0; |
| @@ -2300,11 +2300,11 @@ | |
| 2300 | ** Print the approximate span of time from now to TIMESTAMP. |
| 2301 | */ |
| 2302 | void test_timespan_cmd(void){ |
| 2303 | double rDiff; |
| 2304 | if( g.argc!=3 ) usage("TIMESTAMP"); |
| 2305 | sqlite3_open(":memory:", &g.db); |
| 2306 | rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]); |
| 2307 | fossil_print("Time differences: %s\n", db_timespan_name(rDiff)); |
| 2308 | sqlite3_close(g.db); |
| 2309 | g.db = 0; |
| 2310 | } |
| 2311 |
+1
-1
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -301,11 +301,11 @@ | ||
| 301 | 301 | fprintf(sshOut, "\n\n"); |
| 302 | 302 | }else if( g.urlIsFile ){ |
| 303 | 303 | char *zCmd; |
| 304 | 304 | fclose(transport.pFile); |
| 305 | 305 | zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth", |
| 306 | - fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile | |
| 306 | + g.nameOfExe, g.urlName, transport.zOutFile, transport.zInFile | |
| 307 | 307 | ); |
| 308 | 308 | fossil_system(zCmd); |
| 309 | 309 | free(zCmd); |
| 310 | 310 | transport.pFile = fopen(transport.zInFile, "rb"); |
| 311 | 311 | } |
| 312 | 312 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -301,11 +301,11 @@ | |
| 301 | fprintf(sshOut, "\n\n"); |
| 302 | }else if( g.urlIsFile ){ |
| 303 | char *zCmd; |
| 304 | fclose(transport.pFile); |
| 305 | zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth", |
| 306 | fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile |
| 307 | ); |
| 308 | fossil_system(zCmd); |
| 309 | free(zCmd); |
| 310 | transport.pFile = fopen(transport.zInFile, "rb"); |
| 311 | } |
| 312 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -301,11 +301,11 @@ | |
| 301 | fprintf(sshOut, "\n\n"); |
| 302 | }else if( g.urlIsFile ){ |
| 303 | char *zCmd; |
| 304 | fclose(transport.pFile); |
| 305 | zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth", |
| 306 | g.nameOfExe, g.urlName, transport.zOutFile, transport.zInFile |
| 307 | ); |
| 308 | fossil_system(zCmd); |
| 309 | free(zCmd); |
| 310 | transport.pFile = fopen(transport.zInFile, "rb"); |
| 311 | } |
| 312 |
+20
-20
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -13,11 +13,11 @@ | ||
| 13 | 13 | ** Author contact information: |
| 14 | 14 | ** [email protected] |
| 15 | 15 | ** http://www.hwaci.com/drh/ |
| 16 | 16 | ** |
| 17 | 17 | ******************************************************************************* |
| 18 | -** | |
| 18 | +** | |
| 19 | 19 | ** Code for the JSON API. |
| 20 | 20 | ** |
| 21 | 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | 22 | ** |
| 23 | 23 | ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit |
| @@ -74,11 +74,11 @@ | ||
| 74 | 74 | getrusage(RUSAGE_SELF, &sBegin); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /* Return the difference of two time_structs in milliseconds */ |
| 78 | 78 | static double timeDiff(struct timeval *pStart, struct timeval *pEnd){ |
| 79 | - return ((pEnd->tv_usec - pStart->tv_usec)*0.001 + | |
| 79 | + return ((pEnd->tv_usec - pStart->tv_usec)*0.001 + | |
| 80 | 80 | (double)((pEnd->tv_sec - pStart->tv_sec)*1000.0)); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /* |
| 84 | 84 | ** Print the timing results. |
| @@ -128,11 +128,11 @@ | ||
| 128 | 128 | if( NULL != hinstLib ){ |
| 129 | 129 | getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); |
| 130 | 130 | if( NULL != getProcessTimesAddr ){ |
| 131 | 131 | return 1; |
| 132 | 132 | } |
| 133 | - FreeLibrary(hinstLib); | |
| 133 | + FreeLibrary(hinstLib); | |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | return 0; |
| 138 | 138 | } |
| @@ -170,11 +170,11 @@ | ||
| 170 | 170 | #define BEGIN_TIMER beginTimer() |
| 171 | 171 | #define END_TIMER endTimer() |
| 172 | 172 | #define HAS_TIMER hasTimer() |
| 173 | 173 | |
| 174 | 174 | #else |
| 175 | -#define BEGIN_TIMER | |
| 175 | +#define BEGIN_TIMER | |
| 176 | 176 | #define END_TIMER 0.0 |
| 177 | 177 | #define HAS_TIMER 0 |
| 178 | 178 | #endif |
| 179 | 179 | |
| 180 | 180 | /* |
| @@ -212,11 +212,11 @@ | ||
| 212 | 212 | C(ALLOC,"Resource allocation failed"); |
| 213 | 213 | C(NYI,"Not yet implemented"); |
| 214 | 214 | C(PANIC,"x"); |
| 215 | 215 | C(MANIFEST_READ_FAILED,"Reading artifact manifest failed"); |
| 216 | 216 | C(FILE_OPEN_FAILED,"Opening file failed"); |
| 217 | - | |
| 217 | + | |
| 218 | 218 | C(AUTH,"Authentication error"); |
| 219 | 219 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 220 | 220 | C(DENIED,"Access denied"); |
| 221 | 221 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| 222 | 222 | C(LOGIN_FAILED,"Login failed"); |
| @@ -348,11 +348,11 @@ | ||
| 348 | 348 | if( 0 != rc ){ |
| 349 | 349 | cson_value_free( v ); |
| 350 | 350 | } |
| 351 | 351 | assert( (0==rc) && "Adding item to GC failed." ); |
| 352 | 352 | if(0!=rc){ |
| 353 | - fprintf(stderr,"%s: FATAL: alloc error.\n", fossil_nameofexe()) | |
| 353 | + fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0]) | |
| 354 | 354 | /* reminder: allocation error is the only reasonable cause of |
| 355 | 355 | error here, provided g.json.gc.a and v are not NULL. |
| 356 | 356 | */ |
| 357 | 357 | ; |
| 358 | 358 | fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere |
| @@ -384,11 +384,11 @@ | ||
| 384 | 384 | va_start(vargs,fmt); |
| 385 | 385 | zStr = vmprintf(fmt,vargs); |
| 386 | 386 | va_end(vargs); |
| 387 | 387 | v = cson_value_new_string(zStr, strlen(zStr)); |
| 388 | 388 | free(zStr); |
| 389 | - return v; | |
| 389 | + return v; | |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | cson_value * json_new_int( int v ){ |
| 393 | 393 | return cson_value_new_integer((cson_int_t)v); |
| 394 | 394 | } |
| @@ -673,11 +673,11 @@ | ||
| 673 | 673 | ? "application/javascript; charset=utf-8" |
| 674 | 674 | : "application/javascript"; |
| 675 | 675 | }else{ |
| 676 | 676 | /* |
| 677 | 677 | Content-type |
| 678 | - | |
| 678 | + | |
| 679 | 679 | If the browser does not sent an ACCEPT for application/json |
| 680 | 680 | then we fall back to text/plain. |
| 681 | 681 | */ |
| 682 | 682 | char const * cstr; |
| 683 | 683 | cstr = PD("HTTP_ACCEPT",NULL); |
| @@ -1117,11 +1117,11 @@ | ||
| 1117 | 1117 | if( stdin != inFile ){ |
| 1118 | 1118 | fclose(inFile); |
| 1119 | 1119 | } |
| 1120 | 1120 | break; |
| 1121 | 1121 | } |
| 1122 | - | |
| 1122 | + | |
| 1123 | 1123 | /* g.json.reqPayload exists only to simplify some of our access to |
| 1124 | 1124 | the request payload. We currently only use this in the context of |
| 1125 | 1125 | Object payloads, not Arrays, strings, etc. |
| 1126 | 1126 | */ |
| 1127 | 1127 | g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload ); |
| @@ -1146,11 +1146,11 @@ | ||
| 1146 | 1146 | json_string_split(cmd, '/', 0, g.json.cmd.a); |
| 1147 | 1147 | g.json.cmd.commandStr = cmd; |
| 1148 | 1148 | } |
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - | |
| 1151 | + | |
| 1152 | 1152 | if(!g.json.jsonp){ |
| 1153 | 1153 | g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL); |
| 1154 | 1154 | } |
| 1155 | 1155 | if(!g.isHTTP){ |
| 1156 | 1156 | g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/; |
| @@ -1447,11 +1447,11 @@ | ||
| 1447 | 1447 | VAL(param, g.json.param.v); |
| 1448 | 1448 | VAL(POST, g.json.post.v); |
| 1449 | 1449 | VAL(warnings, cson_array_value(g.json.warnings)); |
| 1450 | 1450 | /*cson_output_opt outOpt;*/ |
| 1451 | 1451 | |
| 1452 | - | |
| 1452 | + | |
| 1453 | 1453 | #undef INT |
| 1454 | 1454 | #undef CSTR |
| 1455 | 1455 | #undef VAL |
| 1456 | 1456 | return cson_object_value(pay); |
| 1457 | 1457 | } |
| @@ -1495,11 +1495,11 @@ | ||
| 1495 | 1495 | cson_value_free(tmp); \ |
| 1496 | 1496 | tmp = NULL; \ |
| 1497 | 1497 | goto cleanup; \ |
| 1498 | 1498 | }while(0) |
| 1499 | 1499 | |
| 1500 | - | |
| 1500 | + | |
| 1501 | 1501 | tmp = json_new_string(MANIFEST_UUID); |
| 1502 | 1502 | SET("fossil"); |
| 1503 | 1503 | |
| 1504 | 1504 | tmp = json_new_timestamp(-1); |
| 1505 | 1505 | SET(FossilJsonKeys.timestamp); |
| @@ -1524,11 +1524,11 @@ | ||
| 1524 | 1524 | tmp = json_new_string(g.json.cmd.commandStr); |
| 1525 | 1525 | }else{ |
| 1526 | 1526 | tmp = json_response_command_path(); |
| 1527 | 1527 | } |
| 1528 | 1528 | SET("command"); |
| 1529 | - | |
| 1529 | + | |
| 1530 | 1530 | tmp = json_getenv(FossilJsonKeys.requestId); |
| 1531 | 1531 | if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp ); |
| 1532 | 1532 | |
| 1533 | 1533 | if(0){/* these are only intended for my own testing...*/ |
| 1534 | 1534 | if(g.json.cmd.v){ |
| @@ -1561,11 +1561,11 @@ | ||
| 1561 | 1561 | } |
| 1562 | 1562 | if(g.json.warnings){ |
| 1563 | 1563 | tmp = cson_array_value(g.json.warnings); |
| 1564 | 1564 | SET("warnings"); |
| 1565 | 1565 | } |
| 1566 | - | |
| 1566 | + | |
| 1567 | 1567 | /* Only add the payload to SUCCESS responses. Else delete it. */ |
| 1568 | 1568 | if( NULL != payload ){ |
| 1569 | 1569 | if( resultCode ){ |
| 1570 | 1570 | cson_value_free(payload); |
| 1571 | 1571 | payload = NULL; |
| @@ -1578,11 +1578,11 @@ | ||
| 1578 | 1578 | if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0) |
| 1579 | 1579 | &&(g.perm.Admin||g.perm.Setup)){ |
| 1580 | 1580 | tmp = json_g_to_json(); |
| 1581 | 1581 | SET("g"); |
| 1582 | 1582 | } |
| 1583 | - | |
| 1583 | + | |
| 1584 | 1584 | #undef SET |
| 1585 | 1585 | goto ok; |
| 1586 | 1586 | cleanup: |
| 1587 | 1587 | cson_value_free(v); |
| 1588 | 1588 | v = NULL; |
| @@ -1628,11 +1628,11 @@ | ||
| 1628 | 1628 | if(!resp){ |
| 1629 | 1629 | /* about the only error case here is out-of-memory. DO NOT |
| 1630 | 1630 | call fossil_panic() here because that calls this function. |
| 1631 | 1631 | */ |
| 1632 | 1632 | fprintf(stderr, "%s: Fatal error: could not allocate " |
| 1633 | - "response object.\n", fossil_nameofexe()); | |
| 1633 | + "response object.\n", g.argv[0]); | |
| 1634 | 1634 | fossil_exit(1); |
| 1635 | 1635 | } |
| 1636 | 1636 | if( g.isHTTP ){ |
| 1637 | 1637 | if(alsoOutput){ |
| 1638 | 1638 | json_send_response(resp); |
| @@ -1701,11 +1701,11 @@ | ||
| 1701 | 1701 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1702 | 1702 | assert(NULL != colNamesV); |
| 1703 | 1703 | /*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/; |
| 1704 | 1704 | colNames = cson_value_get_array(colNamesV); |
| 1705 | 1705 | assert(NULL != colNames); |
| 1706 | - } | |
| 1706 | + } | |
| 1707 | 1707 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1708 | 1708 | if(!row && !warnMsg){ |
| 1709 | 1709 | warnMsg = "Could not convert at least one result row to JSON."; |
| 1710 | 1710 | continue; |
| 1711 | 1711 | } |
| @@ -1720,11 +1720,11 @@ | ||
| 1720 | 1720 | } |
| 1721 | 1721 | cson_value_free(colNamesV); |
| 1722 | 1722 | if(warnMsg){ |
| 1723 | 1723 | json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg ); |
| 1724 | 1724 | } |
| 1725 | - return cson_array_value(a); | |
| 1725 | + return cson_array_value(a); | |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | /* |
| 1729 | 1729 | ** Works just like json_stmt_to_array_of_obj(), but each row in the |
| 1730 | 1730 | ** result set is represented as an Array of values instead of an |
| @@ -1809,11 +1809,11 @@ | ||
| 1809 | 1809 | if(*tags){ |
| 1810 | 1810 | v = json_string_split2(tags,',',0); |
| 1811 | 1811 | } |
| 1812 | 1812 | free(tags); |
| 1813 | 1813 | } |
| 1814 | - return v; | |
| 1814 | + return v; | |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | /* |
| 1818 | 1818 | ** Returns a "new" value representing the boolean value of zVal |
| 1819 | 1819 | ** (false if zVal is NULL). Note that cson does not really allocate |
| @@ -1859,11 +1859,11 @@ | ||
| 1859 | 1859 | C(ALLOC); |
| 1860 | 1860 | C(NYI); |
| 1861 | 1861 | C(PANIC); |
| 1862 | 1862 | C(MANIFEST_READ_FAILED); |
| 1863 | 1863 | C(FILE_OPEN_FAILED); |
| 1864 | - | |
| 1864 | + | |
| 1865 | 1865 | C(AUTH); |
| 1866 | 1866 | C(MISSING_AUTH); |
| 1867 | 1867 | C(DENIED); |
| 1868 | 1868 | C(WRONG_MODE); |
| 1869 | 1869 | C(LOGIN_FAILED); |
| 1870 | 1870 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -13,11 +13,11 @@ | |
| 13 | ** Author contact information: |
| 14 | ** [email protected] |
| 15 | ** http://www.hwaci.com/drh/ |
| 16 | ** |
| 17 | ******************************************************************************* |
| 18 | ** |
| 19 | ** Code for the JSON API. |
| 20 | ** |
| 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | ** |
| 23 | ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit |
| @@ -74,11 +74,11 @@ | |
| 74 | getrusage(RUSAGE_SELF, &sBegin); |
| 75 | } |
| 76 | |
| 77 | /* Return the difference of two time_structs in milliseconds */ |
| 78 | static double timeDiff(struct timeval *pStart, struct timeval *pEnd){ |
| 79 | return ((pEnd->tv_usec - pStart->tv_usec)*0.001 + |
| 80 | (double)((pEnd->tv_sec - pStart->tv_sec)*1000.0)); |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | ** Print the timing results. |
| @@ -128,11 +128,11 @@ | |
| 128 | if( NULL != hinstLib ){ |
| 129 | getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); |
| 130 | if( NULL != getProcessTimesAddr ){ |
| 131 | return 1; |
| 132 | } |
| 133 | FreeLibrary(hinstLib); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | return 0; |
| 138 | } |
| @@ -170,11 +170,11 @@ | |
| 170 | #define BEGIN_TIMER beginTimer() |
| 171 | #define END_TIMER endTimer() |
| 172 | #define HAS_TIMER hasTimer() |
| 173 | |
| 174 | #else |
| 175 | #define BEGIN_TIMER |
| 176 | #define END_TIMER 0.0 |
| 177 | #define HAS_TIMER 0 |
| 178 | #endif |
| 179 | |
| 180 | /* |
| @@ -212,11 +212,11 @@ | |
| 212 | C(ALLOC,"Resource allocation failed"); |
| 213 | C(NYI,"Not yet implemented"); |
| 214 | C(PANIC,"x"); |
| 215 | C(MANIFEST_READ_FAILED,"Reading artifact manifest failed"); |
| 216 | C(FILE_OPEN_FAILED,"Opening file failed"); |
| 217 | |
| 218 | C(AUTH,"Authentication error"); |
| 219 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 220 | C(DENIED,"Access denied"); |
| 221 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| 222 | C(LOGIN_FAILED,"Login failed"); |
| @@ -348,11 +348,11 @@ | |
| 348 | if( 0 != rc ){ |
| 349 | cson_value_free( v ); |
| 350 | } |
| 351 | assert( (0==rc) && "Adding item to GC failed." ); |
| 352 | if(0!=rc){ |
| 353 | fprintf(stderr,"%s: FATAL: alloc error.\n", fossil_nameofexe()) |
| 354 | /* reminder: allocation error is the only reasonable cause of |
| 355 | error here, provided g.json.gc.a and v are not NULL. |
| 356 | */ |
| 357 | ; |
| 358 | fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere |
| @@ -384,11 +384,11 @@ | |
| 384 | va_start(vargs,fmt); |
| 385 | zStr = vmprintf(fmt,vargs); |
| 386 | va_end(vargs); |
| 387 | v = cson_value_new_string(zStr, strlen(zStr)); |
| 388 | free(zStr); |
| 389 | return v; |
| 390 | } |
| 391 | |
| 392 | cson_value * json_new_int( int v ){ |
| 393 | return cson_value_new_integer((cson_int_t)v); |
| 394 | } |
| @@ -673,11 +673,11 @@ | |
| 673 | ? "application/javascript; charset=utf-8" |
| 674 | : "application/javascript"; |
| 675 | }else{ |
| 676 | /* |
| 677 | Content-type |
| 678 | |
| 679 | If the browser does not sent an ACCEPT for application/json |
| 680 | then we fall back to text/plain. |
| 681 | */ |
| 682 | char const * cstr; |
| 683 | cstr = PD("HTTP_ACCEPT",NULL); |
| @@ -1117,11 +1117,11 @@ | |
| 1117 | if( stdin != inFile ){ |
| 1118 | fclose(inFile); |
| 1119 | } |
| 1120 | break; |
| 1121 | } |
| 1122 | |
| 1123 | /* g.json.reqPayload exists only to simplify some of our access to |
| 1124 | the request payload. We currently only use this in the context of |
| 1125 | Object payloads, not Arrays, strings, etc. |
| 1126 | */ |
| 1127 | g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload ); |
| @@ -1146,11 +1146,11 @@ | |
| 1146 | json_string_split(cmd, '/', 0, g.json.cmd.a); |
| 1147 | g.json.cmd.commandStr = cmd; |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | if(!g.json.jsonp){ |
| 1153 | g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL); |
| 1154 | } |
| 1155 | if(!g.isHTTP){ |
| 1156 | g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/; |
| @@ -1447,11 +1447,11 @@ | |
| 1447 | VAL(param, g.json.param.v); |
| 1448 | VAL(POST, g.json.post.v); |
| 1449 | VAL(warnings, cson_array_value(g.json.warnings)); |
| 1450 | /*cson_output_opt outOpt;*/ |
| 1451 | |
| 1452 | |
| 1453 | #undef INT |
| 1454 | #undef CSTR |
| 1455 | #undef VAL |
| 1456 | return cson_object_value(pay); |
| 1457 | } |
| @@ -1495,11 +1495,11 @@ | |
| 1495 | cson_value_free(tmp); \ |
| 1496 | tmp = NULL; \ |
| 1497 | goto cleanup; \ |
| 1498 | }while(0) |
| 1499 | |
| 1500 | |
| 1501 | tmp = json_new_string(MANIFEST_UUID); |
| 1502 | SET("fossil"); |
| 1503 | |
| 1504 | tmp = json_new_timestamp(-1); |
| 1505 | SET(FossilJsonKeys.timestamp); |
| @@ -1524,11 +1524,11 @@ | |
| 1524 | tmp = json_new_string(g.json.cmd.commandStr); |
| 1525 | }else{ |
| 1526 | tmp = json_response_command_path(); |
| 1527 | } |
| 1528 | SET("command"); |
| 1529 | |
| 1530 | tmp = json_getenv(FossilJsonKeys.requestId); |
| 1531 | if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp ); |
| 1532 | |
| 1533 | if(0){/* these are only intended for my own testing...*/ |
| 1534 | if(g.json.cmd.v){ |
| @@ -1561,11 +1561,11 @@ | |
| 1561 | } |
| 1562 | if(g.json.warnings){ |
| 1563 | tmp = cson_array_value(g.json.warnings); |
| 1564 | SET("warnings"); |
| 1565 | } |
| 1566 | |
| 1567 | /* Only add the payload to SUCCESS responses. Else delete it. */ |
| 1568 | if( NULL != payload ){ |
| 1569 | if( resultCode ){ |
| 1570 | cson_value_free(payload); |
| 1571 | payload = NULL; |
| @@ -1578,11 +1578,11 @@ | |
| 1578 | if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0) |
| 1579 | &&(g.perm.Admin||g.perm.Setup)){ |
| 1580 | tmp = json_g_to_json(); |
| 1581 | SET("g"); |
| 1582 | } |
| 1583 | |
| 1584 | #undef SET |
| 1585 | goto ok; |
| 1586 | cleanup: |
| 1587 | cson_value_free(v); |
| 1588 | v = NULL; |
| @@ -1628,11 +1628,11 @@ | |
| 1628 | if(!resp){ |
| 1629 | /* about the only error case here is out-of-memory. DO NOT |
| 1630 | call fossil_panic() here because that calls this function. |
| 1631 | */ |
| 1632 | fprintf(stderr, "%s: Fatal error: could not allocate " |
| 1633 | "response object.\n", fossil_nameofexe()); |
| 1634 | fossil_exit(1); |
| 1635 | } |
| 1636 | if( g.isHTTP ){ |
| 1637 | if(alsoOutput){ |
| 1638 | json_send_response(resp); |
| @@ -1701,11 +1701,11 @@ | |
| 1701 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1702 | assert(NULL != colNamesV); |
| 1703 | /*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/; |
| 1704 | colNames = cson_value_get_array(colNamesV); |
| 1705 | assert(NULL != colNames); |
| 1706 | } |
| 1707 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1708 | if(!row && !warnMsg){ |
| 1709 | warnMsg = "Could not convert at least one result row to JSON."; |
| 1710 | continue; |
| 1711 | } |
| @@ -1720,11 +1720,11 @@ | |
| 1720 | } |
| 1721 | cson_value_free(colNamesV); |
| 1722 | if(warnMsg){ |
| 1723 | json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg ); |
| 1724 | } |
| 1725 | return cson_array_value(a); |
| 1726 | } |
| 1727 | |
| 1728 | /* |
| 1729 | ** Works just like json_stmt_to_array_of_obj(), but each row in the |
| 1730 | ** result set is represented as an Array of values instead of an |
| @@ -1809,11 +1809,11 @@ | |
| 1809 | if(*tags){ |
| 1810 | v = json_string_split2(tags,',',0); |
| 1811 | } |
| 1812 | free(tags); |
| 1813 | } |
| 1814 | return v; |
| 1815 | } |
| 1816 | |
| 1817 | /* |
| 1818 | ** Returns a "new" value representing the boolean value of zVal |
| 1819 | ** (false if zVal is NULL). Note that cson does not really allocate |
| @@ -1859,11 +1859,11 @@ | |
| 1859 | C(ALLOC); |
| 1860 | C(NYI); |
| 1861 | C(PANIC); |
| 1862 | C(MANIFEST_READ_FAILED); |
| 1863 | C(FILE_OPEN_FAILED); |
| 1864 | |
| 1865 | C(AUTH); |
| 1866 | C(MISSING_AUTH); |
| 1867 | C(DENIED); |
| 1868 | C(WRONG_MODE); |
| 1869 | C(LOGIN_FAILED); |
| 1870 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -13,11 +13,11 @@ | |
| 13 | ** Author contact information: |
| 14 | ** [email protected] |
| 15 | ** http://www.hwaci.com/drh/ |
| 16 | ** |
| 17 | ******************************************************************************* |
| 18 | ** |
| 19 | ** Code for the JSON API. |
| 20 | ** |
| 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | ** |
| 23 | ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit |
| @@ -74,11 +74,11 @@ | |
| 74 | getrusage(RUSAGE_SELF, &sBegin); |
| 75 | } |
| 76 | |
| 77 | /* Return the difference of two time_structs in milliseconds */ |
| 78 | static double timeDiff(struct timeval *pStart, struct timeval *pEnd){ |
| 79 | return ((pEnd->tv_usec - pStart->tv_usec)*0.001 + |
| 80 | (double)((pEnd->tv_sec - pStart->tv_sec)*1000.0)); |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | ** Print the timing results. |
| @@ -128,11 +128,11 @@ | |
| 128 | if( NULL != hinstLib ){ |
| 129 | getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); |
| 130 | if( NULL != getProcessTimesAddr ){ |
| 131 | return 1; |
| 132 | } |
| 133 | FreeLibrary(hinstLib); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | return 0; |
| 138 | } |
| @@ -170,11 +170,11 @@ | |
| 170 | #define BEGIN_TIMER beginTimer() |
| 171 | #define END_TIMER endTimer() |
| 172 | #define HAS_TIMER hasTimer() |
| 173 | |
| 174 | #else |
| 175 | #define BEGIN_TIMER |
| 176 | #define END_TIMER 0.0 |
| 177 | #define HAS_TIMER 0 |
| 178 | #endif |
| 179 | |
| 180 | /* |
| @@ -212,11 +212,11 @@ | |
| 212 | C(ALLOC,"Resource allocation failed"); |
| 213 | C(NYI,"Not yet implemented"); |
| 214 | C(PANIC,"x"); |
| 215 | C(MANIFEST_READ_FAILED,"Reading artifact manifest failed"); |
| 216 | C(FILE_OPEN_FAILED,"Opening file failed"); |
| 217 | |
| 218 | C(AUTH,"Authentication error"); |
| 219 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 220 | C(DENIED,"Access denied"); |
| 221 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| 222 | C(LOGIN_FAILED,"Login failed"); |
| @@ -348,11 +348,11 @@ | |
| 348 | if( 0 != rc ){ |
| 349 | cson_value_free( v ); |
| 350 | } |
| 351 | assert( (0==rc) && "Adding item to GC failed." ); |
| 352 | if(0!=rc){ |
| 353 | fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0]) |
| 354 | /* reminder: allocation error is the only reasonable cause of |
| 355 | error here, provided g.json.gc.a and v are not NULL. |
| 356 | */ |
| 357 | ; |
| 358 | fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere |
| @@ -384,11 +384,11 @@ | |
| 384 | va_start(vargs,fmt); |
| 385 | zStr = vmprintf(fmt,vargs); |
| 386 | va_end(vargs); |
| 387 | v = cson_value_new_string(zStr, strlen(zStr)); |
| 388 | free(zStr); |
| 389 | return v; |
| 390 | } |
| 391 | |
| 392 | cson_value * json_new_int( int v ){ |
| 393 | return cson_value_new_integer((cson_int_t)v); |
| 394 | } |
| @@ -673,11 +673,11 @@ | |
| 673 | ? "application/javascript; charset=utf-8" |
| 674 | : "application/javascript"; |
| 675 | }else{ |
| 676 | /* |
| 677 | Content-type |
| 678 | |
| 679 | If the browser does not sent an ACCEPT for application/json |
| 680 | then we fall back to text/plain. |
| 681 | */ |
| 682 | char const * cstr; |
| 683 | cstr = PD("HTTP_ACCEPT",NULL); |
| @@ -1117,11 +1117,11 @@ | |
| 1117 | if( stdin != inFile ){ |
| 1118 | fclose(inFile); |
| 1119 | } |
| 1120 | break; |
| 1121 | } |
| 1122 | |
| 1123 | /* g.json.reqPayload exists only to simplify some of our access to |
| 1124 | the request payload. We currently only use this in the context of |
| 1125 | Object payloads, not Arrays, strings, etc. |
| 1126 | */ |
| 1127 | g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload ); |
| @@ -1146,11 +1146,11 @@ | |
| 1146 | json_string_split(cmd, '/', 0, g.json.cmd.a); |
| 1147 | g.json.cmd.commandStr = cmd; |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | if(!g.json.jsonp){ |
| 1153 | g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL); |
| 1154 | } |
| 1155 | if(!g.isHTTP){ |
| 1156 | g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/; |
| @@ -1447,11 +1447,11 @@ | |
| 1447 | VAL(param, g.json.param.v); |
| 1448 | VAL(POST, g.json.post.v); |
| 1449 | VAL(warnings, cson_array_value(g.json.warnings)); |
| 1450 | /*cson_output_opt outOpt;*/ |
| 1451 | |
| 1452 | |
| 1453 | #undef INT |
| 1454 | #undef CSTR |
| 1455 | #undef VAL |
| 1456 | return cson_object_value(pay); |
| 1457 | } |
| @@ -1495,11 +1495,11 @@ | |
| 1495 | cson_value_free(tmp); \ |
| 1496 | tmp = NULL; \ |
| 1497 | goto cleanup; \ |
| 1498 | }while(0) |
| 1499 | |
| 1500 | |
| 1501 | tmp = json_new_string(MANIFEST_UUID); |
| 1502 | SET("fossil"); |
| 1503 | |
| 1504 | tmp = json_new_timestamp(-1); |
| 1505 | SET(FossilJsonKeys.timestamp); |
| @@ -1524,11 +1524,11 @@ | |
| 1524 | tmp = json_new_string(g.json.cmd.commandStr); |
| 1525 | }else{ |
| 1526 | tmp = json_response_command_path(); |
| 1527 | } |
| 1528 | SET("command"); |
| 1529 | |
| 1530 | tmp = json_getenv(FossilJsonKeys.requestId); |
| 1531 | if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp ); |
| 1532 | |
| 1533 | if(0){/* these are only intended for my own testing...*/ |
| 1534 | if(g.json.cmd.v){ |
| @@ -1561,11 +1561,11 @@ | |
| 1561 | } |
| 1562 | if(g.json.warnings){ |
| 1563 | tmp = cson_array_value(g.json.warnings); |
| 1564 | SET("warnings"); |
| 1565 | } |
| 1566 | |
| 1567 | /* Only add the payload to SUCCESS responses. Else delete it. */ |
| 1568 | if( NULL != payload ){ |
| 1569 | if( resultCode ){ |
| 1570 | cson_value_free(payload); |
| 1571 | payload = NULL; |
| @@ -1578,11 +1578,11 @@ | |
| 1578 | if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0) |
| 1579 | &&(g.perm.Admin||g.perm.Setup)){ |
| 1580 | tmp = json_g_to_json(); |
| 1581 | SET("g"); |
| 1582 | } |
| 1583 | |
| 1584 | #undef SET |
| 1585 | goto ok; |
| 1586 | cleanup: |
| 1587 | cson_value_free(v); |
| 1588 | v = NULL; |
| @@ -1628,11 +1628,11 @@ | |
| 1628 | if(!resp){ |
| 1629 | /* about the only error case here is out-of-memory. DO NOT |
| 1630 | call fossil_panic() here because that calls this function. |
| 1631 | */ |
| 1632 | fprintf(stderr, "%s: Fatal error: could not allocate " |
| 1633 | "response object.\n", g.argv[0]); |
| 1634 | fossil_exit(1); |
| 1635 | } |
| 1636 | if( g.isHTTP ){ |
| 1637 | if(alsoOutput){ |
| 1638 | json_send_response(resp); |
| @@ -1701,11 +1701,11 @@ | |
| 1701 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1702 | assert(NULL != colNamesV); |
| 1703 | /*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/; |
| 1704 | colNames = cson_value_get_array(colNamesV); |
| 1705 | assert(NULL != colNames); |
| 1706 | } |
| 1707 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1708 | if(!row && !warnMsg){ |
| 1709 | warnMsg = "Could not convert at least one result row to JSON."; |
| 1710 | continue; |
| 1711 | } |
| @@ -1720,11 +1720,11 @@ | |
| 1720 | } |
| 1721 | cson_value_free(colNamesV); |
| 1722 | if(warnMsg){ |
| 1723 | json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg ); |
| 1724 | } |
| 1725 | return cson_array_value(a); |
| 1726 | } |
| 1727 | |
| 1728 | /* |
| 1729 | ** Works just like json_stmt_to_array_of_obj(), but each row in the |
| 1730 | ** result set is represented as an Array of values instead of an |
| @@ -1809,11 +1809,11 @@ | |
| 1809 | if(*tags){ |
| 1810 | v = json_string_split2(tags,',',0); |
| 1811 | } |
| 1812 | free(tags); |
| 1813 | } |
| 1814 | return v; |
| 1815 | } |
| 1816 | |
| 1817 | /* |
| 1818 | ** Returns a "new" value representing the boolean value of zVal |
| 1819 | ** (false if zVal is NULL). Note that cson does not really allocate |
| @@ -1859,11 +1859,11 @@ | |
| 1859 | C(ALLOC); |
| 1860 | C(NYI); |
| 1861 | C(PANIC); |
| 1862 | C(MANIFEST_READ_FAILED); |
| 1863 | C(FILE_OPEN_FAILED); |
| 1864 | |
| 1865 | C(AUTH); |
| 1866 | C(MISSING_AUTH); |
| 1867 | C(DENIED); |
| 1868 | C(WRONG_MODE); |
| 1869 | C(LOGIN_FAILED); |
| 1870 |
+5
-9
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -99,10 +99,11 @@ | ||
| 99 | 99 | /* |
| 100 | 100 | ** All global variables are in this structure. |
| 101 | 101 | */ |
| 102 | 102 | struct Global { |
| 103 | 103 | int argc; char **argv; /* Command-line arguments to the program */ |
| 104 | + char *nameOfExe; /* Full path of executable. */ | |
| 104 | 105 | int isConst; /* True if the output is unchanging */ |
| 105 | 106 | sqlite3 *db; /* The connection to the databases */ |
| 106 | 107 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 107 | 108 | int useAttach; /* True if global_config is attached to repository */ |
| 108 | 109 | int configOpen; /* True if the config database is open */ |
| @@ -477,12 +478,14 @@ | ||
| 477 | 478 | g.argc = argc; |
| 478 | 479 | g.argv = argv; |
| 479 | 480 | #ifdef _WIN32 |
| 480 | 481 | parse_windows_command_line(&g.argc, &g.argv); |
| 481 | 482 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 482 | - g.argv[0] = fossil_unicode_to_utf8(buf); | |
| 483 | - for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]); | |
| 483 | + g.nameOfExe = fossil_unicode_to_utf8(buf); | |
| 484 | + for(i=0; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]); | |
| 485 | +#else | |
| 486 | + g.nameOfExe = g.argv[0]; | |
| 484 | 487 | #endif |
| 485 | 488 | for(i=1; i<g.argc-1; i++){ |
| 486 | 489 | z = g.argv[i]; |
| 487 | 490 | if( z[0]!='-' ) continue; |
| 488 | 491 | z++; |
| @@ -651,17 +654,10 @@ | ||
| 651 | 654 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 652 | 655 | ** shutting down, the recursive errors are silently ignored. |
| 653 | 656 | */ |
| 654 | 657 | static int mainInFatalError = 0; |
| 655 | 658 | |
| 656 | -/* | |
| 657 | -** Return the name of the current executable. | |
| 658 | -*/ | |
| 659 | -const char *fossil_nameofexe(void){ | |
| 660 | - return g.argv[0]; | |
| 661 | -} | |
| 662 | - | |
| 663 | 659 | /* |
| 664 | 660 | ** Exit. Take care to close the database first. |
| 665 | 661 | */ |
| 666 | 662 | NORETURN void fossil_exit(int rc){ |
| 667 | 663 | db_close(1); |
| 668 | 664 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -99,10 +99,11 @@ | |
| 99 | /* |
| 100 | ** All global variables are in this structure. |
| 101 | */ |
| 102 | struct Global { |
| 103 | int argc; char **argv; /* Command-line arguments to the program */ |
| 104 | int isConst; /* True if the output is unchanging */ |
| 105 | sqlite3 *db; /* The connection to the databases */ |
| 106 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 107 | int useAttach; /* True if global_config is attached to repository */ |
| 108 | int configOpen; /* True if the config database is open */ |
| @@ -477,12 +478,14 @@ | |
| 477 | g.argc = argc; |
| 478 | g.argv = argv; |
| 479 | #ifdef _WIN32 |
| 480 | parse_windows_command_line(&g.argc, &g.argv); |
| 481 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 482 | g.argv[0] = fossil_unicode_to_utf8(buf); |
| 483 | for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]); |
| 484 | #endif |
| 485 | for(i=1; i<g.argc-1; i++){ |
| 486 | z = g.argv[i]; |
| 487 | if( z[0]!='-' ) continue; |
| 488 | z++; |
| @@ -651,17 +654,10 @@ | |
| 651 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 652 | ** shutting down, the recursive errors are silently ignored. |
| 653 | */ |
| 654 | static int mainInFatalError = 0; |
| 655 | |
| 656 | /* |
| 657 | ** Return the name of the current executable. |
| 658 | */ |
| 659 | const char *fossil_nameofexe(void){ |
| 660 | return g.argv[0]; |
| 661 | } |
| 662 | |
| 663 | /* |
| 664 | ** Exit. Take care to close the database first. |
| 665 | */ |
| 666 | NORETURN void fossil_exit(int rc){ |
| 667 | db_close(1); |
| 668 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -99,10 +99,11 @@ | |
| 99 | /* |
| 100 | ** All global variables are in this structure. |
| 101 | */ |
| 102 | struct Global { |
| 103 | int argc; char **argv; /* Command-line arguments to the program */ |
| 104 | char *nameOfExe; /* Full path of executable. */ |
| 105 | int isConst; /* True if the output is unchanging */ |
| 106 | sqlite3 *db; /* The connection to the databases */ |
| 107 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 108 | int useAttach; /* True if global_config is attached to repository */ |
| 109 | int configOpen; /* True if the config database is open */ |
| @@ -477,12 +478,14 @@ | |
| 478 | g.argc = argc; |
| 479 | g.argv = argv; |
| 480 | #ifdef _WIN32 |
| 481 | parse_windows_command_line(&g.argc, &g.argv); |
| 482 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 483 | g.nameOfExe = fossil_unicode_to_utf8(buf); |
| 484 | for(i=0; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]); |
| 485 | #else |
| 486 | g.nameOfExe = g.argv[0]; |
| 487 | #endif |
| 488 | for(i=1; i<g.argc-1; i++){ |
| 489 | z = g.argv[i]; |
| 490 | if( z[0]!='-' ) continue; |
| 491 | z++; |
| @@ -651,17 +654,10 @@ | |
| 654 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 655 | ** shutting down, the recursive errors are silently ignored. |
| 656 | */ |
| 657 | static int mainInFatalError = 0; |
| 658 | |
| 659 | /* |
| 660 | ** Exit. Take care to close the database first. |
| 661 | */ |
| 662 | NORETURN void fossil_exit(int rc){ |
| 663 | db_close(1); |
| 664 |
+2
-2
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -109,11 +109,11 @@ | ||
| 109 | 109 | wanted -= got; |
| 110 | 110 | } |
| 111 | 111 | fclose(out); |
| 112 | 112 | out = 0; |
| 113 | 113 | sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", |
| 114 | - fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName, | |
| 114 | + g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName, | |
| 115 | 115 | inet_ntoa(p->addr.sin_addr), p->zOptions |
| 116 | 116 | ); |
| 117 | 117 | fossil_system(zCmd); |
| 118 | 118 | in = fossil_fopen(zReplyFName, "rb"); |
| 119 | 119 | if( in ){ |
| @@ -614,11 +614,11 @@ | ||
| 614 | 614 | db_open_repository(zRepository); |
| 615 | 615 | } |
| 616 | 616 | db_close(0); |
| 617 | 617 | /* Build the fully-qualified path to the service binary file. */ |
| 618 | 618 | blob_zero(&binPath); |
| 619 | - blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe()); | |
| 619 | + blob_appendf(&binPath, "\"%s\" server", g.nameOfExe); | |
| 620 | 620 | if( zPort ) blob_appendf(&binPath, " --port %s", zPort); |
| 621 | 621 | if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound); |
| 622 | 622 | if( zLocalAuth ) blob_append(&binPath, " --localauth", -1); |
| 623 | 623 | blob_appendf(&binPath, " \"%s\"", g.zRepositoryName); |
| 624 | 624 | /* Create the service. */ |
| 625 | 625 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -109,11 +109,11 @@ | |
| 109 | wanted -= got; |
| 110 | } |
| 111 | fclose(out); |
| 112 | out = 0; |
| 113 | sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", |
| 114 | fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName, |
| 115 | inet_ntoa(p->addr.sin_addr), p->zOptions |
| 116 | ); |
| 117 | fossil_system(zCmd); |
| 118 | in = fossil_fopen(zReplyFName, "rb"); |
| 119 | if( in ){ |
| @@ -614,11 +614,11 @@ | |
| 614 | db_open_repository(zRepository); |
| 615 | } |
| 616 | db_close(0); |
| 617 | /* Build the fully-qualified path to the service binary file. */ |
| 618 | blob_zero(&binPath); |
| 619 | blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe()); |
| 620 | if( zPort ) blob_appendf(&binPath, " --port %s", zPort); |
| 621 | if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound); |
| 622 | if( zLocalAuth ) blob_append(&binPath, " --localauth", -1); |
| 623 | blob_appendf(&binPath, " \"%s\"", g.zRepositoryName); |
| 624 | /* Create the service. */ |
| 625 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -109,11 +109,11 @@ | |
| 109 | wanted -= got; |
| 110 | } |
| 111 | fclose(out); |
| 112 | out = 0; |
| 113 | sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", |
| 114 | g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName, |
| 115 | inet_ntoa(p->addr.sin_addr), p->zOptions |
| 116 | ); |
| 117 | fossil_system(zCmd); |
| 118 | in = fossil_fopen(zReplyFName, "rb"); |
| 119 | if( in ){ |
| @@ -614,11 +614,11 @@ | |
| 614 | db_open_repository(zRepository); |
| 615 | } |
| 616 | db_close(0); |
| 617 | /* Build the fully-qualified path to the service binary file. */ |
| 618 | blob_zero(&binPath); |
| 619 | blob_appendf(&binPath, "\"%s\" server", g.nameOfExe); |
| 620 | if( zPort ) blob_appendf(&binPath, " --port %s", zPort); |
| 621 | if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound); |
| 622 | if( zLocalAuth ) blob_append(&binPath, " --localauth", -1); |
| 623 | blob_appendf(&binPath, " \"%s\"", g.zRepositoryName); |
| 624 | /* Create the service. */ |
| 625 |