Guest User

raIP.c

a guest
Jan 3rd, 2026
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 21.21 KB | Fixit | 0 0
  1. /*
  2.  **************************************************************************
  3.  * Project:  raIP-Finder                                                   *
  4.  * Purpose:  GUI for getting IP of a given URL                             *
  5.  * File:     raip.c                                                        *
  6.  * Version:  1.0 RELEASE                                                   *
  7.  * Author:   Michael Bergmann                                              *
  8.  * Date:     2026/02/01                                                    *
  9.  * Tested Compilers: amiga-gcc v6.5                                        *
  10.  * m68k-amigaos-gcc -Wall -s -Os raip.c -o raIP -lamiga -lsocket -noixemul *
  11.  **************************************************************************
  12. */
  13. #include <clib/macros.h>
  14. #include <clib/alib_protos.h>
  15. #include <clib/compiler-specific.h>
  16.  
  17. #include <proto/exec.h>
  18. #include <proto/dos.h>
  19. #include <proto/utility.h>
  20. #include <proto/graphics.h>
  21. #include <proto/intuition.h>
  22. #include <proto/gadtools.h>
  23. #include <proto/icon.h>
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <errno.h>
  29. #include <netdb.h>
  30. #include <sys/types.h>
  31. /* network includes */
  32. #include <netinet/in.h>
  33. #include <arpa/inet.h>
  34. #include <bsdsocket/socketbasetags.h>
  35.  
  36. #include <proto/window.h>
  37. #include <proto/layout.h>
  38. #include <proto/button.h>
  39. #include <proto/string.h>
  40. #include <proto/label.h>
  41. #include <proto/requester.h>
  42. #include <classes/requester.h>
  43.  
  44. #include <libraries/gadtools.h>
  45. #include <reaction/reaction.h>
  46. #include <intuition/gadgetclass.h>
  47. #include <intuition/icclass.h>
  48. #include <reaction/reaction_macros.h>
  49. #include <classes/window.h>
  50. #include <exec/memory.h>
  51.  
  52. #define mydebug FALSE  /* Debugging Texts TRUE or FALSE */
  53.  
  54.  
  55. /* --- Version String ------------------ */
  56. const UBYTE VersionTag[] = "\0$VER: IP-Finder v1.0 (02.01.2026) (c) Micha B.\0";
  57.  
  58. /* --- Other global variables ---------- */
  59. char *url_string;
  60. char *ip_string;
  61.  
  62.  
  63. /* --- Function Prototypes ------------- */
  64. void window_main( void );
  65. int setup( void );
  66. void cleanup( void );
  67. void runWindow(
  68.                 Object *window_object, int window_id,
  69.                 struct Menu *menu_strip, struct Gadget *win_gadgets[]
  70.               );
  71. int req_about(Object *reactionWindow);
  72. int req_quit(Object *reactionWindow);
  73.  
  74.  
  75.  
  76. /* --- Screen Info ----------------------*/
  77. struct Screen   *gScreen = NULL;
  78. struct DrawInfo *gDrawInfo = NULL;
  79. APTR gVisinfo = NULL;
  80. struct MsgPort  *gAppPort = NULL;
  81.  
  82. /* --- Menu IDs -------------------------------------------------------------- */
  83. enum menus
  84. {
  85.   /* Menu "Projekt"  */
  86.   MN_CLEAR, MN_GETIP, MN_ABOUT, MN_QUIT
  87. };
  88.  
  89. /* --- EasyRequesters -------------------------------------------------------- */
  90. struct EasyStruct warnreq =
  91. {
  92.   sizeof(struct EasyStruct),
  93.   0,
  94.   "Error",
  95.   "raIP-Finder needs AmigaOS 3.2.x\n\nNo Chance to run this program on your machine!",
  96.   "Ok"
  97. };
  98.  
  99. /* --- ReAction Requester: req_about() --------------------------------------- */
  100. int req_about(Object *reactionWindow)
  101. {
  102.   Object *reqobj;
  103.   ULONG win;
  104.   int res=0;
  105.  
  106.   GetAttr(WINDOW_Window, reactionWindow, &win);
  107.   reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_Image, REQIMAGE_INFO,
  108.        REQ_TitleText, "About IP-Finder",
  109.        REQ_BodyText,"raIP-Finder v1.0 \nThis program shows the IP of a given URL \n\n" \
  110.                     "based on a MUI program by [email protected]\n\n " \
  111.                     "Author: Micha B. 2026/01 \n Web: www.mbergmann-sh.de \n Email: [email protected] \n\n" \
  112.                     "GUI made with ReBuild v1.3 beta\n" \
  113.                     "ReBuild is © by Darren Coles\n\n" \
  114.                     "Compiler: Bebbo's amiga-gcc v6.5.0b 251015095727 ",
  115.        REQ_GadgetText, "_Ok",
  116.        TAG_DONE);
  117.   if (reqobj)
  118.   {
  119.     res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);
  120.     DisposeObject(reqobj);
  121.   }
  122.   return res;
  123. }  /* END req_about() */
  124.  
  125. /* --- ReAction Requester: req_quit() ------------------------------------------ */
  126. int req_quit(Object *reactionWindow)
  127. {
  128.   Object *reqobj;
  129.   ULONG win;
  130.   int res=0;
  131.  
  132.   GetAttr(WINDOW_Window, reactionWindow, &win);
  133.   reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_Image, REQIMAGE_QUESTION,
  134.        REQ_TitleText, "IP-Finder says 'Good bye!'",
  135.        REQ_BodyText," You are about to quit this program.\n Do you really want to do that, dude? ",
  136.        REQ_GadgetText, "_Yes, quit now!|_Cancel",
  137.        TAG_DONE);
  138.   if (reqobj)
  139.   {
  140.     res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);
  141.     DisposeObject(reqobj);
  142.   }
  143.   return res;
  144. }  /* END reqquit*/
  145.  
  146. struct Library *WindowBase = NULL,
  147.                *ButtonBase = NULL,
  148.                *StringBase = NULL,
  149.                *LabelBase = NULL,
  150.                *RequesterBase = NULL,
  151.                *GadToolsBase = NULL,
  152.                *LayoutBase = NULL,
  153.                *IconBase = NULL;
  154. struct IntuitionBase *IntuitionBase = NULL;
  155.  
  156. //window ids
  157. enum win { window_main_id = 4 };
  158.  
  159. //Window_Main gadgets
  160. enum window_main_idx { vert_mainlayout, horiz_parameter, vert_http, string_http, string_address,
  161.   horiz_controls, button_clear, button_getip };
  162. enum window_main_id { vert_mainlayout_id = 6, horiz_parameter_id = 7, vert_http_id = 8,
  163.   string_http_id = 10, string_address_id = 11, horiz_controls_id = 12,
  164.   button_clear_id = 13, button_getip_id = 14 };
  165.  
  166. /* --- Function: setup() --------------------------------------------------------------------------------- */
  167. /* --- Open libs, gadgets, classes and other ressources -------------------------------------------------- */
  168. int setup( void )
  169. {
  170.   if( !(IntuitionBase = (struct IntuitionBase*) OpenLibrary("intuition.library",0L)) ) return 0;
  171.   if( !(GadToolsBase = (struct Library*) OpenLibrary("gadtools.library",0L) ) ) return 0;
  172.   if( !(WindowBase = (struct Library*) OpenLibrary("window.class",0L) ) ) return 0;
  173.   if( !(IconBase = (struct Library*) OpenLibrary("icon.library",0L) ) ) return 0;
  174.   /* --- Check for a sufficient OS! --- */
  175.   if( !(LayoutBase = (struct Library*) OpenLibrary("gadgets/layout.gadget",47L) ) )
  176.   {
  177.     EasyRequest(NULL, &warnreq, NULL);
  178.     return 0;
  179.   }
  180.   if( !(ButtonBase = (struct Library*) OpenLibrary("gadgets/button.gadget",0L) ) ) return 0;
  181.   if( !(StringBase = (struct Library*) OpenLibrary("gadgets/string.gadget",0L) ) ) return 0;
  182.   if( !(LabelBase = (struct Library*) OpenLibrary("images/label.image",0L) ) ) return 0;
  183.   if( !(RequesterBase = (struct Library*) OpenLibrary("classes/requester.class",0L) ) )
  184.   {
  185.     puts("ERROR: Could not open requester.class.\n");
  186.     return 0;
  187.   }
  188.   if( !(gScreen = LockPubScreen( 0 ) ) ) return 0;
  189.   if( !(gVisinfo = GetVisualInfo( gScreen, TAG_DONE ) ) ) return 0;
  190.   if( !(gDrawInfo = GetScreenDrawInfo ( gScreen ) ) ) return 0;
  191.   if( !(gAppPort = CreateMsgPort() ) ) return 0;
  192.  
  193.   return -1;
  194. } /* END setup() */
  195.  
  196. /* --- Function: cleanup() -------------------------------------------------------------------------------- */
  197. /* --- Close used ressources and clean up for shutdown ---------------------------------------------------- */
  198. void cleanup( void )
  199. {
  200.   if ( gDrawInfo ) FreeScreenDrawInfo( gScreen, gDrawInfo);
  201.   if ( gVisinfo ) FreeVisualInfo( gVisinfo );
  202.   if ( gAppPort ) DeleteMsgPort( gAppPort );
  203.   if ( gScreen ) UnlockPubScreen( 0, gScreen );
  204.   if (GadToolsBase) CloseLibrary( (struct Library *)GadToolsBase );
  205.   if (IconBase) CloseLibrary( (struct Library *)IconBase );
  206.   if (IntuitionBase) CloseLibrary( (struct Library *)IntuitionBase );
  207.   if (ButtonBase) CloseLibrary( (struct Library *)ButtonBase );
  208.   if (StringBase) CloseLibrary( (struct Library *)StringBase );
  209.   if (LabelBase) CloseLibrary( (struct Library *)LabelBase );
  210.   if (LayoutBase) CloseLibrary( (struct Library *)LayoutBase );
  211.   if (WindowBase) CloseLibrary( (struct Library *)WindowBase );
  212.   if (RequesterBase) CloseLibrary( (struct Library *)RequesterBase );
  213. } /* END cleanup() */
  214.  
  215. /* --- Function: runWindow() -------------------------------------------------------------------------------- */
  216. /* --- Application's message handling is done here! --------------------------------------------------------- */
  217. void runWindow( Object *window_object, int window_id, struct Menu *menu_strip, struct Gadget *win_gadgets[] )
  218. {
  219.   struct Window *main_window = NULL;
  220.   struct MenuItem *menuitem = NULL;
  221.   LONG myItem = 0;
  222.   ULONG status = 0;
  223.   int req_result = 0;
  224.   struct hostent *h;
  225.  
  226.  
  227.   if ( window_object )
  228.   {
  229.     if ( main_window = (struct Window *) RA_OpenWindow( window_object ))
  230.     {
  231.       WORD Code;
  232.       ULONG wait = 0, signal = 0, result = 0, done = FALSE;
  233.       GetAttr( WINDOW_SigMask, window_object, &signal );
  234.       if ( menu_strip)  SetMenuStrip( main_window, menu_strip );
  235.       while ( !done)
  236.       {
  237.         wait = Wait( signal | SIGBREAKF_CTRL_C );
  238.  
  239.         if ( wait & SIGBREAKF_CTRL_C )
  240.           done = TRUE;
  241.         else
  242.           while (( result = RA_HandleInput( window_object, &Code )) != WMHI_LASTMSG)
  243.           {
  244.             switch ( result & WMHI_CLASSMASK )
  245.             {
  246.               /* --- WMHI_CLOSEWINDOW --------------------------------------------- */
  247.               case WMHI_CLOSEWINDOW:
  248.                 SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  249.                 /* call Quit-Requester */
  250.                 req_result = req_quit(window_object);
  251.                 if (req_result == 1) done = TRUE;
  252.                 SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */
  253.                 break;
  254.  
  255.               /* --- Menus -------------------------------------------------------- */
  256.               case WMHI_MENUPICK:                
  257.                 menuitem = ItemAddress(menu_strip, result & WMHI_MENUMASK);
  258.                 if(mydebug)
  259.                 {
  260.                   puts("menu pick");
  261.                   printf("ItemAdress = %ld\n", menuitem);
  262.                 }
  263.                 /* Check if menuitem equals to Zero. If Zero, an enforcer hit will occour when */
  264.                 /* attempting to examine,so we do not allow switching on menuitem == 0!        */
  265.                 if(!(menuitem == 0))
  266.                 {
  267.                   /* --- ...get menu entries by using GadTools' GTMENUITEM_USERDATA field macro --- */
  268.                  
  269.                   myItem = ((long)GTMENUITEM_USERDATA(ItemAddress(menu_strip, result & WMHI_MENUMASK)));
  270.                   /* --- Identify selected menu entry      */
  271.                   /* MN_CLEAR, MN_GETIP, MN_ABOUT, MN_QUIT */
  272.                   switch(myItem)
  273.                   {
  274.                     /* --- Menu "Project" --- */
  275.                     case MN_CLEAR:
  276.                       if(mydebug)
  277.                       {
  278.                         puts("Clear");
  279.                       }
  280.                       /* empty URL string gadget */
  281.                       SetGadgetAttrs( (APTR)win_gadgets[string_http], main_window, NULL, STRINGA_TextVal, "", TAG_END );
  282.                       /* empty IP string gadget */
  283.                       SetGadgetAttrs( (APTR)win_gadgets[string_address], main_window, NULL, STRINGA_TextVal, "", TAG_END );
  284.                       break;
  285.                     case MN_GETIP:
  286.                       if(mydebug)
  287.                       {
  288.                         puts("Get IP");
  289.                       }
  290.                        /* Get URL string */
  291.                       GetAttr(STRINGA_TextVal, (APTR)win_gadgets[string_http], (ULONG *)&url_string);
  292.                       h = gethostbyname(url_string);
  293.                       /* Set IP string */
  294.                       SetGadgetAttrs((APTR)win_gadgets[string_address], main_window, NULL, STRINGA_TextVal, inet_ntoa(*((struct in_addr *)h->h_addr)), TAG_END);
  295.                       break;
  296.                      
  297.                       break;
  298.                     case MN_ABOUT:
  299.                       if(mydebug)
  300.                       {
  301.                         puts("About");
  302.                       }
  303.                       SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  304.                       req_result = req_about(window_object);
  305.                       SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */
  306.                       break;
  307.                     case MN_QUIT:
  308.                       if(mydebug)
  309.                       {
  310.                         puts("Quit");
  311.                       }
  312.                       SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  313.                       /* call Quit-Requester */
  314.                       req_result = req_quit(window_object);
  315.                       if (req_result == 1) done = TRUE;
  316.                       SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */
  317.                       break;
  318.                   } /* END switch(myitem) */  
  319.                 } /* END Check menu items for zero*/
  320.                 break;
  321.  
  322.               /* --- Gadgets ----------------------------------------------------- */
  323.               case WMHI_GADGETUP:
  324.                 switch (result & WMHI_GADGETMASK)
  325.                 {
  326.                   case button_clear_id:
  327.                     if(mydebug)
  328.                     {
  329.                       puts("Button: Clear");
  330.                     }
  331.                     /* empty URL string gadget */
  332.                     SetGadgetAttrs( (APTR)win_gadgets[string_http], main_window, NULL, STRINGA_TextVal, "", TAG_END );
  333.                     /* empty IP string gadget */
  334.                     SetGadgetAttrs( (APTR)win_gadgets[string_address], main_window, NULL, STRINGA_TextVal, "", TAG_END );
  335.                     break;
  336.                   case button_getip_id:
  337.                     if(mydebug)
  338.                     {
  339.                       puts("Button: Get IP");
  340.                     }
  341.                     /* Get URL string */
  342.                     GetAttr(STRINGA_TextVal, (APTR)win_gadgets[string_http], (ULONG *)&url_string);
  343.                     h = gethostbyname(url_string);
  344.                     /* Set IP string */
  345.                     SetGadgetAttrs((APTR)win_gadgets[string_address], main_window, NULL, STRINGA_TextVal, inet_ntoa(*((struct in_addr *)h->h_addr)), TAG_END);
  346.                     break;
  347.                 }
  348.                 break;
  349.  
  350.               /* --- Iconify ----------------------------------------------------- */
  351.               case WMHI_ICONIFY:
  352.                 if ( RA_Iconify( window_object ) )
  353.                   main_window = NULL;
  354.                 break;
  355.  
  356.               /* --- Uniconify --------------------------------------------------- */
  357.               case WMHI_UNICONIFY:
  358.                 main_window = RA_OpenWindow( window_object );
  359.                 if ( menu_strip)  SetMenuStrip( main_window, menu_strip );
  360.               break;
  361.  
  362.             }  /* END switch(result & WMHI_CLASSMASK */
  363.           }  /* END while (( result = RA_HandleInput( window_object, &Code )) != WMHI_LASTMSG) */
  364.       }  /* END while(!done) */
  365.     }  /* END if ( main_window = (struct Window *) RA_OpenWindow( window_object )) */
  366.   }  /* END if(window_object) */
  367. } /* END runWindow() */
  368.  
  369. /* --- Function: window_main() ---------------------------------------------------------------------------------------- */
  370. /* --- All window-specific setup for main Window is done here. runWindow() is called for message handling afterwards. - */
  371. void window_main( void )
  372. {
  373.   struct NewMenu menuData[] =
  374.   {
  375.     { NM_TITLE, "Project", 0, 0, 0, NULL },
  376.     { NM_ITEM, "Clear", "C", 0, 62, (APTR) MN_CLEAR },
  377.     { NM_ITEM, "Get IP", "G", 0, 61, (APTR) MN_GETIP },
  378.     { NM_ITEM, NM_BARLABEL, 0, 0, 59, NULL },
  379.     { NM_ITEM, "About...", "A", 0, 55, (APTR) MN_ABOUT },
  380.     { NM_ITEM, NM_BARLABEL, 0, 0, 47, NULL },
  381.     { NM_ITEM, "Quit", "Q", 0, 31, (APTR) MN_QUIT },
  382.     { NM_END, NULL, 0, 0, 0, (APTR)0 }
  383.   };
  384.  
  385.   struct Menu   *menu_strip = NULL;
  386.   struct Gadget *main_gadgets[ 9 ];
  387.   Object *window_object = NULL;
  388.   struct HintInfo hintInfo[] =
  389.   {
  390.     {vert_mainlayout_id,-1,"",0},
  391.     {horiz_parameter_id,-1,"",0},
  392.     {vert_http_id,-1,"",0},
  393.     {string_http_id,-1,"Enter URL to look up",0},
  394.     {string_address_id,-1,"IP is shown here",0},
  395.     {horiz_controls_id,-1,"",0},
  396.     {button_clear_id,-1,"Clear Mask",0},
  397.     {button_getip_id,-1,"Get a domain's IP",0},
  398.     {-1,-1,NULL,0}
  399.   };
  400.   menu_strip = CreateMenusA( menuData, TAG_END );
  401.   LayoutMenus( menu_strip, gVisinfo,
  402.     GTMN_NewLookMenus, TRUE,
  403.     TAG_DONE );
  404.  
  405.  
  406.   window_object = NewObject( WINDOW_GetClass(), NULL,
  407.     WA_Title, "raIP-Finder v1.0",
  408.     WA_ScreenTitle, "raIP-Finder v1.0",
  409.     WA_Left, 5,
  410.     WA_Top, 20,
  411.     WA_Width, 150,
  412.     WA_Height, 20,
  413.     WA_MinWidth, 150,
  414.     WA_MinHeight, 20,
  415.     WA_MaxWidth, 8192,
  416.     WA_MaxHeight, 8192,
  417.     WINDOW_LockHeight, TRUE,
  418.     WINDOW_IconifyGadget, TRUE,
  419.     WINDOW_HintInfo, hintInfo,
  420.     WINDOW_GadgetHelp, TRUE,
  421.     WINDOW_AppPort, gAppPort,
  422.     WINDOW_IconifyGadget, TRUE,
  423.     WA_CloseGadget, TRUE,
  424.     WA_DepthGadget, TRUE,
  425.     WA_SizeGadget, TRUE,
  426.     WA_DragBar, TRUE,
  427.     WA_Activate, TRUE,
  428.     WA_SizeBBottom, TRUE,
  429.     WINDOW_Position, WPOS_TOPLEFT,
  430.     WINDOW_IconTitle, "raIP",
  431.     WINDOW_Icon,  GetDiskObject("raIP"),
  432.     WA_NoCareRefresh, TRUE,
  433.     WA_IDCMP, IDCMP_GADGETUP | IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_NEWSIZE | IDCMP_IDCMPUPDATE,
  434.     WINDOW_ParentGroup, NewObject( LAYOUT_GetClass(), NULL,
  435.     LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  436.     LAYOUT_SpaceOuter, TRUE,
  437.     LAYOUT_DeferLayout, TRUE,
  438.       LAYOUT_AddChild, main_gadgets[vert_mainlayout] = NewObject( LAYOUT_GetClass(), NULL,
  439.         GA_ID, vert_mainlayout_id,
  440.         LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  441.         LAYOUT_SpaceOuter, TRUE,
  442.         LAYOUT_LeftSpacing, 2,
  443.         LAYOUT_RightSpacing, 2,
  444.         LAYOUT_TopSpacing, 2,
  445.         LAYOUT_BottomSpacing, 2,
  446.         LAYOUT_DeferLayout, TRUE,
  447.         LAYOUT_AddChild, main_gadgets[horiz_parameter] = NewObject( LAYOUT_GetClass(), NULL,
  448.           GA_ID, horiz_parameter_id,
  449.           LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  450.           LAYOUT_HorizAlignment, LALIGN_CENTER,
  451.           LAYOUT_BevelStyle, BVS_THIN,
  452.           LAYOUT_LeftSpacing, 2,
  453.           LAYOUT_RightSpacing, 2,
  454.           LAYOUT_TopSpacing, 2,
  455.           LAYOUT_BottomSpacing, 2,
  456.           LAYOUT_Label, "Get IP Address",
  457.           LAYOUT_EvenSize, TRUE,
  458.           LAYOUT_AddChild, main_gadgets[vert_http] = NewObject( LAYOUT_GetClass(), NULL,
  459.             GA_ID, vert_http_id,
  460.             LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  461.             LAYOUT_EvenSize, TRUE,
  462.             LAYOUT_DeferLayout, TRUE,
  463.             LAYOUT_AddChild, main_gadgets[string_http] = NewObject( STRING_GetClass(), NULL,
  464.               GA_ID, string_http_id,
  465.               GA_RelVerify, TRUE,
  466.               GA_TabCycle, TRUE,
  467.               STRINGA_TextVal, "google.com",
  468.               STRINGA_MaxChars, 175,
  469.               STRINGA_MinVisible, 15,
  470.             TAG_END),
  471.             CHILD_Label, NewObject( LABEL_GetClass(), NULL,
  472.               LABEL_Text, "Enter URL - http://",
  473.             TAG_END),
  474.             LAYOUT_AddChild, main_gadgets[string_address] = NewObject( STRING_GetClass(), NULL,
  475.               GA_ID, string_address_id,
  476.               GA_RelVerify, TRUE,
  477.               GA_TabCycle, TRUE,
  478.               STRINGA_MaxChars, 80,
  479.             TAG_END),
  480.             CHILD_Label, NewObject( LABEL_GetClass(), NULL,
  481.               LABEL_Text, "IP Address:",
  482.             TAG_END),
  483.           TAG_END),
  484.         TAG_END),
  485.         LAYOUT_AddChild, main_gadgets[horiz_controls] = NewObject( LAYOUT_GetClass(), NULL,
  486.           GA_ID, horiz_controls_id,
  487.           LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  488.           LAYOUT_BevelStyle, BVS_THIN,
  489.           LAYOUT_LeftSpacing, 2,
  490.           LAYOUT_RightSpacing, 2,
  491.           LAYOUT_TopSpacing, 2,
  492.           LAYOUT_BottomSpacing, 2,
  493.           LAYOUT_Label, "Controls",
  494.           LAYOUT_EvenSize, TRUE,
  495.           LAYOUT_DeferLayout, TRUE,
  496.           LAYOUT_AddChild, main_gadgets[button_clear] = NewObject( BUTTON_GetClass(), NULL,
  497.             GA_ID, button_clear_id,
  498.             GA_Text, "_Clear",
  499.             GA_RelVerify, TRUE,
  500.             GA_TabCycle, TRUE,
  501.             BUTTON_TextPen, 1,
  502.             BUTTON_BackgroundPen, 0,
  503.             BUTTON_FillTextPen, 1,
  504.             BUTTON_FillPen, 3,
  505.           TAG_END),
  506.           LAYOUT_AddChild, main_gadgets[button_getip] = NewObject( BUTTON_GetClass(), NULL,
  507.             GA_ID, button_getip_id,
  508.             GA_Text, "_Get IP",
  509.             GA_RelVerify, TRUE,
  510.             GA_TabCycle, TRUE,
  511.             BUTTON_TextPen, 1,
  512.             BUTTON_BackgroundPen, 0,
  513.             BUTTON_FillTextPen, 1,
  514.             BUTTON_FillPen, 3,
  515.           TAG_END),
  516.         TAG_END),
  517.       TAG_END),
  518.     TAG_END),
  519.   TAG_END);  
  520.   main_gadgets[8] = 0;
  521.  
  522.   runWindow( window_object, window_main_id, menu_strip, main_gadgets );
  523.  
  524.   if ( window_object ) DisposeObject( window_object );
  525.   if ( menu_strip ) FreeMenus( menu_strip );
  526. } /* END window_main() */
  527.  
  528. /* --- Main Function ---------------------------------------------------------------------------------- */
  529. int main(void)
  530. {
  531.   if ( setup() )    /* This will satisfy all needs... */
  532.   {
  533.     window_main();  /* ...and open Application's main Window by running 'runWindow()' */
  534.   }
  535.   cleanup();        /* Clean up stuff and exit */
  536. } /* END main() */
  537.  
  538.  
  539.  
Advertisement
Add Comment
Please, Sign In to add comment