LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-06-2006, 01:56 PM   #1
nick021
Member
 
Registered: Jan 2005
Location: india
Distribution: slackware 10.0 (kernel 2.4.26)
Posts: 104

Rep: Reputation: 15
how to catch events


hi all..
i want to how to catch events in gcc...
i am working on usb driver project....
and need to catch file-copy and paste events...

how can i do that in gcc....

regards...
 
Old 04-07-2006, 10:30 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, I'll assume you don't really mean 'in gcc', but 'using the C language'. Within the scope of the C language as commonly used in Linux (this is LinuxQuestions.org), there is no such functionality. You can trap system signals with the linux 'signal()' system call, but that won't accomplish any 'file-copy and paste' event trapping. File IO is the purview of the linux kernel and, as such, is probably not detectable as an 'event'.

Two schemes that come to mind for accomplishing your objective are:

1.) Periodic polling of the file(s) in question. This begs the questions of how often to poll, and what, exactly, to poll. How often is fast enough? How many files do you have to test? Unless the application uses a finite predefined number of files, this is probably not a solution. This is the scenario of many applications such as file editors that detect when another program has modified a file that is currently open and in use by the application.

2.) Use of a virtual file system. Using this method, your application presents itself to the system as a mountable filesystem. Access to your application's functionality is through standard file IO system calls (ie. open-read-write-close) calls. Your application provides a predefined set of callbacks that respond to these system calls and thereby provide the desired functionality. There is a nice library to help with this kind of thing; 'Fuse, Filesystem in UserSpace' at http://fuse.sourceforge.net I have successfully used this package in my work. There may be other packages which provide similar functionality.

Now, it also sounds like you may be referring to GUI oriented actions, like 'drag and drop' types of events. These would fall in the domain of the 'desktop' GUI, as I understand it. To trap these sorts of actions, you will need the development libraries and documentation for your target GUI environment. I guess these would be things like GTK and Qt development packages. May I humbly suggest that these are probably not the level at which to base an interface to anything I would describe as a 'driver'.

Hope this helps.

--- rod.
 
Old 04-07-2006, 07:24 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
Could famd be a solution?

AFAIU this is a deamon which monitors alteration of files, and provide an interface to applications.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to catch hotplug events ? ritchy Linux - General 2 04-06-2006 02:02 PM
The grub catch 22 Devyn Linux - Software 21 11-19-2005 09:39 PM
C++ catch ctrl+c true_atlantis Programming 1 10-01-2004 11:23 AM
try catch(...) Sinner6 Linux - Newbie 3 06-25-2004 09:22 AM
Well...I'll catch you all later... Whitehat General 30 03-11-2004 09:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration