version 1.2, 2002/04/18 21:48:36 |
version 1.3, 2002/04/18 22:07:04 |
|
|
/* $OpenBSD $*/ |
/* $OpenBSD$ */ |
/* |
/* |
* Copyright (c) 2002 Marc Espie. |
* Copyright (c) 2002 Marc Espie. |
* |
* |
|
|
#include <vis.h> |
#include <vis.h> |
#include "extern.h" |
#include "extern.h" |
|
|
unsigned long cddb_discid(int, struct cd_toc_entry *); |
unsigned long cddb_discid(int, struct cd_toc_entry *); |
unsigned long cddb_sum(unsigned long); |
unsigned long cddb_sum(unsigned long); |
void send_hello(FILE *); |
void send_hello(FILE *); |
void send_query(FILE *, int, struct cd_toc_entry *); |
void send_query(FILE *, int, struct cd_toc_entry *); |
int further_query(FILE *, char *); |
int further_query(FILE *, char *); |
int connect_to(const char *, const char *); |
int connect_to(const char *, const char *); |
int parse_connect_to(const char *, const char *); |
int parse_connect_to(const char *, const char *); |
char * get_line(FILE *); |
char * get_line(FILE *); |
char * get_answer(FILE *); |
char * get_answer(FILE *); |
void verify_track_names(char **, int, struct cd_toc_entry *); |
void verify_track_names(char **, int, struct cd_toc_entry *); |
char * safe_copy(const char *); |
char * safe_copy(const char *); |
|
|
unsigned long |
unsigned long |
cddb_sum(unsigned long v) |
cddb_sum(unsigned long v) |
|
|
return (sum); |
return (sum); |
} |
} |
|
|
unsigned long |
unsigned long |
cddb_discid(int n, struct cd_toc_entry *e) |
cddb_discid(int n, struct cd_toc_entry *e) |
{ |
{ |
unsigned long sum; |
unsigned long sum; |
int i; |
int i; |
|
|
sum = 0; |
sum = 0; |
for (i =0; i < n; i++) |
for (i =0; i < n; i++) |
sum += cddb_sum(entry2time(e+i)); |
sum += cddb_sum(entry2time(e+i)); |
return (((sum % 0xff) << 24) | |
return (((sum % 0xff) << 24) | |
((entry2time(e+n) - entry2time(e)) << 8) | n); |
((entry2time(e+n) - entry2time(e)) << 8) | n); |
} |
} |
|
|
|
|
|
|
if (gethostname(hostname, sizeof(hostname)) == -1) |
if (gethostname(hostname, sizeof(hostname)) == -1) |
strcpy(hostname, "unknown"); |
strcpy(hostname, "unknown"); |
fprintf(cout, "CDDB HELLO %s %s cdio " VERSION "\r\n", |
fprintf(cout, "CDDB HELLO %s %s cdio " VERSION "\r\n", |
getlogin(), hostname); |
getlogin(), hostname); |
fflush(cout); |
fflush(cout); |
} |
} |
|
|
void |
void |
send_query(FILE *f, int n, struct cd_toc_entry *e) |
send_query(FILE *f, int n, struct cd_toc_entry *e) |
{ |
{ |
int i; |
int i; |
|
|
} |
} |
} |
} |
|
|
char ** |
char ** |
cddb(const char *host_port, int n, struct cd_toc_entry *e, char *arg) |
cddb(const char *host_port, int n, struct cd_toc_entry *e, char *arg) |
{ |
{ |
int s = -1; |
int s = -1; |