コード例 #1
0
	//Später die gesamten ausgeschriebenen Pfade durch das Install-
	//prefix welches vom configure script gesetzt wird ersetzen
    string ConfigurationManagerLinux::findRastullahConf( const string& cfg_name )
    {
        // Erstmal im Homeverzeichnis suchen.
        // getenv(home) nicht ungefährlich...
        string filename = string(::getenv("HOME")) + "/." + cfg_name;
        
        //wenn die Datei existiert ist das unsere favorisierte Wahl
        if(checkForFile(filename)) return filename;
       
        // Als nächstes schauen wir mal ob in /etc/rl eine standard
        // config vorhanden ist
        filename = "/etc/rl/" + cfg_name;
        if(checkForFile(filename)) return filename;
        
        // /usr/local/share/rl und /usr/share/rl wären noch Kandidaten
        filename = "/usr/local/share/rl/" + cfg_name;
        if(checkForFile(filename)) return filename;
        
        filename = "/usr/share/rl/" + cfg_name;
        if(checkForFile(filename)) return filename;
        
        //nix gefunden, also geben wir das home des Benutzers zurück, damit eine
        //neue Datei angelegt werden kann.
        //TODO: Es sollte IMMER wenn im home des current calling users keine 
        //.rastullah_ogre.cfg ist eine für diesen Benutzer mit seinen persönlichen
        //settings angelegt werden, oder aber aus den oben genannten Standard
        //pfade eine kopiert und angepasst!!!
        return string(::getenv("HOME")) + "/." + cfg_name;
    }
コード例 #2
0
	string ConfigurationManagerLinux::findModulesRootDir()
    {
    	// ModulesRootDir ist in rl.conf definiert, also suchen wir danach
    	
    	// erster Ansatz wie immer das HOME des users (getenv gefährlich)
    	string filename = string(::getenv("HOME")) + "/.rl.conf";
    	
    	if(checkForFile(filename))
    	{
    		// wir geben die erste nichtleere Zeile aus dem File zurück, 
    		// da diese den gesuchten Pfad repräsentiert
    		// später mit tags die einzelnen Variablen beschreiben, 
    		// die dann vernünftig geparst werden!
    		ifstream file(filename.c_str());
    		string line;
    		while(getline(file, line))
    		{
    			if(line.length() > 0)
    			{
    				file.close();
    				return line;
    			}
    		}
    		file.close();
    	}
    	
        // der nächste Versuch die Datei zu finden ist /etc/rl/rl.conf
        filename = "/etc/rl/rl.conf";
        if(checkForFile(filename))
    	{
    		// wir geben die erste nichtleere Zeile aus dem File zurück, 
    		// da diese den gesuchten Pfad repräsentiert
    		// später mit tags die einzelnen Variablen beschreiben, 
    		// die dann vernünftig geparst werden!
    		ifstream file(filename.c_str());
    		string line;
    		while(getline(file, line))
    		{
    			if(line.length() > 0)
    			{
    				file.close();
    				return line;
    			}
    		}
    		file.close();
    	}
        
        // alles war erfolglos, also gehen wir mal vom aktuellen Verzeichnis
        // aus
        return ".";
    }
