hacking contest

hacking exploits security forum
hacking
compliance articles
upgrade backup exec
information security consultant

s7r1k3r
Hello,

I need a C library for reading writting configuration files. No specific configuration files. I am writting an application that will have its own set of conf files and was hoping that I could find a library to read and write the files instead of having to write my own.
Blackknight
just write your own.. its simple
open the files search for \n then use strtok to break it up what ever method your using
server=127.0.0.1; for example
CODE

pwnd=strtok(buff,"=");
printf("%s\n",pwnd);
pwnd=strtok(NULL,";");
printf("%s\n",pwnd);

you could probably make it more efficent but meh you get the idea it aint that hard
and using other peoples files you always end up editing them heavily anyway to suit your needs might as well start clean blink.gif


edit: oh btw keep in mind that strtok will overwrite the values with \0 effictivley destroying the buff so have a tmp buff or what not if u want to keep it
ShadowRun
search those sites
CODE
http://www.programmersheaven.com
http://www.codeproject.com


here's mine java class for properties reading
if u're interested
CODE
import java.util.Vector;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;

class FileConfig{

   String filePath;
   Vector nazwy = new Vector();
   Vector configi = new Vector();
   int error = 0;

FileConfig(String path){
           filePath = path;
           readConfigs();
}

       private void readConfigs() {
           String string = "";
           int confNr = -1;
           try{              
               String line;
               String str;
               FileReader fileIn = new FileReader(filePath);
 BufferedReader in = new BufferedReader(fileIn);
 while ((line = in.readLine())!=null){
                   java.util.StringTokenizer st = new java.util.StringTokenizer(line, " :\n");
                   while (st.hasMoreTokens()) {
                       str = st.nextToken();
                       string += str +"*";                    
                           if (str.equals("config")) {
                               confNr++;
                               configi.add(confNr, new Vector());                          
                           }
                           else {
                               if (!(str.equals("name") || str.equals("computer") || str.equals("port") || str.equals("database"))) {
                                   ((Vector)configi.get(confNr)).add(str);                                    
                               }
                           }
                       //}                            
                   }
                   //in.close();
               }
           } catch(IOException e) {    
               error=1;
           }                                    
           
           for (int i=0; i<configi.size();i++) {                
               Vector config = (Vector)configi.get(i);
               nazwy.add((String)config.get(1));
               for (int j=0; j<config.size(); j++) {                    
               }
           }
                     
       }
       
public Vector getNames(){
  if(error==0)
 return nazwy;
  else
    return null;
}
       
       public Vector getConfig(int nr) {
           return (Vector)configi.get(nr);
       }
       /*
       public static void main(String args[]) {
           javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
           int returnVal = chooser.showOpenDialog(new javax.swing.JFrame());
           String path = chooser.getSelectedFile().getPath();          
           new FileConfig(path);
       }*/
}


good luck

ps. you could try with XML files but it may be too difficult for you
but i think u'll find some C parsers on the net for XML
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.