~ubuntu-branches/ubuntu/jaunty/xterm/jaunty

« back to all changes in this revision

Viewing changes to os2main.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau, Branden Robinson, Julien Cristau
  • Date: 2007-06-18 14:02:22 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070618140222-pk2uof6pyni5omqf
Tags: 226-1
[ Branden Robinson ]
* Remove debian/NEWS; the events it attested to (like the "upcoming 7.0
  modularization" are no longer news, and are in the past.

[ Julien Cristau ]
* Configure with --with-tty-group=tty, to prevent security problems in case
  of buggy build environment (closes: #349142).
* New upstream release.
  + fix  an  infinite  loop  when  showing  a  2-column character in a
    1-column screen (closes: #426863).
  + add  XF86Paste  and  SunPaste  to the default translations
    (closes: #422521, patch by Bernhard R Link).
  + improve  permissions  logic  when  closing pseudo-terminal
    (closes: #12261, patch by Nathanael Nerode, analysis by Richard
    Braakman).
  + add  a check in case someone tries to call the popup-menu() action
    on a menu which is not initialized (closes: #426364).
  + fix error-checking on internal font switching for "Selection" menu
    entry (closes: #421523).
  + amend select/paste change from patch #225 by limiting it to
    non-UTF-8/non-KOI8-R encoding (closes: #420974).
  + add  workaround  for  groff  ".URL" codes which are not present in
    some commonly-used bitmap fonts (closes: #418324).
* Update reference to xlibs-data in xterm's description, refer to xbitmaps
  instead.
* Build-depend on desktop-file-utils to install the new desktop files for
  xterm and uxterm, and change debian/rules and debian/xterm.install to
  install these files and the icons.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: os2main.c,v 1.247 2007/03/19 23:48:32 tom Exp $ */
 
1
/* $XTermId: os2main.c,v 1.249 2007/06/09 13:42:04 tom Exp $ */
2
2
 
3
3
/* removed all foreign stuff to get the code more clear (hv)
4
4
 * and did some rewrite for the obscure OS/2 environment
127
127
 
128
128
static SIGNAL_T reapchild(int n);
129
129
static int spawnXTerm(XtermWidget /* xw */ );
130
 
static void resize_termcap(XTermWidget xw, char *oldtc, char *newtc);
 
130
static void resize_termcap(XtermWidget xw, char *newtc);
131
131
static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode);
132
132
 
133
133
static Bool added_utmp_entry = False;
192
192
#define CWERASE CONTROL('W')
193
193
#endif
194
194
 
 
195
#define TERMIO_STRUCT struct termio
 
196
 
195
197
/*
196
198
 * SYSV has the termio.c_cc[V] and ltchars; BSD has tchars and ltchars;
197
199
 * SVR4 has only termio.c_cc, but it includes everything from ltchars.
1474
1476
        if (why != ENOENT
1475
1477
            && save_ruid == 0) {
1476
1478
            fprintf(stderr, "Cannot chown %s to %ld,%ld: %s\n",
1477
 
                    device, (long) uid, (long) gid, strerror(why));
1478
 
        }
1479
 
    }
1480
 
#ifndef __EMX__
1481
 
/* EMX can chmod files only, not devices */
1482
 
    if (chmod(device, mode) < 0) {
1483
 
        why = errno;
1484
 
        if (why != ENOENT) {
1485
 
            struct stat sb;
1486
 
            if (stat(device, &sb) < 0) {
1487
 
                fprintf(stderr, "Cannot chmod %s to %03o: %s\n",
1488
 
                        device, mode, strerror(why));
1489
 
            } else {
1490
 
                fprintf(stderr,
1491
 
                        "Cannot chmod %s to %03o currently %03o: %s\n",
1492
 
                        device, mode, (sb.st_mode & S_IFMT), strerror(why));
1493
 
            }
1494
 
        }
1495
 
    }
1496
 
#endif
 
1479
                    device, (long) uid, (long) gid,
 
1480
                    strerror(why));
 
1481
        }
 
1482
    }
1497
1483
}
1498
1484
 
1499
1485
#define THE_PARENT 1
1538
1524
    int Xsocket = ConnectionNumber(screen->display);
1539
1525
 
1540
1526
    int ttyfd = -1;
1541
 
    struct termio tio;
 
1527
    TERMIO_STRUCT tio;
1542
1528
    int status;
 
1529
    Bool ok_termcap;
 
1530
    char *newtc;
1543
1531
 
1544
 
    char newtc[TERMCAP_SIZE];
1545
1532
    char *TermName = NULL;
1546
1533
    char *ptr, *shname, buf[64];
1547
 
    int i, no_dev_tty = False, envsize;
 
1534
    int i, no_dev_tty = False;
1548
1535
    char *dev_tty_name = (char *) 0;
1549
1536
    TTYSIZE_STRUCT ts;
1550
1537
    int pgrp = getpid();
1641
1628
#if OPT_TEK4014
1642
1629
    if (TEK4014_ACTIVE(xw)) {
1643
1630
        envnew = tekterm;
1644
 
        ptr = TekScreenOf(tekWidget)->tcapbuf;
 
1631
        newtc = TekScreenOf(tekWidget)->tcapbuf;
1645
1632
    } else
1646
1633
#endif
1647
1634
    {
1648
1635
        envnew = vtterm;
1649
 
        ptr = screen->tcapbuf;
 
1636
        newtc = screen->tcapbuf;
1650
1637
    }
1651
1638
 
1652
1639
    /*
1656
1643
     * entry is not found.
1657
1644
     */
1658
1645
    ok_termcap = True;
1659
 
    if (!get_termcap(TermName = resource.term_name, ptr)) {
 
1646
    if (!get_termcap(TermName = resource.term_name, newtc)) {
1660
1647
        char *last = NULL;
1661
1648
        TermName = *envnew;
1662
1649
        ok_termcap = False;
1663
1650
        while (*envnew != NULL) {
1664
1651
            if ((last == NULL || strcmp(last, *envnew))
1665
 
                && get_termcap(*envnew, ptr)) {
 
1652
                && get_termcap(*envnew, newtc)) {
1666
1653
                TermName = *envnew;
1667
1654
                ok_termcap = True;
1668
1655
                break;
1672
1659
        }
1673
1660
    }
1674
1661
    if (ok_termcap) {
1675
 
        resize_termcap(xw, ptr, newtc);
 
1662
        resize_termcap(xw, newtc);
1676
1663
    }
1677
1664
 
1678
1665
    /* tell tty how big window is */
1754
1741
             * not have a line discipline structure
1755
1742
             */
1756
1743
            {
1757
 
                struct termio t, t1;
 
1744
                TERMIO_STRUCT t, t1;
1758
1745
                if (ptioctl(ttyfd, TCGETA, (char *) &t) < 0)
1759
1746
                    t = d_tio;
1760
1747
 
1769
1756
                if (Console) {
1770
1757
                    int on = 1;
1771
1758
                    if (ioctl(ttyfd, TIOCCONS, (char *) &on) == -1)
1772
 
                        fprintf(stderr, "%s: cannot open console\n", xterm_name);
 
1759
                        fprintf(stderr, "%s: cannot open console: %s\n",
 
1760
                                xterm_name, strerror(errno));
1773
1761
                }
1774
1762
            }
1775
1763
 
1781
1769
            signal(SIGQUIT, SIG_DFL);
1782
1770
            signal(SIGTERM, SIG_DFL);
1783
1771
 
1784
 
            /* copy the environment before Setenv'ing */
1785
 
            for (i = 0; gblenvp[i] != NULL; i++) ;
1786
 
 
1787
 
            /* compute number of xtermSetenv() calls below */
1788
 
            envsize = 1;        /* (NULL terminating entry) */
1789
 
            envsize += 5;       /* TERM, WINDOWID, DISPLAY, _SHELL, _VERSION */
1790
 
            envsize += 2;       /* COLUMNS, LINES */
1791
 
 
1792
 
            envnew = TypeCallocN(char *, (unsigned) i + envsize);
1793
 
            memmove((char *) envnew, (char *) gblenvp, i * sizeof(char *));
1794
 
            gblenvp = envnew;
1795
 
            xtermSetenv("TERM=", TermName);
 
1772
            xtermCopyEnv(gblenvp);
 
1773
 
 
1774
            xtermSetenv("TERM", TermName);
1796
1775
            if (!TermName)
1797
1776
                *newtc = 0;
1798
1777
 
1799
1778
            sprintf(buf, "%lu",
1800
1779
                    ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU()))));
1801
 
            xtermSetenv("WINDOWID=", buf);
 
1780
            xtermSetenv("WINDOWID", buf);
1802
1781
 
1803
1782
            /* put the display into the environment of the shell */
1804
 
            xtermSetenv("DISPLAY=", XDisplayString(screen->display));
 
1783
            xtermSetenv("DISPLAY", XDisplayString(screen->display));
1805
1784
 
1806
 
            xtermSetenv("XTERM_VERSION=", xtermVersion());
 
1785
            xtermSetenv("XTERM_VERSION", xtermVersion());
1807
1786
 
1808
1787
            signal(SIGTERM, SIG_DFL);
1809
1788
 
1833
1812
            }