コード例 #3
0
ファイル: help.c プロジェクト: CivilPol/sdcboot
int lang_add(char *base_dir, const char *home_page)
{
   char testpath[257];

   if (base_dir[0] != '\0')
   {
      if (base_dir[strlen(base_dir)-1] != '\\' &&
          base_dir[strlen(base_dir)-1] != '/')
          strcat(base_dir, "\\");
   }

   if (getenv ("LANG"))
   {
      struct ffblk dummy_ffblk;
      strcpy (testpath, base_dir);
      strcat (testpath, getenv("LANG"));

      if (findfirst(testpath, &dummy_ffblk, FA_DIREC) == 0)
      {
         /* found */
         strcpy (base_dir, testpath);
         strcat (base_dir, "\\");
      }
      else
         strcat (base_dir, "en\\");
   }
   else
   {
      strcat (base_dir, "en\\");
   }

   strcpy(testpath, base_dir);
   strcat(testpath, home_page);
   return checkForFile(testpath);
}
コード例 #4
0
ファイル: PionPlugin.cpp プロジェクト: enyo/old-brainslug
bool PionPlugin::findFile(std::string& path_to_file, const std::string& name,
						  const std::string& extension)
{
	// first, try the name as-is
	if (checkForFile(path_to_file, name, "", extension))
		return true;

	// nope, check search paths
	boost::mutex::scoped_lock plugin_lock(m_plugin_mutex);
	for (std::vector<std::string>::iterator i = m_plugin_dirs.begin();
		 i != m_plugin_dirs.end(); ++i)
	{
		if (checkForFile(path_to_file, *i, name, extension))
			return true;
	}
	
	// no plug-in file found
	return false;
}
コード例 #5
0
	ConfigurationManagerLinux::ConfigurationManagerLinux()
	{
		mModulesRootDirectory = findModulesRootDir();
		mPluginCfgPath = mModulesRootDirectory + 
			"/modules/common/conf/plugins-linux.cfg";
		mSoundCfgPath = mModulesRootDirectory +
			"/modules/common/conf/sound.cfg";
		mRastullahCfgPath = findRastullahConf( "rastullah_ogre.cfg" );
		mRastullahSystemCfgPath = findRastullahConf( "rastullah_system.cfg" );
        if (!checkForFile(mRastullahSystemCfgPath))
        {
            string filename = mModulesRootDirectory + "/modules/common/conf/rastullah_system.cfg";
            if (checkForFile(filename))
            {
                mRastullahSystemCfgPath = filename;
            }
        }
		mOgreLogPath = mModulesRootDirectory+"/logs/ogre.log";
		mRastullahLogPath = mModulesRootDirectory+"/logs/rastullah.log";
		mModulesCfgPath = mModulesRootDirectory + "/modules/modules.cfg";
		mModuleconfigCfgPath = "/conf/moduleconfig.cfg";
	}
