A little essay on Open Source

1 Introduction
Open Source and Creative Commons licences provide a means for the dissem-
ination of material be that code, art or scientific research. The reasons for
using such a licence are many, in this paper we consider both the advantages
and disadvantages of doing so.
The Open Source Initiative (http://www.opensource.org/) provides a definition for
what they term as Open Source. A key necessity for them to class a licence
as being compatible with their definition is the requirement for ’free redistribution’
meaning other parties are permitted to redistribute source code.
Creative Commons (http://creativecommons.org/) provide six main licences
which vary from being very liberal to being slightly more restrictive.

2 Problems with copyright
“A report produced by the Congressional Research Service indicates that
only about two percent of works between fifty-five and seventy-five years
of age retain commercial value” [5] this means 98% of works are still under
copyright even though they are unlikely to hold any value. Open Source goes
some way to solving the lack fine-grained granularity in the copyright system,
enabling work to be freely distributed even though it is still copyrighted.
Copyright aims to protect works by preventing unfair duplication which may
cause a loss of earnings – the problem with this system is that not everyone
wants to sell their copyrighted works. Some may instead want to permit
redistribution under specific conditions – which is where Open Source and
Creative Commons is very useful. Interestingly “unlike many other types of
property ownership, an owner of intellectual property has no responsibility
to the public to care for the property” [5] this can make the process of
tracking the current owner of a copyrighted work very difficult and potentially
infeasible, meaning people may risk the use of works which may still be
copyrighted.

3 Open Source – A new era?
Open Source gives people more freedom, with respect to the code “People
improve it, people adapt it, people fix bugs.” [1] this occurs at an unprece-
dented rate thanks to the Internet and many altruistic people.
There are a vast amount of Open Source Software (OSS) licences, in this
paper we will discuss two of the main ones: GPL and BSD.
Open Source effectively makes “users better off than they would be with
only the default copyright rule” [4] meaning the very reason OSS licences are
needed is down to limitations with current legislature.

3.1 GPL
The General Public Licence (GPL) is a very stringent licence developed by
the Free Software Foundation (FSF – http://www.fsf.org/) in that
“the source code of everything that went into the executable should be
made publicly available under terms that were compatible with the GPL.” [12].
GPL is a ’copyleft’ licence meaning any projects based upon GPL’d code,
must also release their code through the GPL or a GPL compatible licence.
Potentially copyleft may dissuade companies from using Open Source, it is
important to note not all Open Source licences are ’copyleft’ though.
GPL version 3 was released June 2007. It provides a number of interesting
additions. In respect to GPL v3 code, “if you break the DRM, you’ll be free
to distribute your own software that does that, and you won’t be threatened
by the DMCA or similar laws.”
(http://www.fsf.org/licensing/licenses/quick-guide-gplv3.html).
For instance if a hardware manufacturer incorporated DRM along with GPL
v3 code, you would have the freedom to reverse engineer that
software/hardware with indemnity from prosecution under the Digital
Millenium Copyright Act (DMCA). This aims to prevent what the Free
Software Foundation term ’Tivoization’, with reference to the
Tivo, a Personal Video Recorder device, which uses Linux. It contains soft-
ware protection measures to make it difficult for 3rd parties to run additonal
software on it.

This shows the FSF to be a very technically savy institution aware of cutting
technological issues regarding the law; because of this agility they can adapt
their licences efficiently in a way that changes to state legislature simply can’t
match.

3.2 BSD
The BSD licence is not copyleft and as such it allows inclusion of BSD licenced
source code into proprietary software provided this is acknowledged. This
makes the BSD licence permissive and very similar to public domain works.
Some may feel the BSD licence as overly liberal, in that people can simply
take your code and create a commercial product based upon it, which is
exactly how OSX was created. For many companies the lack of copyleft may
seem repulsive as it means competitors can take your work and modify it
how they see fit without giving anything back.

4 Creative Commons
Creative Commons aims to provide a system for authors of creative material
to more effectively manage their content without the need to resort to in-
termediaries such as publishers. In [14] Suthersanen writes how CC licences
are now accepted as valid by the courts due to a couple of court cases. One
interesting development she mentions is that of the Science Commons, an
effort to encourage sharing of data and biological content between scientists.
According to Dusollier [3] there are 6 Creative Commons licences. The most
liberal of which being the attribution licence, where either non-commercial or
commercial usage is permitted, provided attribution is given to the rightful
author. The most restrictive is the ’attribution non-commercial no deriva-
tive’, which means the work can only be distributed in its original form with
attribution and only for non-commercial purposes. The variety of licence
choices provided by the Creative Commons gives authors the freedom to
choose one most suitable for their work. This undoubtedly gives the author
a greater freedom than the existing copyright system – which can only be a
good thing. The creative commons licence is split into three parts. ’Legal
code’ – legalese for lawyers. ’Commons deed’ – human readable licence. By
separating legal jargon out into a separate file from the commons deed, the
system is far more comprehensible. Generally if people are presented with
long licences e.g. EULAs they simply ignore it – by paraphrasing the tech-
nicalities of a licence in a simple form, the licence is far more accessible –
meaning there is less likely to be confusion. Finally ’digital code’ is used
to works under specific licences easily indexable – this very important step
means that other creatives can easily search for works that they could inte-
grate into their own, thereby serving to increase creativity something which
cannot happen under the current, potentially draconian copyright laws.
The are a number of reasons for distributing work under the creative com-
mons “Furthering the use of educational materials, culture, and informa-
tion may be one reason” [5], “Purely commercial promotional strategy might
be another” [5]. According to [5] Creative Commons licences have not yet
been tested in the court of law (as of 2007) meaning there are a number
of uncertainties. One question the pose is whether “an educational website
carries my article but requires a membership password to access it. Is their
use of my article a commercial or noncommercial use?”, such questions must
be debated in law before an answer is known.

There will always be a need for low-cost to free software, especially in de-
veloping countries, Open Source definitely goes a long way to filling such a
need – the fact there is are Open Source equivalents for all main software
applications, shows this. (See
http://www.linuxrsp.ru/win-lin-soft/table-eng.html for a list of Open Source
equivalents to proprietry applications)

5 Microsoft
The fact that companies such as Microsoft are embracing Open Source to
a limited extent shows that Open Source will certainly not whither away.
Microsoft uses what they term a Shared Source licence 6 to give prospective
customers e.g. government agencies the chance to scrutinize code for bugs.
Microsoft makes use of Open Source BSD licenced software in its own prod-
ucts e.g. “several FreeBSD volunteers combing through Microsoft products,
including the new Windows 2000 operating system, found numerous instances
where Microsoft had made use of their software”, showing Microsoft obvi-
ously deems OSS as being of a high enough standard for inclusion in its own
products. (http://news.zdnet.com/2100-9595 22-116100.html)

Shared source is an umbrella term used by Microsoft for a number of different
licences for which the source code of a program is available to people other
than Microsoft (this doesn’t necessarily mean all these licences are Open
Source though, as not all give permission for re-distribution of code).
The Microsoft Reference Licence is decidedly un-open in its design, purely de-
signed to allow companies to inspect the quality of source code as it prevents
re-distribution of source which is certainly not Open Source. The Microsoft
Community Licence on the other hand allows re-distribution of code and ac-
cording to [9] bears resemblance to the Mozilla Public Licence – making it a
true Open Source licence.

Microsoft Permissive Licence, now known as Microsoft Public Licence is com-
patible with the GPL and as such shows Microsoft to be considering seriously
the benefits of Open Source. It is unlikely Microsoft will ever Open Source
all it’s software being an IP company it would loose a vast amount of revenue
if it did so, however it definitely shows a positive change of attitude to Open
Source from Microsoft.

In [15] Valimaki writes of an interesting incident where Tatu Ylnen developed
SSH (Secure Shell), software which facilitates encrypted communication with
a remote computer for the purpose of remote-control. Originally the software
was licenced in an open fashion, Valimaki later decided to concentrate instead
on a proprietary version. Because of this a group of people created a fork now
known as OpenSSH, which is now the most prevalent SSH software in use.
This shows that because Open Source opens the marketplace for competitors,
it is possible to loose a position in the marketplace to another ’fork’ if people
feel that offers greater benefits.

6 Forking
With OSS comes the potential for a ’fork’ to develop. That is a project based
on a particular projects source, with the aims of steering the project in a
different direction. The potential for forking ensures that the project leaders
attempt to work in the interests of the users rather than solely themselves.
A fork would be bad for a project, as it divides the user base. Such an event
could not happen with proprietary software – potentially being one of the
reasons propriety software stagnates, as the users are not fully catered for.

7 Government OSS usage
“nearly every household has a PC with Microsoft Office installed, and many
students have grown up using it” (Malcolm Trobe, Association of school
and college leaders) – this presents a catch-22 situation, using this as an
excuse to avoid teaching OSS means people won’t use OSS at home, thereby
perpetuating an economy driven by proprietary software. It is therefore
necessary to break this cycle through education if OSS is to truly flourish.
The government seems slow at realising the benefits and even existence of
OSS, in one case “the Cabinet Office turned to Microsoft, which duly estab-
lished a portal that users of non-Microsoft products were unable to access.”
[7] highlighting its inability to see beyond Microsoft driven systems.
Kettell in [7] says “despite the increasing international popularity of OSS, and
despite the wide range of benefits that it provides, the lack of government
activism remains a key obstacle to overcome”. This is a definite problem
which should be tackled at the highest levels if Open Source is to succeed in
any great measures. For people to want to willingly use OSS on their personal
computers it is necessary for them to be introduced to it, their workplace or
educational establishment presents a perfect opportunity for this.

8 Economy
Open Source presents an interesting problem – how is it possible to monetize
software when its source is freely available. One company Red Hat, presents
us with a fine example – the presence of after sales support.
We believe Open Source software is more difficult to market that off-the-
shelf software as their simply isn’t the budget to advertise and it wouldn’t
generally be sold in shops, the exception being Linux distributions.
Red Hat one of the largest Linux distributions switched from a boxed retail
package to a subscriber based enterprise edition. We believe this is very wise,
as it is easy for people to simply copy the source re-compile it and provide
a system almost identical for a lower price or even for free. A subscriber
approach leads to a recurring payment in return for always having the latest
version and support.

However for a product to be successful it doesn’t need to be profitable like
Red Hat. As Chege mentions in [2] “Debian is proof that the community
model can work just as well as the commercial model”. At the time of
writing debian is the 5th most popular Linux distribution, however it also
powers Ubuntu the most popular distribution, along with with many others.
Richard Stallman in the GNU manifesto says “many people will program with
absolutely no monetary incentive” [13]. This may be true to some extent but
I can’t imagine many of the programmers for example at Microsoft suddenly
seeing the light and deciding to program for free. In a Utopian society it
would be great if people freely gave away their time in selfless endeavours –
however as we don’t yet live in a such a society it is still possible to make
money developing Open Source for instance working for a company such as
Red Hat.

9 Security
The security advantages of Open Source can no longer be simply ignored. As
the source code is easily obtainable it can be inspected for vulnerabilities very
easily. To perform a similar process with closed source is extremely difficult
requiring techniques akin to reverse engineering – a very complex and time
consuming process. The amount of malware written proprietary operating
systems is vast compared to that written for Open Source OS’s.
Eric S. Raymond in his seminal work The Cathedral and The Bazaar [11]
advised “given enough eyeballs, all bugs are shallow”. The ability for code to
be evaluated by many developers for free is a great incentive for companies
open sourcing code.

10 Community
With Open Source projects there is a community feeling, generally mailing
lists where questions can be asked, bug trackers where problems can be filed,
IRC channels for debates and real-time feedback. This connectedness with
other users enables problems to be answered and bugs fixed in a very effi-
cient manor. Reporting a bug to a company such as Microsoft is a much
more cumbersome matter, sure its possible but you may have to wait for the
next release for the fix. With Open Source it’s possible to update to the
bleeding-edge source release if necessary, provided version control systems
are used (the great majority of projects do), meaning provided a patch has
been submitted, your problem will be solved.

11 Wikipedia
Wikipedia is licenced under an Open Source licence ‘GNU Free Documenta-
tion License’, providing a freely accessible democratically edited encyclope-
dia. The fact Wikipedia works so well is likely due to it functioning under
a similar principle to Raymond’s Linus’ law. Rather than functioning like
a standard encyclopedia where there are only a limited number of editors,
Wikipedia collates information from anyone across the globe. The fact that
Wikipedia has no restrictions on its usage means it can be freely distributed.
For example the one laptop per child (OLPC) project includes on each lap-
top, static copies of specific Wikipedia articles. The fact this is even possible
is due to the copy-left licencing of Wikipedia and its anyone can be an editor
policy.

12 Why Open Source may not be the way to
go?
Open Source strangely may not always prove the cheapest option “if a system
with a higher purchase price enables an organization’s workers to be more
productive than one with a lower purchase price, the higher-priced system
may provide a quicker return on investment – and thus be more cost effective –
than the lower priced alternative.“ [16]. This is due to the fact that an Open
Source project may provide little in the means of support – although the
program may provide very complex functionality, if there is no documentation
for instance, then the program is almost worthless.

13 Conclusions
Open Source is certainly not a marginal development, with many Open
Source projects powering many websites Linux, Apache, MySQL and PHP
(LAMP). It is hard to imagine Open Source fading away into the back-
ground. Sites like Sourceforge.net and Freshmeat.net (86,858 projects) host
vast amounts of Open Source projects, it is difficult to understand why Open
Source isn’t already being used more widely by companies. For instance ap-
plications available include complete Office environments, e.g. OpenOffice,
which can almost rival Microsoft Office. As a government funded survey [10]
mentioned “OSS is indeed the start of a fundamental change in the soft-
ware infrastructure marketplace, and is not a hype bubble that will burst.”,
highlighting the fact Open Source won’t simply die out.

OSS can potentially serve as a great educator to the future great programmers
of the world, providing them with ideas to learn their trade along with the
community to further their interest.

Both Open Source and Creative Commons are noble pursuits to loosen the
shackles of our overly restrictive copyright regime. It is unlikely Open Source
will ever die out. Potentially the ideas presented by the Creative Commons
licencing strategy may be integrated into the copyright system, but they too
are unlikely to disappear, just possibly take a different form.
The amount of man hours generated by Open Source projects is simply im-
mense – when one half of the world is sleeping the other is awake – meaning
the project is always alive. Something which conventional development can’t
hope to match.

Graham in his essay on the benefits of Open Source, writes “ (1) that people
work harder on stuff they like, (2) that the standard office environment is very
unproductive, and (3) that bottom-up often works better than top-down.”
[6], this is certainly very true, because of the breadth of OSS people are able
to choose projects which most interest this undoubtedly leads to an increase
to the vitality of all projects. With OSS the concentration of the project is
generally on the quality of the code rather than tight deadlines which may
result in poor quality. Therefore the greater freedom in the development of
OSS likely leads to a higher class of product.

“About 73% of CC licensors said they do not make money from their copy-
righted works at all.” [8] meaning their reasons for licencing their works are
likely therefore not for profit, showing that there is a definite desire for al-
ternate ways of licencing works which the existing copyright system doesn’t
fulfill.
As an example of the huge ammount of Creative Commons licenced con-
tent, there are currently 88,264,237 photos on flickr under various Creative
Commons licences.

We therefore envisage in the future the number of Open Source projects and
Creative Commons content will likely increase at an even greater rate than
at present. The sheer quality of some of the works available e.g. Linux, rivals
and in some cases surpasses commercial content. The question remains when,
not if, will large corporations take notice of this advancement.

References
[1] K. Bowrey. Law and Internet Cultures. 2005.
[2] M. Chege. Ubuntuism, Commodification, and the Software Dialectic.
2008.
[3] S. Dusollier. The Masters Tools v. The Masters House: Creative Com-
mons v. Copyright.
[4] J. Feller, B. Fitzgerald, S. A. Hissam, and K. R. Lakhani. Perspectives
on Free and Open Source Software. 2005.
[5] A. K. GOSS. CODIFYING A COMMONS: COPYRIGHT, COPY-
LEFT, AND THE CREATIVE COMMONS PROJECT. 2007.
[6] P. Graham. What Business Can Learn from Open Source?
[7] S. Kettell. The Political Economy of Open-Source Software in the United
Kingdom. 2008.
[8] M. Kim. The Creative Commons and Copyright Protection in the Digital
Era: Uses of Creative Commons Licenses. 2007.
[9] A.-K. Kuehnel. Microsoft, Open Source and the software ecosystem: of
predators and prey – the leopard can change its spots. 2008.
[10] D. N. Peeling and D. J. Satchell. Analysis of the Impact of Open Source
Software. 2001.
[11] E. S. Raymond. The cathedral and the bazaar: musings on Linux and
open source by an accidental revolutionary. O’Reilly & Associates, Inc.,
revised edition, 2001.
[12] B. Reese and D. Stenberg. Working without copyleft.
http://daniel.haxx.se/transition.html.
[13] R. Stallman. The GNU Manifesto.
[14] U. Suthersanen. Creative Commons the other way? 2007.
[15] M. Valimaki. The Rise of Open Source Licensing – A Challenge to the
Use of Intellectual Property in the Software Industry.
[16] M. Wynants and J. Cornelis. How Open is the Future? Economic, Social
& Cultural Scenarios inspired by Free & Open-Source Software.

Neat films

Fierce people –

Intending to go on an anthropological adventure with his father, instead ends up living in the grounds of a mansion, studying a modern day ‘tribe’. Also see ‘Charlie Bartlett’.

Slacker –

A simply brilliant movie – its as if you can see the illustrious streams of consciousness being played out before our very eyes. Each character simply exudes life. Its as if Linklater has captured the soul on celluloid for each character – a true masterpiece (Also see ‘Dazed and Confused’).

IPhone Flash

So it appears Apple aren’t too keen for Adobe to develop a version of Flash for the IPhone (See http://futureoftheinternet.org/flash-for-android-not-the-iphone for a good round up of the issue). If I was Adobe I’d pull support all support for Photoshop on OSX, sure Adobe would loose a lot of business but it’d be funny just to see how well OSX copes without Adobe’s creative applications. I don’t see how the IPhone can survive when open alternatives such as Android and soon Symbian have a whole lot more too offer. Viva la revolution.

Edit: Must… Keep… Ahead.. Of… Tech… News, Apparently Adobe is now working with apple to make Flash on the IPhone a reality http://www.engadget.com/2009/01/31/apple-teams-up-with-adobe-for-iphone-flash-at-long-last

Apple are also keeping up their Big Brother front, refusing yet more applications onto their App Store:
http://www.telegraph.co.uk/news/worldnews/northamerica/usa/barackobama/4576991/Apple-rejects-Barack-Obama-trampoline-iPhone-application.html

Latex wordcounting

I wanted a quick way to get the word count for my latex document – so I now have 2 lovely hacky scripts.
My latex file is called document.tex, so ‘document’ should be changed to the name of your file.

In your Latex file you need to include ‘\input{hack}’ at the top of your document and ‘\input{wordcount}’ wherever you want to include your wordcount.

The following script removes the bibliography and citations and then counts the words outputting to a file:
makeme:

echo > wordcount
echo "\renewcommand{\cite}[1] {}
\renewcommand{\maketitle}[1] {}
\renewcommand{\bibliography}[1] {}" > hack
pdflatex document
ps2ascii document.pdf | wc -w > wordcount

makemepropper:

echo > wordcount
./makeme
echo "" > hack
bibtex document
pdflatex document
bibtex document
pdflatex document
bibtex document
pdflatex document

Eclipse & Subversion

Somehow I managed to overwrite my 54th revision of a project with a far less developed version. I wasn’t able to find any way to recover the file from subversion as it’s copy had been replaced (if there is a way to see ‘every’ change made to SVN I’d like to know!). So I attempted to revert my file in Eclipse using a local revision however it was stubbornly telling me there was no history for the specified file. In the end I managed to find my document 🙂 using Eclipse’s history. On linux the history tends to be in ‘~/workspace/.metadata/.plugins/org.eclipse.core.resources/.history’, this directory contains many folders, with files which have hashes for their name.

To find the files with the particular contents I wanted I ran this:
This gave me a list of files along with their dates of modification, so I could choose the relevant ones.

for x in `grep -Rl “SEARCH_FOR” *`; do echo `ls -l $x`; done

Search movies by colour

The script below averages a number of frames in a movie and generates an image of this. This image is scaled down to 1 pixel and its colour value is then obtained. The colour value is placed in a MYSQL database along with the name of the movie.


#!/bin/sh
for movie in /path_to_movies/*.avi
do
	echo "Processing $movie"
	IMGLIST=""
	rm *.jpg
	# scan first hour of frames
	for ((i=0;i<=3600;i+=60)); do
		mplayer  -ao volume=0 "$movie" -ss $i -frames 1 -vo jpeg 		
		mv 00000001.jpg $i.jpg
		if [ ! -e "$i.jpg" ]
		then
			break
		fi
		IMGLIST+="$i.jpg "
		convert -average $IMGLIST avg.jpg
	done

	if [ -e "avg.jpg" ] 
	then	
		I=`convert avg.jpg -scale 1x1 -depth 8 txt:-  |  \
                sed "s/.*rgb//g;s/(//g;s/)//g"`
		NAME=`echo "$movie" | sed "s/.*\///g"`
		mysql -u [username] -h localhost -p[password] \ 
                '[database]' -e "insert into movies (movie,r,g,b) values ('$NAME',$I)"
	fi 
done

Ajaxified website made to enable movies to be selected by colour from RGB slider:
(the color slider was obtained from http://webfx.eae.net/dhtml/slider/slider.html, an excellent site full of lots of web 2.0 goodies)

If you need the PHP code, just send me a mail.

RGB color space plot made of a number of movies:

Shortcut keyboard

I have two keyboards attached to my computer now, one for the sole purpose of launching other
programs when specific keys are struck.

This is input device portion of my xorg.conf file. It is set up so my input device is that of my main keyboard. This means any other keyboards attached to the PC don’t produce characters when their keys are struck.

Section “InputDevice”
Identifier “Keyboard0”
Driver “evdev”
Option “Device” “/dev/input/event4”
EndSection

To catch the key presses and run specific programs upon specific key codes I used:
http://www.bedroomlan.org/~alexios/coding_evrouter.html

Below is the config file I use which means when the ‘f’ key is pressed firefox is launched.

~/.evrouterrc:

Window “”: # Window title
“Keyboard” “” any key/33 “Shell/firefox”

Run using:
./evrouter /dev/input/event2

(n.b. you will have to run as root unless /dev/input… is user accessible, this is obviously a bad idea, as it means any program run from it will also be root. An entry in /etc/udev/rules.d/ can be added so your user can read the device, remember this does make it easier for keyloggers to gain access to your keystrokes)

Facebook status notifier

Simple python script which notifies you when a status for a particular person has changed.
It requires the pynotify library along with the Facebook python API.

#!/usr/bin/python

import pynotify
import time 




def desktop_app():
    from facebook import Facebook


    pynotify.init("Facebook_status")

    # need to obtain two md5sums from your own app you create with facebook
    facebook = Facebook("md5","md5")

    facebook.auth.createToken()
    # Show login window
    facebook.login()

    # Login to the window, then press enter
    print 'After logging in, press enter...'
    raw_input()

    facebook.auth.getSession()
        
    dict = {}
    
    while True:
        friends = facebook.friends.get()
        friends = facebook.users.getInfo(friends, ['name', 'status'])

        for friend in friends:
            name=friend['name']
            status=""
            newMsg = False
            
            if 'message' in friend['status']:
                status=friend['status'][unicode("message")]                    
                if dict.has_key(name):
                    if dict.get(name) != status:
                        dict[name]=status
                        newMsg=True
                else:
                    dict[name]=status
                    newMsg = True

                    
                if status != u'' and newMsg == True:
                    n = pynotify.Notification("Facebook", name+" " +status, "gtk.STOCK_INFO")
                    n.set_urgency(pynotify.URGENCY_NORMAL)
                    n.set_timeout(12000)
                    n.show()         
                    

        time.sleep(60)
        print "looped"
    
desktop_app()

application configuration incorrect

I was trying to get my application which uses OpenMP to work under Windows XP without any service packs, I kept getting the error message “application configuration incorrect”.

To get it work in the end I copied OpenMP related files from my WinXP SP2 computer in the WinSxS folder over to the same folders on the older computer

C:\Windows\WinSxS\Policies\x86*OpenMP*\ (folder)
C:\Windows\WinSxS\Manifests\*OpenMP* (files)
C:\Windows\WinSxS\x86*OpenMP* (folder)

This could have easily avoided if I could install Vcredist.exe however it complained it couldn’t run certain DLLs

Command line copy & paste

I needed a way to copy a lot of text through a shell and couldn’t find an easy way to do it through the command line:
Now I can copy & paste like so:
cat 1.txt | copy

and on another shell:
paste | grep “test”

N.b. the copy program has to remain running to be able to paste text, I believe this is common to all Linux applications which provide clipboard functionality. As far as I am aware there is no specific memory set aside for a clipboard, so it is down to individual programs to provide this memory.

Compile the Copy.c file with:

gcc -I/usr/lib:. -lpthread -lgthread-2.0 -g -Wall Copy.c -o copy `pkg-config –cflags gtk+-2.0 gthread-2.0` `pkg-config –libs gtk+-2.0 gthread-2.0

Copy.c:

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>


int main( int   argc,  char *argv[] )
{
        GtkWidget *window;
        gtk_init (&argc, &argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        GString* gstr = g_string_new (NULL);
        GtkClipboard* clip = gtk_clipboard_get(NULL);

        int c;
        while((c = fgetc(stdin)) != EOF){
                printf("%c",c);
                g_string_append_printf (gstr,"%c",c);
        }

        gtk_clipboard_set_text(clip,g_string_free(gstr,FALSE),-1);
        gtk_main (); // infinite loop
        return 0;
}

Paste.c

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>


int main( int   argc,  char *argv[] )
{
        GtkWidget *window;
        gtk_init (&argc, &argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        GString* gstr = g_string_new (NULL);
        GtkClipboard* clip = gtk_clipboard_get(NULL);
        printf("%s",gtk_clipboard_wait_for_text(clip));

        return 0;
}

« Older entries Newer entries »