1834
1813
 
1835
1814
            sprintf(numbuf, "%d", MaxCols(screen));
1836
 
            xtermSetenv("COLUMNS=", numbuf);
 
1815
            xtermSetenv("COLUMNS", numbuf);
1837
1816
            sprintf(numbuf, "%d", MaxRows(screen));
1838
 
            xtermSetenv("LINES=", numbuf);
 
1817
            xtermSetenv("LINES", numbuf);
1839
1818
 
1840
 
            /* reconstruct dead environ variable */
1841
 
            environ = gblenvp;
 
1819
            gblenvp = environ;
1842
1820
 
1843
1821
            /* need to reset after all the ioctl bashing we did above */
1844
1822
            ptioctl(0, TIOCSWINSZ, (char *) &ts);
1862
1840
             * to command that the user gave anyway.
1863
1841
             */
1864
1842
            if (command_to_exec_with_luit) {
1865
 
                xtermSetenv("XTERM_SHELL=",
 
1843
                xtermSetenv("XTERM_SHELL",
1866
1844
                            xtermFindShell(*command_to_exec_with_luit, False));
1867
1845
                TRACE(("spawning command \"%s\"\n", *command_to_exec_with_luit));
1868
1846
                execvp(*command_to_exec_with_luit, command_to_exec_with_luit);
1874
1852
            }
1875
1853
#endif
1876
1854
            if (command_to_exec) {
1877
 
                xtermSetenv("XTERM_SHELL=",
 
1855
                xtermSetenv("XTERM_SHELL",
1878
1856
                            xtermFindShell(*command_to_exec, False));
1879
1857
                TRACE(("spawning command \"%s\"\n", *command_to_exec));
1880
1858
                execvpe(*command_to_exec, command_to_exec, gblenvp);
1885
1863
            }
1886
1864
 
1887
1865
            /* use a layered mechanism to find a shell */
1888
 
            ptr = getenv("X11SHELL");
1889
 
            if (!ptr)
1890
 
                ptr = getenv("SHELL");
1891
 
            if (!ptr)
1892
 
                ptr = getenv("OS2_SHELL");
 
1866
            ptr = x_getenv("X11SHELL");
 
1867
            if (!ptr)
 
1868
                ptr = x_getenv("SHELL");
 
1869
            if (!ptr)
 
1870
                ptr = x_getenv("OS2_SHELL");
1893
1871
            if (!ptr)
1894
1872
                ptr = "SORRY_NO_SHELL_FOUND";
1895
 
            xtermSetenv("XTERM_SHELL=", ptr);
 
1873
            xtermSetenv("XTERM_SHELL", ptr);
1896
1874
 
1897
1875
            shname = x_basename(ptr);
1898
1876
            if (command_to_exec) {
1968
1946
 
1969
1947
/* ARGSUSED */
1970
1948
static void
1971
 
resize_termcap(XTermWidget xw, TScreen * screen, char *oldtc, char *newtc)
 
1949
resize_termcap(XtermWidget xw, char *newtc)
1972
1950
{
1973
1951
}
1974
1952
 
2032
2010
 
2033
2011
    TRACE(("parse_tty_modes\n"));
2034
2012
    while (1) {
 
2013
        size_t len;
 
2014
 
2035
2015
        while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))
2036
2016
            s++;
2037
2017
        if (!*s)
2038
2018
            return count;
2039
2019
 
 
2020
        for (len = 0; isalnum(CharOf(s[len])); ++len) ;
2040
2021
        for (mp = modelist; mp->name; mp++) {
2041
 
            if (strncmp(s, mp->name, mp->len) == 0)
 
2022
            if (len == mp->len
 
2023
                && strncmp(s, mp->name, mp->len) == 0)
2042
2024
                break;
2043
2025
        }
2044
2026
        if (!mp->name)
2082
2064
    APIRET rc;
2083
2065
    ULONG len;
2084
2066
    struct pt_termios pt;
2085
 
    struct termio *t;
 
2067
    TERMIO_STRUCT *t;
2086
2068
    int i;
2087
2069
 
2088
2070
    switch (func) {
2092
2074
                         (ULONG *) & pt, sizeof(struct pt_termios), &len);
2093
2075
        if (rc)
2094
2076
            return -1;
2095
 
        t = (struct termio *) data;
 
2077
        t = (TERMIO_STRUCT *) data;
2096
2078
        t->c_iflag = pt.c_iflag;
2097
2079
        t->c_oflag = pt.c_oflag;
2098
2080
        t->c_cflag = pt.c_cflag;
2103
2085
    case TCSETA:
2104
2086
    case TCSETAW:
2105
2087
    case TCSETAF:
2106
 
        t = (struct termio *) data;
 
2088
        t = (TERMIO_STRUCT *) data;
2107
2089
        pt.c_iflag = t->c_iflag;
2108
2090
        pt.c_oflag = t->c_oflag;
2109
2091
        pt.c_cflag = t->c_cflag;