コード例 #6
0
ファイル: ee367client.c プロジェクト: reedv/ee367L-lab2
void processGet(char* display, char* filename)
{
//	printf("**processClient/get\n");
	strcpy(display, "get");  // temp. debug output


	int has_file = checkForFile(filename);
	if(has_file) {
		getFileContents(display, filename);
	} else {
		strcpy(display, "Server did NOT find: ");
		strcat(display, filename);
	}
}
コード例 #7
0
ファイル: ee367server.c プロジェクト: reedv/ee367L-lab2
void processCheck(char* out_buffer, char* filename)
{
	printf("**entering processClient/processCheck\n");
//	strcpy(out_buffer, "check");  // temp. debug output

	int has_file = checkForFile(filename);

    if(has_file) {
    	strcpy(out_buffer, "Server found: ");
    	strcat(out_buffer, filename);
    }
    else {
    	strcpy(out_buffer, "Server did NOT find: ");
    	strcat(out_buffer, filename);
    }

}
コード例 #8
0
ファイル: help.c プロジェクト: CivilPol/sdcboot
int
main (int argc, char *argv[])
{
  /* These have been moved from global to local variables */
  /* this reduces binary size and improves code structure. RP */
  /* Also size of home_page and help_page reduced from 257. RP 11-mar-04 */
  char home_page[20] = "index.htm";
  char help_page[20] = "help.htm";
  char base_dir[257];

  char *showcommand = 0;
  char *oldscreen;
  int oldcursorx = wherex (), oldcursory = wherey ();
  int i;			/* counter for loop */
  int forcemono = 0, fancyscheme = 0;
  int AsciiExtendedChars = 1;
  int codepage = 0;

  cat = catopen("htmlhelp", 0);

  if (getenv ("HELPPATH") == NULL)
    {
      get_base_dir (base_dir, argv[0]);
      strcat (base_dir, "..\\help\\"); /* default location */

      if (lang_add(base_dir, home_page) != 0)
      {
         char testpath[257];
         get_base_dir (base_dir, argv[0]);
         strcat (base_dir, "..\\help\\"); /* bookshelf location */

         strcpy(testpath, base_dir);
         strcat(testpath, home_page);
         if (checkForFile(testpath) != 0)
         {
            get_base_dir (base_dir, argv[0]); /* try same dir as exe */
            strcpy(testpath, base_dir);
            strcat(testpath, home_page);
            if (checkForFile(testpath) != 0)
            {
               *base_dir = '\0'; /* try current dir */
               strcpy(testpath, home_page);
               if (checkForFile(testpath) != 0)
               {
                  get_base_dir (base_dir, argv[0]);
                  strcat (base_dir, "..\\help\\");
               }
            }
         }
      }
    }
  else
    {
      strcpy (base_dir, getenv ("HELPPATH"));
      if (lang_add(base_dir, home_page) != 0)
      {
         strcpy (base_dir, getenv ("HELPPATH"));
         if (base_dir[0] != '\0')
         {
            if (base_dir[strlen(base_dir)-1] != '\\' &&
                base_dir[strlen(base_dir)-1] != '/');
	            strcat (base_dir, "\\");
         }
      }

    }

  if (getenv ("HELPCMD"))
    {
      if (strstr (getenv ("HELPCMD"), "/A"))
	AsciiExtendedChars = 0;
      if (strstr (getenv ("HELPCMD"), "/M"))
	forcemono = 1;
      if (strstr (getenv ("HELPCMD"), "/F1"))
         fancyscheme = 1;
      if (strstr (getenv ("HELPCMD"), "/F2"))
         fancyscheme = 2;
    }

  for (i = 1; i < argc; i++)
    {
      if (argv[i][0] == '/')
	{
	  switch (argv[i][1])
	    {

	    default:
	      printf ("%s -- %s\n", hcatInvArg, argv[i] + 1);
		   printf ("%s\n", hcatHowGetUsage);
         break;

	    case '?':
	      show_usage ();
	      return 0;

	    case 'a':
	    case 'A':
	      if (argv[i][2] == 0)
		AsciiExtendedChars = 0;
	      break;

       case 'c':
       case 'C':
       codepage = atoi(argv[i]+2);
       if (codepage == 0)
       {
          printf("%s (/Cnnn)\n", hcatCodepagePlease);
          printf("%s:\n%s\n", hcatCodepagesSupported, supportedCodepages);
          return 0;
       }
       break;

	    case 'f':
	    case 'F':
	      fancyscheme = atoi(argv[i] + 2);
         if (fancyscheme < 1 || fancyscheme > 2)
            fancyscheme = 1;
         break;

	    case 'h':
	    case 'H':
	      if (argv[i][2] == 0)	/* Only put /h or /H */
		{
        printf ("%s\n", hcatInvArg);
		  printf ("%s\n", hcatHowGetUsage);
		  return 0;
		}
	      else
		{
           strncpy(help_page, argv[i] + 2, 14);
		}
	      break;

	    case 'l':
	    case 'L':
	      strcat (base_dir, argv[i] + 2);
	      checkForFile (base_dir);
	      get_home_page (home_page, base_dir);
	      get_base_dir (base_dir, base_dir);
	      break;

	    case 'm':
	    case 'M':
	      if (argv[i][2] == '\0')
		forcemono = 1;
	      else
		{
		  printf ("%s -- %s\n", hcatInvArg, argv[i] + 1);
		  printf ("%s\n", hcatHowGetUsage);
		  return 0;
		}
	      break;

	    case 'o':		/* Override index file path/name */
	    case 'O':
	      strcpy (base_dir, argv[i] + 2);
         if (lang_add(base_dir, home_page) != 0)
         {
	         strcpy (base_dir, argv[i] + 2);
	         checkForFile (base_dir);
	         get_home_page (home_page, base_dir);
	         get_base_dir (base_dir, base_dir);
         }
	    }
	}
      else if (showcommand == 0)
	{
	  showcommand = malloc (strlen (argv[i]) + 11);
	  if (!showcommand)
	    {
	      printf ("%s\n", hcatMemErr);
	      return 0;
	    }
	  sprintf (showcommand, "#%s", argv[i]);
	}
      else
	{
	  printf ("%s\n", hcat2ManyTopics);
	  printf ("%s\n", hcatHowGetUsage);
	  return 0;
	}
    }

  if (fancyscheme && forcemono)
  {
     printf ("%s\n", hcatFwithN);
	  printf ("%s\n", hcatHowGetUsage);
     return 0;
  }

  /* detect (or force) the codepage to select UTF-8 and entity
     substition support */
  if (selectCodepage(codepage) != codepage && codepage > 0)
  {
     printf("%s\n", hcatCodepageNotSupported);
     printf("%s:\n%s\n", hcatCodepagesSupported, supportedCodepages);
     return 0;
  }

  /* initialise user interface */
  conio_init (forcemono);

  if (forcemono == 0)
    {
      oldscreen = malloc (W * H * 2);
      if (oldscreen)
	save_window (X, Y, W, H, oldscreen);
    }

  if (MonoOrColor == COLOR_MODE && fancyscheme == 0)
    {
      TEXT_COLOR = C_TEXT_COLOR;
      BOLD_COLOR = C_BOLD_COLOR;
      ITALIC_COLOR = C_ITALIC_COLOR;
      BORDER_BOX_COLOR = C_BORDER_COLOR;
      BORDER_TEXT_COLOR = C_BORDER_TEXT_COLOR;
      LINK_COLOR = C_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = C_LINK_HIGHLIGHTED_COLOR;
    }
  else if (MonoOrColor == COLOR_MODE && fancyscheme == 1)
    {
      TEXT_COLOR = F1_TEXT_COLOR;
      BOLD_COLOR = F1_BOLD_COLOR;
      ITALIC_COLOR = F1_ITALIC_COLOR;
      BORDER_BOX_COLOR = F1_BORDER_COLOR;
      BORDER_TEXT_COLOR = F1_BORDER_TEXT_COLOR;
      LINK_COLOR = F1_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = F1_LINK_HIGHLIGHTED_COLOR;
    }
  else if (MonoOrColor == COLOR_MODE && fancyscheme == 2)
    {
      TEXT_COLOR = F2_TEXT_COLOR;
      BOLD_COLOR = F2_BOLD_COLOR;
      ITALIC_COLOR = F2_ITALIC_COLOR;
      BORDER_BOX_COLOR = F2_BORDER_COLOR;
      BORDER_TEXT_COLOR = F2_BORDER_TEXT_COLOR;
      LINK_COLOR = F2_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = F2_LINK_HIGHLIGHTED_COLOR;
    }
  else
    {
      TEXT_COLOR = M_TEXT_COLOR;
      BOLD_COLOR = M_BOLD_COLOR;
      ITALIC_COLOR = M_ITALIC_COLOR;
      BORDER_BOX_COLOR = M_BORDER_COLOR;
      BORDER_TEXT_COLOR = M_BORDER_TEXT_COLOR;
      LINK_COLOR = M_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = M_LINK_HIGHLIGHTED_COLOR;
    }
  if (AsciiExtendedChars == 0)
    {
      strcpy (Border22f, "+-+( )+-+");
      strcpy (Border22if, "+-+( )+-+");
      BarBlock1 = '.';
      BarBlock2 = '#';
    }
  show_mouse ();
  move_mouse (80, 25);
  drawmenu ();
  html_view (showcommand, base_dir, home_page, help_page);
  free (showcommand);
  hide_mouse ();
  if ((oldscreen != 0) && (forcemono == 0))
    {
      load_window (X, Y, W, H, oldscreen);
      free (oldscreen);
    }
  conio_exit ();
  gotoxy (oldcursorx, oldcursory);

  return 0;
}
コード例 #9
0
ファイル: main.c プロジェクト: BrandonOS/Programming
int main(){
	char inputFile[24] = "";
	char outFile[24] = "";
	
	printf("Please enter the name of input data file  (max 20 characters): ");
	scanf("%s", inputFile);
	strcat (inputFile,".txt");
	checkForFile(inputFile, 0);

	printf("Please enter name of report file to be generated (max 20 characters): ");
	scanf("%s", outFile);
	strcat (outFile,".txt");
	checkForFile(outFile, 1);
	


	FILE *ficaTxt = fopen("fica.txt", "r");
	FILE *inFile = fopen(inputFile, "r");
	FILE *reportFile = fopen(outFile, "a");
	fclose(reportFile);
	


	int PK = 0;
	int LK = 0;
	const int Max_Lines = 5;
	int noOfRecords = 0;

	double ficaRate;
	int ficaLimit;
	char st1[9], st2[8];


	int empNo;
	char givenName[15], surName[15], dept[6];
	double ytd, payRate, hours;

	double totalGross = 0, totalFica = 0, totalNet = 0;
	
	while ( fscanf(ficaTxt, "%s %d %s %lf", st1, &ficaLimit, st2, &ficaRate) != EOF ) { };		// Get the current FICA values
	fclose(ficaTxt);

	if( PK == 0 ) header(outFile);

	//Start to Read the file
	double fica, gross, net;
	double tFica = 0, tGross = 0, tNet = 0;	
	if(PK == 0) newPage(&PK, LK, outFile);

	while ( fscanf(inFile, "%d %s %s %s %lf %lf %lf", &empNo, givenName, surName, dept, &ytd, &payRate, &hours) != EOF ) 
	{	
		FILE *reportFile = fopen(outFile, "a");
		
						//
		gross = calGross(hours, payRate);	
		fica = calFica(ytd, gross, ficaLimit, ficaRate);
		net = calNet(gross, fica);


		fprintf(reportFile, "%-5d \t%-12s\t %-12s\t %5s\t %9.2f\t %8.2f\t  %6.2f\t %8.2f\n", empNo, givenName, surName, dept, ytd, gross, fica, net);
		printf("%-5d \t%-12s\t %-12s\t %5s\t %9.2f\t %8.2f\t  %6.2f\t %8.2f\n", empNo, givenName, surName, dept, ytd, gross, fica, net);
	noOfRecords++;

	totalGross += gross;
	totalFica += fica;
	totalNet += net;
	LK++;
	fclose(reportFile);

	// Check the Line counter to see if we need a new header
	if (LK == Max_Lines){		
		footer(PK, totalGross, totalFica, totalNet, outFile);
		newPage(&PK, LK, outFile);
		header(outFile);
		
		LK = 0;
		
		tGross += totalGross;
		totalGross = 0;

		tFica += totalFica;
		totalFica = 0;

		tNet += totalNet;
		totalNet = 0;
			
		}
	}
	
	// print the rest of the report (if theres any unaccounted items)
	if(LK > 0 && LK < Max_Lines){
			
		footer(PK, totalGross, totalFica, totalNet, outFile);

		int i;	
		FILE *openFile = fopen(outFile, "a");	
		for (i = LK; i < Max_Lines; i++){
			printf("\n");
			fprintf(openFile, "\n");
			LK++;			
		}	
		PK++;
		fclose(openFile);

	}
	
	closingPage(&PK, noOfRecords, tGross, tFica, tNet, outFile);
return 0;	
}
コード例 #10
0
ファイル: help_htm.c プロジェクト: CivilPol/sdcboot
int
html_view_internal (struct eventState *pes, char *base_dir, char *home_page)
{
  int i;

  if (pes->link_text != 0)
    {
      statusbar (hcatStatusLooking);
      if (*pes->link_text == '#')
	{
	  char *anchor;

	  if (strnicmp (pes->link_text + 1, HTMLHELP_INTERNAL_SEARCHLINK,
			strlen (HTMLHELP_INTERNAL_SEARCHLINK)) == 0)
	    {
	      /* Internal search engine link */
	      anchor = pes->body_start + atoi (pes->link_text +
					       strlen
					       (HTMLHELP_INTERNAL_SEARCHLINK)
					       + 1);
	    }
	  else
	    {
	      sprintf (pes->text_holder, "<a name=\"%.*s\"",
		       link_length (pes->link_text + 1), pes->link_text + 1);
	      anchor = strstr (pes->body_start, pes->text_holder);
	    }

	  if (anchor)
	    {
	      /* Locate start of line. */
	      while (anchor != pes->body_start && *anchor != '\n')
		anchor--;

	      if (*anchor == '\n')
		anchor++;

	      /* Move to this line, just near top of screen */
         if (!pes->first_time)
            addBookmark(pes);
	      pes->seek_base = anchor;
	      pes->seek_cnt = -1;
         pes->clink = 0; /* RP - Added 5.3.2 */
	      pes->link_text = 0;
	      *pes->text_holder = 0;
	      statusbar (NULL);
	      return NAVIGATE_DONT;
	    }
	  else
	    {
	      int triedasfile = 0;
         int tryexact = 1;
	      sprintf (pes->text_holder, "%.*s",
		       link_length (pes->link_text + 1), pes->link_text + 1);
	      strlwr (pes->text_holder);
		   write_string (TEXT_COLOR, X + strlen(hcatStatusLooking) + 3, TY,
				                       hcatStatusEscape);
	      do
		{

		  pes->p = pes->body_start;
		  while ((pes->p = strstr (pes->p, "<a")) != 0)
		    {
		      static struct event ev;
		      get_event (&ev, EV_KEY | EV_NONBLOCK);
		      if (ev.ev_type == EV_KEY && ev.key == 27)
			{
			  pes->link_text = 0;
           show_error(hcatUserAborted);
			  return NAVIGATE_DONT;
			}

		      pes->p = strchr (pes->p, '>');
		      if (pes->p)
			{
			  ++(pes->p);
			  if ((strnicmp(pes->p, pes->text_holder,
			                        strlen (pes->text_holder)) == 0) &&
                (pes->p[strlen(pes->text_holder)] == '<' || !tryexact))
			    {
			      while (pes->p != pes->body_start &&
				     strncmp (pes->p, "<a", 2))
				pes->p--;

			      pes->p = strstr (pes->p, "href=");
			      if (pes->p != 0)
				{
				  pes->p += 6;
				  if (*pes->p == '\"')
				    pes->p++;

				  if (*pes->p == '#')
				    break;

				  if (prepare_link (pes))
				    {
                  if (tryexact == 0)
                     show_error(hcatNoExactFound);
				      return NAVIGATE_LINK;
				    }
				}
			    }
			}
		    }
		  if (triedasfile == 0)
		    {
		      int undostrcat = strlen (base_dir);
		      if (base_dir[strlen (base_dir) - 1] != '\\'
			  && base_dir[0] != 0)
			strcat (base_dir, "\\");
		      strcat (base_dir, pes->text_holder);
		      if (checkForFile (base_dir))
			{
			  /* Didn't work */
			  base_dir[undostrcat] = '\0';
			}
		      else
			{
			  if (pes->first_time)
			    pes->hidden = 1;
			  get_home_page (home_page, base_dir);
			  get_base_dir (base_dir, base_dir);
			  return NAVIGATE_HOME;
			}
		      triedasfile = 1;
		    }
		  else
		    {
            /* don't try to match end with the < */
            if (tryexact)
            {
               tryexact = 0;
            }
            else
            {
		         pes->p = pes->text_holder + strlen (pes->text_holder) - 1;
		         if (*pes->p > 'a')
			         --(*pes->p);
		         else
			         *pes->p = 0;
            }
		    }
		}
	      while (*(pes->text_holder) != 0);
	    }
     statusbar (NULL);

	  sprintf (pes->text_holder, "%s '%.*s'", hcatCouldntFind,
		   link_length (pes->link_text + 1), pes->link_text + 1);
	  show_error (pes->text_holder);
	  pes->link_text = 0;
	  *(pes->text_holder) = 0;
	  return NAVIGATE_DONT;
	}
      else if (prepare_link (pes))
	return NAVIGATE_LINK;

      pes->link_text = 0;
    }

  if (pes->first_time)
  {
     drawmenu();
     save_window (X, Y, W, H, pes->screen_buf);
     pes->first_time = 0;
  }

  if (pes->seek_cnt != 0)
    {
      if (pes->seek_cnt <= 0)
	{
	  i = -pes->seek_cnt;
	  pes->p = pes->seek_base - 1;
	  if (*pes->p == '\n')
	    pes->p--;

	  for (; (pes->p != pes->body_start); pes->p--)
	    if (*pes->p == '\n')
	      {
		i--;
		if (i == 0)
		  {
		    pes->p++;
		    break;
		  }
	      }
	  pes->top = pes->p;
	}
      else if (pes->seek_cnt > 0)
	{
	  i = pes->seek_cnt;
	  pes->p = pes->seek_base;
	  for (; pes->p != pes->body_end; pes->p++)
	    if (*pes->p == '\n')
	      {
		i--;
		if (i == 0)
		  {
		    pes->p++;
		    break;
		  }
	      }

	  if (pes->p == pes->body_end)
	    {
	      pes->seek_base = pes->body_end - 1;
	      pes->seek_cnt = -1;
	      return NAVIGATE_DONT;
	    }

	  pes->top = pes->p;
	}
      pes->seek_cnt = 0;
    }

  if (pes->maxtop != 0)
    pes->barpos = ((pes->top - pes->body_start) * BARLEN) / pes->maxtop;
  else
    pes->barpos = BARLEN - 1;

  if (pes->barpos >= BARLEN || pes->barpos < 0)	/* <0 fix - RP */
    pes->barpos = BARLEN - 1;

  if (pes->bar_hooked)
    {
      pes->seek_base = pes->top;
      if (pes->forced_barpos == 0)
	{
	  pes->top = pes->body_start;
	  pes->barpos = 0;
	}
      else if (pes->forced_barpos == BARLEN - 1
	       && pes->barpos != pes->forced_barpos)
	{
	  pes->old_barpos = pes->barpos;
	  pes->seek_base = pes->body_end;
	  pes->seek_cnt = -N;
	  return NAVIGATE_DONT;
	}
      else if (pes->forced_barpos < pes->barpos
	       && pes->forced_barpos < pes->old_barpos)
	{
	  pes->old_barpos = pes->barpos;
	  pes->seek_cnt = -1;
	  return NAVIGATE_DONT;
	}
      else if (pes->forced_barpos > pes->barpos
	       && pes->forced_barpos > pes->old_barpos)
	{
	  pes->old_barpos = pes->barpos;
	  pes->seek_cnt = +1;
	  return NAVIGATE_DONT;
	}
    }

  pes->old_barpos = pes->barpos;
  if (pes->top != pes->old_top)
    pes->force_redraw = 1;

  /* ------ Display processing ------------------------------------ */
  displayProcess (pes);

  /* ------ Event processing -------------------------------------- */
  return processEvents (pes);
}