home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 18 / amigaformatcd18.iso / -readerstuff- / steve_boxall / contact97main.c < prev    next >
C/C++ Source or Header  |  1997-07-18  |  4KB  |  155 lines

  1. #include <exec/types.h>
  2. #include <exec/lists.h>
  3. #include <exec/nodes.h>
  4. #include <exec/memory.h>
  5.  
  6. #include <clib/alib_protos.h>
  7. #include <clib/exec_protos.h>
  8. #include <clib/amigaguide_protos.h>
  9.  
  10. #include <libraries/amigaguide.h>
  11.  
  12. #include <string.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include "EZPrinter.c"
  16.  
  17. extern struct Library *AmigaGuideBase;
  18.  
  19. struct List *NameList010List=NULL;
  20. struct List *AddrList010List=NULL;
  21. struct List *addrlist_g=NULL;
  22. struct List *namelist_g=NULL;
  23.  
  24. int prt_ok_g;
  25.  
  26. AMIGAGUIDECONTEXT Contact97Guide;
  27. struct NewAmigaGuide Contact97Help;
  28.  
  29. struct AddressAddress {
  30.     struct Node nn_Node;
  31.     char nn_Data[30];
  32. };    
  33.  
  34. struct AddressMaster {
  35.     char AddrName[30];
  36.     char AddrComp[30];
  37.     char AddrEmail[30];
  38.     char AddrTel[20];
  39.     char AddrFax[20];
  40. };
  41.  
  42. struct NameNode {
  43.     struct Node nn_Node;            /* System Node structure */
  44.     struct AddressMaster nn_Address;    /* Node-specific data */
  45. };
  46.  
  47. #define NAMENODE_ID   100       /* The type of "NameNode" */
  48. #define ADDRNODE_ID   101       /* The type of "NameNode" */
  49.  
  50. long selected_g=-1;
  51.  
  52. #include "Contact97Gui.c"
  53. #include "Contact97Gui_Handle.c"
  54.  
  55. /***********************************************
  56.     Entry Point for Workbench
  57. ************************************************/
  58.  
  59. int wbmain()
  60. {
  61.     main();
  62. return 0;
  63. }
  64.  
  65. /***********************************************
  66.     Contact97 Main Program Entry Point
  67. ************************************************/
  68.  
  69. int main()
  70. {
  71.     int running=0;
  72.  
  73. /***********************************************
  74.     Initialise Exec Lists
  75. ************************************************/
  76.  
  77.     NameList010List=AllocMem(sizeof(struct List),MEMF_CLEAR);
  78.     AddrList010List=AllocMem(sizeof(struct List),MEMF_CLEAR);
  79.  
  80.     NewList(NameList010List);
  81.     NewList(AddrList010List);
  82.  
  83. /***********************************************
  84.     Load Data From File (if possible)
  85. ************************************************/
  86.  
  87.     LoadContactData(NameList010List,AddrList010List);
  88.  
  89. /***********************************************
  90.     Setup Screen & Open Main Window + help
  91. ************************************************/
  92.  
  93.     SetupScreen();
  94.  
  95.     Contact97Help.nag_Flags =HTF_NOACTIVATE;
  96.     Contact97Help.nag_BaseName ="Contact97";
  97.     Contact97Help.nag_Name="Contact97.guide";
  98.     Contact97Help.nag_ClientPort = "Contact97_Help";
  99.     Contact97Help.nag_Context = NULL;
  100.     
  101.     Contact97Guide =OpenAmigaGuideAsync(&Contact97Help,NULL);
  102.  
  103.     OpenProject0Window();
  104.  
  105. /***********************************************
  106.     Setup ListView in Main Window
  107. ************************************************/
  108.  
  109.     UpdateLVList(Project0Wnd,Project0Gadgets[4],NameList010List,1);
  110.  
  111. /***********************************************
  112.     Wait for Intuition Response(s)
  113. ************************************************/
  114.  
  115.     while(running!=100)
  116.     {
  117.         running=HandleProject0IDCMP();
  118.     }
  119.  
  120. /***********************************************
  121.     Close Main Window & Screen + help
  122. ************************************************/
  123.  
  124.     CloseProject0Window();
  125.  
  126.     if(Contact97Guide !=NULL) CloseAmigaGuide(Contact97Guide);    
  127.  
  128.     CloseDownScreen();
  129.  
  130. /***********************************************
  131.     Close Down Program
  132. ************************************************/
  133.     if(NameList010List!=NULL)
  134.     {
  135.         FreeNameNodes(NameList010List,1);
  136.         FreeMem(NameList010List,sizeof(struct List));
  137.     }
  138.     if(AddrList010List!=NULL)
  139.     { 
  140.         FreeNameNodes(AddrList010List,0);
  141.         FreeMem(AddrList010List,sizeof(struct List));
  142.     }
  143.     if(addrlist_g!=NULL)
  144.     { 
  145.         FreeNameNodes(addrlist_g,0);
  146.         FreeMem(addrlist_g,sizeof(struct List));
  147.     }
  148.     if(namelist_g!=NULL)
  149.     {
  150.         FreeMem(namelist_g,sizeof(struct List));
  151.     }
  152. return 0;
  153. }
  154.  
  155.