Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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 |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
dacc6946157383da12b3cf650eea6a3e |
| User & Date: | jan.nijtmans 2012-09-24 09:03:26.259 |
Context
|
2012-09-24
| ||
| 10:12 | fix -pedantic gcc warning: overflow in implicit constant conversion check-in: 03424a031b user: jan.nijtmans tags: trunk | |
| 09:03 | 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 check-in: dacc694615 user: jan.nijtmans tags: trunk | |
| 07:00 | previous commit fixed the MSVC build, but broke the mingw build. Now fix both of them. check-in: 1ef58e5246 user: jan.nijtmans tags: trunk | |
Changes
Changes to src/allrepo.c.
| ︙ | ︙ | |||
145 146 147 148 149 150 151 |
db_end_transaction(0);
return;
}else{
fossil_fatal("\"all\" subcommand should be one of: "
"changes ignore list ls push pull rebuild sync");
}
verify_all_options();
| | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
db_end_transaction(0);
return;
}else{
fossil_fatal("\"all\" subcommand should be one of: "
"changes ignore list ls push pull rebuild sync");
}
verify_all_options();
zFossil = quoteFilename(g.nameOfExe);
if( useCheckouts ){
db_prepare(&q,
"SELECT substr(name, 7) COLLATE nocase, max(rowid)"
" FROM global_config"
" WHERE substr(name, 1, 6)=='ckout:'"
" GROUP BY 1 ORDER BY 1"
);
|
| ︙ | ︙ |
Changes to src/branch.c.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 | const char *zColor; /* Color of the new branch */ Blob branch; /* manifest for the new branch */ Manifest *pParent; /* Parsed parent manifest */ Blob mcksum; /* Self-checksum on the manifest */ const char *zDateOvrd; /* Override date string */ const char *zUserOvrd; /* Override user name */ int isPrivate = 0; /* True if the branch should be private */ | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
const char *zColor; /* Color of the new branch */
Blob branch; /* manifest for the new branch */
Manifest *pParent; /* Parsed parent manifest */
Blob mcksum; /* Self-checksum on the manifest */
const char *zDateOvrd; /* Override date string */
const char *zUserOvrd; /* Override user name */
int isPrivate = 0; /* True if the branch should be private */
noSign = find_option("nosign","",0)!=0;
zColor = find_option("bgcolor","c",1);
isPrivate = find_option("private",0,0)!=0;
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
verify_all_options();
if( g.argc<5 ){
usage("new BRANCH-NAME BASIS ?OPTIONS?");
}
db_find_and_open_repository(0, 0);
noSign = db_get_int("omitsign", 0)|noSign;
/* fossil branch new name */
zBranch = g.argv[3];
if( zBranch==0 || zBranch[0]==0 ){
fossil_panic("branch name cannot be empty");
}
if( db_exists(
"SELECT 1 FROM tagxref"
|
| ︙ | ︙ | |||
130 131 132 133 134 135 136 |
" ORDER BY tagname",
rootid);
while( db_step(&q)==SQLITE_ROW ){
const char *zTag = db_column_text(&q, 0);
blob_appendf(&branch, "T -%F *\n", zTag);
}
db_finalize(&q);
| | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
" ORDER BY tagname",
rootid);
while( db_step(&q)==SQLITE_ROW ){
const char *zTag = db_column_text(&q, 0);
blob_appendf(&branch, "T -%F *\n", zTag);
}
db_finalize(&q);
blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(&branch, &mcksum);
blob_appendf(&branch, "Z %b\n", &mcksum);
if( !noSign && clearsign(&branch, &branch) ){
Blob ans;
blob_zero(&ans);
prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
|
| ︙ | ︙ | |||
163 164 165 166 167 168 169 |
if( g.argc==3 ){
fossil_print(
"\n"
"Note: the local check-out has not been updated to the new\n"
" branch. To begin working on the new branch, do this:\n"
"\n"
" %s update %s\n",
| | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
if( g.argc==3 ){
fossil_print(
"\n"
"Note: the local check-out has not been updated to the new\n"
" branch. To begin working on the new branch, do this:\n"
"\n"
" %s update %s\n",
g.argv[0], zBranch
);
}
/* Commit */
db_end_transaction(0);
/* Do an autosync push, if requested */
if( !isPrivate ) autosync(AUTOSYNC_PUSH);
}
/*
** Prepare a query that will list branches.
**
|
| ︙ | ︙ | |||
379 380 381 382 383 384 385 |
** This routine is called while for each check-in that is rendered by
** the timeline of a "brlist" page. Add some additional hyperlinks
** to the end of the line.
*/
static void brtimeline_extra(int rid){
Stmt q;
if( !g.perm.Hyperlink ) return;
| | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
** This routine is called while for each check-in that is rendered by
** the timeline of a "brlist" page. Add some additional hyperlinks
** to the end of the line.
*/
static void brtimeline_extra(int rid){
Stmt q;
if( !g.perm.Hyperlink ) return;
db_prepare(&q,
"SELECT substr(tagname,5) FROM tagxref, tag"
" WHERE tagxref.rid=%d"
" AND tagxref.tagid=tag.tagid"
" AND tagxref.tagtype>0"
" AND tag.tagname GLOB 'sym-*'",
rid
);
|
| ︙ | ︙ |
Changes to src/configure.c.
| ︙ | ︙ | |||
64 65 66 67 68 69 70 |
{ "/xfer", CONFIGSET_XFER, "Transfer setup", },
{ "/all", CONFIGSET_ALL, "All of the above" },
};
/*
** The following is a list of settings that we are willing to
| | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
{ "/xfer", CONFIGSET_XFER, "Transfer setup", },
{ "/all", CONFIGSET_ALL, "All of the above" },
};
/*
** The following is a list of settings that we are willing to
** transfer.
**
** Setting names that begin with an alphabetic characters refer to
** single entries in the CONFIG table. Setting names that begin with
** "@" are for special processing.
*/
static struct {
const char *zName; /* Name of the configuration parameter */
|
| ︙ | ︙ | |||
220 221 222 223 224 225 226 |
** evaluated will populate the corresponding table with data.
*/
void configure_render_special_name(const char *zName, Blob *pOut){
Stmt q;
if( fossil_strcmp(zName, "@shun")==0 ){
db_prepare(&q, "SELECT uuid FROM shun");
while( db_step(&q)==SQLITE_ROW ){
| | | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
** evaluated will populate the corresponding table with data.
*/
void configure_render_special_name(const char *zName, Blob *pOut){
Stmt q;
if( fossil_strcmp(zName, "@shun")==0 ){
db_prepare(&q, "SELECT uuid FROM shun");
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n",
db_column_text(&q, 0)
);
}
db_finalize(&q);
}else if( fossil_strcmp(zName, "@reportfmt")==0 ){
db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt");
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)"
" VALUES(%Q,%Q,%Q);\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2)
);
}
db_finalize(&q);
}else if( fossil_strcmp(zName, "@user")==0 ){
db_prepare(&q,
"SELECT login, CASE WHEN length(pw)==40 THEN pw END,"
" cap, info, quote(photo) FROM user");
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)"
" VALUES(%Q,%Q,%Q,%Q,%s);\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
|
| ︙ | ︙ | |||
272 273 274 275 276 277 278 | ** Two SQL functions: ** ** config_is_reset(int) ** config_reset(int) ** ** The config_is_reset() function takes the integer valued argument and ** ANDs it against the static variable "configHasBeenReset" below. The | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | ** Two SQL functions: ** ** config_is_reset(int) ** config_reset(int) ** ** The config_is_reset() function takes the integer valued argument and ** ANDs it against the static variable "configHasBeenReset" below. The ** function returns TRUE or FALSE depending on the result depending on ** whether or not the corresponding configuration table has been reset. The ** config_reset() function adds the bits to "configHasBeenReset" that ** are given in the argument. ** ** These functions are used below in the WHEN clause of a trigger to ** get the trigger to fire exactly once. */ |
| ︙ | ︙ | |||
335 336 337 338 339 340 341 |
@ );
@ INSERT INTO _xfer_reportfmt
@ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
@ INSERT INTO _xfer_user
@ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
;
db_multi_exec(zSQL1);
| | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
@ );
@ INSERT INTO _xfer_reportfmt
@ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
@ INSERT INTO _xfer_user
@ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
;
db_multi_exec(zSQL1);
/* When the replace flag is set, add triggers that run the first time
** that new data is seen. The triggers run only once and delete all the
** existing data.
*/
if( replaceFlag ){
static const char zSQL2[] =
@ CREATE TRIGGER _xfer_r1 BEFORE INSERT ON _xfer_reportfmt
|
| ︙ | ︙ | |||
439 440 441 442 443 444 445 | ** zName is one of "/config", "/user", "/shun", "/reportfmt", or "/concealed". ** zName indicates the table that holds the configuration information being ** transferred. pContent is a string that consist of alternating Fossil ** and SQL tokens. The First token is a timestamp in seconds since 1970. ** The second token is a primary key for the table identified by zName. If ** The entry with the corresponding primary key exists and has a more recent ** mtime, then nothing happens. If the entry does not exist or if it has | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | ** zName is one of "/config", "/user", "/shun", "/reportfmt", or "/concealed". ** zName indicates the table that holds the configuration information being ** transferred. pContent is a string that consist of alternating Fossil ** and SQL tokens. The First token is a timestamp in seconds since 1970. ** The second token is a primary key for the table identified by zName. If ** The entry with the corresponding primary key exists and has a more recent ** mtime, then nothing happens. If the entry does not exist or if it has ** an older mtime, then the content described by subsequent token pairs is ** inserted. The first element of each token pair is a column name and ** the second is its value. ** ** In overview, we have: ** ** NAME CONTENT ** ------- ----------------------------------------------------------- |
| ︙ | ︙ | |||
517 518 519 520 521 522 523 |
if( nToken<2 ) return;
if( aType[ii].zName[0]=='/' ){
thisMask = configure_is_exportable(azToken[1]);
}else{
thisMask = configure_is_exportable(aType[ii].zName);
}
if( (thisMask & groupMask)==0 ) return;
| | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
if( nToken<2 ) return;
if( aType[ii].zName[0]=='/' ){
thisMask = configure_is_exportable(azToken[1]);
}else{
thisMask = configure_is_exportable(aType[ii].zName);
}
if( (thisMask & groupMask)==0 ) return;
blob_zero(&sql);
if( groupMask & CONFIGSET_OVERWRITE ){
if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]);
configHasBeenReset |= thisMask;
}
blob_append(&sql, "REPLACE INTO ", -1);
|
| ︙ | ︙ | |||
604 605 606 607 608 609 610 |
g.perm.Admin = g.perm.RdAddr = 1;
configure_receive(zName, &content, groupMask);
blob_reset(&content);
blob_seek(pIn, 1, BLOB_SEEK_CUR);
}
}
}
| | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
g.perm.Admin = g.perm.RdAddr = 1;
configure_receive(zName, &content, groupMask);
blob_reset(&content);
blob_seek(pIn, 1, BLOB_SEEK_CUR);
}
}
}
/*
** Send "config" cards using the new format for all elements of a group
** that have recently changed.
**
** Output goes into pOut. The groupMask identifies the group(s) to be sent.
** Send only entries whose timestamp is later than or equal to iStart.
|
| ︙ | ︙ | |||
754 755 756 757 758 759 760 |
int groupMask, /* Mask indicating which configuration to export */
const char *zMask, /* Name of the configuration */
sqlite3_int64 iStart, /* Start date */
const char *zFilename /* Write into this file */
){
Blob out;
blob_zero(&out);
| | | 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
int groupMask, /* Mask indicating which configuration to export */
const char *zMask, /* Name of the configuration */
sqlite3_int64 iStart, /* Start date */
const char *zFilename /* Write into this file */
){
Blob out;
blob_zero(&out);
blob_appendf(&out,
"# The \"%s\" configuration exported from\n"
"# repository \"%s\"\n"
"# on %s\n",
zMask, g.zRepositoryName,
db_text(0, "SELECT datetime('now')")
);
configure_send_group(&out, groupMask, iStart);
|
| ︙ | ︙ | |||
815 816 817 818 819 820 821 | ** %fossil configuration reset AREA ** ** Restore the configuration to the default. AREA as above. ** ** %fossil configuration sync AREA ?URL? ** ** Synchronize configuration changes in the local repository with | | | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
** %fossil configuration reset AREA
**
** Restore the configuration to the default. AREA as above.
**
** %fossil configuration sync AREA ?URL?
**
** Synchronize configuration changes in the local repository with
** the remote repository at URL.
**
** Options:
** -R|--repository FILE Extract info from repository FILE
**
** See also: settings, unset
*/
void configuration_cmd(void){
|
| ︙ | ︙ | |||
850 851 852 853 854 855 856 |
zSince, zSince
);
}else{
iStart = 0;
}
export_config(mask, g.argv[3], iStart, g.argv[4]);
}else
| | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
zSince, zSince
);
}else{
iStart = 0;
}
export_config(mask, g.argv[3], iStart, g.argv[4]);
}else
if( strncmp(zMethod, "import", n)==0
|| strncmp(zMethod, "merge", n)==0 ){
Blob in;
int groupMask;
if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod));
blob_read_from_file(&in, g.argv[3]);
db_begin_transaction();
if( zMethod[0]=='i' ){
|
| ︙ | ︙ | |||
913 914 915 916 917 918 919 |
}
}else
if( strncmp(zMethod, "reset", n)==0 ){
int mask, i;
char *zBackup;
if( g.argc!=4 ) usage("reset AREA");
mask = configure_name_to_mask(g.argv[3], 1);
| | | 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
}
}else
if( strncmp(zMethod, "reset", n)==0 ){
int mask, i;
char *zBackup;
if( g.argc!=4 ) usage("reset AREA");
mask = configure_name_to_mask(g.argv[3], 1);
zBackup = db_text(0,
"SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')");
db_begin_transaction();
export_config(mask, g.argv[3], 0, zBackup);
for(i=0; i<count(aConfig); i++){
const char *zName = aConfig[i].zName;
if( (aConfig[i].groupMask & mask)==0 ) continue;
if( zName[0]!='@' ){
|
| ︙ | ︙ | |||
935 936 937 938 939 940 941 |
db_multi_exec("DELETE FROM shun");
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
db_multi_exec("DELETE FROM reportfmt");
}
}
db_end_transaction(0);
fossil_print("Configuration reset to factory defaults.\n");
| | | | 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
db_multi_exec("DELETE FROM shun");
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
db_multi_exec("DELETE FROM reportfmt");
}
}
db_end_transaction(0);
fossil_print("Configuration reset to factory defaults.\n");
fossil_print("To recover, use: %s %s import %s\n",
g.argv[0], g.argv[1], zBackup);
}else
{
fossil_fatal("METHOD should be one of:"
" export import merge pull push reset");
}
}
|
Changes to src/db.c.
| ︙ | ︙ | |||
63 64 65 66 67 68 69 |
/*
** Call this routine when a database error occurs.
*/
static void db_err(const char *zFormat, ...){
va_list ap;
char *z;
int rc = 1;
| | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
/*
** Call this routine when a database error occurs.
*/
static void db_err(const char *zFormat, ...){
va_list ap;
char *z;
int rc = 1;
static const char zRebuildMsg[] =
"If you have recently updated your fossil executable, you might\n"
"need to run \"fossil all rebuild\" to bring the repository\n"
"schemas up to date.\n";
va_start(ap, zFormat);
z = vmprintf(zFormat, ap);
va_end(ap);
#ifdef FOSSIL_ENABLE_JSON
|
| ︙ | ︙ | |||
90 91 92 93 94 95 96 |
}
else if( g.cgiOutput ){
g.cgiOutput = 0;
cgi_printf("<h1>Database Error</h1>\n"
"<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
cgi_reply();
}else{
| | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
}
else if( g.cgiOutput ){
g.cgiOutput = 0;
cgi_printf("<h1>Database Error</h1>\n"
"<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
cgi_reply();
}else{
fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg);
}
free(z);
db_force_rollback();
fossil_exit(rc);
}
/*
|
| ︙ | ︙ | |||
693 694 695 696 697 698 699 |
zDbName, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
zVfs
);
if( rc!=SQLITE_OK ){
db_err(sqlite3_errmsg(db));
}
| | | 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
zDbName, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
zVfs
);
if( rc!=SQLITE_OK ){
db_err(sqlite3_errmsg(db));
}
sqlite3_busy_timeout(db, 5000);
sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
return db;
}
/*
|
| ︙ | ︙ | |||
830 831 832 833 834 835 836 | if( file_access(zDbName, F_OK) ) return 0; lsize = file_size(zDbName); if( lsize%1024!=0 || lsize<4096 ) return 0; db_open_or_attach(zDbName, "localdb"); /* If the "isexe" column is missing from the vfile table, then ** add it now. This code added on 2010-03-06. After all users have | | | | | | | | | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
if( file_access(zDbName, F_OK) ) return 0;
lsize = file_size(zDbName);
if( lsize%1024!=0 || lsize<4096 ) return 0;
db_open_or_attach(zDbName, "localdb");
/* If the "isexe" column is missing from the vfile table, then
** add it now. This code added on 2010-03-06. After all users have
** upgraded, this code can be safely deleted.
*/
if( !db_local_column_exists("vfile", "isexe") ){
db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
}
/* If "islink"/"isLink" columns are missing from tables, then
** add them now. This code added on 2011-01-17 and 2011-08-27.
** After all users have upgraded, this code can be safely deleted.
*/
if( !db_local_column_exists("vfile", "islink") ){
db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
}
if( !db_local_column_exists("stashfile", "isLink") &&
db_local_table_exists("stashfile") ){
db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
}
if( !db_local_column_exists("undo", "isLink") &&
db_local_table_exists("undo") ){
db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
}
if( !db_local_column_exists("undo_vfile", "islink") &&
db_local_table_exists("undo_vfile") ){
db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
}
return 1;
}
/*
** Locate the root directory of the local repository tree. The root
** directory is found by searching for a file named "_FOSSIL_" or ".fslckout"
** that contains a valid repository database.
**
** For legacy, also look for ".fos". The use of ".fos" is deprecated
** since "fos" has negative connotations in Hungarian, we are told.
**
** If no valid _FOSSIL_ or .fos file is found, we move up one level and
** try again. Once the file is found, the g.zLocalRoot variable is set
** to the root of the repository tree and this routine returns 1. If
** no database is found, then this routine return 0.
**
** This routine always opens the user database regardless of whether or
** not the repository database is found. If the _FOSSIL_ or .fos file
** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
int i, n;
char zPwd[2000];
static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
if( g.localOpen) return 1;
file_getcwd(zPwd, sizeof(zPwd)-20);
n = strlen(zPwd);
if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
while( n>0 ){
if( file_access(zPwd, W_OK) ) break;
for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
|
| ︙ | ︙ | |||
1395 1396 1397 1398 1399 1400 1401 |
db_begin_transaction();
db_initial_setup(zTemplate, zDate, zDefaultUser, 1);
db_end_transaction(0);
if( zTemplate ) db_detach("settingSrc");
fossil_print("project-id: %s\n", db_get("project-code", 0));
fossil_print("server-id: %s\n", db_get("server-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
| | | 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
db_begin_transaction();
db_initial_setup(zTemplate, zDate, zDefaultUser, 1);
db_end_transaction(0);
if( zTemplate ) db_detach("settingSrc");
fossil_print("project-id: %s\n", db_get("project-code", 0));
fossil_print("server-id: %s\n", db_get("server-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
fossil_print("admin-user: %s (initial password is \"%s\")\n",
g.zLogin, zPassword);
}
/*
** SQL functions for debugging.
**
** The print() function writes its arguments on stdout, but only
|
| ︙ | ︙ | |||
1441 1442 1443 1444 1445 1446 1447 |
if( g.zLogin!=0 ){
sqlite3_result_text(context, g.zLogin, -1, SQLITE_STATIC);
}
}
/*
** Implement the cgi() SQL function. cgi() takes a an argument which is
| | | 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
if( g.zLogin!=0 ){
sqlite3_result_text(context, g.zLogin, -1, SQLITE_STATIC);
}
}
/*
** Implement the cgi() SQL function. cgi() takes a an argument which is
** a name of CGI query parameter. The value of that parameter is returned,
** if available. optional second argument will be returned if the first
** doesn't exist as a CGI parameter.
*/
static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){
const char* zP;
if( argc!=1 && argc!=2 ) return;
zP = P((const char*)sqlite3_value_text(argv[0]));
|
| ︙ | ︙ | |||
1636 1637 1638 1639 1640 1641 1642 |
char *zVersionedSetting = 0;
int noWarn = 0;
struct _cacheEntry {
struct _cacheEntry *next;
const char *zName, *zValue;
} *cacheEntry = 0;
static struct _cacheEntry *cache = 0;
| | | 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
char *zVersionedSetting = 0;
int noWarn = 0;
struct _cacheEntry {
struct _cacheEntry *next;
const char *zName, *zValue;
} *cacheEntry = 0;
static struct _cacheEntry *cache = 0;
/* Look up name in cache */
cacheEntry = cache;
while( cacheEntry!=0 ){
if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
zVersionedSetting = fossil_strdup(cacheEntry->zValue);
break;
}
|
| ︙ | ︙ | |||
1863 1864 1865 1866 1867 1868 1869 |
file_canonical_name(g.zLocalRoot, &localRoot, 1);
db_multi_exec(
"REPLACE INTO global_config(name, value)"
"VALUES('ckout:%q','%q');",
blob_str(&localRoot), blob_str(&full)
);
db_swap_connections();
| | | 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 |
file_canonical_name(g.zLocalRoot, &localRoot, 1);
db_multi_exec(
"REPLACE INTO global_config(name, value)"
"VALUES('ckout:%q','%q');",
blob_str(&localRoot), blob_str(&full)
);
db_swap_connections();
db_optional_sql("repository",
"REPLACE INTO config(name,value,mtime)"
"VALUES('ckout:%q',1,now())",
blob_str(&localRoot)
);
blob_reset(&localRoot);
}else{
db_swap_connections();
|
| ︙ | ︙ | |||
2062 2063 2064 2065 2066 2067 2068 | ** file exists. ** ** The "unset" command clears a property setting. ** ** ** allow-symlinks If enabled, don't follow symlinks, and instead treat ** (versionable) them as symlinks on Unix. Has no effect on Windows | | | 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 | ** file exists. ** ** The "unset" command clears a property setting. ** ** ** allow-symlinks If enabled, don't follow symlinks, and instead treat ** (versionable) them as symlinks on Unix. Has no effect on Windows ** (existing links in repository created on Unix become ** plain-text files with link destination path inside). ** Default: off ** ** auto-captcha If enabled, the Login page provides a button to ** fill in the captcha password. Default: on ** ** auto-hyperlink Use javascript to enable hyperlinks on web pages |
| ︙ | ︙ | |||
2210 2211 2212 2213 2214 2215 2216 | ** web browser when given a URL as an argument. ** Defaults to "start" on windows, "open" on Mac, ** and "firefox" on Unix. ** ** Options: ** --global set or unset the given property globally instead of ** setting or unsetting it for the open repository only. | | | 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 |
** web browser when given a URL as an argument.
** Defaults to "start" on windows, "open" on Mac,
** and "firefox" on Unix.
**
** Options:
** --global set or unset the given property globally instead of
** setting or unsetting it for the open repository only.
**
** See also: configuration
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int unsetFlag = g.argv[1][0]=='u';
db_open_config(1);
|
| ︙ | ︙ | |||
2298 2299 2300 2301 2302 2303 2304 |
** %fossil test-timespan TIMESTAMP
**
** Print the approximate span of time from now to TIMESTAMP.
*/
void test_timespan_cmd(void){
double rDiff;
if( g.argc!=3 ) usage("TIMESTAMP");
| | | 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 |
** %fossil test-timespan TIMESTAMP
**
** Print the approximate span of time from now to TIMESTAMP.
*/
void test_timespan_cmd(void){
double rDiff;
if( g.argc!=3 ) usage("TIMESTAMP");
sqlite3_open(":memory:", &g.db);
rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
sqlite3_close(g.db);
g.db = 0;
}
|
Changes to src/http_transport.c.
| ︙ | ︙ | |||
299 300 301 302 303 304 305 |
void transport_flip(void){
if( g.urlIsSsh ){
fprintf(sshOut, "\n\n");
}else if( g.urlIsFile ){
char *zCmd;
fclose(transport.pFile);
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
| | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
void transport_flip(void){
if( g.urlIsSsh ){
fprintf(sshOut, "\n\n");
}else if( g.urlIsFile ){
char *zCmd;
fclose(transport.pFile);
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
g.nameOfExe, g.urlName, transport.zOutFile, transport.zInFile
);
fossil_system(zCmd);
free(zCmd);
transport.pFile = fopen(transport.zInFile, "rb");
}
}
|
| ︙ | ︙ |
Changes to src/json.c.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** Code for the JSON API. ** ** For notes regarding the public JSON interface, please see: ** ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit ** ** |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 |
*/
static void beginTimer(void){
getrusage(RUSAGE_SELF, &sBegin);
}
/* Return the difference of two time_structs in milliseconds */
static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
| | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
*/
static void beginTimer(void){
getrusage(RUSAGE_SELF, &sBegin);
}
/* Return the difference of two time_structs in milliseconds */
static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
return ((pEnd->tv_usec - pStart->tv_usec)*0.001 +
(double)((pEnd->tv_sec - pStart->tv_sec)*1000.0));
}
/*
** Print the timing results.
*/
static double endTimer(void){
|
| ︙ | ︙ | |||
126 127 128 129 130 131 132 |
if( hProcess ){
HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
if( NULL != hinstLib ){
getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
if( NULL != getProcessTimesAddr ){
return 1;
}
| | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
if( hProcess ){
HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
if( NULL != hinstLib ){
getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
if( NULL != getProcessTimesAddr ){
return 1;
}
FreeLibrary(hinstLib);
}
}
}
return 0;
}
/*
|
| ︙ | ︙ | |||
168 169 170 171 172 173 174 | } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER hasTimer() #else | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER hasTimer() #else #define BEGIN_TIMER #define END_TIMER 0.0 #define HAS_TIMER 0 #endif /* ** Returns true (non-0) if fossil appears to be running in JSON mode. */ |
| ︙ | ︙ | |||
210 211 212 213 214 215 216 |
C(TIMEOUT,"Timeout reached");
C(ASSERT,"Assertion failed");
C(ALLOC,"Resource allocation failed");
C(NYI,"Not yet implemented");
C(PANIC,"x");
C(MANIFEST_READ_FAILED,"Reading artifact manifest failed");
C(FILE_OPEN_FAILED,"Opening file failed");
| | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
C(TIMEOUT,"Timeout reached");
C(ASSERT,"Assertion failed");
C(ALLOC,"Resource allocation failed");
C(NYI,"Not yet implemented");
C(PANIC,"x");
C(MANIFEST_READ_FAILED,"Reading artifact manifest failed");
C(FILE_OPEN_FAILED,"Opening file failed");
C(AUTH,"Authentication error");
C(MISSING_AUTH,"Authentication info missing from request");
C(DENIED,"Access denied");
C(WRONG_MODE,"Request not allowed (wrong operation mode)");
C(LOGIN_FAILED,"Login failed");
C(LOGIN_FAILED_NOSEED,"Anonymous login attempt was missing password seed");
C(LOGIN_FAILED_NONAME,"Login failed - name not supplied");
|
| ︙ | ︙ | |||
346 347 348 349 350 351 352 |
int const rc = cson_array_append( g.json.gc.a, v );
assert( NULL != g.json.gc.a );
if( 0 != rc ){
cson_value_free( v );
}
assert( (0==rc) && "Adding item to GC failed." );
if(0!=rc){
| | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
int const rc = cson_array_append( g.json.gc.a, v );
assert( NULL != g.json.gc.a );
if( 0 != rc ){
cson_value_free( v );
}
assert( (0==rc) && "Adding item to GC failed." );
if(0!=rc){
fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0])
/* reminder: allocation error is the only reasonable cause of
error here, provided g.json.gc.a and v are not NULL.
*/
;
fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere
where this function is called again.
*/;
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 | char * zStr; va_list vargs; va_start(vargs,fmt); zStr = vmprintf(fmt,vargs); va_end(vargs); v = cson_value_new_string(zStr, strlen(zStr)); free(zStr); | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
char * zStr;
va_list vargs;
va_start(vargs,fmt);
zStr = vmprintf(fmt,vargs);
va_end(vargs);
v = cson_value_new_string(zStr, strlen(zStr));
free(zStr);
return v;
}
cson_value * json_new_int( int v ){
return cson_value_new_integer((cson_int_t)v);
}
/*
|
| ︙ | ︙ | |||
671 672 673 674 675 676 677 |
if( g.json.jsonp ){
return doUtf8
? "application/javascript; charset=utf-8"
: "application/javascript";
}else{
/*
Content-type
| | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
if( g.json.jsonp ){
return doUtf8
? "application/javascript; charset=utf-8"
: "application/javascript";
}else{
/*
Content-type
If the browser does not sent an ACCEPT for application/json
then we fall back to text/plain.
*/
char const * cstr;
cstr = PD("HTTP_ACCEPT",NULL);
if( NULL == cstr ){
return doUtf8
|
| ︙ | ︙ | |||
1115 1116 1117 1118 1119 1120 1121 |
}
cgi_parse_POST_JSON(inFile, 0);
if( stdin != inFile ){
fclose(inFile);
}
break;
}
| | | 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
}
cgi_parse_POST_JSON(inFile, 0);
if( stdin != inFile ){
fclose(inFile);
}
break;
}
/* g.json.reqPayload exists only to simplify some of our access to
the request payload. We currently only use this in the context of
Object payloads, not Arrays, strings, etc.
*/
g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload );
if( g.json.reqPayload.v ){
g.json.reqPayload.o = cson_value_get_object( g.json.reqPayload.v )
|
| ︙ | ︙ | |||
1144 1145 1146 1147 1148 1149 1150 |
char const * cmd = json_getenv_cstr("command");
if(cmd){
json_string_split(cmd, '/', 0, g.json.cmd.a);
g.json.cmd.commandStr = cmd;
}
}
| | | 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
char const * cmd = json_getenv_cstr("command");
if(cmd){
json_string_split(cmd, '/', 0, g.json.cmd.a);
g.json.cmd.commandStr = cmd;
}
}
if(!g.json.jsonp){
g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL);
}
if(!g.isHTTP){
g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/;
}
|
| ︙ | ︙ | |||
1445 1446 1447 1448 1449 1450 1451 | VAL(gc, g.json.gc.v); VAL(cmd, g.json.cmd.v); VAL(param, g.json.param.v); VAL(POST, g.json.post.v); VAL(warnings, cson_array_value(g.json.warnings)); /*cson_output_opt outOpt;*/ | | | 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 | VAL(gc, g.json.gc.v); VAL(cmd, g.json.cmd.v); VAL(param, g.json.param.v); VAL(POST, g.json.post.v); VAL(warnings, cson_array_value(g.json.warnings)); /*cson_output_opt outOpt;*/ #undef INT #undef CSTR #undef VAL return cson_object_value(pay); } |
| ︙ | ︙ | |||
1493 1494 1495 1496 1497 1498 1499 |
rc = cson_object_set( o, K, tmp ); \
if(rc) do{\
cson_value_free(tmp); \
tmp = NULL; \
goto cleanup; \
}while(0)
| | | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 |
rc = cson_object_set( o, K, tmp ); \
if(rc) do{\
cson_value_free(tmp); \
tmp = NULL; \
goto cleanup; \
}while(0)
tmp = json_new_string(MANIFEST_UUID);
SET("fossil");
tmp = json_new_timestamp(-1);
SET(FossilJsonKeys.timestamp);
if( 0 != resultCode ){
|
| ︙ | ︙ | |||
1522 1523 1524 1525 1526 1527 1528 |
if(g.json.cmd.commandStr){
tmp = json_new_string(g.json.cmd.commandStr);
}else{
tmp = json_response_command_path();
}
SET("command");
| | | 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 |
if(g.json.cmd.commandStr){
tmp = json_new_string(g.json.cmd.commandStr);
}else{
tmp = json_response_command_path();
}
SET("command");
tmp = json_getenv(FossilJsonKeys.requestId);
if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp );
if(0){/* these are only intended for my own testing...*/
if(g.json.cmd.v){
tmp = g.json.cmd.v;
SET("$commandPath");
|
| ︙ | ︙ | |||
1559 1560 1561 1562 1563 1564 1565 |
*/
cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)((span>1.0)?span:1)));
}
if(g.json.warnings){
tmp = cson_array_value(g.json.warnings);
SET("warnings");
}
| | | | 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 |
*/
cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)((span>1.0)?span:1)));
}
if(g.json.warnings){
tmp = cson_array_value(g.json.warnings);
SET("warnings");
}
/* Only add the payload to SUCCESS responses. Else delete it. */
if( NULL != payload ){
if( resultCode ){
cson_value_free(payload);
payload = NULL;
}else{
tmp = payload;
SET(FossilJsonKeys.payload);
}
}
if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0)
&&(g.perm.Admin||g.perm.Setup)){
tmp = json_g_to_json();
SET("g");
}
#undef SET
goto ok;
cleanup:
cson_value_free(v);
v = NULL;
ok:
return v;
|
| ︙ | ︙ | |||
1626 1627 1628 1629 1630 1631 1632 |
}
resp = json_create_response(rc, msg, NULL);
if(!resp){
/* about the only error case here is out-of-memory. DO NOT
call fossil_panic() here because that calls this function.
*/
fprintf(stderr, "%s: Fatal error: could not allocate "
| | | 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 |
}
resp = json_create_response(rc, msg, NULL);
if(!resp){
/* about the only error case here is out-of-memory. DO NOT
call fossil_panic() here because that calls this function.
*/
fprintf(stderr, "%s: Fatal error: could not allocate "
"response object.\n", g.argv[0]);
fossil_exit(1);
}
if( g.isHTTP ){
if(alsoOutput){
json_send_response(resp);
}else{
/* almost a duplicate of json_send_response() :( */
|
| ︙ | ︙ | |||
1699 1700 1701 1702 1703 1704 1705 |
}
if(!colNames){
colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
assert(NULL != colNamesV);
/*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/;
colNames = cson_value_get_array(colNamesV);
assert(NULL != colNames);
| | | | 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 |
}
if(!colNames){
colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
assert(NULL != colNamesV);
/*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/;
colNames = cson_value_get_array(colNamesV);
assert(NULL != colNames);
}
row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames);
if(!row && !warnMsg){
warnMsg = "Could not convert at least one result row to JSON.";
continue;
}
if( 0 != cson_array_append(a, row) ){
cson_value_free(row);
if(pTgt != a) {
cson_free_array(a);
}
assert( 0 && "Alloc error.");
return NULL;
}
}
cson_value_free(colNamesV);
if(warnMsg){
json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg );
}
return cson_array_value(a);
}
/*
** Works just like json_stmt_to_array_of_obj(), but each row in the
** result set is represented as an Array of values instead of an
** Object (key/value pairs). If pTgt is NULL and the statement
** has no results then NULL is returned, not an empty array.
|
| ︙ | ︙ | |||
1807 1808 1809 1810 1811 1812 1813 |
char * tags = info_tags_of_checkin(rid, propagatingOnly);
if(tags){
if(*tags){
v = json_string_split2(tags,',',0);
}
free(tags);
}
| | | 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
char * tags = info_tags_of_checkin(rid, propagatingOnly);
if(tags){
if(*tags){
v = json_string_split2(tags,',',0);
}
free(tags);
}
return v;
}
/*
** Returns a "new" value representing the boolean value of zVal
** (false if zVal is NULL). Note that cson does not really allocate
** any memory for boolean values, but they "should" (for reasons of
** style and philosophy) be cleaned up like any other values (but
|
| ︙ | ︙ | |||
1857 1858 1859 1860 1861 1862 1863 |
C(TIMEOUT);
C(ASSERT);
C(ALLOC);
C(NYI);
C(PANIC);
C(MANIFEST_READ_FAILED);
C(FILE_OPEN_FAILED);
| | | 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 |
C(TIMEOUT);
C(ASSERT);
C(ALLOC);
C(NYI);
C(PANIC);
C(MANIFEST_READ_FAILED);
C(FILE_OPEN_FAILED);
C(AUTH);
C(MISSING_AUTH);
C(DENIED);
C(WRONG_MODE);
C(LOGIN_FAILED);
C(LOGIN_FAILED_NOSEED);
C(LOGIN_FAILED_NONAME);
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
#endif
/*
** All global variables are in this structure.
*/
struct Global {
int argc; char **argv; /* Command-line arguments to the program */
int isConst; /* True if the output is unchanging */
sqlite3 *db; /* The connection to the databases */
sqlite3 *dbConfig; /* Separate connection for global_config table */
int useAttach; /* True if global_config is attached to repository */
int configOpen; /* True if the config database is open */
sqlite3_int64 now; /* Seconds since 1970 */
int repositoryOpen; /* True if the main repository database is open */
| > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
#endif
/*
** All global variables are in this structure.
*/
struct Global {
int argc; char **argv; /* Command-line arguments to the program */
char *nameOfExe; /* Full path of executable. */
int isConst; /* True if the output is unchanging */
sqlite3 *db; /* The connection to the databases */
sqlite3 *dbConfig; /* Separate connection for global_config table */
int useAttach; /* True if global_config is attached to repository */
int configOpen; /* True if the config database is open */
sqlite3_int64 now; /* Seconds since 1970 */
int repositoryOpen; /* True if the main repository database is open */
|
| ︙ | ︙ | |||
475 476 477 478 479 480 481 | #endif g.argc = argc; g.argv = argv; #ifdef _WIN32 parse_windows_command_line(&g.argc, &g.argv); GetModuleFileNameW(NULL, buf, MAX_PATH); | | | > > | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
#endif
g.argc = argc;
g.argv = argv;
#ifdef _WIN32
parse_windows_command_line(&g.argc, &g.argv);
GetModuleFileNameW(NULL, buf, MAX_PATH);
g.nameOfExe = fossil_unicode_to_utf8(buf);
for(i=0; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
#else
g.nameOfExe = g.argv[0];
#endif
for(i=1; i<g.argc-1; i++){
z = g.argv[i];
if( z[0]!='-' ) continue;
z++;
if( z[0]=='-' ) z++;
if( z[0]==0 ) return; /* Stop searching at "--" */
|
| ︙ | ︙ | |||
649 650 651 652 653 654 655 | /* ** The following variable becomes true while processing a fatal error ** or a panic. If additional "recursive-fatal" errors occur while ** shutting down, the recursive errors are silently ignored. */ static int mainInFatalError = 0; | < < < < < < < | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
/*
** The following variable becomes true while processing a fatal error
** or a panic. If additional "recursive-fatal" errors occur while
** shutting down, the recursive errors are silently ignored.
*/
static int mainInFatalError = 0;
/*
** Exit. Take care to close the database first.
*/
NORETURN void fossil_exit(int rc){
db_close(1);
exit(rc);
}
|
| ︙ | ︙ |
Changes to src/winhttp.c.
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
break;
}
wanted -= got;
}
fclose(out);
out = 0;
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
| | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
break;
}
wanted -= got;
}
fclose(out);
out = 0;
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName,
inet_ntoa(p->addr.sin_addr), p->zOptions
);
fossil_system(zCmd);
in = fossil_fopen(zReplyFName, "rb");
if( in ){
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
send(p->s, zHdr, got, 0);
|
| ︙ | ︙ | |||
612 613 614 615 616 617 618 |
file_simplify_name(g.zRepositoryName, -1, 0);
}else{
db_open_repository(zRepository);
}
db_close(0);
/* Build the fully-qualified path to the service binary file. */
blob_zero(&binPath);
| | | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
file_simplify_name(g.zRepositoryName, -1, 0);
}else{
db_open_repository(zRepository);
}
db_close(0);
/* Build the fully-qualified path to the service binary file. */
blob_zero(&binPath);
blob_appendf(&binPath, "\"%s\" server", g.nameOfExe);
if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
/* Create the service. */
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
|
| ︙ | ︙ |