xclip-0.12+svn84.orig/0000755000000000000000000000000011713731113013164 5ustar rootrootxclip-0.12+svn84.orig/INSTALL0000644000000000000000000000371310664103655014231 0ustar rootroot BUILDING ======== You should be able to build and install xclip by running the following commands in the xclip source directory: ./configure # create the Makefile make # build the binary su # su to root to install make install # install xclip make install.man # install man page This should make and install xclip using the configuration (in terms of install directories, libraries, etc) used to build everything else in your X11 distribution. REQUIREMENTS ============ xclip should compile on pretty much any unix-like system. The requirements to compile xclip are pretty minimal, if you can compile any X apps at all, you'll be able to compile xclip. This means you will need a C compiler, C development environment, xlib development environment, make, etc. All of these should be available as packages for most useful distributions. PLATFORMS ========= xclip should compile and work on any unix-like platform, I have taken great effort to avoid using anything that isn't absolutely standard. I have decided that it's not practical to compile a list of specific platforms that xclip works on, but it has been known to work on GNU/Linux, Solaris, Cygwin and Irix. If you are able to get xclip working on a different platform, or have any problems getting it to work on a platform you feel it should work on, please drop me an email - I'd be interested to know. TESTING ======= The xctest shell script tests xclip by creating a file, and transferring it with xclip -i and xclip -o to put it trough xclip, then making sure that xclip -o returns exactly what we put in with xclip -i with diff. It was written primarily for my own benefit so that I can quickly test that all xclip features are working correctly after I make a change. However, I have included it to help out anyone who may be modifying the xclip code themselves. Basically, when you run xctest, you shouln't see any extra output from diff inbetween each test (because the input and output should be identical). xclip-0.12+svn84.orig/Makefile.in0000644000000000000000000000361411240070600015225 0ustar rootroot prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ mandir = @mandir@ datarootdir = @datarootdir@ datadir = @datadir@ VERSION = @PACKAGE_VERSION@ CC = @CC@ INSTALL = @INSTALL@ CFLAGS = @CFLAGS@ @X_CFLAGS@ @DEFS@ LDFLAGS = @LDFLAGS@ @LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ STRIP = @STRIP@ OBJS = xclib.o xcprint.o xclip.o .PHONY: all all: xclip xclip: $(X11OBJ) $(OBJS) $(CC) $(OBJS) $(CFLAGS) -o $@ $(X11OBJ) $(LDFLAGS) -lX11 -lXmu install: installbin install.man .PHONY: installbin installbin: xclip xclip-copyfile xclip-pastefile xclip-cutfile mkdir -p $(DESTDIR)$(bindir) $(INSTALL) $^ $(DESTDIR)$(bindir) .PHONY: install.man install.man: xclip.1 xclip-copyfile.1 mkdir -p $(DESTDIR)$(mandir)/man1 $(INSTALL) -m 644 $^ $(DESTDIR)$(mandir)/man1 .PHONY: clean clean: rm -f *.o *~ xclip xclip-$(VERSION).tar.gz .PHONY: distclean distclean: clean rm -rf autom4te.cache config.log config.status Makefile .PHONY: dist dist: xclip-$(VERSION).tar.gz .PHONY: xclip-$(VERSION).tar.gz xclip-$(VERSION).tar.gz: mkdir -p /tmp/xclip-make-dist-dir ln -sf `pwd` /tmp/xclip-make-dist-dir/xclip-$(VERSION) (cd /tmp/xclip-make-dist-dir; \ tar zcvf xclip-$(VERSION)/xclip-$(VERSION).tar.gz \ xclip-$(VERSION)/COPYING \ xclip-$(VERSION)/README \ xclip-$(VERSION)/ChangeLog \ xclip-$(VERSION)/configure \ xclip-$(VERSION)/configure.ac \ xclip-$(VERSION)/bootstrap \ xclip-$(VERSION)/xclip-copyfile \ xclip-$(VERSION)/xclip-pastefile \ xclip-$(VERSION)/xclip-cutfile \ xclip-$(VERSION)/install-sh \ xclip-$(VERSION)/Makefile.in \ xclip-$(VERSION)/xclip.spec \ xclip-$(VERSION)/*.c \ xclip-$(VERSION)/*.h \ xclip-$(VERSION)/xclip-copyfile.1 \ xclip-$(VERSION)/xclip.1 ) rm -rf /tmp/xclip-make-dist-dir Makefile: Makefile.in configure ./config.status configure: configure.ac ./bootstrap .SUFFIXES: .SUFFIXES: .c .o .c.o: $(CC) $(CFLAGS) -o $@ -c $< xclip-0.12+svn84.orig/indent-all0000755000000000000000000000005310644207647015153 0ustar rootroot#!/bin/bash indent -i4 -br -l100 -npcs *.c xclip-0.12+svn84.orig/COPYING0000644000000000000000000004313110633633727014235 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. xclip-0.12+svn84.orig/xcprint.c0000644000000000000000000001014011366634651015030 0ustar rootroot/* * * * xcprint.c - functions to print help, version, errors, etc * Copyright (C) 2001 Kim Saunders * Copyright (C) 2007-2008 Peter Åstrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "xcdef.h" #include "xclib.h" #include "xcprint.h" /* print the help screen. argument is argv[0] from main() */ void prhelp(char *name) { fprintf(stderr, "Usage: %s [OPTION] [FILE]...\n" "Access an X server selection for reading or writing.\n" "\n" " -i, -in read text into X selection from standard input or files\n" " (default)\n" " -o, -out prints the selection to standard out (generally for\n" " piping to a file or program)\n" " -l, -loops number of selection requests to " "wait for before exiting\n" " -d, -display X display to connect to (eg " "localhost:0\")\n" " -h, -help usage information\n" " -selection selection to access (\"primary\", " "\"secondary\", \"clipboard\" or \"buffer-cut\")\n" " -noutf8 don't treat text as utf-8, use old unicode\n" " -target use the given target atom\n" " -version version information\n" " -silent errors only, run in background (default)\n" " -quiet run in foreground, show what's happening\n" " -verbose running commentary\n" "\n" "Report bugs to \n", name); exit(EXIT_SUCCESS); } /* A function to print the software version info */ void prversion(void) { fprintf(stderr, "%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); fprintf(stderr, "Copyright (C) 2001-2008 Kim Saunders et al.\n"); fprintf(stderr, "Distributed under the terms of the GNU GPL\n"); exit(EXIT_SUCCESS); } /* failure message for malloc() problems */ void errmalloc(void) { fprintf(stderr, "Error: Could not allocate memory.\n"); exit(EXIT_FAILURE); } /* failure to connect to X11 display */ void errxdisplay(char *display) { /* if the display wasn't specified, read it from the enviroment * just like XOpenDisplay would */ if (display == NULL) display = getenv("DISPLAY"); fprintf(stderr, "Error: Can't open display: %s\n", display); exit(EXIT_FAILURE); } /* a wrapper for perror that joins multiple prefixes together. Arguments * are an integer, and any number of strings. The integer needs to be set to * the number of strings that follow. */ void errperror(int prf_tot, ...) { va_list ap; /* argument pointer */ char *msg_all; /* all messages so far */ char *msg_cur; /* current message string */ int prf_cur; /* current prefix number */ /* start off with an empty string */ msg_all = xcstrdup(""); /* start looping through the viariable arguments */ va_start(ap, prf_tot); /* loop through each of the arguments */ for (prf_cur = 0; prf_cur < prf_tot; prf_cur++) { /* get the current argument */ msg_cur = va_arg(ap, char *); /* realloc msg_all so it's big enough for itself, the current * argument, and a null terminator */ msg_all = (char *) xcrealloc(msg_all, strlen(msg_all) + strlen(msg_cur) + sizeof(char) ); /* append the current message the the total message */ strcat(msg_all, msg_cur); } va_end(ap); perror(msg_all); /* free the complete string */ free(msg_all); } xclip-0.12+svn84.orig/xclip-cutfile0000755000000000000000000000060210666604736015700 0ustar rootroot#!/bin/sh # FIXME: We shouldn't remove the files until xclip has successfully # transferred the data. With the current process model, this is not # very easy, though. set -e if [ "x$1" = "x" ]; then echo "Usage: [options] $0 file..." >&2 echo "-p Copy path information; preserve tree structure" exit 1 fi xclip-copyfile "$@" if [ "x$1" = "x-p" ]; then shift fi rm "$@" xclip-0.12+svn84.orig/configure.ac0000644000000000000000000000112411366634465015470 0ustar rootrootAC_INIT(xclip, 0.12) AC_CONFIG_SRCDIR([xclip.c]) AC_PROG_CC if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall" fi AC_PROG_INSTALL AC_LANG_C AC_HEADER_STDC AC_PATH_XTRA AC_CHECK_TOOL(STRIP, strip, :) AC_CHECK_HEADER([X11/Xmu/Atoms.h], [], AC_MSG_ERROR([*** X11/Xmu/Atoms.h is missing ***])) AC_CHECK_HEADER([X11/Intrinsic.h], [], AC_MSG_ERROR([*** X11/Intrinsic.h is missing ***])) AC_CHECK_HEADER([iconv.h], AC_SEARCH_LIBS([iconv], [iconv], AC_DEFINE([HAVE_ICONV]), []), []) AC_CHECK_LIB(Xmu, XmuClientWindow, [], AC_MSG_ERROR([*** libXmu not found ***])) AC_OUTPUT(Makefile) xclip-0.12+svn84.orig/xctest0000755000000000000000000000501410664313230014424 0ustar rootroot#!/bin/sh # # # # xctest - shell script to test xclip # Copyright (C) 2001 Kim Saunders # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA delay=1 # seconds to wait before running xclip -o # test to make sure ./xclip exists if [ ! -f xclip ]; then echo "Error: xclip doesn't exist in the current directory." exit fi checker="" for param in $@; do case $param in --valgrind) checker="valgrind --num-callers=8";; esac done # test xclip on different amounts of data to bring out any errors for lines in 2 16 128 1024 8192 do # temp file names (in and out) tempi=`mktemp` || exit 1 tempo=`mktemp` || exit 1 linec=0 # current line of file in while loop # append lines two at a time to input temp file while [ $linec -lt `expr $lines / 2` ] do echo -n -e "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\n" >> $tempi echo -n -e "abcdefghijklmnopqrstuvwzyz!@#$%^&*()\n" >> $tempi linec=$(($linec+1)) done # test piping the file to xclip, using all selections echo Piping a $lines line file to xclip for sel in primary secondary clipboard buffer do echo " Using the $sel selection" cat $tempi | $checker ./xclip -sel $sel -i sleep $delay $checker ./xclip -sel $sel -o > $tempo diff $tempi $tempo done echo # test xclip reading the file echo Reading a $lines line file with xclip for sel in primary secondary clipboard buffer do echo " Using the $sel selection" $checker ./xclip -sel $sel -i $tempi sleep $delay $checker ./xclip -sel $sel -o > $tempo diff $tempi $tempo done echo # test xclip filtering a file echo Filtering a $lines line file through xclip for sel in primary secondary clipboard buffer do echo " Using the $sel selection" $checker ./xclip -sel $sel -f < $tempi > $tempo sleep $delay diff $tempi $tempo done echo # quietly remove temp files rm $tempi $tempo 2> /dev/null done # Kill any remain xclip processes killall xclip xclip-0.12+svn84.orig/ChangeLog0000644000000000000000000001204111257641751014747 0ustar rootrootVersion 0.12 (Peter Åstrand) Build fixes: Check for Xmu and Xt The version number has been corrected. Man pages are now available. Contributed by Maximilian Gass. Version 0.11 (Peter Åstrand) xclip-copyfile is now compatible with recent tar versions. The Fedora UTF-8 patch has been applied. Version 0.10 (Peter Åstrand) The performance has been greatly enhanced, especially over slow networks. Two helper scripts, xclip-copyfile and xclip-pastefile, has been added. Taken together, xclip can now be used as an alternative to sftp/scp, thus avoiding password prompt when X11 forwarding has already been setup. Autoconf is now used instead of Imake. The maintainer and web site address has been updated. All Debian patches have been applied. Version 0.09: (Baruch Even) Changed dir to / when staying running so that the current directory can be umounted if necessary. Version 0.08: Remove all event loops from xclib fuctions, to allow xclib to be integrated into general-purpose event loops of other software more easily. Started using debian.org for email and website. Version 0.07: Not a lot of changes in terms of features, but tonnes of bug and portability fixes, as well as general code cleanup. Fixed a segfault problem with errperror in v0.06. Can't believe I didn't notice it before I released it. Cleaned up the code, hopefully for complete compatibilty with more C compilers and platforms. xclip compiles without warning on my Debian GNU/Linux development platform with gcc -Wall -W -pedantic -ansi -Wtraditional -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline I figure if it compiles without warning with those options, it should compile OK on pretty much any suitable platform (see README for what counts as a suitable platform). I wish GCC just had a -Wanal-retentive option... I discovered the wonders of Electric Fence, so I was able to fix up some memory problems that didn't cause problems before, but probably wouldn't have helped things either. I rewrote the way a few things work. For example, xclip doesn't store the selection data in strings any more, but rather just in allocated memory of known length, so you can now copy and paste data with nulls in it. It's probably not recommended though, gtk doesn't seem to read beyond the first null byte. I have successfully used xclip to copy and paste a 500k PNG image, it came out identical (same md5sum), so it's fairly robust in terms of the size and nature of the data that it will handle. Version 0.06: Added support for INCR mechanism. This means that -o should be able to print out selections that were previously too big and would have resulted in a message "Error: Support for format not yet implemented." In in mode, using the INCR mechanism means that you can use xclip on really big data. It used to work OK on big data, but it is better behaved about it now. Created xclib.c file to look after the xlib selection and property code from xclip.c. This may (or may not) be handy for anyone who wants a simple way to use selections without using a widget set or getting too involved in doing it themselves with xlib. I know a lot of people are using xclip from inside scripts or other programs at the moment, perhaps it xclib.c would be allow people to integrate the code into their own projects easily. All in all, a general cleanup (as I am now semi-competant with C), and complete support for the INCR mechanism. Version 0.05: Added -selection option to allow access to XA_SECONDARY and XA_CLIPBOARD. Use "-selection secondary", or "-s s" Changed email address. Added -Wall to C compiler options in Imakefile, fixed up some warnings. Updated man page. Version 0.04: Changed use of getopt_long() to XrmParseCommand(), a function in xlib, for portability. Apparently System V Unix derived machines don't have getopt_long(). XrmParseCommand() is part of xlib, and hence should *always* be available. XrmParseCommand is pretty average. It ignores ambiguous options (-ver gets ignored, instead of going to -verbose or -version). It doesn't do multiple options with one hyphen (-if instead of (-i -f), etc. Added xclip -out (out mode) and -filter (print stdin back to stdout). Version 0.03: Changed use of getopt_long_only to getopt_long, which should work better with non-GNU platforms. Fixed segfault when given a non-existant file to read. Made Imakefile for use with xmkmf. This means that xclip should build and install fairly nicely on any system with an X Consortium derived X server (nearly all Unix style X servers I would imagine). Wrote a decent man page. Version 0.02: Patch to allow reading from files if specified as arguments applied. Cleaned up source file (indenting, comments, etc). Started wrapping documentation at 80 chars. Added this changelog. Version 0.01: Everything. First release, pretty basic, but it worked. xclip-0.12+svn84.orig/xclip.c0000644000000000000000000004170011367614145014463 0ustar rootroot/* * * * xclip.c - command line interface to X server selections * Copyright (C) 2001 Kim Saunders * Copyright (C) 2007-2008 Peter Åstrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #ifdef HAVE_ICONV #include #include #endif #include #include #include #include "xcdef.h" #include "xcprint.h" #include "xclib.h" /* command line option table for XrmParseCommand() */ XrmOptionDescRec opt_tab[13]; /* Options that get set on the command line */ int sloop = 0; /* number of loops */ char *sdisp = NULL; /* X display to connect to */ Atom sseln = XA_PRIMARY; /* X selection to work with */ Atom target = XA_STRING; /* Flags for command line options */ static int fverb = OSILENT; /* output level */ static int fdiri = T; /* direction is in */ static int ffilt = F; /* filter mode */ Display *dpy; /* connection to X11 display */ XrmDatabase opt_db = NULL; /* database for options */ char **fil_names; /* names of files to read */ int fil_number = 0; /* number of files to read */ int fil_current = 0; FILE *fil_handle = NULL; /* variables to hold Xrm database record and type */ XrmValue rec_val; char *rec_typ; int tempi = 0; /* Use XrmParseCommand to parse command line options to option variable */ static void doOptMain(int argc, char *argv[]) { /* Initialise resource manager and parse options into database */ XrmInitialize(); XrmParseCommand(&opt_db, opt_tab, sizeof(opt_tab) / sizeof(opt_tab[0]), PACKAGE_NAME, &argc, argv); /* set output level */ if (XrmGetResource(opt_db, "xclip.olevel", "Xclip.Olevel", &rec_typ, &rec_val) ) { /* set verbose flag according to option */ if (strcmp(rec_val.addr, "S") == 0) fverb = OSILENT; if (strcmp(rec_val.addr, "Q") == 0) fverb = OQUIET; if (strcmp(rec_val.addr, "V") == 0) fverb = OVERBOSE; } /* set direction flag (in or out) */ if (XrmGetResource(opt_db, "xclip.direction", "Xclip.Direction", &rec_typ, &rec_val) ) { if (strcmp(rec_val.addr, "I") == 0) fdiri = T; if (strcmp(rec_val.addr, "O") == 0) fdiri = F; } /* set filter mode */ if (XrmGetResource(opt_db, "xclip.filter", "Xclip.Filter", &rec_typ, &rec_val) ) { /* filter mode only allowed in silent mode */ if (fverb == OSILENT) ffilt = T; } /* check for -help and -version */ if (XrmGetResource(opt_db, "xclip.print", "Xclip.Print", &rec_typ, &rec_val) ) { if (strcmp(rec_val.addr, "H") == 0) prhelp(argv[0]); if (strcmp(rec_val.addr, "V") == 0) prversion(); } /* check for -display */ if (XrmGetResource(opt_db, "xclip.display", "Xclip.Display", &rec_typ, &rec_val) ) { sdisp = rec_val.addr; if (fverb == OVERBOSE) /* print in verbose mode only */ fprintf(stderr, "Display: %s\n", sdisp); } /* check for -loops */ if (XrmGetResource(opt_db, "xclip.loops", "Xclip.Loops", &rec_typ, &rec_val) ) { sloop = atoi(rec_val.addr); if (fverb == OVERBOSE) /* print in verbose mode only */ fprintf(stderr, "Loops: %i\n", sloop); } /* Read remaining options (filenames) */ while ((fil_number + 1) < argc) { if (fil_number > 0) { fil_names = xcrealloc(fil_names, (fil_number + 1) * sizeof(char *) ); } else { fil_names = xcmalloc(sizeof(char *)); } fil_names[fil_number] = argv[fil_number + 1]; fil_number++; } } /* process selection command line option */ static void doOptSel(void) { /* set selection to work with */ if (XrmGetResource(opt_db, "xclip.selection", "Xclip.Selection", &rec_typ, &rec_val) ) { switch (tolower(rec_val.addr[0])) { case 'p': sseln = XA_PRIMARY; break; case 's': sseln = XA_SECONDARY; break; case 'c': sseln = XA_CLIPBOARD(dpy); break; case 'b': sseln = XA_STRING; break; } if (fverb == OVERBOSE) { fprintf(stderr, "Using selection: "); if (sseln == XA_PRIMARY) fprintf(stderr, "XA_PRIMARY"); if (sseln == XA_SECONDARY) fprintf(stderr, "XA_SECONDARY"); if (sseln == XA_CLIPBOARD(dpy)) fprintf(stderr, "XA_CLIPBOARD"); if (sseln == XA_STRING) fprintf(stderr, "XA_STRING"); fprintf(stderr, "\n"); } } } /* process noutf8 and target command line options */ static void doOptTarget(void) { /* check for -noutf8 */ if (XrmGetResource(opt_db, "xclip.noutf8", "Xclip.noutf8", &rec_typ, &rec_val) ) { if (fverb == OVERBOSE) /* print in verbose mode only */ fprintf(stderr, "Using old UNICODE instead of UTF8.\n"); } else if (XrmGetResource(opt_db, "xclip.target", "Xclip.Target", &rec_typ, &rec_val) ) { target = XInternAtom(dpy, rec_val.addr, False); if (fverb == OVERBOSE) /* print in verbose mode only */ fprintf(stderr, "Using %s.\n", rec_val.addr); } else { target = XA_UTF8_STRING(dpy); if (fverb == OVERBOSE) /* print in verbose mode only */ fprintf(stderr, "Using UTF8_STRING.\n"); } } static int doIn(Window win, const char *progname) { unsigned char *sel_buf; /* buffer for selection data */ unsigned long sel_len = 0; /* length of sel_buf */ unsigned long sel_all = 0; /* allocated size of sel_buf */ XEvent evt; /* X Event Structures */ int dloop = 0; /* done loops counter */ /* in mode */ sel_all = 16; /* Reasonable ballpark figure */ sel_buf = xcmalloc(sel_all * sizeof(char)); /* Put chars into inc from stdin or files until we hit EOF */ do { if (fil_number == 0) { /* read from stdin if no files specified */ fil_handle = stdin; } else { if ((fil_handle = fopen(fil_names[fil_current], "r")) == NULL) { errperror(3, progname, ": ", fil_names[fil_current] ); return EXIT_FAILURE; } else { /* file opened successfully. Print * message (verbose mode only). */ if (fverb == OVERBOSE) fprintf(stderr, "Reading %s...\n", fil_names[fil_current] ); } } fil_current++; while (!feof(fil_handle)) { /* If sel_buf is full (used elems = * allocated elems) */ if (sel_len == sel_all) { /* double the number of * allocated elements */ sel_all *= 2; sel_buf = (unsigned char *) xcrealloc(sel_buf, sel_all * sizeof(char) ); } sel_len += fread(sel_buf + sel_len, sizeof(char), sel_all - sel_len, fil_handle); } } while (fil_current < fil_number); /* if there are no files being read from (i.e., input * is from stdin not files, and we are in filter mode, * spit all the input back out to stdout */ if ((fil_number == 0) && ffilt) { fwrite(sel_buf, sizeof(char), sel_len, stdout); fclose(stdout); } /* Handle cut buffer if needed */ if (sseln == XA_STRING) { XStoreBuffer(dpy, (char *) sel_buf, (int) sel_len, 0); return EXIT_SUCCESS; } /* take control of the selection so that we receive * SelectionRequest events from other windows */ /* FIXME: Should not use CurrentTime, according to ICCCM section 2.1 */ XSetSelectionOwner(dpy, sseln, win, CurrentTime); /* fork into the background, exit parent process if we * are in silent mode */ if (fverb == OSILENT) { pid_t pid; pid = fork(); /* exit the parent process; */ if (pid) exit(EXIT_SUCCESS); } /* print a message saying what we're waiting for */ if (fverb > OSILENT) { if (sloop == 1) fprintf(stderr, "Waiting for one selection request.\n"); if (sloop < 1) fprintf(stderr, "Waiting for selection requests, Control-C to quit\n"); if (sloop > 1) fprintf(stderr, "Waiting for %i selection requests, Control-C to quit\n", sloop); } /* Avoid making the current directory in use, in case it will need to be umounted */ chdir("/"); /* loop and wait for the expected number of * SelectionRequest events */ while (dloop < sloop || sloop < 1) { /* print messages about what we're waiting for * if not in silent mode */ if (fverb > OSILENT) { if (sloop > 1) fprintf(stderr, " Waiting for selection request %i of %i.\n", dloop + 1, sloop); if (sloop == 1) fprintf(stderr, " Waiting for a selection request.\n"); if (sloop < 1) fprintf(stderr, " Waiting for selection request number %i\n", dloop + 1); } /* wait for a SelectionRequest event */ while (1) { static unsigned int clear = 0; static unsigned int context = XCLIB_XCIN_NONE; static unsigned long sel_pos = 0; static Window cwin; static Atom pty; int finished; XNextEvent(dpy, &evt); finished = xcin(dpy, &cwin, evt, &pty, target, sel_buf, sel_len, &sel_pos, &context); if (evt.type == SelectionClear) clear = 1; if ((context == XCLIB_XCIN_NONE) && clear) return EXIT_SUCCESS; if (finished) break; } dloop++; /* increment loop counter */ } return EXIT_SUCCESS; } static void printSelBuf(FILE * fout, Atom sel_type, unsigned char *sel_buf, size_t sel_len) { #ifdef HAVE_ICONV Atom html = XInternAtom(dpy, "text/html", True); #endif if (fverb == OVERBOSE) { /* print in verbose mode only */ char *atom_name = XGetAtomName(dpy, sel_type); fprintf(stderr, "Type is %s.\n", atom_name); XFree(atom_name); } if (sel_type == XA_INTEGER) { /* if the buffer contains integers, print them */ long *long_buf = (long *) sel_buf; size_t long_len = sel_len / sizeof(long); while (long_len--) fprintf(fout, "%ld\n", *long_buf++); return; } if (sel_type == XA_ATOM) { /* if the buffer contains atoms, print their names */ Atom *atom_buf = (Atom *) sel_buf; size_t atom_len = sel_len / sizeof(Atom); while (atom_len--) { char *atom_name = XGetAtomName(dpy, *atom_buf++); fprintf(fout, "%s\n", atom_name); XFree(atom_name); } return; } #ifdef HAVE_ICONV if (html != None && sel_type == html) { /* if the buffer contains UCS-2 (UTF-16), convert to * UTF-8. Mozilla-based browsers do this for the * text/html target. */ iconv_t cd; char *sel_charset = NULL; if (sel_buf[0] == 0xFF && sel_buf[1] == 0xFE) sel_charset = "UTF-16LE"; else if (sel_buf[0] == 0xFE && sel_buf[1] == 0xFF) sel_charset = "UTF-16BE"; if (sel_charset != NULL && (cd = iconv_open("UTF-8", sel_charset)) != (iconv_t) - 1) { char *out_buf_start = malloc(sel_len), *in_buf = (char *) sel_buf + 2, *out_buf = out_buf_start; size_t in_bytesleft = sel_len - 2, out_bytesleft = sel_len; while (iconv(cd, &in_buf, &in_bytesleft, &out_buf, &out_bytesleft) == -1 && errno == E2BIG) { fwrite(out_buf_start, sizeof(char), sel_len - out_bytesleft, fout); out_buf = out_buf_start; out_bytesleft = sel_len; } if (out_buf != out_buf_start) fwrite(out_buf_start, sizeof(char), sel_len - out_bytesleft, fout); free(out_buf_start); iconv_close(cd); return; } } #endif /* otherwise, print the raw buffer out */ fwrite(sel_buf, sizeof(char), sel_len, fout); } static int doOut(Window win) { Atom sel_type = None; unsigned char *sel_buf; /* buffer for selection data */ unsigned long sel_len = 0; /* length of sel_buf */ XEvent evt; /* X Event Structures */ unsigned int context = XCLIB_XCOUT_NONE; if (sseln == XA_STRING) sel_buf = (unsigned char *) XFetchBuffer(dpy, (int *) &sel_len, 0); else { while (1) { /* only get an event if xcout() is doing something */ if (context != XCLIB_XCOUT_NONE) XNextEvent(dpy, &evt); /* fetch the selection, or part of it */ xcout(dpy, win, evt, sseln, target, &sel_type, &sel_buf, &sel_len, &context); if (context == XCLIB_XCOUT_BAD_TARGET) { if (target == XA_UTF8_STRING(dpy)) { /* fallback is needed. set XA_STRING to target and restart the loop. */ context = XCLIB_XCOUT_NONE; target = XA_STRING; continue; } else { /* no fallback available, exit with failure */ char *atom_name = XGetAtomName(dpy, target); fprintf(stderr, "Error: target %s not available\n", atom_name); XFree(atom_name); return EXIT_FAILURE; } } /* only continue if xcout() is doing something */ if (context == XCLIB_XCOUT_NONE) break; } } if (sel_len) { /* only print the buffer out, and free it, if it's not * empty */ printSelBuf(stdout, sel_type, sel_buf, sel_len); if (sseln == XA_STRING) XFree(sel_buf); else free(sel_buf); } return EXIT_SUCCESS; } int main(int argc, char *argv[]) { /* Declare variables */ Window win; /* Window */ int exit_code; /* set up option table. I can't figure out a better way than this to * do it while sticking to pure ANSI C. The option and specifier * members have a type of volatile char *, so they need to be allocated * by strdup or malloc, you can't set them to a string constant at * declare time, this is note pure ANSI C apparently, although it does * work with gcc */ /* loop option entry */ opt_tab[0].option = xcstrdup("-loops"); opt_tab[0].specifier = xcstrdup(".loops"); opt_tab[0].argKind = XrmoptionSepArg; opt_tab[0].value = (XPointer) NULL; /* display option entry */ opt_tab[1].option = xcstrdup("-display"); opt_tab[1].specifier = xcstrdup(".display"); opt_tab[1].argKind = XrmoptionSepArg; opt_tab[1].value = (XPointer) NULL; /* selection option entry */ opt_tab[2].option = xcstrdup("-selection"); opt_tab[2].specifier = xcstrdup(".selection"); opt_tab[2].argKind = XrmoptionSepArg; opt_tab[2].value = (XPointer) NULL; /* filter option entry */ opt_tab[3].option = xcstrdup("-filter"); opt_tab[3].specifier = xcstrdup(".filter"); opt_tab[3].argKind = XrmoptionNoArg; opt_tab[3].value = (XPointer) xcstrdup(ST); /* in option entry */ opt_tab[4].option = xcstrdup("-in"); opt_tab[4].specifier = xcstrdup(".direction"); opt_tab[4].argKind = XrmoptionNoArg; opt_tab[4].value = (XPointer) xcstrdup("I"); /* out option entry */ opt_tab[5].option = xcstrdup("-out"); opt_tab[5].specifier = xcstrdup(".direction"); opt_tab[5].argKind = XrmoptionNoArg; opt_tab[5].value = (XPointer) xcstrdup("O"); /* version option entry */ opt_tab[6].option = xcstrdup("-version"); opt_tab[6].specifier = xcstrdup(".print"); opt_tab[6].argKind = XrmoptionNoArg; opt_tab[6].value = (XPointer) xcstrdup("V"); /* help option entry */ opt_tab[7].option = xcstrdup("-help"); opt_tab[7].specifier = xcstrdup(".print"); opt_tab[7].argKind = XrmoptionNoArg; opt_tab[7].value = (XPointer) xcstrdup("H"); /* silent option entry */ opt_tab[8].option = xcstrdup("-silent"); opt_tab[8].specifier = xcstrdup(".olevel"); opt_tab[8].argKind = XrmoptionNoArg; opt_tab[8].value = (XPointer) xcstrdup("S"); /* quiet option entry */ opt_tab[9].option = xcstrdup("-quiet"); opt_tab[9].specifier = xcstrdup(".olevel"); opt_tab[9].argKind = XrmoptionNoArg; opt_tab[9].value = (XPointer) xcstrdup("Q"); /* verbose option entry */ opt_tab[10].option = xcstrdup("-verbose"); opt_tab[10].specifier = xcstrdup(".olevel"); opt_tab[10].argKind = XrmoptionNoArg; opt_tab[10].value = (XPointer) xcstrdup("V"); /* utf8 option entry */ opt_tab[11].option = xcstrdup("-noutf8"); opt_tab[11].specifier = xcstrdup(".noutf8"); opt_tab[11].argKind = XrmoptionNoArg; opt_tab[11].value = (XPointer) xcstrdup("N"); /* target option entry */ opt_tab[12].option = xcstrdup("-target"); opt_tab[12].specifier = xcstrdup(".target"); opt_tab[12].argKind = XrmoptionSepArg; opt_tab[12].value = (XPointer) NULL; /* parse command line options */ doOptMain(argc, argv); /* Connect to the X server. */ if ((dpy = XOpenDisplay(sdisp))) { /* successful */ if (fverb == OVERBOSE) fprintf(stderr, "Connected to X server.\n"); } else { /* couldn't connect to X server. Print error and exit */ errxdisplay(sdisp); } /* parse selection command line option */ doOptSel(); /* parse noutf8 and target command line options */ doOptTarget(); /* Create a window to trap events */ win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 0, 0, 0); /* get events about property changes */ XSelectInput(dpy, win, PropertyChangeMask); if (fdiri) exit_code = doIn(win, argv[0]); else exit_code = doOut(win); /* Disconnect from the X server */ XCloseDisplay(dpy); /* exit */ return exit_code; } xclip-0.12+svn84.orig/xclip-copyfile.10000644000000000000000000000505411240070167016201 0ustar rootroot.\"· .\" .\" xclip-copyfile.1 .\" Copyright (C) 2009 Maximilian Gass .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .\" .TH XCLIP-COPYFILE 1 .SH NAME xclip\-copyfile, xclip\-cutfile, xclip\-pastefile - copy and move files via the X clipboard .SH SYNOPSIS .B xclip\-copyfile [\-p] FILES... .B xclip\-cutfile [\-p] FILES... .B xclip\-pastefile .SH DESCRIPTION .B xclip\-copyfile copies files into the X clipboard, recursing into directories. .B xclip\-cutfile copies the files, but also deletes them afterwards. .TP \fB\-p\fR preserve path formation .PP .B xclip\-pastefile pastes the files out of the clipboard .SH EXAMPLES .B Copying a file to a remote host .nf [maggie.lkpg.cendio.se ~]$ echo "A file created on ${HOSTNAME}" > file1 [maggie.lkpg.cendio.se ~]$ xclip-copyfile file1 [sofie.homeip.net ~/doc]$ xclip-pastefile file1 [sofie.homeip.net ~/doc]$ cat file1 A file created on maggie.lkpg.cendio.se .B Copying an entire tree structure .nf [sofie.homeip.net ~]$ xclip-copyfile doc [maggie.lkpg.cendio.se ~/tmp]$ xclip-pastefile doc/ doc/letter-mom-april.txt doc/file1 doc/letter-dad-march.txt .B Copying files with preserved path information .nf [maggie.lkpg.cendio.se ~]$ xclip-copyfile \-p /etc/sysconfig/grub tar: Removing leading `/' from member names [sofie.homeip.net ~/tmp]$ xclip-pastefile etc/sysconfig/grub [sofie.homeip.net ~/tmp]$ ls etc/sysconfig/grub etc/sysconfig/grub .B Moving files .nf [sofie.homeip.net ~]$ ls letter-brother-may.txt letter-brother-may.txt [sofie.homeip.net ~]$ xclip-cutfile letter-brother-may.txt [sofie.homeip.net ~]$ ls letter-brother-may.txt ls: cannot access letter-brother-may.txt: No such file or directory [sofie.homeip.net ~]$ cd doc [sofie.homeip.net ~/doc]$ xclip-pastefile letter-brother-may.txt .SH AUTHORS This manual page was written by Maximilian Gass for the Debian project. It may be used for everything else, of course. xclip-0.12+svn84.orig/bootstrap0000755000000000000000000000005610664103655015140 0ustar rootroot#!/bin/sh rm -rf autom4te.cache autoreconf -i xclip-0.12+svn84.orig/xclip-copyfile0000755000000000000000000000107411036170361016043 0ustar rootroot#!/bin/sh set -e if [ "x$1" = "x" ]; then echo "Usage: [options] $0 file..." >&2 echo "-p Copy path information; preserve tree structure" exit 1 fi archive=`mktemp` || exit 1 trap 'rm -f "${archive}"' 1 2 3 15 if [ "x$1" = "x-p" ]; then tar cf "${archive}" "$@" else flags="cf" for file in "$@"; do filedir=`dirname "${file}"` filename=`basename "${file}"` tar "${flags}" "${archive}" -C "${filedir}" "${filename}" flags="rf" done fi gzip -c "${archive}" | xclip -selection secondary -loops 1 -i rm "${archive}" xclip-0.12+svn84.orig/xclib.c0000644000000000000000000002742411367614072014453 0ustar rootroot/* * * * xclib.c - xclip library to look after xlib mechanics for xclip * Copyright (C) 2001 Kim Saunders * Copyright (C) 2007-2008 Peter Åstrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include "xcdef.h" #include "xcprint.h" #include "xclib.h" /* check a pointer to allocater memory, print an error if it's null */ void xcmemcheck(void *ptr) { if (ptr == NULL) errmalloc(); } /* wrapper for malloc that checks for errors */ void * xcmalloc(size_t size) { void *mem; mem = malloc(size); xcmemcheck(mem); return (mem); } /* wrapper for realloc that checks for errors */ void * xcrealloc(void *ptr, size_t size) { void *mem; mem = realloc(ptr, size); xcmemcheck(mem); return (mem); } /* a strdup() implementation since ANSI C doesn't include strdup() */ void * xcstrdup(const char *string) { void *mem; /* allocate a buffer big enough to hold the characters and the * null terminator, then copy the string into the buffer */ mem = xcmalloc(strlen(string) + sizeof(char)); strcpy(mem, string); return (mem); } /* Returns the machine-specific number of bytes per data element * returned by XGetWindowProperty */ static size_t mach_itemsize(int format) { if (format == 8) return sizeof(char); if (format == 16) return sizeof(short); if (format == 32) return sizeof(long); return 0; } /* Retrieves the contents of a selections. Arguments are: * * A display that has been opened. * * A window * * An event to process * * The selection to return * * The target(UTF8_STRING or XA_STRING) to return * * A pointer to an atom that receives the type of the data * * A pointer to a char array to put the selection into. * * A pointer to a long to record the length of the char array * * A pointer to an int to record the context in which to process the event * * Return value is 1 if the retrieval of the selection data is complete, * otherwise it's 0. */ int xcout(Display * dpy, Window win, XEvent evt, Atom sel, Atom target, Atom * type, unsigned char **txt, unsigned long *len, unsigned int *context) { /* a property for other windows to put their selection into */ static Atom pty; static Atom inc; int pty_format; /* buffer for XGetWindowProperty to dump data into */ unsigned char *buffer; unsigned long pty_size, pty_items, pty_machsize; /* local buffer of text to return */ unsigned char *ltxt = *txt; if (!pty) { pty = XInternAtom(dpy, "XCLIP_OUT", False); } if (!inc) { inc = XInternAtom(dpy, "INCR", False); } switch (*context) { /* there is no context, do an XConvertSelection() */ case XCLIB_XCOUT_NONE: /* initialise return length to 0 */ if (*len > 0) { free(*txt); *len = 0; } /* send a selection request */ XConvertSelection(dpy, sel, target, pty, win, CurrentTime); *context = XCLIB_XCOUT_SENTCONVSEL; return (0); case XCLIB_XCOUT_SENTCONVSEL: if (evt.type != SelectionNotify) return (0); /* return failure when the current target failed */ if (evt.xselection.property == None) { *context = XCLIB_XCOUT_BAD_TARGET; return (0); } /* find the size and format of the data in property */ XGetWindowProperty(dpy, win, pty, 0, 0, False, AnyPropertyType, type, &pty_format, &pty_items, &pty_size, &buffer); XFree(buffer); if (*type == inc) { /* start INCR mechanism by deleting property */ XDeleteProperty(dpy, win, pty); XFlush(dpy); *context = XCLIB_XCOUT_INCR; return (0); } /* not using INCR mechanism, just read the property */ XGetWindowProperty(dpy, win, pty, 0, (long) pty_size, False, AnyPropertyType, type, &pty_format, &pty_items, &pty_size, &buffer); /* finished with property, delete it */ XDeleteProperty(dpy, win, pty); /* compute the size of the data buffer we received */ pty_machsize = pty_items * mach_itemsize(pty_format); /* copy the buffer to the pointer for returned data */ ltxt = (unsigned char *) xcmalloc(pty_machsize); memcpy(ltxt, buffer, pty_machsize); /* set the length of the returned data */ *len = pty_machsize; *txt = ltxt; /* free the buffer */ XFree(buffer); *context = XCLIB_XCOUT_NONE; /* complete contents of selection fetched, return 1 */ return (1); case XCLIB_XCOUT_INCR: /* To use the INCR method, we basically delete the * property with the selection in it, wait for an * event indicating that the property has been created, * then read it, delete it, etc. */ /* make sure that the event is relevant */ if (evt.type != PropertyNotify) return (0); /* skip unless the property has a new value */ if (evt.xproperty.state != PropertyNewValue) return (0); /* check size and format of the property */ XGetWindowProperty(dpy, win, pty, 0, 0, False, AnyPropertyType, type, &pty_format, &pty_items, &pty_size, (unsigned char **) &buffer); if (pty_size == 0) { /* no more data, exit from loop */ XFree(buffer); XDeleteProperty(dpy, win, pty); *context = XCLIB_XCOUT_NONE; /* this means that an INCR transfer is now * complete, return 1 */ return (1); } XFree(buffer); /* if we have come this far, the propery contains * text, we know the size. */ XGetWindowProperty(dpy, win, pty, 0, (long) pty_size, False, AnyPropertyType, type, &pty_format, &pty_items, &pty_size, (unsigned char **) &buffer); /* compute the size of the data buffer we received */ pty_machsize = pty_items * mach_itemsize(pty_format); /* allocate memory to accommodate data in *txt */ if (*len == 0) { *len = pty_machsize; ltxt = (unsigned char *) xcmalloc(*len); } else { *len += pty_machsize; ltxt = (unsigned char *) xcrealloc(ltxt, *len); } /* add data to ltxt */ memcpy(<xt[*len - pty_machsize], buffer, pty_machsize); *txt = ltxt; XFree(buffer); /* delete property to get the next item */ XDeleteProperty(dpy, win, pty); XFlush(dpy); return (0); } return (0); } /* put data into a selection, in response to a SelecionRequest event from * another window (and any subsequent events relating to an INCR transfer). * * Arguments are: * * A display * * A window * * The event to respond to * * A pointer to an Atom. This gets set to the property nominated by the other * app in it's SelectionRequest. Things are likely to break if you change the * value of this yourself. * * The target(UTF8_STRING or XA_STRING) to respond to * * A pointer to an array of chars to read selection data from. * * The length of the array of chars. * * In the case of an INCR transfer, the position within the array of chars * that is being processed. * * The context that event is the be processed within. */ int xcin(Display * dpy, Window * win, XEvent evt, Atom * pty, Atom target, unsigned char *txt, unsigned long len, unsigned long *pos, unsigned int *context) { unsigned long chunk_len; /* length of current chunk (for incr * transfers only) */ XEvent res; /* response to event */ static Atom inc; static Atom targets; static long chunk_size; if (!targets) { targets = XInternAtom(dpy, "TARGETS", False); } if (!inc) { inc = XInternAtom(dpy, "INCR", False); } /* We consider selections larger than a quarter of the maximum request size to be "large". See ICCCM section 2.5 */ if (!chunk_size) { chunk_size = XExtendedMaxRequestSize(dpy) / 4; if (!chunk_size) { chunk_size = XMaxRequestSize(dpy) / 4; } } switch (*context) { case XCLIB_XCIN_NONE: if (evt.type != SelectionRequest) return (0); /* set the window and property that is being used */ *win = evt.xselectionrequest.requestor; *pty = evt.xselectionrequest.property; /* reset position to 0 */ *pos = 0; /* put the data into an property */ if (evt.xselectionrequest.target == targets) { Atom types[2] = { targets, target }; /* send data all at once (not using INCR) */ XChangeProperty(dpy, *win, *pty, XA_ATOM, 32, PropModeReplace, (unsigned char *) types, (int) (sizeof(types) / sizeof(Atom)) ); } else if (len > chunk_size) { /* send INCR response */ XChangeProperty(dpy, *win, *pty, inc, 32, PropModeReplace, 0, 0); /* With the INCR mechanism, we need to know * when the requestor window changes (deletes) * its properties */ XSelectInput(dpy, *win, PropertyChangeMask); *context = XCLIB_XCIN_INCR; } else { /* send data all at once (not using INCR) */ XChangeProperty(dpy, *win, *pty, target, 8, PropModeReplace, (unsigned char *) txt, (int) len); } /* Perhaps FIXME: According to ICCCM section 2.5, we should confirm that XChangeProperty succeeded without any Alloc errors before replying with SelectionNotify. However, doing so would require an error handler which modifies a global variable, plus doing XSync after each XChangeProperty. */ /* set values for the response event */ res.xselection.property = *pty; res.xselection.type = SelectionNotify; res.xselection.display = evt.xselectionrequest.display; res.xselection.requestor = *win; res.xselection.selection = evt.xselectionrequest.selection; res.xselection.target = evt.xselectionrequest.target; res.xselection.time = evt.xselectionrequest.time; /* send the response event */ XSendEvent(dpy, evt.xselectionrequest.requestor, 0, 0, &res); XFlush(dpy); /* if len < chunk_size, then the data was sent all at * once and the transfer is now complete, return 1 */ if (len > chunk_size) return (0); else return (1); break; case XCLIB_XCIN_INCR: /* length of current chunk */ /* ignore non-property events */ if (evt.type != PropertyNotify) return (0); /* ignore the event unless it's to report that the * property has been deleted */ if (evt.xproperty.state != PropertyDelete) return (0); /* set the chunk length to the maximum size */ chunk_len = chunk_size; /* if a chunk length of maximum size would extend * beyond the end ot txt, set the length to be the * remaining length of txt */ if ((*pos + chunk_len) > len) chunk_len = len - *pos; /* if the start of the chunk is beyond the end of txt, * then we've already sent all the data, so set the * length to be zero */ if (*pos > len) chunk_len = 0; if (chunk_len) { /* put the chunk into the property */ XChangeProperty(dpy, *win, *pty, target, 8, PropModeReplace, &txt[*pos], (int) chunk_len); } else { /* make an empty property to show we've * finished the transfer */ XChangeProperty(dpy, *win, *pty, target, 8, PropModeReplace, 0, 0); } XFlush(dpy); /* all data has been sent, break out of the loop */ if (!chunk_len) *context = XCLIB_XCIN_NONE; *pos += chunk_size; /* if chunk_len == 0, we just finished the transfer, * return 1 */ if (chunk_len > 0) return (0); else return (1); break; } return (0); } xclip-0.12+svn84.orig/xcdef.h0000644000000000000000000000220211051254144014421 0ustar rootroot/* * * * xcdef.h - definitions for use throughout xclip * Copyright (C) 2001 Kim Saunders * Copyright (C) 2007-2008 Peter Åstrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* output level constants */ #define OSILENT 0 #define OQUIET 1 #define OVERBOSE 2 /* generic true/false constants for stuff */ #define F 0 /* false... */ #define T 1 /* true... */ /* true/false string constants */ #define SF "F" /* false */ #define ST "T" /* true */ xclip-0.12+svn84.orig/xclib.h0000644000000000000000000000315711366634566014466 0ustar rootroot/* * * * xclib.h - header file for functions in xclib.c * Copyright (C) 2001 Kim Saunders * Copyright (C) 2007-2008 Peter Åstrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include /* xcout() contexts */ #define XCLIB_XCOUT_NONE 0 /* no context */ #define XCLIB_XCOUT_SENTCONVSEL 1 /* sent a request */ #define XCLIB_XCOUT_INCR 2 /* in an incr loop */ #define XCLIB_XCOUT_BAD_TARGET 3 /* given target failed */ /* xcin() contexts */ #define XCLIB_XCIN_NONE 0 #define XCLIB_XCIN_SELREQ 1 #define XCLIB_XCIN_INCR 2 /* functions in xclib.c */ extern int xcout( Display*, Window, XEvent, Atom, Atom, Atom*, unsigned char**, unsigned long*, unsigned int* ); extern int xcin( Display*, Window*, XEvent, Atom*, Atom, unsigned char*, unsigned long, unsigned long*, unsigned int* ); extern void *xcmalloc(size_t); extern void *xcrealloc(void*, size_t); extern void *xcstrdup(const char *); extern void xcmemcheck(void*); xclip-0.12+svn84.orig/xclip-pastefile0000755000000000000000000000020510666605015016207 0ustar rootroot#!/bin/sh set -e if [ "x$1" != "x" ]; then echo "Usage: $0" >&2 exit 1 fi xclip -selection secondary -o | gunzip -c | tar xv xclip-0.12+svn84.orig/xclip.spec0000644000000000000000000000243411257642116015171 0ustar rootrootName: xclip Version: 0.12 Release: 1%{?dist} License: GPLv2+ Group: Applications/System Summary: Command line clipboard grabber URL: http://sourceforge.net/projects/xclip Source0: http://downloads.sourceforge.net/xclip/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libXmu-devel, libICE-devel, libX11-devel, libXext-devel Packager: Peter Åstrand %description xclip is a command line utility that is designed to run on any system with an X11 implementation. It provides an interface to X selections ("the clipboard") from the command line. It can read data from standard in or a file and place it in an X selection for pasting into other X applications. xclip can also print an X selection to standard out, which can then be redirected to a file or another program. %prep %setup -q %build %configure make CDEBUGFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install make DESTDIR=$RPM_BUILD_ROOT install.man %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc COPYING README ChangeLog %{_bindir}/xclip %{_bindir}/xclip-copyfile %{_bindir}/xclip-cutfile %{_bindir}/xclip-pastefile %{_mandir}/man1/xclip.1* %{_mandir}/man1/xclip-copyfile.1* xclip-0.12+svn84.orig/xclip.10000644000000000000000000001206011456625022014371 0ustar rootroot.\" .\" .\" xclip.man - xclip manpage .\" Copyright (C) 2001 Kim Saunders .\" Copyright (C) 2007-2008 Peter Åstrand .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .\" .TH XCLIP 1 .SH NAME xclip \- command line interface to X selections (clipboard) .SH SYNOPSIS .B xclip [OPTION] [FILE]... .SH DESCRIPTION Reads from standard in, or from one or more files, and makes the data available as an X selection for pasting into X applications. Prints current X selection to standard out. .TP \fB\-i\fR, \fB\-in\fR read text into X selection from standard input or files (default) .TP \fB\-o\fR, \fB\-out\fR print the selection to standard out (generally for piping to a file or program) .TP \fB\-f\fR, \fB\-filter\fR when xclip is invoked in the in mode with output level set to silent (the defaults), the filter option will cause xclip to print the text piped to standard in back to standard out unmodified .TP \fB\-l\fR, \fB\-loops\fR number of X selection requests (pastes into X applications) to wait for before exiting, with a value of 0 (default) causing xclip to wait for an unlimited number of requests until another application (possibly another invocation of xclip) takes ownership of the selection .TP \fB\-t\fR, \fB\-target\fR specify a particular data format using the given target atom. With \fB\-o\fR the special target atom name "TARGETS" can be used to get a list of valid target atoms for this selection. For more information about target atoms refer to ICCCM section 2.6.2 .TP \fB\-d\fR, \fB\-display\fR X display to use (e.g. "localhost:0"), xclip defaults to the value in $\fBDISPLAY\fR if this option is omitted .TP \fB\-h\fR, \fB\-help\fR show quick summary of options .TP \fB\-selection\fR specify which X selection to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or "clipboard" for XA_CLIPBOARD .TP \fB\-version\fR show version information .TP \fB\-silent\fR fork into the background to wait for requests, no informational output, errors only (default) .TP \fB\-quiet\fR show informational messages on the terminal and run in the foreground .TP \fB\-verbose\fR provide a running commentary of what xclip is doing .TP \fB\-noutf8\fR operate in legacy (i.e. non UTF-8) mode for backwards compatibility (Use this option only when really necessary, as the old behavior was broken) .PP xclip reads text from standard in or files and makes it available to other X applications for pasting as an X selection (traditionally with the middle mouse button). It reads from all files specified, or from standard in if no files are specified. xclip can also print the contents of a selection to standard out with the .B \-o option. xclip was designed to allow tighter integration of X applications and command line programs. The default action is to silently wait in the background for X selection requests (pastes) until another X application places data in the clipboard, at which point xclip exits silently. You can use the \fB\-verbose\fR option to see if and when xclip actually receives selection requests from other X applications. Options can be abbreviated as long as they remain unambiguous. For example, it is possible to use \fB\-d\fR or \fB\-disp\fR instead of \fB\-display\fR. However, \fB\-v\fR couldn't be used because it is ambiguous (it could be short for \fB\-verbose\fR or \fB\-version\fR), so it would be interpreted as a filename. Note that only the first character of the selection specified with the \fB\-selection\fR option is important. This means that "p", "sec" and "clip" would have the same effect as using "primary", "secondary" or "clipboard" respectively. .SH EXAMPLES .PP I hate man pages without examples! .B uptime | xclip .PP Put your uptime in the X selection. Then middle click in an X application to paste. .B xclip -loops 10 -verbose /etc/motd .PP Exit after /etc/motd (message of the day) has been pasted 10 times. Show how many selection requests (pastes) have been processed. .B xclip -o > helloworld.c .PP Put the contents of the selection into a file. .B xclip -t text/html index.html .PP Middle click in an X application supporting HTML to paste the contents of the given file as HTML. .SH ENVIRONMENT .TP .SM \fBDISPLAY\fR X display to use if none is specified with the .B \-display option. .SH REPORTING BUGS Please report any bugs, problems, queries, experiences, etc. directly to the author. .SH AUTHORS Kim Saunders Peter Åstrand .br xclip-0.12+svn84.orig/install-sh0000644000000000000000000001270110664103655015176 0ustar rootroot#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else : fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else : fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else : fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 xclip-0.12+svn84.orig/xcprint.h0000644000000000000000000000176510657553441015051 0ustar rootroot/* * * * xcprint.h - header file for functions in xcprint.c * Copyright (C) 2001 Kim Saunders * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* functions in xcprint.c */ extern void prhelp(char *); extern void prversion(void); extern void errmalloc(void); extern void errxdisplay(char *); extern void errperror(int, ...); xclip-0.12+svn84.orig/README0000644000000000000000000000746410666606611014071 0ustar rootroot WHAT IS XCLIP? ============== xclip is a command line utility that is designed to run on any system with an X11 implementation. It provides an interface to X selections ("the clipboard") from the command line. It can read data from standard in or a file and place it in an X selection for pasting into other X applications. xclip can also print an X selection to standard out, which can then be redirected to a file or another program. USING XCLIP =========== Here are some ideas for things you can do with xclip: Copy your uptime into the selection for pasting: uptime | xclip Copy your password file for pasting: xclip /etc/passwd Save some text you have Edit | Copied in a web browser: xclip -o -sel clip > webpage.txt Open a URL selected in an email client mozilla `xclip -o` Copy XA_PRIMARY to XA_CLIPBOARD xclip -o | xclip -sel clip In command mode in vim, select some lines of text, then press shift-: for an ex prompt, and use this command to copy the selected lines of text to the primary X selection: !xclip -f USING XCLIP FOR MOVING FILES ============================ The programs xclip-copyfile, xclip-pastefile, and xclip-cutfile can be used for copying and moving files between different directories and even machines, assuming that you have a working X11 connection. Here are some examples: # Copying a file to a remote host [maggie.lkpg.cendio.se ~]$ echo "A file created on ${HOSTNAME}" > file1 [maggie.lkpg.cendio.se ~]$ xclip-copyfile file1 [sofie.homeip.net ~/doc]$ xclip-pastefile file1 [sofie.homeip.net ~/doc]$ cat file1 A file created on maggie.lkpg.cendio.se # Copying an entire tree structure [sofie.homeip.net ~]$ xclip-copyfile doc [maggie.lkpg.cendio.se ~/tmp]$ xclip-pastefile doc/ doc/letter-mom-april.txt doc/file1 doc/letter-dad-march.txt # Copying files with preserved path information [maggie.lkpg.cendio.se ~]$ xclip-copyfile -p /etc/sysconfig/grub tar: Removing leading `/' from member names [sofie.homeip.net ~/tmp]$ xclip-pastefile etc/sysconfig/grub [sofie.homeip.net ~/tmp]$ ls etc/sysconfig/grub etc/sysconfig/grub # Moving files [sofie.homeip.net ~]$ ls letter-brother-may.txt letter-brother-may.txt [sofie.homeip.net ~]$ xclip-cutfile letter-brother-may.txt [sofie.homeip.net ~]$ ls letter-brother-may.txt ls: cannot access letter-brother-may.txt: No such file or directory [sofie.homeip.net ~]$ cd doc [sofie.homeip.net ~/doc]$ xclip-pastefile letter-brother-may.txt FEATURES ======== * Reads data piped to standard in or files given as arguments * Prints contents of selection to standard out * Accesses the XA_PRIMARY, XA_SECONDARY or XA_CLIPBOARD selection * Accesses the cut-buffers * Supports the INCR mechanism for large transfers * Connects to the X display in $DISPLAY, or specified with -display host:0 * Waits for selection requests in the background SELECTIONS ========== For a good overview of what selections are about, have a look at . Short version: * XA_PRIMARY contains the last text you highlighted * Middle click pastes XA_PRIMARY * XA_CLIPBOARD contains text explicitly copied with Edit | Copy, Ctrl-C etc. * Edit | Paste pastes XA_CLIPBOARD * xclip uses XA_PRIMARY unless you specify otherwise with -selection CAN I HELP? =========== Glad you asked! At this stage, I'm pretty happy with the features and implementation, so if you have anything at all that should be done, I want to hear about it. Doesn't matter how small, compiler warnings, segfaults, spelling mistakes, whatever, I want to get it sorted out. xclip is not a big project, I'd like to get all these things sorted out and then declare it "complete". LICENSE ======= GNU GPL, see the COPYING file for details. CONTACT ======= Web: http://xclip.sourceforge.net Email: astrand@lysator.liu.se Please email me about problems, experiences, patches, fixes, etc.