Linux-Development-Apps Digest #304, Volume #7 Thu, 29 Mar 01 02:13:11 EST Contents: Re: increasing open file limit? (Dustin Puryear) Sound Format Question (Matt Fuerst) Re: Listing local ip addresses (Floyd Davidson) Re: Getting directory sizes - fast (Juergen Heinzl) Re: WaitForMultipleObjects on linux? (Uwe Bonnes) RH7.* -- downgrading to gcc/g++ 2.95.3 (Carlos Moreno) Re: WaitForMultipleObjects on linux? (Dave Blake) Ojbect files generated by GCC and G++ can not be linked together ([EMAIL PROTECTED]) Re: RH7.* -- downgrading to gcc/g++ 2.95.3 ("Jacob Williams") Re: RH7.* -- downgrading to gcc/g++ 2.95.3 (Mladen Gavrilovic) Re: Ojbect files generated by GCC and G++ can not be linked together ("Arthur H. Gold") Re: RH7.* -- downgrading to gcc/g++ 2.95.3 (Carlos Moreno) Re: RH7.* -- downgrading to gcc/g++ 2.95.3 (Carlos Moreno) Re: Ojbect files generated by GCC and G++ can not be linked together (Carlos Moreno) Re: RH7.* -- downgrading to gcc/g++ 2.95.3 ("Jacob Williams") How to handle newline character(s) in a TCP server (InterFan) Re: Ojbect files generated by GCC and G++ can not be linked together (Erik Max Francis) Question about ethertap device (Jimmy) ---------------------------------------------------------------------------- From: [EMAIL PROTECTED] (Dustin Puryear) Subject: Re: increasing open file limit? Date: Wed, 28 Mar 2001 13:58:43 -0600 Reply-To: [EMAIL PROTECTED] On Wed, 28 Mar 2001 10:49:02 +0800, Victor <[EMAIL PROTECTED]> wrote: >You can change /proc/sys/fs/file-max (sometimes also inode-max) to expand >the system's limitation. >Then use "ulimit -HSn [number]" to change current user's limitation(you must >be a root). >And you can change FD_SETSIZE in "/usr/include/bits/types.h" to get around >the select() issue. Ah. I found that there are two definitions for FD_SETSIZE (__FD_SETSIZE). One is in /usr/include/bits/types.h and the other in /usr/include/linux/posix_types.h. By changing those to 4096 I could increase my possible connections when using select(). Why is this value initially so low under Linux? Regards, Dustin -- Dustin Puryear <[EMAIL PROTECTED]> http://members.telocity.com/~dpuryear Integrate Linux Solutions into Your Windows Network - http://www.prima-tech.com/integrate-linux ------------------------------ From: Matt Fuerst <[EMAIL PROTECTED]> Subject: Sound Format Question Date: Wed, 28 Mar 2001 16:36:09 -0500 Greetings, I am currently developing a little voice mail system for my own personal use. Fair and easy enough. I am using a Dialogic Card that is pretty spiffy. It records and plays in its own little format, a VOX file. I have a program for Windows that will play these files natively called Cool Edit, but what I really want is the code to play these files since I want to be able to select a voice mail from my computer and have it play over my speakers. I have searched sourceforge.net and freshmeat.net for programs that play the VOX format without any luck. My goal is to look at the code that decodes these files and rip it out and use it in my program (giving proper credit to all those involve, of course). Any ideas? The files themselves are ADPCM at 6 KHz.. though they could be 8 KHz also.. any pointers would be great. Thanks Matt [EMAIL PROTECTED] ------------------------------ From: Floyd Davidson <[EMAIL PROTECTED]> Subject: Re: Listing local ip addresses Date: 28 Mar 2001 11:55:27 -0900 [EMAIL PROTECTED] (Lew Pitcher) wrote: >On Wed, 28 Mar 2001 18:21:13 +0300, Rauno Tamminen ><[EMAIL PROTECTED]> wrote: > >>Hi, >> >>I need to write a program that lists all local ip addresses. >>Does anyone know a good documentation of ioctl(SIOCGIFCONF) >>or any other good way to to this? > >Not sure about ioctl(SIOCGIFCONF), but you can use one of the >gethostby* functions. They return a pointer to a structure that >carries all the IP addresses associated with the host. It's an easy >thing to iterate through that list, enumerating each IP address. Except that first you need to _know_ some part of the required information (whatever the '*' in gethostby* is). It seems the real question is just how do you find that information in the first place, and indeed an ioctl call will do it. Below is a program that prints out the interface and its IP address for each interface that is up. /* * display network interfaces and IP addresses */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <net/if_arp.h> #include <net/if.h> #include <arpa/inet.h> #define inaddrr(x) (*(struct in_addr *) &ifr->x[sizeof sa.sin_port]) #define IFRSIZE ((int)(size * sizeof (struct ifreq))) int main(void) { int sockfd, size = 1; struct ifreq *ifr; struct ifconf ifc; struct sockaddr_in sa; if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) { fprintf(stderr, "Cannot open socket.\n"); exit(EXIT_FAILURE); } ifc.ifc_len = IFRSIZE; ifc.ifc_req = NULL; do { ++size; /* realloc buffer size until no overflow occurs */ if (NULL == (ifc.ifc_req = realloc(ifc.ifc_req, IFRSIZE))) { fprintf(stderr, "Out of memory.\n"); exit(EXIT_FAILURE); } ifc.ifc_len = IFRSIZE; if (ioctl(sockfd, SIOCGIFCONF, &ifc)) { perror("ioctl SIOCFIFCONF"); exit(EXIT_FAILURE); } } while (IFRSIZE <= ifc.ifc_len); ifr = ifc.ifc_req; for (;(char *) ifr < (char *) ifc.ifc_req + ifc.ifc_len; ++ifr) { if (ifr->ifr_addr.sa_data == (ifr+1)->ifr_addr.sa_data) { continue; /* duplicate, skip it */ } if (ioctl(sockfd, SIOCGIFFLAGS, ifr)) { continue; /* failed to get flags, skip it */ } if (! ifr->ifr_flags & IFF_UP) { continue; /* interface not up, skip it */ } printf("Interface: %8.8s\t", ifr->ifr_name); printf("IP Address: %s\n", inet_ntoa(inaddrr(ifr_addr.sa_data))); } close(sockfd); return EXIT_SUCCESS; } -- Floyd L. Davidson <http://www.ptialaska.net/~floyd> Ukpeagvik (Barrow, Alaska) [EMAIL PROTECTED] ------------------------------ From: [EMAIL PROTECTED] (Juergen Heinzl) Subject: Re: Getting directory sizes - fast Date: Wed, 28 Mar 2001 21:57:09 GMT In article <[EMAIL PROTECTED]>, Michel Bardiaux wrote: >Jem Berkes wrote: >> >> > > is there a way to programmatically get the size of directories that is >> > >faster than calling and parsing the output of du (i.e. "du >> > >/usr/local/src/") ? >> > [-] >> > lstat() >> >> lstat returns the size of a file, but for directories (at least on the >> systems I tried it on) it just returns 4096. [-] It depends as it returns the size of a directory which *is* a file 8-) Oh and for my home the result is 5120. > >It can be larger for directories containing many many files, but you're >right, it does not total the sizes of contained files. >> >> Maybe try taking a look at the source for du? It might have some clues. >> >There is *no* other way than what "du" does, ie recursively enumerate >the directory and total the sizes, because files are not 'in' a >directory; a directory contains pointers ('hard links') to files, but a >file with several references (the 2nd column in the output of 'ls -al') >can not be attributed to *one* directory. Consequence: the filesystem >does not keep track of 'total size used by a directory' because that is >not a well-founded notion (for UNIX filesystems; IIRC FAT and NTFS are >different in that regard). [-] Huh ? opendir() / readdir() / closedir() and, well, (l)stat(). >du does the best it can, but I think files with N hard links will be >tallied N times. [-] st_nlink, but I think you need to make more clear what you mean by "size of a directory". Happy hacking, Juergen -- \ Real name : Juergen Heinzl \ no flames / \ EMail Private : [EMAIL PROTECTED] \ send money instead / ------------------------------ From: Uwe Bonnes <[EMAIL PROTECTED]> Subject: Re: WaitForMultipleObjects on linux? Date: 28 Mar 2001 22:58:33 GMT steve burkett <[EMAIL PROTECTED]> wrote: : i dont see anything like a WaitForMultipleObjects in linux. How can : this be (best) simulated? Have a look at the wine source (http://www.winehq.com) to see how they implemented (part of ) that functionality. Bye -- Uwe Bonnes [EMAIL PROTECTED] Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt ========= Tel. 06151 162516 ======== Fax. 06151 164321 ========== ------------------------------ From: Carlos Moreno <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Wed, 28 Mar 2001 18:23:42 -0500 The chicken or the egg?? (or chasing my own tail??) I'm wondering what would be the correct procedure to downgrade from gcc/g++ 2.96 to the latest *official* release, 2.95.3 If I download the source and have to compile it, then I feel like I'm using the broken compiler (and of course it's broken, otherwise I wouldn't be downgrading) to generate the executable code of the new compiler... What is then my hope that this new compiler will produce correct code? :-( I tried uninstalling first 2.96 (rpm --erase gcc, gcc-c++, etc.), and use kgcc instead, but kept running into trouble (configure would complain that it doesn't have a suitable compiler -- I defined the environment variable CC=kgcc, and I even created an alias: alias gcc='kgcc' -- configure would still complain that the available compiler was not able to generate executable code) So, what is the right solution? Or am I not really chasing my own tail if I use gcc 2.96 to compile gcc 2.95.3 ?? (Am I making any sense here?? :-)) Thanks for any comments! Carlos -- ------------------------------ From: [EMAIL PROTECTED] (Dave Blake) Subject: Re: WaitForMultipleObjects on linux? Date: 28 Mar 2001 23:51:36 GMT Reply-To: [EMAIL PROTECTED] steve burkett <[EMAIL PROTECTED]> wrote: > i dont see anything like a WaitForMultipleObjects in linux. How can > this be (best) simulated? What is WaitForMultipleObjects ?? You can wait for multiple file handles using select. -- Dave Blake [EMAIL PROTECTED] ------------------------------ From: [EMAIL PROTECTED] Crossposted-To: comp.os.linux.development.system Subject: Ojbect files generated by GCC and G++ can not be linked together Date: Wed, 28 Mar 2001 20:02:38 -0500 Hello, I'm trying to link some C++ code with a C library. The C library is compiled with Gcc on Linux (RedHat 7.0) while the C++ code is compiled with g++. Individual files all compile ok but linking with G++ fails. All the C functions come up as undefined reference. The manual page of gcc/g++ refers to C sytle linking and C++ style linking. What's the difference? How do you make them work? Your comments and suggestions are much appreciated. w. ------------------------------ From: "Jacob Williams" <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: Re: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Thu, 29 Mar 2001 11:36:47 +1000 why dont you track down an RPM install of a compiler and forcefully install that, then install the latest official release using the older compiler ? "Carlos Moreno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > > The chicken or the egg?? (or chasing my own tail??) > > I'm wondering what would be the correct procedure to downgrade > from gcc/g++ 2.96 to the latest *official* release, 2.95.3 > > If I download the source and have to compile it, then I feel > like I'm using the broken compiler (and of course it's broken, > otherwise I wouldn't be downgrading) to generate the executable > code of the new compiler... What is then my hope that this > new compiler will produce correct code? :-( > > I tried uninstalling first 2.96 (rpm --erase gcc, gcc-c++, etc.), > and use kgcc instead, but kept running into trouble (configure > would complain that it doesn't have a suitable compiler -- I > defined the environment variable CC=kgcc, and I even created > an alias: alias gcc='kgcc' -- configure would still complain > that the available compiler was not able to generate executable > code) > > So, what is the right solution? Or am I not really chasing > my own tail if I use gcc 2.96 to compile gcc 2.95.3 ?? > > (Am I making any sense here?? :-)) > > Thanks for any comments! > > Carlos > -- ------------------------------ From: Mladen Gavrilovic <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: Re: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Thu, 29 Mar 2001 01:37:02 GMT Carlos Moreno wrote: > > The chicken or the egg?? (or chasing my own tail??) > > I'm wondering what would be the correct procedure to downgrade > from gcc/g++ 2.96 to the latest *official* release, 2.95.3 > Red Hat has a new version of the compiler available on its errata site. Just download it, install with rpm -Uvh, and you're set. Mladen ------------------------------ Date: Wed, 28 Mar 2001 20:52:06 -0600 From: "Arthur H. Gold" <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.development.system Subject: Re: Ojbect files generated by GCC and G++ can not be linked together [EMAIL PROTECTED] wrote: > > Hello, > > I'm trying to link some C++ code with a C library. The C library is > compiled with Gcc on Linux (RedHat 7.0) while the C++ code is compiled > with g++. Individual files all compile ok but linking with G++ fails. > All the C functions come up as undefined reference. > > The manual page of gcc/g++ refers to C sytle linking and C++ style > linking. What's the difference? How do you make them work? > > Your comments and suggestions are much appreciated. > In `C' style linking, what you see is what you get, i.e. if you have a function called `foo', that's also its name as far as the linker is concerned. C++ on the other hand, because of the fact that you can overload functions with different signatures, does `name-mangling' which encodes the argument types in the name that's exposed to the linker. The simplest way of getting this to work would be to do the following in C++ code that uses C-linked functions (we assume that the prototypes for these functions are in a header file called "myCheaders.h" ... extern "C" { #include 'myCheaders.h" } ..... This ensures that you can call C functions by their normal names (and correspondingly you'll be able to link them). HTH, --ag -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info) mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED] -- Clone Bernie! ------------------------------ From: Carlos Moreno <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: Re: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Wed, 28 Mar 2001 22:43:02 -0500 > Red Hat has a new version of the compiler available on its errata site. > Just download it, install with rpm -Uvh, and you're set. But it is still 2.96, so it is still not tagged as reliable :-( Carlos -- ------------------------------ From: Carlos Moreno <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: Re: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Wed, 28 Mar 2001 22:48:12 -0500 > why dont you track down an RPM install of a compiler and forcefully install > that, then install the latest official release using the older compiler ? Hmmm, I thought that is what I would end up doing with the command: rpm --erase gcc. Since kgcc reports itself as egcsXXXXXX 2.91.66. Now, to forcefully install an older compiler from an RPM, I guess I should first uninstall the one I have, and that is what seems to be giving me the headaches... (presumably, the other option would be installing RedHat without selecting the "Development" or "Kernel Development" options, and then install from the RPM of the old version? -- of course, that option is, at the present time, not viable, but if it makes sense, I could keep it in mind for the next time that I install a RedHat system, or next time that I upgrade mine) Comments? Boy, I'm so rude! I didn't even say thanks! And I didn't say thanks to the other person that replied!! :-) So... Thanks! Carlos -- ------------------------------ From: Carlos Moreno <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.development.system Subject: Re: Ojbect files generated by GCC and G++ can not be linked together Date: Wed, 28 Mar 2001 22:52:21 -0500 "Arthur H. Gold" wrote: > > In `C' style linking, what you see is what you get, i.e. if > you have a function called `foo', that's also its name as > far as the linker is concerned Well, not necessarily. The compiler is free to use any internal name it likes, including _foo. (but of course, this does not contradict your argument, since any trans- formation that the compiler may do, will do it the same way for every function) > extern "C" { > #include 'myCheaders.h" > } > ..... > > This ensures that you can call C functions by their normal > names (and correspondingly you'll be able to link them). As a side effect, naturally, you can not use function overloading with those, or default argument values -- but of course, that has to be ok: if you're writing code in C, well, that code will not try to use function overloading, since the feature does not exist in C. Carlos -- ------------------------------ From: "Jacob Williams" <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.setup Subject: Re: RH7.* -- downgrading to gcc/g++ 2.95.3 Date: Thu, 29 Mar 2001 16:03:56 +1000 couldn't you just use rpm -ivh --force gcc.whatever_version.rpm and not worry about uninstalling the old one... it should overwrite all the relevant files.... ( i believe ) "Carlos Moreno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > > > why dont you track down an RPM install of a compiler and forcefully install > > that, then install the latest official release using the older compiler ? > > Hmmm, I thought that is what I would end up doing with > the command: rpm --erase gcc. Since kgcc reports > itself as egcsXXXXXX 2.91.66. > > Now, to forcefully install an older compiler from an > RPM, I guess I should first uninstall the one I have, > and that is what seems to be giving me the headaches... > (presumably, the other option would be installing > RedHat without selecting the "Development" or "Kernel > Development" options, and then install from the RPM > of the old version? -- of course, that option is, at > the present time, not viable, but if it makes sense, > I could keep it in mind for the next time that I > install a RedHat system, or next time that I upgrade > mine) > > Comments? > > Boy, I'm so rude! I didn't even say thanks! And I > didn't say thanks to the other person that replied!! > :-) > > So... Thanks! > > Carlos > -- ------------------------------ From: [EMAIL PROTECTED] (InterFan) Crossposted-To: comp.unix.programmer,comp.os.linux.development.system Subject: How to handle newline character(s) in a TCP server Date: Thu, 29 Mar 2001 06:34:06 GMT Reply-To: [EMAIL PROTECTED] I want to design a TCP server. It just receives a line from client and handles it. Then, it sends the response back to the client. The problem is that a line of message may end with ASCII characeter 13, 10 or 13+10. I use blocking I/O function. How can I handle these conditions smoothly. Thank a lot. Best Regards, Chuan He ------------------------------ From: Erik Max Francis <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.development.system Subject: Re: Ojbect files generated by GCC and G++ can not be linked together Date: Wed, 28 Mar 2001 22:45:11 -0800 [EMAIL PROTECTED] wrote: > I'm trying to link some C++ code with a C library. The C library is > compiled with Gcc on Linux (RedHat 7.0) while the C++ code is compiled > with g++. Individual files all compile ok but linking with G++ fails. > All the C functions come up as undefined reference. > > The manual page of gcc/g++ refers to C sytle linking and C++ style > linking. What's the difference? How do you make them work? In the C++ world you need to declare the C functions as being extern "C". -- Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Only the ephemeral is of lasting value. \__/ Ionesco Maths reference / http://www.alcyone.com/max/reference/maths/ A mathematics reference. ------------------------------ From: Jimmy <[EMAIL PROTECTED]> Subject: Question about ethertap device Date: Thu, 29 Mar 2001 14:50:13 +0800 Hi all, Just want to ask if some packets are redirected to the ethertap device will they be processed by the system automatically? Say, if I send some ping packets to the ethertap interface(eg. /dev/tap0), will they get the replies automatically? Thx a lot. Jimmy ------------------------------ ** FOR YOUR REFERENCE ** The service address, to which questions about the list itself and requests to be added to or deleted from it should be directed, is: Internet: [EMAIL PROTECTED] You can send mail to the entire list by posting to the comp.os.linux.development.apps newsgroup. Linux may be obtained via one of these FTP sites: ftp.funet.fi pub/Linux tsx-11.mit.edu pub/linux sunsite.unc.edu pub/Linux End of Linux-Development-Apps Digest ******************************