~ubuntu-branches/ubuntu/karmic/x11-xserver-utils/karmic

« back to all changes in this revision

Viewing changes to iceauth/iceauth.c

  • Committer: Bazaar Package Importer
  • Author(s): Brice Goglin, Julien Cristau, Brice Goglin
  • Date: 2007-08-17 09:58:34 UTC
  • Revision ID: james.westby@ubuntu.com-20070817095834-ywge2nyzj1s3rqnd
Tags: 7.3+1
[ Julien Cristau ]
* iceauth 1.0.2.
  + removes blank line in the manpage (closes: #25285).
* xmodmap 1.0.3.
  + manpage updated to state that -pm is the default (closes: #236198)
* xgamma 1.0.2.
  + the manpage now explains how to print the gamma value more clearly
    (closes: #296021).
* xsetroot 1.0.2.
* xrdb 1.0.4.
  + fixes manpage typo (closes: #276286).
* Add upstream URL to debian/copyright, and update it from xgamma's COPYING
  file.

[ Brice Goglin ]
* Add menu entries for xrefresh and xvidtune.
* sessreg 1.0.3.
* xset 1.0.3.
* Add myself to Uploaders, and remove Branden with his permission.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Xorg: iceauth.c,v 1.4 2001/02/09 02:05:31 xorgcvs Exp $
 
3
 *
 
4
 * xauth - manipulate authorization file
 
5
 *
 
6
 * 
 
7
Copyright 1989, 1998  The Open Group
 
8
 
 
9
Permission to use, copy, modify, distribute, and sell this software and its
 
10
documentation for any purpose is hereby granted without fee, provided that
 
11
the above copyright notice appear in all copies and that both that
 
12
copyright notice and this permission notice appear in supporting
 
13
documentation.
 
14
 
 
15
The above copyright notice and this permission notice shall be included in
 
16
all copies or substantial portions of the Software.
 
17
 
 
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
21
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
22
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
23
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 
 
25
Except as contained in this notice, the name of The Open Group shall not be
 
26
used in advertising or otherwise to promote the sale, use or other dealings
 
27
in this Software without prior written authorization from The Open Group.
 
28
 * *
 
29
 * Original Author of "xauth" : Jim Fulton, MIT X Consortium
 
30
 * Modified into "iceauth"    : Ralph Mor, X Consortium
 
31
 */
 
32
/* $XFree86: xc/programs/iceauth/iceauth.c,v 1.4 2001/01/17 23:44:54 dawes Exp $ */
 
33
 
 
34
#include "iceauth.h"
 
35
 
 
36
 
 
37
/*
 
38
 * global data
 
39
 */
 
40
const char *ProgramName;                /* argv[0], set at top of main() */
 
41
int verbose = -1;                       /* print certain messages */
 
42
Bool ignore_locks = False;              /* for error recovery */
 
43
Bool break_locks = False;               /* for error recovery */
 
44
 
 
45
/*
 
46
 * local data
 
47
 */
 
48
 
 
49
static char *authfilename = NULL;       /* filename of cookie file */
 
50
static char *defcmds[] = { "source", "-", NULL };  /* default command */
 
51
static int ndefcmds = 2;
 
52
static const char *defsource = "(stdin)";
 
53
 
 
54
 
 
55
/*
 
56
 * utility routines
 
57
 */
 
58
static void usage (void)
 
59
{
 
60
    static const char prefixmsg[] = 
 
61
"\n"
 
62
"where options include:\n"
 
63
"    -f authfilename                name of authority file to use\n"
 
64
"    -v                             turn on extra messages\n"
 
65
"    -q                             turn off extra messages\n"
 
66
"    -i                             ignore locks on authority file\n"
 
67
"    -b                             break locks on authority file\n"
 
68
"\n"
 
69
"and commands have the following syntax:\n";
 
70
    static const char suffixmsg[] = 
 
71
"A dash may be used with the \"merge\" and \"source\" to read from the\n"
 
72
"standard input.  Commands beginning with \"n\" use numeric format.\n";
 
73
 
 
74
    fprintf (stderr, "usage:  %s [-options ...] [command arg ...]\n",
 
75
             ProgramName);
 
76
    fprintf (stderr, "%s\n", prefixmsg);
 
77
    print_help (stderr, "    ");        /* match prefix indentation */
 
78
    fprintf (stderr, "\n%s\n", suffixmsg);
 
79
    exit (1);
 
80
}
 
81
 
 
82
 
 
83
/*
 
84
 * The main routine - parses command line and calls action procedures
 
85
 */
 
86
int
 
87
main (int argc, char *argv[])
 
88
{
 
89
    int i;
 
90
    const char *sourcename = defsource;
 
91
    char **arglist = defcmds;
 
92
    int nargs = ndefcmds;
 
93
    int status;
 
94
 
 
95
    ProgramName = argv[0];
 
96
 
 
97
    for (i = 1; i < argc; i++) {
 
98
        char *arg = argv[i];
 
99
 
 
100
        if (arg[0] == '-') {
 
101
            char *flag;
 
102
 
 
103
            for (flag = (arg + 1); *flag; flag++) {
 
104
                switch (*flag) {
 
105
                  case 'f':             /* -f authfilename */
 
106
                    if (++i >= argc) usage ();
 
107
                    authfilename = argv[i];
 
108
                    continue;
 
109
                  case 'v':             /* -v */
 
110
                    verbose = 1;
 
111
                    continue;
 
112
                  case 'q':             /* -q */
 
113
                    verbose = 0;
 
114
                    continue;
 
115
                  case 'b':             /* -b */
 
116
                    break_locks = True;
 
117
                    continue;
 
118
                  case 'i':             /* -i */
 
119
                    ignore_locks = True;
 
120
                    continue;
 
121
                  default:
 
122
                    usage ();
 
123
                }
 
124
            }
 
125
        } else {
 
126
            sourcename = "(argv)";
 
127
            nargs = argc - i;
 
128
            arglist = argv + i;
 
129
            if (verbose == -1) verbose = 0;
 
130
            break;
 
131
        }
 
132
    }
 
133
 
 
134
    if (verbose == -1) {                /* set default, don't junk stdout */
 
135
        verbose = (isatty(fileno(stdout)) != 0);
 
136
    }
 
137
 
 
138
    if (!authfilename) {
 
139
        authfilename = IceAuthFileName ();      /* static name, do not free */
 
140
        if (!authfilename) {
 
141
            fprintf (stderr,
 
142
                     "%s:  unable to generate an authority file name\n",
 
143
                     ProgramName);
 
144
            exit (1);
 
145
        }
 
146
    }
 
147
    if (auth_initialize (authfilename) != 0) {
 
148
        /* error message printed in auth_initialize */
 
149
        exit (1);
 
150
    }
 
151
 
 
152
    status = process_command (sourcename, 1, nargs, arglist);
 
153
 
 
154
    (void) auth_finalize ();
 
155
    exit ((status != 0) ? 1 : 0);
 
156
}