| @@ -25,6 +25,7 @@ struct dir {
void die(const char *fmt, ...);
void display(Item *item);
Item *selectitem(Item *entry);
+void status(char *fmt, ...);
const char *typedisplay(char t);
void uicleanup(void);
char *uiprompt(char *fmt, ...); |
| @@ -341,8 +341,10 @@ connectto(const char *host, const char *port)
struct addrinfo *addrs, *addr;
int sock, r;
- if (r = getaddrinfo(host, port, &hints, &addrs))
- die("Can't resolve hostname ā%sā: %s", host, gai_strerror(r));
+ if (r = getaddrinfo(host, port, &hints, &addrs)) {
+ status("Can't resolve hostname ā%sā: %s", host, gai_strerror(r));
+ return -1;
+ }
for (addr = addrs; addr; addr = addr->ai_next) {
if ((sock = socket(addr->ai_family, addr->ai_socktype,
@@ -354,10 +356,14 @@ connectto(const char *host, const char *port)
}
break;
}
- if (sock < 0)
- die("Can't open socket: %s", strerror(errno));
- if (r < 0)
- die("Can't connect to: %s:%s: %s", host, port, strerror(errno));
+ if (sock < 0) {
+ status("Can't open socket: %s", strerror(errno));
+ return -1;
+ }
+ if (r < 0) {
+ status("Can't connect to: %s:%s: %s", host, port, strerror(errno));
+ return -1;
+ }
freeaddrinfo(addrs);
@@ -372,7 +378,8 @@ download(Item *item, int dest)
int src;
if (!item->tag) {
- src = connectto(item->host, item->port);
+ if ((src = connectto(item->host, item->port)) < 0)
+ return 0;
sendselector(src, item->selector);
} else if ((src = open(item->tag, O_RDONLY)) < 0) {
printf("Can't open source file %s: %s\n",
@@ -446,7 +453,8 @@ fetchitem(Item *item)
{
int sock;
- sock = connectto(item->host, item->port);
+ if ((sock = connectto(item->host, item->port)) < 0)
+ return 0;
sendselector(sock, item->selector);
item->raw = getrawitem(sock);
close(sock); |
| @@ -118,6 +118,29 @@ help(Item *entry)
return &item;
}
+void
+status(char *fmt, ...)
+{
+ va_list ap;
+
+ putp(tparm(save_cursor));
+
+ putp(tparm(cursor_address, lines-1, 0));
+ putp(tparm(enter_standout_mode));
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+
+ printf(" ");
+ getchar();
+
+ putp(tparm(exit_standout_mode));
+
+ putp(tparm(restore_cursor));
+ fflush(stdout);
+}
+
static void
displaystatus(Item *item)
{ |
| @@ -56,6 +56,21 @@ ndigits(size_t n)
return (n < 10) ? 1 : (n < 100) ? 2 : 3;
}
+void
+status(char *fmt, ...)
+{
+ va_list arg;
+
+ va_start(arg, fmt);
+ vprintf(fmt, arg);
+ va_end(arg);
+
+ printf(" ");
+ fflush(stdout);
+
+ getchar();
+}
+
static void
printstatus(Item *item, char c)
{ |