home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / wapuniverse-src-0.3.5.build9.tar.gz / wapuniverse-src-0.3.5.build9.tar / wapuniverse-0.3.5.build9 / history.c < prev    next >
C/C++ Source or Header  |  2000-11-12  |  2KB  |  77 lines

  1. //---------------------------------------------------------------------------
  2. // history.c
  3. // Contains all platform independant WAP/history code 
  4. //
  5. // Project: WAPUniverse for PalmOS
  6. // Copyright ⌐ 1999-2000 Filip Onkelinx
  7. //
  8. // http://www.wapuniverse.com/
  9. // filip@onkelinx.com
  10. //
  11. // This program is free software; you can redistribute it and/or
  12. // modify it under the terms of the GNU General Public License
  13. // as published by the Free Software Foundation; either version 2
  14. // of the License, or (at your option) any later version.
  15. //
  16. // This program is distributed in the hope that it will be useful,
  17. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU General Public License for more details.
  20. //
  21. // You should have received a copy of the GNU General Public License
  22. // along with this program; if not, write to the Free Software 
  23. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
  24. //
  25. //
  26. // $Workfile: history.c $  
  27. // $Author: wapuniverse $  
  28. // $Date: 2000/11/11 20:51:09 $     
  29. // $Revision: 1.3 $
  30. //
  31. // $Header: /cvsroot/wapuniverse/wapuniverse/src/history.c,v 1.3 2000/11/11 20:51:09 wapuniverse Exp $
  32. //
  33. //---------------------------------------------------------------------------
  34.  
  35. #include "history.h"
  36. #include "WAP.h"
  37. #include "WAPUniverse.h"
  38.  
  39. int historyPush(Char *url, GlobalsType *g )
  40. {
  41.     if ( !g->History ) { // no history yet, please create one
  42.         g->History = Malloc ( sizeof(historyType) );
  43.         MemSet(g->History,sizeof(historyType),0);
  44.         g->History->index = -1;
  45.     }
  46.  
  47.     if (g->History->index < (MAX_HISTORY - 1))
  48.         g->History->index++;
  49.     else
  50.         g->History->index = 0;    
  51.  
  52.     if(g->History->hist[g->History->index].url)
  53.         free(g->History->hist[g->History->index].url);
  54.     g->History->hist[g->History->index].url = Malloc(StrLen(url)+1);
  55.     ErrFatalDisplayIf (!g->History->hist[g->History->index].url, "wml.c/Malloc(history2)");
  56.     StrCopy(g->History->hist[g->History->index].url,url);                
  57. }
  58.  
  59. Char *historyPop(GlobalsType *g)
  60. {
  61. Char *tmp, *ret;
  62.  
  63.     if ( !g->History )
  64.         return(NULL);
  65.     if (g->History->index > 0)
  66.         g->History->index--;
  67.     else
  68.         g->History->index = (MAX_HISTORY - 1);    
  69.     tmp = g->History->hist[g->History->index].url;
  70.     ret = Malloc(StrLen(tmp)+1);
  71.     ErrFatalDisplayIf (!ret, "wml.c/Malloc(history3)");
  72.     StrCopy(ret,tmp);                
  73.     return(ret);
  74. }
  75.  
  76.     
  77.