linux

Generic printing using a USB port

I am developing on a device that has no printer support natively. I need to print to any printer using a USB port. Is this feasible? Is there any generic standard for all printers to print via USB? The device runs on Linux/PowerPC. ...

How to get mac address for an interface in linux using a C Program?

i want to find the mac address using a C program in linux. how to do it? ...

linux/gcc: ldd functionality from inside a C/C++ program

Is there some simple an efficient way to know that a given dynamically linked ELF is missing a required .so for it to run, all from the inside of a C/C++ program? I need to program a somewhat similar functionality as ldd, without trying to execute the ELF to find out the (met/unmet) dependencies in the system. perhaps asking the ld-linu...

What is the best solution to replace a new memory allocator in an existing code?

During the last few days I've gained some information about memory allocators other than the standard malloc(). There are some implementations that seem to be much better than malloc() for applications with many threads. For example it seems that tcmalloc and ptmalloc have better performance. I have a C++ application that uses both mall...

How to get this getnameinfo code working

i am getting the error ai_family not supported in call to getnameinfo. 1 #include <iostream> 2 #include <sys/types.h> 3 #include <unistd.h> 4 #include <sys/socket.h> 5 #include <netdb.h> 6 #include <arpa/inet.h> 7 #include <iomanip> 8 extern "C" { 9 #include "../../pg/include/errhnd.h" 10 } 11 12 using namespace st...

Version Roll Back

I am doing a concept in linux in which i want to do version rollback for an app installed in linux. Is it possible?? For eg I have an application named X with version 1.1 I get an update. It changes it to version 1.2 I note what all the packages in the app going to be modified. Then i save them and apply the changes. Now after sometime ...

What package do i need to install for using routing sockets?

i am trying code given in Unix Network Programming by Richard Stevens. but i am not able to get the code to compile. here is the source code. http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15213-f00/unpv12e/libroute/ i don't have the header file net/if_dl.h and the net/route.h header file does not include the constants and structu...

Shared memory access without semaphores

Hi All, using shared memory apis in linux, If I have one write(by A process) and only one read( by B process) do I still need semaphore.?. Is there a example to show, using sharing memory without semaphore will get into deadlock state in linux. ...

Bash: looping through content of a file?

How do I iterate through each line of a text file with Bash? With this script echo Start! for p in (peptides.txt) do echo $p done I get this output on the screen: Start! ./runPep.sh: line 3: syntax error near unexpected token `(' ./runPep.sh: line 3: `for p in (peptides.txt)' (Later I want to do something more complicated with...

"Nonrepresentable section on output" error during linking on linux

I get this error at the linker stage when compiling the webkit-1.1.5 package on my Ubuntu 9.04 box: libtool: link: gcc -ansi -fno-strict-aliasing -O2 -Wall -W -Wcast-align -Wchar-subscripts -Wreturn-type -Wformat -Wformat-security -Wno-format-y2k -Wundef -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-unused-parameter -W...

How do I read events from a HID device under Ubuntu Jaunty?

I have a Linux USB HID device (a Hama MCE), and I can read its events manually by reading cat /dev/input/event7 and cat /dev/input/event8. Whenever I press a key on the device, a few bytes become available for reading with one of the cat commands above. I have a default installation of Ubuntu Jaunty 64-bit desktop on the machine. I thin...

Does Creating a New Thread Duplicate File Descriptors and Socket Descriptors in Linux?

Everyone knows the classic model of a process listening for connections on a socket and forking a new process to handle each new connection. Normal practice is for the parent process to immediately call close on the newly created socket, decrementing the handle count so that only the child has a handle to the new socket. I've read that...

Minimum configuration to run embedded Linux on an ARM processor?

I need to produce an embedded ARM design that has requirements to do many things that embedded Linux would do. However the design is cost sensitive and does not need huge amounts of horse power. Mostly will be talking to serial interfaces. Ideally I would like to use one of the low end ARMs. What is the lowest configuration of an ARM tha...

Howto get include directories (ruby.h) for Linux Ruby C extension project?

I'm using scons to build a linux C based ruby extension. What is the "right" way to get the include paths right? By "right" I mean it works out of the box on 1.9 and 1.8. I don't want to use the mkmf/Makefile solution. Thanks! Dave ...

Can you write a simple weekly reminder using a (ba)?sh script quine?

I need to set myself a reminder to attend a weekly meeting. The trouble with my company's standard reminder tool is that when it runs under wine, it pops up on an off-screen virtual desktop. I thought it would be interesting to see if I could come up with an "at" command that pops up a reminder window and then resubmits itself for the ...

What’s the best way to distribute a binary application for Linux?

I just finished porting an application from Windows into Linux. I have to create an installer of the application. The application is not open source => I should distribute the application's binaries (executable file, couple .so files, help files and images). I found several methods to do it: - RPM and DEB packages; - installer in .sh fi...

How I can Replace main() in already-compiled application?

I need additional initialization over existing in dynamic-linked application. ...

how to associate the the device in /dev/ with the actual driver

Hi , I am trying to understand how device driver works in linux. I have a device node as follows (Major number 89, device name i2c-0) crw-r--r-- 1 0 0 89, 0 Sep 29 01:36 /dev/i2c-0 I have the i2c driver with the name i2c.ko and I will do insmod i2c.ko during start up. And in the driver , following function will ...

Unicode issue with freetype (C)

Hi guys, I currently working on a library for the NekoVM to create a binding to Freetype 2. It is written in plain c and it all works really nice, except when the user enters some unicode chars like "ü", "Ä" or "ß" they will be transformed into to some ugly square-like letters. When I recieve the data from the NekoVM you use val_string ...

Linux ioctl -> how to tell if current IP was obtained by dhcp

Hello all, I'm fiddling with the sockets ioctl's to get the current interfaces setup and I can already get the IP, interface name, netmask and check if the interface is up or down, (I just do IOCTl to SIOCGIFCONF, SIOCGIFNETMASK and SIOCGIFFLAGS). I am looking for a way to tell if my current IP address was obtained through dhcp or if ...