Changeset 17805 in vbox for trunk/src/apps/adpctl
- Timestamp:
- Mar 13, 2009 11:02:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r17778 r17805 25 25 * Header Files * 26 26 *******************************************************************************/ 27 #include <string>28 #include <list>29 27 #include <assert.h> 30 28 #include <stdio.h> … … 76 74 } 77 75 76 #define MAX_ADDRESSES 128 77 #define MAX_ADDRLEN 64 78 78 79 static bool removeAddresses(const char *pszAdapterName) 79 80 { 80 static char szCmd[1024], szBuf[1024]; 81 char szCmd[1024], szBuf[1024]; 82 char aszAddresses[MAX_ADDRESSES][MAX_ADDRLEN]; 81 83 84 memset(aszAddresses, 0, sizeof(aszAddresses)); 82 85 snprintf(szCmd, sizeof(szCmd), VBOXADPCTL_IFCONFIG_PATH " %s", pszAdapterName); 83 86 FILE *fp = popen(szCmd, "r"); … … 86 89 return false; 87 90 88 std::list<std::string> Addresses; 89 90 while (fgets(szBuf, sizeof(szBuf), fp)) 91 int cAddrs; 92 for (cAddrs = 0; cAddrs < MAX_ADDRESSES && fgets(szBuf, sizeof(szBuf), fp);) 91 93 { 92 94 int cbSkipWS = strspn(szBuf, " \t"); … … 100 102 if (!pszWord || !strncmp(pszWord, "fe80", 4)) 101 103 continue; 102 Addresses.push_back(std::string(pszWord));104 strncpy(aszAddresses[cAddrs++], pszWord, MAX_ADDRLEN-1); 103 105 } 104 106 pclose(fp); 105 107 106 std::list<std::string>::const_iterator it; 107 for (it = Addresses.begin(); it != Addresses.end(); it++) 108 for (int i = 0; i < cAddrs; i++) 108 109 { 109 if (executeIfconfig(pszAdapterName, "inet6", it->c_str(), "remove") != EXIT_SUCCESS)110 if (executeIfconfig(pszAdapterName, "inet6", aszAddresses[i], "remove") != EXIT_SUCCESS) 110 111 return false; 111 112 }
Note:
See TracChangeset
for help on using the changeset viewer.