Пример #1
0
/**
 * This function figures out what interface is used, and reads the
 * two different configuration files, the global and the user one.
 */
void settings_read_interface(void)
{
  char *interface, *global_filename, *user_filename;
  char *homedir;
  void *value;

  /* Get the name of the interface. */
  settings_get("interface", &value);
  interface = (char *)value;

  /* Global configuration file, /etc/zen/<interface>.conf */
  global_filename = (char *)malloc(strlen(GLOBAL_CONFIGDIR) +
				   strlen(interface) + 42);
  if(global_filename == NULL)
    return;
  sprintf(global_filename, "%s/%s.conf", GLOBAL_CONFIGDIR, interface);
  read_configuration(global_filename, 0);
  free(global_filename);

  /* User configuration file, ~/.zen/<interface>.conf */
  homedir = find_homedir();
  user_filename = (char *)malloc(strlen(homedir) + 
				 strlen(interface) + 42);
  if(user_filename == NULL)
    return;
  sprintf(user_filename, "%s/.zen/%s.conf", homedir, interface);
  read_configuration(user_filename, 0);
  free(user_filename);
}
Пример #2
0
int main( int argc, char* argv[] , char *envp[])
{
  QApplication myapp( argc, argv );
  
  QString rcfil;
  QString bibl;
  QStringList lines;
  QString homeDir( QDir::homeDirPath() );
  
  rcfil.append(homeDir);
  rcfil.append("/.olfixrc");	/* resursfil, configfil		*/
  QFile file(rcfil);
  /***************************************************/
  /*  Testa om $HOME/.olfixrc existerar, om inte skapa den.    */
  /***************************************************/
  if ( !file.open( IO_ReadOnly )){
      file.close();
      find_homedir(envp);		/* Hämta $HOME		    			*/
      copy_rcfile();			/* Kopiera från /opt/olfix/script/.olficrc till  $HOME/.olfixrc	*/
  }
/*  fprintf(stderr,"Start 2 OLFIXW\n");	*/
/****************************************/
/*  Vilken databas ska användas?		*/
/****************************************/      
   which_database(envp);
/*fprintf(stderr,"Start 3 OLFIXW\n");	*/
  /****************************************/
  /*  Läs in data från $HOME/.olfixrc här	 */
  /****************************************/
   file.close();
   if ( file.open( IO_ReadOnly ) ) {
	QTextStream stream( &file );
	QString line;
        while ( !stream.eof() ) {
            line = stream.readLine(); // line of text excluding '\n'
            int i = line.find( QRegExp("PATH="), 0 );    // i == 1
	    if ( i == 0){
	    	int l =line.length();
	    	bibl = line.mid(5,l);
	    }
            lines += line;
        }
	file.close();
//	fprintf(stdout,"Bibliotek=%s\n",bibl.latin1() );
  }else{
      	qWarning( "Cannot find the $HOME/.olfixrc file" );
 	fprintf(stderr,"%s\n", rcfil.latin1() );
  }
  QDir::setCurrent ( bibl );
 
  frmOlfix* mywidget = new frmOlfix();
  mywidget->lineEditDatabase->setText(database);
  
  myapp.setMainWidget( mywidget);
  mywidget->show();
  return myapp.exec();
}