}
while (fail < 5) {
if (fail > 0) {
- ERR("Trying IMAP connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
- sleep((int)mail->interval);
+ ERR("Trying IMAP connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
}
if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
fail++;
- continue;
+ goto next_iteration;
}
their_addr.sin_family = AF_INET; // host byte order
sizeof(struct sockaddr)) == -1) {
perror("connect");
fail++;
- continue;
+ goto next_iteration;
}
struct timeval timeout;
int res;
0)) == -1) {
perror("recv");
fail++;
- continue;
+ goto next_iteration;
}
} else {
ERR("IMAP connection failed: timeout");
fail++;
- continue;
+ goto next_iteration;
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "* OK") != recvbuf) {
ERR("IMAP connection failed, probably not an IMAP server");
fail++;
- continue;
+ goto next_iteration;
}
strncpy(sendbuf, "a1 login ", MAXDATASIZE);
strncat(sendbuf, mail->user,
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send a1");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv a1");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "a1 OK") == NULL) {
ERR("IMAP server login failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
strncat(sendbuf, mail->folder,
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send a2");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv a2");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "a2 OK") == NULL) {
ERR("IMAP status failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
// now we get the data
reply = strstr(recvbuf, " (MESSAGES ");
if (reply == NULL) {
ERR("Error parsing IMAP response: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
} else {
timed_thread_lock (mail->p_timed_thread);
sscanf(reply, "MESSAGES %lu UNSEEN %lu",
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send a3");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv a3");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "a3 OK") == NULL) {
ERR("IMAP logout failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
close(sockfd);
if (strlen(mail->command) > 1 && (mail->unseen > old_unseen || (mail->messages > old_messages && mail->unseen > 0))) { // new mail goodie
fail = 0;
old_unseen = mail->unseen;
old_messages = mail->messages;
+next_iteration:
if (timed_thread_test (mail->p_timed_thread))
timed_thread_exit (mail->p_timed_thread);
}
}
while (fail < 5) {
if (fail > 0) {
- ERR("Trying POP3 connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
- sleep((int)mail->interval);
+ ERR("Trying POP3 connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
}
if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
fail++;
- continue;
+ goto next_iteration;
}
their_addr.sin_family = AF_INET; // host byte order
sizeof(struct sockaddr)) == -1) {
perror("connect");
fail++;
- continue;
+ goto next_iteration;
}
struct timeval timeout;
int res;
0)) == -1) {
perror("recv");
fail++;
- continue;
+ goto next_iteration;
}
} else {
ERR("POP3 connection failed: timeout\n");
fail++;
- continue;
+ goto next_iteration;
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "+OK ") != recvbuf) {
ERR("POP3 connection failed, probably not a POP3 server");
fail++;
- continue;
+ goto next_iteration;
}
strncpy(sendbuf, "USER ", MAXDATASIZE);
strncat(sendbuf, mail->user,
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send USER");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv USER");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "+OK ") == NULL) {
ERR("POP3 server login failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
strncpy(sendbuf, "PASS ", MAXDATASIZE);
strncat(sendbuf, mail->pass,
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send PASS");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv PASS");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "+OK ") == NULL) {
ERR("POP3 server login failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
strncpy(sendbuf, "STAT\n", MAXDATASIZE);
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send STAT");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv STAT");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "+OK ") == NULL) {
ERR("POP3 status failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
// now we get the data
reply = recvbuf + 4;
if (reply == NULL) {
ERR("Error parsing POP3 response: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
} else {
timed_thread_lock (mail->p_timed_thread);
sscanf(reply, "%lu %lu", &mail->unseen,
if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
perror("send QUIT");
fail++;
- continue;
+ goto next_iteration;
}
timeout.tv_sec = 60; // 60 second timeout i guess
timeout.tv_usec = 0;
0)) == -1) {
perror("recv QUIT");
fail++;
- continue;
+ goto next_iteration;
}
}
recvbuf[numbytes] = '\0';
if (strstr(recvbuf, "+OK") == NULL) {
ERR("POP3 logout failed: %s", recvbuf);
fail++;
- continue;
+ goto next_iteration;
}
close(sockfd);
if (strlen(mail->command) > 1 && mail->unseen > old_unseen) { // new mail goodie
}
fail = 0;
old_unseen = mail->unseen;
+next_iteration:
if (timed_thread_test (mail->p_timed_thread))
timed_thread_exit (mail->p_timed_thread);
}
int pid = fork();
switch (pid) {
case -1:
- ERR("can't fork() to background: %s",
- strerror(errno));
+ ERR("Conky: couldn't fork() to background: %s", strerror(errno));
break;
case 0:
/* child process */
- sleep(1);
- fprintf(stderr,"\n");fflush(stderr);
+ usleep(25000);
+ fprintf(stderr,"\n"); fflush(stderr);
break;
default:
/* parent process */
- fprintf(stderr,"Conky: forked to background, pid is %d\n",pid);
- fflush(stderr);
+ fprintf(stderr,"Conky: forked to background, pid is %d\n", pid); fflush(stderr);
return 0;
}
}
/* Window decorations */
if (TEST_HINT(window.hints,HINT_UNDECORATED)) {
- fprintf(stderr, "Conky: hint - undecorated\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - undecorated\n"); fflush(stderr);*/
xa = ATOM(_MOTIF_WM_HINTS);
if (xa != None) {
/* Below other windows */
if (TEST_HINT(window.hints,HINT_BELOW)) {
- fprintf(stderr, "Conky: hint - below\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - below\n"); fflush(stderr); */
xa = ATOM(_WIN_LAYER);
if (xa != None) {
/* Above other windows */
if (TEST_HINT(window.hints,HINT_ABOVE)) {
- fprintf(stderr, "Conky: hint - above\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - above\n"); fflush(stderr);*/
xa = ATOM(_WIN_LAYER);
if (xa != None) {
/* Sticky */
if (TEST_HINT(window.hints,HINT_STICKY)) {
- fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr); */
xa = ATOM(_NET_WM_DESKTOP);
if (xa != None) {
/* Skip taskbar */
if (TEST_HINT(window.hints,HINT_SKIP_TASKBAR)) {
- fprintf(stderr, "Conky: hint - skip_taskbar\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - skip_taskbar\n"); fflush(stderr);*/
xa = ATOM(_NET_WM_STATE);
if (xa != None) {
/* Skip pager */
if (TEST_HINT(window.hints,HINT_SKIP_PAGER)) {
- fprintf(stderr, "Conky: hint - skip_pager\n"); fflush(stderr);
+ /*fprintf(stderr, "Conky: hint - skip_pager\n"); fflush(stderr);*/
xa = ATOM(_NET_WM_STATE);
if (xa != None) {