| | @@ -1492,10 +1492,48 @@ |
| 1492 | 1492 | } |
| 1493 | 1493 | db_finalize(&q); |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | |
| 1497 | +/* |
| 1498 | +** define all settings, which can be controlled via the set/unset |
| 1499 | +** command. var is the name of the internal configuration name for db_(un)set. |
| 1500 | +** If var is 0, the settings name is used. |
| 1501 | +** width is the length for the edit field on the behavior page, 0 |
| 1502 | +** is used for on/off checkboxes. |
| 1503 | +** The behaviour page doesn't use a special layout. It lists all |
| 1504 | +** set-commands and displays the 'set'-help as info. |
| 1505 | +*/ |
| 1506 | +#if INTERFACE |
| 1507 | +struct stControlSettings { |
| 1508 | + char const *name; /* Name of the setting */ |
| 1509 | + char const *var; /* Internal variable name used by db_set() */ |
| 1510 | + int width; /* Width of display. 0 for boolean values */ |
| 1511 | + char const *def; /* Default value */ |
| 1512 | +}; |
| 1513 | +#endif /* INTERFACE */ |
| 1514 | +struct stControlSettings const ctrlSettings[] = { |
| 1515 | + { "auto-captcha", "autocaptcha", 0, "0" }, |
| 1516 | + { "auto-shun", 0, 0, "1" }, |
| 1517 | + { "autosync", 0, 0, "0" }, |
| 1518 | + { "binary-glob", 0, 0, "1" }, |
| 1519 | + { "clearsign", 0, 0, "0" }, |
| 1520 | + { "diff-command", 0, 16, "diff" }, |
| 1521 | + { "dont-push", 0, 0, "0" }, |
| 1522 | + { "editor", 0, 16, "" }, |
| 1523 | + { "gdiff-command", 0, 16, "gdiff" }, |
| 1524 | + { "ignore-glob", 0, 40, "" }, |
| 1525 | + { "http-port", 0, 16, "8080" }, |
| 1526 | + { "localauth", 0, 0, "0" }, |
| 1527 | + { "mtime-changes", 0, 0, "0" }, |
| 1528 | + { "pgp-command", 0, 32, "gpg --clearsign -o " }, |
| 1529 | + { "proxy", 0, 32, "off" }, |
| 1530 | + { "ssh-command", 0, 32, "" }, |
| 1531 | + { "web-browser", 0, 32, "" }, |
| 1532 | + { 0,0,0,0 } |
| 1533 | +}; |
| 1534 | + |
| 1497 | 1535 | /* |
| 1498 | 1536 | ** COMMAND: settings |
| 1499 | 1537 | ** COMMAND: unset |
| 1500 | 1538 | ** %fossil settings ?PROPERTY? ?VALUE? ?-global? |
| 1501 | 1539 | ** %fossil unset PROPERTY ?-global? |
| | @@ -1567,29 +1605,10 @@ |
| 1567 | 1605 | ** web browser when given a URL as an argument. |
| 1568 | 1606 | ** Defaults to "start" on windows, "open" on Mac, |
| 1569 | 1607 | ** and "firefox" on Unix. |
| 1570 | 1608 | */ |
| 1571 | 1609 | void setting_cmd(void){ |
| 1572 | | - static const char *azName[] = { |
| 1573 | | - "auto-captcha", |
| 1574 | | - "auto-shun", |
| 1575 | | - "autosync", |
| 1576 | | - "binary-glob", |
| 1577 | | - "clearsign", |
| 1578 | | - "diff-command", |
| 1579 | | - "dont-push", |
| 1580 | | - "editor", |
| 1581 | | - "gdiff-command", |
| 1582 | | - "ignore-glob", |
| 1583 | | - "http-port", |
| 1584 | | - "localauth", |
| 1585 | | - "mtime-changes", |
| 1586 | | - "pgp-command", |
| 1587 | | - "proxy", |
| 1588 | | - "ssh-command", |
| 1589 | | - "web-browser", |
| 1590 | | - }; |
| 1591 | 1610 | int i; |
| 1592 | 1611 | int globalFlag = find_option("global","g",0)!=0; |
| 1593 | 1612 | int unsetFlag = g.argv[1][0]=='u'; |
| 1594 | 1613 | db_open_config(1); |
| 1595 | 1614 | db_find_and_open_repository(0); |
| | @@ -1598,28 +1617,28 @@ |
| 1598 | 1617 | } |
| 1599 | 1618 | if( unsetFlag && g.argc!=3 ){ |
| 1600 | 1619 | usage("PROPERTY ?-global?"); |
| 1601 | 1620 | } |
| 1602 | 1621 | if( g.argc==2 ){ |
| 1603 | | - for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 1604 | | - print_setting(azName[i]); |
| 1622 | + for(i=0; ctrlSettings[i].name; i++){ |
| 1623 | + print_setting(ctrlSettings[i].name); |
| 1605 | 1624 | } |
| 1606 | 1625 | }else if( g.argc==3 || g.argc==4 ){ |
| 1607 | 1626 | const char *zName = g.argv[2]; |
| 1608 | 1627 | int n = strlen(zName); |
| 1609 | | - for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 1610 | | - if( strncmp(azName[i], zName, n)==0 ) break; |
| 1628 | + for(i=0; ctrlSettings[i].name; i++){ |
| 1629 | + if( strncmp(ctrlSettings[i].name, zName, n)==0 ) break; |
| 1611 | 1630 | } |
| 1612 | | - if( i>=sizeof(azName)/sizeof(azName[0]) ){ |
| 1631 | + if( !ctrlSettings[i].name ){ |
| 1613 | 1632 | fossil_fatal("no such setting: %s", zName); |
| 1614 | 1633 | } |
| 1615 | 1634 | if( unsetFlag ){ |
| 1616 | | - db_unset(azName[i], globalFlag); |
| 1635 | + db_unset(ctrlSettings[i].name, globalFlag); |
| 1617 | 1636 | }else if( g.argc==4 ){ |
| 1618 | | - db_set(azName[i], g.argv[3], globalFlag); |
| 1637 | + db_set(ctrlSettings[i].name, g.argv[3], globalFlag); |
| 1619 | 1638 | }else{ |
| 1620 | | - print_setting(azName[i]); |
| 1639 | + print_setting(ctrlSettings[i].name); |
| 1621 | 1640 | } |
| 1622 | 1641 | }else{ |
| 1623 | 1642 | usage("?PROPERTY? ?VALUE?"); |
| 1624 | 1643 | } |
| 1625 | 1644 | } |
| 1626 | 1645 | |