- noecho();
- print_help(_("1-9,C: connect; N: new; D: delete; W: save; Q: quit; arrows: scroll"));
- while (1) {
- switch (c = getch()) {
- case 'q':
- case 'Q':
- exit_program();
- case 'n':
- case 'N':
- goto quit;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- i = c - '0';
- if (record_num <= i || i <= 0)
- goto wrong_num;
- curr = first;
- while (--i > 0)
- curr = curr->next;
- inet_aton(curr->ip, &ap_ip);
- if (community)
- free(community);
- i = strlen(curr->passwd) + 1;
- community = (char *) malloc(i);
- strncpy(community, curr->passwd, i);
- ap_type = curr->type;
- rval=1;
- if (sockfd)
- close(sockfd);
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- rval=0;
- if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
- rval=0;
- print_bottom(inet_ntoa(ap_ip));
- goto quit;
- case 'c':
- case 'C':
- mvwaddstr(main_sub, 1, 1, _("Connect to AP num:"));
- get_value(message, 1, 20, 6, INT_STRING,
- 1, record_num - 1, NULL);
- i = atoi(message);
- curr = first;
- while (--i > 0)
- curr = curr->next;
- inet_aton(curr->ip, &ap_ip);
- if (community)
- free(community);
- i = strlen(curr->passwd) + 1;
- community = (char *) malloc(i);
- strncpy(community, curr->passwd, i);
- ap_type = curr->type;
- rval=1;
- if (sockfd)
- close(sockfd);
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- rval=0;
- if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
- rval=0;
- print_bottom(inet_ntoa(ap_ip));
- goto quit;
- case 'd':
- case 'D':
- mvwaddstr(main_sub, 1, 0, _("Delete num:"));
- get_value(message, 1, 15, 6, INT_STRING,
- 1, record_num - 1, NULL);
- i = atoi(message);
- if (i == 1) {
- curr = first;
- first = first->next;
- free(curr);
- } else {
- curr = first;
- while (--i > 1)
- curr = curr->next;
- pmac = curr->next;
- curr->next = pmac->next;
- free(pmac);
- }
- record_num--;
- begin = 1;
- end = (MAX_LINES < record_num) ? MAX_LINES : record_num;
- _scroll_rows(first, begin, end);
- wrong_num:
- clear_main_new(1, 2);
- continue;
- case KEY_DOWN:
- case KEY_RIGHT:
- if (end < record_num) {
- begin++;
- end++;
- _scroll_rows(first, begin, end);
- }
-
- continue;
- case KEY_UP:
- case KEY_LEFT:
- if (begin > 1) {
- begin--;
- end--;
- _scroll_rows(first, begin, end);
- }
- continue;
-
- case 'w':
- case 'W':
+ noecho();
+ print_help(_("1-9,C: connect; N: new; D: delete; W: save; Q: quit; arrows: scroll"));
+ while (1) {
+ switch (c = getch()) {
+ case 'q':
+ case 'Q':
+ exit_program();
+
+ case 'n':
+ case 'N':
+ goto quit;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ i = c - '0';
+ if (record_num <= i || i <= 0)
+ goto wrong_num;
+
+ curr = first;
+ while (--i > 0)
+ curr = curr->next;
+
+ inet_aton(curr->ip, &ap_ip);
+ if (community)
+ free(community);
+
+ i = strlen(curr->passwd) + 1;
+ community = (char *) malloc(i);
+ strncpy(community, curr->passwd, i);
+ ap_type = curr->type;
+ rval=1;
+ if (sockfd)
+ close(sockfd);
+
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ rval=0;
+
+ if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
+ rval=0;
+
+ print_bottom(inet_ntoa(ap_ip));
+ get_mib_details();
+ goto quit;
+
+ case 'c':
+ case 'C':
+ /* Nothing to connect */
+ if (record_num == 1)
+ continue;
+
+ mvwaddstr(main_sub, 1, 1, _("Connect to AP num:"));
+ get_value(message, 1, 20, 6, INT_STRING, 1, record_num - 1,
+ NULL);
+ i = atoi(message);
+ curr = first;
+ while (--i > 0)
+ curr = curr->next;
+
+ inet_aton(curr->ip, &ap_ip);
+ if (community)
+ free(community);
+
+ i = strlen(curr->passwd) + 1;
+ community = (char *) malloc(i);
+ strncpy(community, curr->passwd, i);
+ ap_type = curr->type;
+ rval=1;
+ if (sockfd)
+ close(sockfd);
+
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ rval=0;
+
+ if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
+ rval=0;
+
+ print_bottom(inet_ntoa(ap_ip));
+ get_mib_details();
+ goto quit;
+
+ case 'd':
+ case 'D':
+ /* Nothing to delete */
+ if (record_num == 1)
+ continue;
+
+ mvwaddstr(main_sub, 1, 0, _("Delete num:"));
+ get_value(message, 1, 15, 6, INT_STRING,
+ 1, (record_num == 1 ? 1 : record_num - 1), NULL);
+ i = atoi(message);
+ if (i == 1) {
+ curr = first;
+ first = first->next;
+ free(curr);
+ } else {
+ curr = first;
+ while (--i > 1)
+ curr = curr->next;
+
+ pmac = curr->next;
+ curr->next = pmac->next;
+ free(pmac);
+ }
+ record_num--;
+ /* Clear incl. line with last AP record */
+ if (record_num == 1) {
+ clear_main_new(1, 3);
+ continue;
+ }
+
+ begin = 1;
+ end = (MAX_LINES < record_num) ? MAX_LINES : record_num;
+ _scroll_rows(first, begin, end);
+wrong_num:
+ clear_main_new(1, 2);
+ continue;
+
+ case KEY_DOWN:
+ case KEY_RIGHT:
+ if (end < record_num) {
+ begin++;
+ end++;
+ _scroll_rows(first, begin, end);
+ }
+ continue;
+
+ case KEY_UP:
+ case KEY_LEFT:
+ if (begin > 1) {
+ begin--;
+ end--;
+ _scroll_rows(first, begin, end);
+ }
+ continue;
+
+ case 'w':
+ case 'W':