Thread: Listing files in C

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    17

    Red face Listing files in C

    I'd like programming a simple firewall.
    This program should read a rules file, and every second check all the files /proc/[1-9][0-9]*/exe (executable file name) and /proc/[1-9][0-9]*/stat (process name). If that pair executable name/process appear in the rules file opening the relative ports. When the process disappears close them. I'll use iptables for this.

    How can I list all the /proc/[1-9][0-9]*$ files in the most portable way?
    "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone" Bjarne Stroustrup

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    correct me if im wrong but...

    since this is for a unix-based system, then i assume any standard C functions will be very portable (within other unix-based systems that have /proc).

  3. #3
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    Quote Originally Posted by nadroj
    correct me if im wrong but...
    since this is for a unix-based system, then i assume any standard C functions will be very portable (within other unix-based systems that have /proc).
    Yup, standard functions are portable across unixes.

    /proc is depreciated and is not in most unix operating systems any more.
    it's been changed to /services or /system depending on the unix
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  4. #4
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    In my BSD and Linux systems, both readdir(3) and opendir(3) calls are exist. And those are the functions that you wil use to work with directories!

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3
    (testing)
    not have /proc system in my Free BSD

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. Listing specific files in a directory
    By knirirr in forum C Programming
    Replies: 14
    Last Post: 01-29-2008, 05:42 AM
  3. Listing files in a directory.
    By Devil Panther in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2006, 09:39 PM
  4. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  5. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM