Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 774933
Collapse All | Expand All

(-)a/GUI/xephem/Makefile (-1 / +1 lines)
Lines 35-41 Link Here
35
# for linux and Apple OS X
35
# for linux and Apple OS X
36
XLIBS = -lXm -lXt -lXext -lXmu -lX11
36
XLIBS = -lXm -lXt -lXext -lXmu -lX11
37
CFLAGS := $(LIBINC) $(CFLAGS)
37
CFLAGS := $(LIBINC) $(CFLAGS)
38
LIBS = $(LIBLNK) $(XLIBS) $(LIBLIB) -lm
38
LIBS = $(LIBLNK) $(XLIBS) $(LIBLIB) -lm -lssl
39
39
40
# static linking on Apple using X11 libs from ports
40
# static linking on Apple using X11 libs from ports
41
# CC = gcc
41
# CC = gcc
(-)a/GUI/xephem/auxil/mpcorb2edb.pl (-1 / +1 lines)
Lines 78-84 Link Here
78
# setup cutoff mag
78
# setup cutoff mag
79
my $dimmag = 13;			# dimmest mag to be saved in "bright" file
79
my $dimmag = 13;			# dimmest mag to be saved in "bright" file
80
# set site and file in case of -f
80
# set site and file in case of -f
81
my $MPCSITE = "http://www.minorplanetcenter.net";
81
my $MPCSITE = "https://www.minorplanetcenter.net";
82
my $MPCFTPDIR = "/iau/MPCORB";
82
my $MPCFTPDIR = "/iau/MPCORB";
83
my $MPCFILE = "MPCORB.DAT";
83
my $MPCFILE = "MPCORB.DAT";
84
my $MPCZIPFILE = "MPCORB.DAT.gz";
84
my $MPCZIPFILE = "MPCORB.DAT.gz";
(-)a/GUI/xephem/earthmenu.c (-11 / +20 lines)
Lines 27-32 Link Here
27
27
28
#include "xephem.h"
28
#include "xephem.h"
29
29
30
/* SSL download parameters */
31
#define NSREAD  2048            /* size of socket read */
32
30
/* these are from earthmap.c */
33
/* these are from earthmap.c */
31
extern MRegion ereg[];
34
extern MRegion ereg[];
32
extern int nereg;
35
extern int nereg;
Lines 4887-4892 Link Here
4887
	char buf[1024];
4890
	char buf[1024];
4888
	int w, h;
4891
	int w, h;
4889
	int fd;
4892
	int fd;
4893
	XE_SSL_FD ssl_fd;
4894
4895
	memset(&ssl_fd, 0, sizeof(ssl_fd));
4890
4896
4891
	/* open test case, else real network */
4897
	/* open test case, else real network */
4892
	fd = openh ("/tmp/latest_cmoll.gif", O_RDONLY);
4898
	fd = openh ("/tmp/latest_cmoll.gif", O_RDONLY);
Lines 4902-4913 Link Here
4902
	    stopd_up();
4908
	    stopd_up();
4903
4909
4904
	    /* make connection to server for the file */
4910
	    /* make connection to server for the file */
4905
	    xe_msg (0, "Getting\nhttp://%s%s", wxhost, wxfile);
4911
	    xe_msg (0, "Getting\nhttps://%s%s", wxhost, wxfile);
4906
	    (void) sprintf (buf, "GET http://%s%s HTTP/1.0\r\nUser-Agent: xephem/%s\r\n\r\n",
4912
	    (void) sprintf (buf, "GET https://%s%s HTTP/1.0\r\nUser-Agent: xephem/%s\r\n\r\n",
4907
						wxhost, wxfile, PATCHLEVEL);
4913
						wxhost, wxfile, PATCHLEVEL);
4908
	    fd = httpGET (wxhost, buf, buf);
4914
	    fd = httpsGET (wxhost, buf, buf, &ssl_fd);
4909
	    if (fd < 0) {
4915
	    if (fd < 0) {
4910
		xe_msg (1, "http get:\n%s", buf);
4916
		xe_msg (1, "https get:\n%s", buf);
4911
		stopd_down();
4917
		stopd_down();
4912
		return (-1);
4918
		return (-1);
4913
	    }
4919
	    }
Lines 4915-4921 Link Here
4915
	    /* read header, looking for some header info */
4921
	    /* read header, looking for some header info */
4916
	    isgif = 0;
4922
	    isgif = 0;
4917
	    length = 0;
4923
	    length = 0;
4918
	    while (recvline (fd, buf, sizeof(buf)) > 1) {
4924
	    while (ssl_recvline (&ssl_fd, buf, sizeof(buf)) > 1) {
4919
		xe_msg (0, "Rcv: %s", buf);
4925
		xe_msg (0, "Rcv: %s", buf);
4920
		if (strstr (buf, "image/gif"))
4926
		if (strstr (buf, "image/gif"))
4921
		    isgif = 1;
4927
		    isgif = 1;
Lines 4923-4931 Link Here
4923
		    length = atoi (buf+15);
4929
		    length = atoi (buf+15);
4924
	    }
4930
	    }
4925
	    if (!isgif) {
4931
	    if (!isgif) {
4926
		while (recvline (fd, buf, sizeof(buf)) > 1)
4932
		while (ssl_recvline (&ssl_fd, buf, sizeof(buf)) > 1)
4927
		    xe_msg (0, "Rcv: %s", buf);
4933
		    xe_msg (0, "Rcv: %s", buf);
4928
		close (fd);
4934
		SSL_free (ssl_fd.ssl);
4935
		close (ssl_fd.fd);
4929
		stopd_down();
4936
		stopd_down();
4930
		return (-1);
4937
		return (-1);
4931
	    }
4938
	    }
Lines 4936-4947 Link Here
4936
	    pm_up();
4943
	    pm_up();
4937
	    for (nrawgif = 0; nrawgif < sizeof(rawgif); nrawgif += nr) {
4944
	    for (nrawgif = 0; nrawgif < sizeof(rawgif); nrawgif += nr) {
4938
		pm_set (100*nrawgif/length);
4945
		pm_set (100*nrawgif/length);
4939
		nr = readbytes (fd, rawgif+nrawgif, 4096);
4946
		nr = SSL_read (ssl_fd.ssl, rawgif+nrawgif, NSREAD);
4940
		if (nr < 0) {
4947
		if (nr < 0) {
4941
		    xe_msg (1, "%s:\n%s", wxhost, syserrstr());
4948
		    xe_msg (1, "%s: ssl read error code: %d", wxhost, SSL_get_error(ssl_fd.ssl, nr));
4942
		    stopd_down();
4949
		    stopd_down();
4943
		    pm_down();
4950
		    pm_down();
4944
		    close (fd);
4951
		    SSL_free (ssl_fd.ssl);
4952
		    close (ssl_fd.fd);
4945
		    return (-1);
4953
		    return (-1);
4946
		}
4954
		}
4947
		if (nr == 0)
4955
		if (nr == 0)
Lines 4949-4955 Link Here
4949
	    }
4957
	    }
4950
	    stopd_down();
4958
	    stopd_down();
4951
	    pm_down();
4959
	    pm_down();
4952
	    close (fd);
4960
	    SSL_free (ssl_fd.ssl);
4961
	    close (ssl_fd.fd);
