]> git.decadent.org.uk Git - ap-utils.git/blobdiff - lib/file.c
Merge commit 'upstream/1.5'
[ap-utils.git] / lib / file.c
index 22dbf7a0f5deb303406f711e5ea87e280498fbb3..415cfcc64f3f84ed0c7b06fef996d1cbdd8b3ca1 100644 (file)
@@ -32,6 +32,7 @@ extern char *ap_types[], *ap_vendorexts[][3];
 extern short ap_type, ap_vendorext;
 extern struct in_addr ap_ip;
 extern int atmel410_filter;
 extern short ap_type, ap_vendorext;
 extern struct in_addr ap_ip;
 extern int atmel410_filter;
+
 #define MAX_LINES LINES-6
 
 struct APList {
 #define MAX_LINES LINES-6
 
 struct APList {
@@ -140,20 +141,13 @@ int get_opts()
 {
     extern char *community;
     extern struct in_addr ap_ip;
 {
     extern char *community;
     extern struct in_addr ap_ip;
-    extern int sockfd;
-       
+
     char *home_dir, buf[1024], mess[64];
     char message[50];
     int c, fd, rval = 0, pos;
     signed int j, i, begin, end, record_num = 0;
     struct APList *first = NULL, *curr = NULL, *pmac; 
     char *home_dir, buf[1024], mess[64];
     char message[50];
     int c, fd, rval = 0, pos;
     signed int j, i, begin, end, record_num = 0;
     struct APList *first = NULL, *curr = NULL, *pmac; 
-    struct sockaddr_in client;
-
 
 
-    memset(&client, 0, sizeof client);
-    client.sin_family = AF_INET;
-    client.sin_port = INADDR_ANY;
-    client.sin_addr.s_addr = INADDR_ANY;
 
     if ((home_dir = getenv("HOME")) == NULL)
        return 0;
 
     if ((home_dir = getenv("HOME")) == NULL)
        return 0;
@@ -246,14 +240,9 @@ int get_opts()
                strncpy(community, curr->passwd, i);
                ap_type = curr->type;
                ap_vendorext = curr->vendorext;
                strncpy(community, curr->passwd, i);
                ap_type = curr->type;
                ap_vendorext = curr->vendorext;
-               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 = 1;
+               if (reopen_sockfd() == -1)
                    rval = 0;
 
                print_bottom(inet_ntoa(ap_ip));
                    rval = 0;
 
                print_bottom(inet_ntoa(ap_ip));
@@ -282,14 +271,9 @@ int get_opts()
                strncpy(community, curr->passwd, i);
                ap_type = curr->type;
                ap_vendorext = curr->vendorext;
                strncpy(community, curr->passwd, i);
                ap_type = curr->type;
                ap_vendorext = curr->vendorext;
-               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 = 1;
+               if (reopen_sockfd() == -1)
                    rval = 0;
 
                print_bottom(inet_ntoa(ap_ip));
                    rval = 0;
 
                print_bottom(inet_ntoa(ap_ip));
@@ -356,6 +340,42 @@ wrong_num:
                }
                continue;
 
                }
                continue;
 
+           case KEY_NPAGE:
+               if (end < record_num) {
+                   end = (end + (MAX_LINES) - 1 < record_num) ?
+                       end + (MAX_LINES) - 1 : record_num;
+                   begin = (end - (MAX_LINES) + 1 > 0) ?
+                       end - (MAX_LINES) + 1 : 1;
+                   _scroll_rows(first, begin, end);
+               }
+               continue;
+
+           case KEY_PPAGE:
+               if (begin > 1) {
+                   begin = (begin - (MAX_LINES) + 1 > 0) ?
+                       begin - (MAX_LINES) + 1 : 1;
+                   end = (begin + (MAX_LINES) - 1 < record_num) ?
+                       begin + (MAX_LINES) - 1 : record_num;
+                   _scroll_rows(first, begin, end);
+               }
+               continue;
+
+           case KEY_END:
+               if (end < record_num) {
+                   begin = (record_num > MAX_LINES) ? record_num + 1 - (MAX_LINES) : 1;
+                   end = record_num;
+                   _scroll_rows(first, begin, end);
+               }
+               continue;
+
+           case KEY_HOME:
+               if (begin > 1) {
+                   begin = 1;
+                   end = (record_num > MAX_LINES) ? MAX_LINES : record_num;
+                   _scroll_rows(first, begin, end);
+               }
+               continue;
+
            case 'w':
            case 'W':
                sprintf(buf, "%s/.ap-config", home_dir);
            case 'w':
            case 'W':
                sprintf(buf, "%s/.ap-config", home_dir);
@@ -368,14 +388,10 @@ wrong_num:
                        curr = curr->next;
                    }
                    close(fd);
                        curr = curr->next;
                    }
                    close(fd);
-                   print_help(
-                       _("AP list file ~/.ap-config successfully written. "
-                         "Press any key."));
-               } else {
-                   print_helperr(
-                       _("Unable to write AP list file ~/.ap-config. "
-                         "Press any key."));
-               }
+                   print_help(DONE_WRITING_APCONF);
+               } else
+                   print_helperr(ERR_WRITING_APCONF);
+
                getch();
                continue;
        }
                getch();
                continue;
        }