1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
3*4882a593Smuzhiyun *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
4*4882a593Smuzhiyun *Copyright (C) Colin Harrison 2005-2008
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun *Permission is hereby granted, free of charge, to any person obtaining
7*4882a593Smuzhiyun * a copy of this software and associated documentation files (the
8*4882a593Smuzhiyun *"Software"), to deal in the Software without restriction, including
9*4882a593Smuzhiyun *without limitation the rights to use, copy, modify, merge, publish,
10*4882a593Smuzhiyun *distribute, sublicense, and/or sell copies of the Software, and to
11*4882a593Smuzhiyun *permit persons to whom the Software is furnished to do so, subject to
12*4882a593Smuzhiyun *the following conditions:
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun *The above copyright notice and this permission notice shall be
15*4882a593Smuzhiyun *included in all copies or substantial portions of the Software.
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18*4882a593Smuzhiyun *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19*4882a593Smuzhiyun *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20*4882a593Smuzhiyun *NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
21*4882a593Smuzhiyun *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22*4882a593Smuzhiyun *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23*4882a593Smuzhiyun *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24*4882a593Smuzhiyun *
25*4882a593Smuzhiyun *Except as contained in this notice, the name of the copyright holder(s)
26*4882a593Smuzhiyun *and author(s) shall not be used in advertising or otherwise to promote
27*4882a593Smuzhiyun *the sale, use or other dealings in this Software without prior written
28*4882a593Smuzhiyun *authorization from the copyright holder(s) and author(s).
29*4882a593Smuzhiyun *
30*4882a593Smuzhiyun * Authors: Harold L Hunt II
31*4882a593Smuzhiyun * Colin Harrison
32*4882a593Smuzhiyun */
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun #ifdef HAVE_XWIN_CONFIG_H
35*4882a593Smuzhiyun #include <xwin-config.h>
36*4882a593Smuzhiyun #endif
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun /*
39*4882a593Smuzhiyun * Including any server header might define the macro _XSERVER64 on 64 bit machines.
40*4882a593Smuzhiyun * That macro must _NOT_ be defined for Xlib client code, otherwise bad things happen.
41*4882a593Smuzhiyun * So let's undef that macro if necessary.
42*4882a593Smuzhiyun */
43*4882a593Smuzhiyun #ifdef _XSERVER64
44*4882a593Smuzhiyun #undef _XSERVER64
45*4882a593Smuzhiyun #endif
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #include <stdio.h>
48*4882a593Smuzhiyun #include <stdlib.h>
49*4882a593Smuzhiyun #include <string.h>
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun /* X headers */
52*4882a593Smuzhiyun #include <X11/Xlib.h>
53*4882a593Smuzhiyun #ifdef X_LOCALE
54*4882a593Smuzhiyun #include <X11/Xlocale.h>
55*4882a593Smuzhiyun #else /* X_LOCALE */
56*4882a593Smuzhiyun #include <locale.h>
57*4882a593Smuzhiyun #endif /* X_LOCALE */
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun #include "winclipboard.h"
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun /*
62*4882a593Smuzhiyun * Main function
63*4882a593Smuzhiyun */
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun int
main(int argc,char * argv[])66*4882a593Smuzhiyun main (int argc, char *argv[])
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun int i;
69*4882a593Smuzhiyun char *pszDisplay = NULL;
70*4882a593Smuzhiyun int fUnicodeClipboard = 1;
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun /* Parse command-line parameters */
73*4882a593Smuzhiyun for (i = 1; i < argc; ++i)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun /* Look for -display "display_name" or --display "display_name" */
76*4882a593Smuzhiyun if (i < argc - 1
77*4882a593Smuzhiyun && (!strcmp (argv[i], "-display")
78*4882a593Smuzhiyun || !strcmp (argv[i], "--display")))
79*4882a593Smuzhiyun {
80*4882a593Smuzhiyun /* Grab a pointer to the display parameter */
81*4882a593Smuzhiyun pszDisplay = argv[i + 1];
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun /* Skip the display argument */
84*4882a593Smuzhiyun i++;
85*4882a593Smuzhiyun continue;
86*4882a593Smuzhiyun }
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun /* Look for -nounicodeclipboard */
89*4882a593Smuzhiyun if (!strcmp (argv[i], "-nounicodeclipboard"))
90*4882a593Smuzhiyun {
91*4882a593Smuzhiyun fUnicodeClipboard = 0;
92*4882a593Smuzhiyun continue;
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun /* Look for -noprimary */
96*4882a593Smuzhiyun if (!strcmp (argv[i], "-noprimary"))
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun fPrimarySelection = False;
99*4882a593Smuzhiyun continue;
100*4882a593Smuzhiyun }
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun /* Yack when we find a parameter that we don't know about */
103*4882a593Smuzhiyun printf ("Unknown parameter: %s\nExiting.\n", argv[i]);
104*4882a593Smuzhiyun exit (1);
105*4882a593Smuzhiyun }
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun /* Do we have Unicode support? */
108*4882a593Smuzhiyun if (fUnicodeClipboard)
109*4882a593Smuzhiyun {
110*4882a593Smuzhiyun printf ("Unicode clipboard I/O\n");
111*4882a593Smuzhiyun }
112*4882a593Smuzhiyun else
113*4882a593Smuzhiyun {
114*4882a593Smuzhiyun printf ("Non Unicode clipboard I/O\n");
115*4882a593Smuzhiyun }
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun /* Apply locale specified in the LANG environment variable */
118*4882a593Smuzhiyun if (!setlocale (LC_ALL, ""))
119*4882a593Smuzhiyun {
120*4882a593Smuzhiyun printf ("setlocale() error\n");
121*4882a593Smuzhiyun exit (1);
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun /* See if X supports the current locale */
125*4882a593Smuzhiyun if (XSupportsLocale () == False)
126*4882a593Smuzhiyun {
127*4882a593Smuzhiyun printf ("Locale not supported by X, falling back to 'C' locale.\n");
128*4882a593Smuzhiyun setlocale(LC_ALL, "C");
129*4882a593Smuzhiyun }
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun winClipboardProc(fUnicodeClipboard, pszDisplay);
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun return 0;
134*4882a593Smuzhiyun }
135