4953
	    if (nr > 0) {
4962
	    if (nr > 0) {
4954
		xe_msg (1, "File too large");
4963
		xe_msg (1, "File too large");
4955
		return (-1);
4964
		return (-1);
(-)a/GUI/xephem/fallbacks.c (-4 / +4 lines)
Lines 747-756 Link Here
747
    "XEphem*WebDB*URL1.value: http://celestrak.com/NORAD/elements/science.txt",
747
    "XEphem*WebDB*URL1.value: http://celestrak.com/NORAD/elements/science.txt",
748
    "XEphem*WebDB*URL2.value: http://celestrak.com/NORAD/elements/tle-new.txt",
748
    "XEphem*WebDB*URL2.value: http://celestrak.com/NORAD/elements/tle-new.txt",
749
    "XEphem*WebDB*URL3.value: http://celestrak.com/NORAD/elements/amateur.txt",
749
    "XEphem*WebDB*URL3.value: http://celestrak.com/NORAD/elements/amateur.txt",
750
    "XEphem*WebDB*URL4.value: http://www.minorplanetcenter.org/iau/Ephemerides/Comets/Soft03Cmt.txt",
750
    "XEphem*WebDB*URL4.value: https://www.minorplanetcenter.org/iau/Ephemerides/Comets/Soft03Cmt.txt",
751
    "XEphem*WebDB*URL5.value: http://www.minorplanetcenter.org/iau/Ephemerides/CritList/Soft03CritList.txt",
751
    "XEphem*WebDB*URL5.value: https://www.minorplanetcenter.org/iau/Ephemerides/CritList/Soft03CritList.txt",
752
    "XEphem*WebDB*URL6.value: http://www.minorplanetcenter.org/iau/Ephemerides/Distant/Soft03Distant.txt",
752
    "XEphem*WebDB*URL6.value: https://www.minorplanetcenter.org/iau/Ephemerides/Distant/Soft03Distant.txt",
753
    "XEphem*WebDB*URL7.value: http://www.minorplanetcenter.org/iau/Ephemerides/Unusual/Soft03Unusual.txt",
753
    "XEphem*WebDB*URL7.value: https://www.minorplanetcenter.org/iau/Ephemerides/Unusual/Soft03Unusual.txt",
754
    "XEphem*WebDB.x: 200",
754
    "XEphem*WebDB.x: 200",
755
    "XEphem*WebDB.y: 200",
755
    "XEphem*WebDB.y: 200",
756
    "XEphem*WeekStart.Monday.set: False",
756
    "XEphem*WeekStart.Monday.set: False",
(-)a/GUI/xephem/net.h (-2 / +12 lines)
Lines 20-25 Link Here
20
#include <sys/select.h>
20
#include <sys/select.h>
21
#endif
21
#endif
22
22
23
#include <openssl/ssl.h>
24
25
typedef struct {
26
	int fd;		//file desciptor for the underlying connection socket
27
	SSL *ssl;	//ssl connection for use with SSL_read( )and SSL_write()
28
} XE_SSL_FD;
29
23
/* support functions */
30
/* support functions */
24
31
25
extern int httpGET (char *host, char *GETcmd, char msg[]);
32
extern int httpGET (char *host, char *GETcmd, char msg[]);
Lines 29-36 Link Here
29
extern int recvline (int fd, char buf[], int max);
36
extern int recvline (int fd, char buf[], int max);
30
extern int recvlineb (int sock, char *buf, int size);
37
extern int recvlineb (int sock, char *buf, int size);
31
extern int sendbytes (int fd, unsigned char buf[], int n);
38
extern int sendbytes (int fd, unsigned char buf[], int n);
32
39
extern int httpsGET (char *host, char *GETcmd, char msg[], XE_SSL_FD *ssl_fd);
33
40
extern int ssl_recvbytes (XE_SSL_FD *ssl_fd, unsigned char buf[], int n);
41
extern int ssl_readbytes (XE_SSL_FD *ssl_fd, unsigned char buf[], int n);
42
extern int ssl_recvline (XE_SSL_FD *ssl_fd, char buf[], int max);
43
extern int ssl_recvlineb (XE_SSL_FD *ssl_fd, char *buf, int size);
34
44
35
/* For RCS Only -- Do Not Edit
45
/* For RCS Only -- Do Not Edit
36
 * @(#) $RCSfile: net.h,v $ $Date: 2003/03/17 07:26:21 $ $Revision: 1.3 $ $Name:  $
46
 * @(#) $RCSfile: net.h,v $ $Date: 2003/03/17 07:26:21 $ $Revision: 1.3 $ $Name:  $
(-)a/GUI/xephem/netmenu.c (-3 / +227 lines)
Lines 9-14 Link Here
9
#include <string.h>
9
#include <string.h>
10
#include <unistd.h>
10
#include <unistd.h>
11
11
12
#include <openssl/ssl.h>
13
12
#include <Xm/Form.h>
14
#include <Xm/Form.h>
13
#include <Xm/Label.h>
15
#include <Xm/Label.h>
14
#include <Xm/PushB.h>
16
#include <Xm/PushB.h>
Lines 70-81 Link Here
70
72
71
static char netcategory[] = "Network";	/* Save category */
73
static char netcategory[] = "Network";	/* Save category */
72
74
75
static SSL_METHOD *ssl_method;	/* global ssl dispatch structure for creating a ssl context */
76
static SSL_CTX *ssl_ctx;	/* global ssl context structure for creating ssl connections */
77
73
/* call to set up without actually bringing up the menus.
78
/* call to set up without actually bringing up the menus.
74
 */
79
 */
75
void
80
void
76
net_create()
81
net_create()
77
{
82
{
78
	if (!netshell_w) {
83
	if (!netshell_w) {
84
	    if (SSL_library_init() < 0) {
85
		fprintf (stderr, "Could not initialize the OpenSSL library !\n");
86
	    } else {
87
		ssl_method = SSLv23_client_method();	/* deprecated since openssl 1.1.x */
88
//		ssl_method = TLS_client_method();	/* since openssl 1.1.x */
89
		ssl_ctx = SSL_CTX_new (ssl_method);
90
		SSL_CTX_set_options (ssl_ctx, SSL_OP_NO_SSLv2);
91
	    };
92
79
	    net_create_form();
93
	    net_create_form();
80
	    (void) net_save();	/* confirming here is just annoying */
94
	    (void) net_save();	/* confirming here is just annoying */
81
	}
95
	}
Lines 251-258 Link Here
251
            struct {
265
            struct {
252
		unsigned char  VN;	/* version number */
266
		unsigned char  VN;	/* version number */
253
		unsigned char  CD;	/* command code */
267
		unsigned char  CD;	/* command code */
254
		unsigned short DSTPORT;	/* destination port */
268
		uint16_t       DSTPORT;	/* destination port */
255
		unsigned long  DSTIP;	/* destination IP addres */
269
		uint32_t       DSTIP;	/* destination IP address */
256
	    } SocksPacket;
270
	    } SocksPacket;
257
271
258
	    struct hostent *hs = gethostbyname (socks_host);
272
	    struct hostent *hs = gethostbyname (socks_host);
Lines 390-396 Link Here
390
404
391
/* read up to and including the next '\n' from socket fd into buf[max].
405
/* read up to and including the next '\n' from socket fd into buf[max].
392
 * we silently ignore all '\r'. we add a trailing '\0'.
406
 * we silently ignore all '\r'. we add a trailing '\0'.
393
 * return line lenth (not counting \0) if all ok, else -1.
407
 * return line length (not counting \0) if all ok, else -1.
394
 * N.B. this never reads ahead -- if that's ok, recvlineb() is better
408
 * N.B. this never reads ahead -- if that's ok, recvlineb() is better
395
 */
409
 */
396
int
410
int
Lines 445-450 Link Here
445
		if (nr <= 0) {
459
		if (nr <= 0) {
446
		    ok = nr;
460
		    ok = nr;
447
		    rb_next = 0;
461
		    rb_next = 0;
462
		    rb_unk = 0;
463
		    break;
464
		}
465
		rb_next = 0;
466
		rb_unk = nr;
467
	    }
468
469
	    if ((c = rb_linebuf[rb_next++]) != '\r')
470
		*buf++ = c;
471
472
	} while (buf-origbuf < size && c != '\n');
473
474
	/* always give back a real line regardless, else status */
475
	if (ok > 0) {
476
	    *buf = '\0';
477
	    ok = buf - origbuf;
478
	}
479
480
	return (ok);
481
}
482
483
/* open the host, do the given GET cmd, and return a socket fd for the result.
484
 * on success it fills the XE_SSL_FD structure for later use by SSL_read() and necessary cleanup.
485
 * return -1 and with excuse in msg[], else 0 if ok.
486
 * N.B. can be called before we are created if net set in app defaults.
487
 */
488
int
489
httpsGET (char *host, char *GETcmd, char msg[], XE_SSL_FD *ssl_fd)
490
{
491
	char buf[2048];
492
	int fd;
493
	int connected;
494
	SSL *ssl;
495
	int n;
496
	int ret;
497
	int httpsport = 443;
498
499
	/* open connection */
500
	if (proxy_on) {
501
	    fd = mkconnection (proxy_host, proxy_port, msg);
502
	    if (fd < 0)
503
		return (-1);
504
505
	    /* fill buf with CONNECT */
506
	    (void) sprintf (buf, "CONNECT %1$s:%2$d HTTP/1.0\r\nUser-Agent: xephem/%3$s\r\nHost: %1$s:%2$d\r\n\r\n", host, httpsport, PATCHLEVEL);
507
508
	    /* add proxy auth if enabled */
509
	    if (!auth_w)
510
		net_create_form();
511
	    if (XmToggleButtonGetState (auth_w))
512
		addAuth(buf);
513
514
	    /* log it */
515
	    xe_msg (0, "https proxy connect: %s", buf);
516
517
	    /* send it */
518
	    n = strlen (buf);
519
	    if (sendbytes(fd, (unsigned char *)buf, n) < 0) {
520
		(void) sprintf (msg, "%s: send error: %s", proxy_host, syserrstr());
521
		(void) close (fd);
522
		return (-1);
523
	    }
524
525
	    connected = 0;
526
	    while (recvline (fd, buf, sizeof(buf)) > 1) {
527
		xe_msg (0, "Rcv: %s", buf);
528
		if (strstr (buf, "200 "))
529
		    connected = 1;
530
	    }
531
	    if (!connected) {
532
		(void) sprintf (msg, "%s: connect error: %s", proxy_host, syserrstr());
533
		(void) close (fd);
534
		return (-1);
535
	    }
536
	} else {
537
	    /* SOCKS or direct are both handled by mkconnection() */
538
	    fd = mkconnection (host, httpsport, msg);
539
	    if (fd < 0)
540
		return (-1);
541
	}
542
543
	/* fill buf with GETcmd */
544
	(void) sprintf (buf, "%s", GETcmd);
545
546
	/* start ssl connection */
547
	ssl = SSL_new (ssl_ctx);
548
	SSL_set_fd (ssl, fd);
549
	SSL_connect (ssl);
550
551
	/* log it */
552
	xe_msg (0, "https: %s", buf);
553
554
	/* send it */
555
	n = strlen (buf);
556
	ret = SSL_write (ssl, (unsigned char *)buf, n);
557
	if (ret <= 0) {
558
	    (void) sprintf (msg, "%s: ssl send error code: %d", host, SSL_get_error (ssl, ret));
559
	    (void) SSL_free (ssl);
560
	    (void) close (fd);
561
	    return (-1);
562
	}
563
564
	/* caller can read response */
565
	ssl_fd->fd = fd;
566
	ssl_fd->ssl = ssl;
567
	return (fd);
568
}
569
570
/* receive exactly n bytes from ssl connection ssl_fd into buf.
571
 * return -1, 0 or n.
572
 * N.B. with fallback to ordinary read from socket if ssl_fd->ssl is NULL
573
 */
574
int
575
ssl_recvbytes (XE_SSL_FD *ssl_fd, unsigned char buf[], int n)
576
{
577
	int ns, tot;
578
579
	for (tot = 0; tot < n; tot += ns) {
580
	    if (tout (TOUT, ssl_fd->fd, 0) < 0)
581
		return (-1);
582
	    if (ssl_fd->ssl)
583
		ns = SSL_read (ssl_fd->ssl, (void *)(buf+tot), n-tot);
584
	    else
585
		ns = read (ssl_fd->fd, (void *)(buf+tot), n-tot);
586
	    if (ns <= 0)
587
		return (ns);
588
	}
589
	return (n);
590
}
591
592
/* like read(2) except we time out and allow user to cancel.
593
 * receive up to n bytes from ssl connection ssl_fd into buf.
594
 * return count, or 0 on eof or -1 on error.
595
 * N.B. with fallback to ordinary read from socket if ssl_fd->ssl is NULL
596
 */
597
int
598
ssl_readbytes (XE_SSL_FD *ssl_fd, unsigned char buf[], int n)
599
{
600
	int ns;
601
602
	if (tout (TOUT, ssl_fd->fd, 0) < 0)
603
	    return (-1);
604
	if (ssl_fd->ssl)
605
	    ns = SSL_read (ssl_fd->ssl, (void *)buf, n);
606
	else
607
	    ns = read (ssl_fd->fd, (void *)buf, n);
608
	return (ns);
609
}
610
611
/* read up to and including the next '\n' from ssl into buf[max].
612
 * we silently ignore all '\r'. we add a trailing '\0'.
613
 * return line length (not counting \0) if all ok, else -1.
614
 * N.B. with fallback to ordinary read from socket if ssl_fd->ssl is NULL
615
 */
616
int
617
ssl_recvline (XE_SSL_FD *ssl_fd, char buf[], int max)
618
{
619
	unsigned char c;
620
	int n;
621
622
	max--;	/* leave room for trailing \0 */
623
624
	for (n = 0; n < max && ssl_recvbytes (ssl_fd, &c, 1) == 1; ) {
625
	    if (c != '\r') {
626
		buf[n++] = c;
627
		if (c == '\n') {
628
		    buf[n] = '\0';
629
		    return (n);
630
		}
631
	    }
632
	}
633
634
	return (-1);
635
}
636
637
/* rather like ssl_recvline but reads ahead in big chunk for efficiency.
638
 * return length if read a line ok, 0 if hit eof, -1 if error.
639
 * N.B. we silently swallow all '\r'.
640
 * N.B. we read ahead and can hide bytes after each call.
641
 * N.B. with fallback to ordinary read from socket if ssl_fd->ssl is NULL
642
 */
643
int
644
ssl_recvlineb (XE_SSL_FD *ssl_fd, char *buf, int size)
645
{
646
	char *origbuf = buf;		/* save to prevent overfilling buf */
647
	char c = '\0';
648
	int ok = 1;
649
650
	/* always leave room for trailing \n */
651
	size -= 1;
652
653
	/* read and copy linebuf[next] to buf until buf fills or copied a \n */
654
	do {
655
656
	    if (rb_next >= rb_unk) {
657
		/* linebuf is empty -- refill */
658
659
		int nr;
660
661
		if (tout (TOUT, ssl_fd->fd, 0) < 0) {
662
		    nr = -1;
663
		    break;
664
		}
665
		if (ssl_fd->ssl)
666
		    nr = SSL_read (ssl_fd->ssl, rb_linebuf, sizeof(rb_linebuf));
667
		else
668
		    nr = read (ssl_fd->fd, rb_linebuf, sizeof(rb_linebuf));
669
		if (nr <= 0) {
670
		    ok = nr;
671
		    rb_next = 0;
448
		    rb_unk = 0;
672
		    rb_unk = 0;
449
		    break;
673
		    break;
450
		}
674
		}
(-)a/GUI/xephem/sunmenu.c (-13 / +19 lines)
Lines 884-892 Link Here
884
	int isjpeg, jpegl;
884
	int isjpeg, jpegl;
885
	int njpeg;
885
	int njpeg;
886
	unsigned char *jpeg;
886
	unsigned char *jpeg;
887
	XE_SSL_FD ssl_fd;
887
	int fd, nr;
888
	int fd, nr;
888
	struct tm tm;
889
	struct tm tm;
889
890
891
	memset(&ssl_fd, 0, sizeof(ssl_fd));
890
	memset(&tm, 0, sizeof(struct tm));
892
	memset(&tm, 0, sizeof(struct tm));
891
893
892
	/* get desired type and size */
894
	/* get desired type and size */
Lines 899-916 Link Here
899
901
900
	/* build GET command */
902
	/* build GET command */
901
	sprintf (get, "GET http://%s%s HTTP/1.0\r\nUser-Agent: xephem/%s\r\n\r\n", sohohost, fn, PATCHLEVEL);
903
	sprintf (get, "GET http://%s%s HTTP/1.0\r\nUser-Agent: xephem/%s\r\n\r\n", sohohost, fn, PATCHLEVEL);
902
904
	
903
	/* query server */
905
	/* query server */
904
	fd = httpGET (sohohost, get, buf);
906
	fd = httpsGET (sohohost, get, buf, &ssl_fd);
905
	if (fd < 0) {
907
	if (fd < 0) {
906
	    xe_msg (1, "http get: %s", buf);
908
	    xe_msg (1, "https get: %s", buf);
907
	    return (-1);
909
	    return (-1);
908
	}
910
	}
909
911
910
	/* read header (everything to first blank line), looking for jpeg */
912
	/* read header (everything to first blank line), looking for jpeg */
911
	isjpeg = 0;
913
	isjpeg = 0;
912
	jpegl = 0;
914
	jpegl = 0;
913
	while (recvline (fd, buf, sizeof(buf)) > 1) {
915
	while (ssl_recvline (&ssl_fd, buf, sizeof(buf)) > 1) {
914
	    xe_msg (0, "Rcv: %s", buf);
916
	    xe_msg (0, "Rcv: %s", buf);
915
	    if (strstr (buf, "Content-Type:") && strstr (buf, "image/jpeg"))
917
	    if (strstr (buf, "Content-Type:") && strstr (buf, "image/jpeg"))
916
		isjpeg = 1;
918
		isjpeg = 1;
Lines 923-937 Link Here
923
	    }
925
	    }
924
	}
926
	}
925
	if (!isjpeg) {
927
	if (!isjpeg) {
926
	    while (recvline (fd, buf, sizeof(buf)) > 0)
928
	    while (ssl_recvline (&ssl_fd, buf, sizeof(buf)) > 0)
927
		xe_msg (0, "Rcv: %s", buf);
929
		xe_msg (0, "Rcv: %s", buf);
928
	    xe_msg (1, "Error talking to SOHO .. see File->System log\n");
930
	    xe_msg (1, "Error talking to SOHO .. see File->System log\n");
929
	    close (fd);
931
	    SSL_free (ssl_fd.ssl);
932
	    close (ssl_fd.fd);
930
	    return (-1);
933
	    return (-1);
931
	}
934
	}
932
	if (jpegl == 0) {
935
	if (jpegl == 0) {
933
	    xe_msg (1, "No Content-Length in header");
936
	    xe_msg (1, "No Content-Length in header");
934
	    close (fd);
937
	    SSL_free (ssl_fd.ssl);
938
	    close (ssl_fd.fd);
935
	    return (-1);
939
	    return (-1);
936
	}
940
	}
937
941
Lines 941-960 Link Here
941
	for (njpeg = 0; njpeg < jpegl; njpeg += nr) {
945
	for (njpeg = 0; njpeg < jpegl; njpeg += nr) {
942
	    pm_set (100*njpeg/jpegl);
946
	    pm_set (100*njpeg/jpegl);
943
	    jpeg = (unsigned char *) XtRealloc ((char*)jpeg, njpeg+NSREAD);
947
	    jpeg = (unsigned char *) XtRealloc ((char*)jpeg, njpeg+NSREAD);
944
	    nr = readbytes (fd, jpeg+njpeg, NSREAD);
948
	    nr = SSL_read (ssl_fd.ssl, jpeg+njpeg, NSREAD);
945
	    if (nr < 0) {
949
	    if (nr <= 0) {
946
		xe_msg (1, "%s:\n%s", sohohost, syserrstr());
950
		xe_msg (1, "%s: ssl read error code: %d", sohohost, SSL_get_error(ssl_fd.ssl, nr));
947
		pm_down();
951
		pm_down();
948
		close (fd);
952
		SSL_free (ssl_fd.ssl);
953
		close (ssl_fd.fd);
949
		return (-1);
954
		return (-1);
950
	    }
955
	    }
951
	    if (nr == 0)
956
	    if (nr == 0)
952
		break;
957
		break;
953
	}
958
	}
954
	pm_down();
959
	pm_down();
955
	close (fd);
960
	SSL_free (ssl_fd.ssl);
961
	close (ssl_fd.fd);
956
962
957
        sprintf (fn, "/%s_%s.jpg", filetime, filetype);
963
	sprintf (fn, "/%s_%s.jpg", filetime, filetype);
958
	/* display jpeg */
964
	/* display jpeg */
959
	if (displayPic (fn, jpeg, njpeg) < 0)
965
	if (displayPic (fn, jpeg, njpeg) < 0)
960
	    return (-1);
966
	    return (-1);
(-)a/GUI/xephem/ucac.c (-11 / +11 lines)
Lines 18-32 Link Here
18
18
19
#define	MAXFOV	15.0			/* max fov, degs */
19
#define	MAXFOV	15.0			/* max fov, degs */
20
20
21
typedef unsigned char UC;		/* byte */
21
typedef unsigned char XE_UC;		/* byte */
22
typedef unsigned int UI;		/* unsigned integer */
22
typedef unsigned int XE_UI;		/* unsigned integer */
23
23
24
/* access an I*2 or I*4 at offset i in UC array a in little-endian byte order.
24
/* access an I*2 or I*4 at offset i in UC array a in little-endian byte order.
25
 * a bit slow but ultra portable.
25
 * a bit slow but ultra portable.
26
 */
26
 */
27
#define	I2(a,i)		((int)(short)((((UI)(a)[i]) | (((UI)(a)[i+1])<<8))))
27
#define	I2(a,i)		((int)(short)((((XE_UI)(a)[i]) | (((XE_UI)(a)[i+1])<<8))))
28
#define	I4(a,i)		((int)((((UI)(a)[i]) | (((UI)(a)[i+1])<<8) | \
28
#define	I4(a,i)		((int)((((XE_UI)(a)[i]) | (((XE_UI)(a)[i+1])<<8) | \
29
				(((UI)(a)[i+2])<<16) | (((UI)(a)[i+3])<<24))))
