Annotation of previous/src/gui-sdl/dlgEthernetAdvanced.c, revision 1.1

1.1     ! root        1: /*
        !             2:   Previous - dlgEthernet.c
        !             3: 
        !             4:   This file is distributed under the GNU Public License, version 2 or at
        !             5:   your option any later version. Read the file gpl.txt for details.
        !             6: */
        !             7: const char DlgEthernetAdvanced_fileid[] = "Previous dlgEthernetAdvanced.c : " __DATE__ " " __TIME__;
        !             8: 
        !             9: #include "main.h"
        !            10: #include "configuration.h"
        !            11: #include "dialog.h"
        !            12: #include "sdlgui.h"
        !            13: #include "file.h"
        !            14: #include "paths.h"
        !            15: 
        !            16: #if HAVE_PCAP
        !            17: #include <pcap.h>
        !            18: 
        !            19: #define DLGENETPCAP_CANCEL  3
        !            20: #define DLGENETPCAP_SELECT  4
        !            21: #define DLGENETPCAP_NEXT    5
        !            22: 
        !            23: #define PCAP_LIST_LEN       29
        !            24: 
        !            25: char pcap_list[PCAP_LIST_LEN] = "";
        !            26: 
        !            27: /* The Boot options dialog: */
        !            28: static SGOBJ enetpcapdlg[] =
        !            29: {
        !            30:        { SGBOX, 0, 0, 0,0, 36,8, NULL },
        !            31:        { SGTEXT, 0, 0, 2,1, 31,1, "Select Host Ethernet Interface:" },
        !            32:     { SGTEXT, 0, 0, 3,3, PCAP_LIST_LEN,1, pcap_list },
        !            33:     
        !            34:        { SGBUTTON, 0, 0, 4,6, 8,1, "Cancel" },
        !            35:     { SGBUTTON, SG_DEFAULT, 0, 14,6, 8,1, "Select" },
        !            36:     { SGBUTTON, 0, 0, 24,6, 8,1, "Next" },
        !            37: 
        !            38:        { -1, 0, 0, 0,0, 0,0, NULL }
        !            39: };
        !            40: 
        !            41: 
        !            42: 
        !            43: /*-----------------------------------------------------------------------*/
        !            44: /**
        !            45:  * Show and process the PCAP Ethernet options dialog.
        !            46:  */
        !            47: bool DlgEthernetAdvanced(void)
        !            48: {
        !            49:        int but;
        !            50:     pcap_if_t *alldevs;
        !            51:     pcap_if_t *dev;
        !            52:     char name[FILENAME_MAX];
        !            53:     char errbuf[PCAP_ERRBUF_SIZE];
        !            54:     bool bNone;
        !            55:     
        !            56:        SDLGui_CenterDlg(enetpcapdlg);
        !            57:     
        !            58:     /* Set up the variables */
        !            59:     if (pcap_findalldevs(&alldevs, errbuf) == -1)
        !            60:     {
        !            61:         printf("Error in pcap_findalldevs: %s\n", errbuf);
        !            62:     }
        !            63:     dev = alldevs;
        !            64:     
        !            65:     /* Draw and process the dialog */
        !            66:     
        !            67:        do
        !            68:        {
        !            69:         if (dev && dev->name) {
        !            70: #ifdef _WIN32
        !            71:             /* on windows use dev->description instead of dev->name */
        !            72:             if (dev->description) {
        !            73:                 strcpy(name, dev->description);
        !            74:             } else {
        !            75:                 strcpy(name, dev->name);
        !            76:             }
        !            77: #else
        !            78:                        strcpy(name, dev->name);
        !            79: #endif
        !            80:             File_ShrinkName(pcap_list, name, PCAP_LIST_LEN);
        !            81:             bNone = false;
        !            82:         } else {
        !            83:             sprintf(pcap_list, "no interface found");
        !            84:             bNone = true;
        !            85:         }
        !            86: 
        !            87:                but = SDLGui_DoDialog(enetpcapdlg, NULL);
        !            88:                
        !            89:                switch (but) {
        !            90:             case DLGENETPCAP_SELECT:
        !            91:                 if (!bNone) {
        !            92:                     snprintf(ConfigureParams.Ethernet.szInterfaceName, FILENAME_MAX, "%s", dev->name);
        !            93:                 }
        !            94:                                break;
        !            95:                        case DLGENETPCAP_NEXT:
        !            96:                 if (!bNone) {
        !            97:                     dev = dev->next;
        !            98:                 }
        !            99:                                break;
        !           100:             case DLGENETPCAP_CANCEL:
        !           101:                 bNone = true;
        !           102:                 break;
        !           103:                                
        !           104:                        default:
        !           105:                                break;
        !           106:                }
        !           107:        }
        !           108:     while (but != DLGENETPCAP_SELECT && but != SDLGUI_QUIT
        !           109:               && but != SDLGUI_ERROR && !bQuitProgram && !bNone);
        !           110:     
        !           111:     pcap_freealldevs(alldevs);
        !           112:     
        !           113:     return !bNone;
        !           114: }
        !           115: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.