29
				(((XE_UI)(a)[i+2])<<16) | (((XE_UI)(a)[i+3])<<24))))
30
30
31
/* keep track of an array of ObjF */
31
/* keep track of an array of ObjF */
32
typedef struct {
32
typedef struct {
Lines 48-56 Link Here
48
48
49
#define	DPMAS	(1.0/3600000.0)		/* degrees per milliarcsecond */
49
#define	DPMAS	(1.0/3600000.0)		/* degrees per milliarcsecond */
50
50
51
typedef UC U2Star[44];			/* UCAC2 record */
51
typedef XE_UC U2Star[44];		/* UCAC2 record */
52
typedef UC U3Star[84];			/* UCAC3 record */
52
typedef XE_UC U3Star[84];		/* UCAC3 record */
53
typedef UC U4Star[78];			/* UCAC4 record */
53
typedef XE_UC U4Star[78];		/* UCAC4 record */
54
static char *basedir;			/* full dir with zone files and index */
54
static char *basedir;			/* full dir with zone files and index */
55
static FILE *indexfp;			/* index file handle */
55
static FILE *indexfp;			/* index file handle */
56
56
Lines 293-299 Link Here
293
read4Index (int rz, int dz, int *nskip, int *nnew)
293
read4Index (int rz, int dz, int *nskip, int *nnew)
294
{
294
{
295
	off_t offset;
295
	off_t offset;
296
	UC i4[4];
296
	XE_UC i4[4];
297
297
298
	offset = (rz*NZH4 + dz)*sizeof(i4);
298
	offset = (rz*NZH4 + dz)*sizeof(i4);
299
	if (fseek (indexfp, offset, SEEK_SET) < 0) {
299
	if (fseek (indexfp, offset, SEEK_SET) < 0) {
Lines 508-514 Link Here
508
read3Index (int rz, int dz, int *nskip, int *nnew)
508
read3Index (int rz, int dz, int *nskip, int *nnew)
509
{
509
{
510
	off_t offset;
510
	off_t offset;
511
	UC i4[4];
511
	XE_UC i4[4];
512
512
513
	offset = (rz*NZH + dz)*sizeof(i4);
513
	offset = (rz*NZH + dz)*sizeof(i4);
514
	if (fseek (indexfp, offset, SEEK_SET) < 0) {
514
	if (fseek (indexfp, offset, SEEK_SET) < 0) {
Lines 663-669 Link Here
663
get2N (int rz, int dz, int *idp)
663
get2N (int rz, int dz, int *idp)
664
{
664
{
665
	off_t offset;
665
	off_t offset;
666
	UC nat[4];
666
	XE_UC nat[4];
667
667
668
	offset = (dz*NZW + rz)*sizeof(nat);
668
	offset = (dz*NZW + rz)*sizeof(nat);
669
	if (fseek (indexfp, offset, SEEK_SET) < 0)
669
	if (fseek (indexfp, offset, SEEK_SET) < 0)
(-)a/GUI/xephem/usno.c (-8 / +8 lines)
Lines 14-21 Link Here
14
#define	CATBPR	12	/* bytes per star record in .cat file */
14
#define	CATBPR	12	/* bytes per star record in .cat file */
15
#define	ACCBPR	30	/* bytes per record in .acc file */
15
#define	ACCBPR	30	/* bytes per record in .acc file */
16
16
17
typedef unsigned int UI;
17
typedef unsigned int XE_UI;
18
typedef unsigned char UC;
18
typedef unsigned char XE_UC;
19
19
20
/* One Field star */
20
/* One Field star */
21
typedef struct {
21
typedef struct {
Lines 36-42 Link Here
36
    double lr[2], int *nd, double fd[2], double ld[2], int zone[2], char msg[]);
36
    double lr[2], int *nd, double fd[2], double ld[2], int zone[2], char msg[]);
37
static int fetchSwath (int zone, double maxmag, double fr, double lr,
37
static int fetchSwath (int zone, double maxmag, double fr, double lr,
38
    double fd, double ld, StarArray *sap, char msg[]);
38
    double fd, double ld, StarArray *sap, char msg[]);
39
static int crackCatBuf (UC buf[CATBPR], FieldStar *fsp);
39
static int crackCatBuf (XE_UC buf[CATBPR], FieldStar *fsp);
40
static int addGS (StarArray *sap, FieldStar *fsp);
40
static int addGS (StarArray *sap, FieldStar *fsp);
41
41
42
static char *cdpath;		/* where CD rom is mounted */
42
static char *cdpath;		/* where CD rom is mounted */
Lines 236-242 Link Here
236
{
236
{
237
	char fn[1024];
237
	char fn[1024];
238
	char buf[ACCBPR];
238
	char buf[ACCBPR];
239
	UC catbuf[CATBPR];
239
	XE_UC catbuf[CATBPR];
240
	FieldStar fs;
240
	FieldStar fs;
241
	long frec;
241
	long frec;
242
	long os;
242
	long os;
Lines 314-326 Link Here
314
 * return 0 if ok, else -1.
314
 * return 0 if ok, else -1.
315
 */
315
 */
316
static int
316
static int
317
crackCatBuf (UC buf[CATBPR], FieldStar *fsp)
317
crackCatBuf (XE_UC buf[CATBPR], FieldStar *fsp)
318
{
318
{
319
#define	BEUPACK(b) (((UI)((b)[0])<<24) | ((UI)((b)[1])<<16) | ((UI)((b)[2])<<8)\
319
#define	BEUPACK(b) (((XE_UI)((b)[0])<<24) | ((XE_UI)((b)[1])<<16) | ((XE_UI)((b)[2])<<8)\
320
							    | ((UI)((b)[3])))
320
							    | ((XE_UI)((b)[3])))
321
	double ra, dec;
321
	double ra, dec;
322
	int red, blu;
322
	int red, blu;
323
	UI mag;
323
	XE_UI mag;
324
324
325
	/* first 4 bytes are packed RA, big-endian */
325
	/* first 4 bytes are packed RA, big-endian */
326
	ra = BEUPACK(buf)/(100.0*3600.0*15.0);
326
	ra = BEUPACK(buf)/(100.0*3600.0*15.0);
(-)a/GUI/xephem/webdbmenu.c (-9 / +32 lines)
Lines 404-409 Link Here
404
char *url;
404
char *url;
405
{
405
{
406
	static char http[] = "http://";
406
	static char http[] = "http://";
407
	static char https[] = "https://";
408
	char *transport = http;
409
	int ltransport = strlen (transport);
410
	int ishttp = 0;
407
	char buf[512], msg[1024];
411
	char buf[512], msg[1024];
408
	char l0[512], l1[512], l2[512];
412
	char l0[512], l1[512], l2[512];
409
	char *l0p = l0, *l1p = l1, *l2p = l2;
413
	char *l0p = l0, *l1p = l1, *l2p = l2;
Lines 411-431 Link Here
411
	char *slash, *dot;
415
	char *slash, *dot;
412
	char filename[256];
416
	char filename[256];
413
	FILE *fp;
417
	FILE *fp;
418
	XE_SSL_FD ssl_fd;
414
	int sockfd;
419
	int sockfd;
415
	int nfound;
420
	int nfound;
416
421
422
	memset(&ssl_fd, 0, sizeof(ssl_fd));
423
417
	/* start */
424
	/* start */
418
	watch_cursor(1);
425
	watch_cursor(1);
419
	l0[0] = l1[0] = l2[0] = '\0';
426
	l0[0] = l1[0] = l2[0] = '\0';
420
427
421
	/* find transport and host */
428
	/* find transport and host */
422
	if (strncmp (url, http, 7)) {
429
	if (!strncmp (url, transport, ltransport)) {
423
	    xe_msg (1, "URL must begin with %s", http);
430
	    ishttp = 1;
431
	} else {
432
	    transport = https;
433
	    ltransport = strlen (transport);
434
	}
435
436
	if ((!ishttp) && (strncmp (url, transport, ltransport))) {
437
	    xe_msg (1, "URL must begin with %s or %s", http, https);
424
	    watch_cursor (0);
438
	    watch_cursor (0);
425
	    return;
439
	    return;
426
	}
440
	}
427
441
428
	slash = strchr (url+7, '/');
442
	slash = strchr (url+ltransport, '/');
429
	dot = strrchr (url, '.');
443
	dot = strrchr (url, '.');
430
	if (!slash || !dot) {
444
	if (!slash || !dot) {
431
	    xe_msg (1, "Badly formed URL");
445
	    xe_msg (1, "Badly formed URL");
Lines 434-444 Link Here
434
	}
448
	}
435
449
436
	/* connect to check url */
450
	/* connect to check url */
437
	sprintf (host, "%.*s", (int)(slash-url-7), url+7);
451
	sprintf (host, "%.*s", (int)(slash-url-ltransport), url+ltransport);
438
	sprintf (buf, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nUser-Agent: xephem/%s\r\n\r\n",
452
	sprintf (buf, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nUser-Agent: xephem/%s\r\n\r\n",
439
						url, host, PATCHLEVEL);
453
						url, host, PATCHLEVEL);
440
	stopd_up();
454
	stopd_up();
441
	sockfd = httpGET (host, buf, msg);
455
	if (ishttp) {
456
	    sockfd = httpGET (host, buf, msg);
457
	    ssl_fd.fd = sockfd;
458
	} else {
459
	    sockfd = httpsGET (host, buf, msg, &ssl_fd);
460
	}
442
	if (sockfd < 0) {
461
	if (sockfd < 0) {
443
	    xe_msg (1, "http GET to %s failed: %s%s\n", host, buf, msg);
462
	    xe_msg (1, "http GET to %s failed: %s%s\n", host, buf, msg);
444
	    stopd_down();
463
	    stopd_down();
Lines 447-466 Link Here
447
	}
466
	}
448
467
449
	/* create local file */
468
	/* create local file */
450
	slash = strrchr (url+7, '/');
469
	slash = strrchr (url+ltransport, '/');
451
	sprintf (filename, "%s/%.*sedb", getPrivateDir(), (int)(dot-slash), slash+1);
470
	sprintf (filename, "%s/%.*sedb", getPrivateDir(), (int)(dot-slash), slash+1);
452
	fp = fopen (filename, "w");
471
	fp = fopen (filename, "w");
453
	if (!fp) {
472
	if (!fp) {
454
	    xe_msg (1, "%s:\n%s", filename, syserrstr());
473
	    xe_msg (1, "%s:\n%s", filename, syserrstr());
455
	    watch_cursor (0);
474
	    watch_cursor (0);
456
	    close (sockfd);
475
	    if (!ishttp)
476
		SSL_free (ssl_fd.ssl);
477
	    close (ssl_fd.fd);
457
	    return;
478
	    return;
458
	}
479
	}
459
480
460
	/* copy to file, insuring only .edb lines.
481
	/* copy to file, insuring only .edb lines.
461
	 */
482
	 */
462
	nfound = 0;
483
	nfound = 0;
463
	while (recvlineb (sockfd, l2p, sizeof(l2)) > 0) {
484
	while (ssl_recvlineb (&ssl_fd, l2p, sizeof(l2)) > 0) {
464
	    char *lrot;
485
	    char *lrot;
465
	    Obj o;
486
	    Obj o;
466
487
Lines 484-490 Link Here
484
505
485
	/* tidy up and done */
506
	/* tidy up and done */
486
	fclose (fp);
507
	fclose (fp);
487
	close (sockfd);
508
	if (!ishttp)
509
	    SSL_free (ssl_fd.ssl);
510
	close (ssl_fd.fd);
488
	if (!nfound) {
511
	if (!nfound) {
489
	    xe_msg (1, "No objects in file");
512
	    xe_msg (1, "No objects in file");
490
	    remove (filename);
513
	    remove (filename);
(-)a/GUI/xephem/xephem.h (-1 / +1 lines)
Lines 12-23 Link Here
12
12
13
#include <stdarg.h>		/* be kind to those who don't use xe_msg() */
13
#include <stdarg.h>		/* be kind to those who don't use xe_msg() */
14
14
15
#include "net.h"		/* has to be included before astro.h because of openssl */
15
#include "astro.h"
16
#include "astro.h"
16
#include "ip.h"
17
#include "ip.h"
17
18
18
/* local glue files */
19
/* local glue files */
19
#include "map.h"
20
#include "map.h"
20
#include "net.h"
21
#include "patchlevel.h"
21
#include "patchlevel.h"
22
#include "preferences.h"
22
#include "preferences.h"
23
#include "db.h"
23
#include "db.h"

Return to bug 774933