Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/dll/nap/dragonap/napi/napi.h
1074 views
1
/*
2
napster code base by Drago ([email protected])
3
released: 11-30-99
4
*/
5
6
#include <stdio.h>
7
#include <errno.h>
8
#include "commands.h"
9
10
#ifndef NAPI_H
11
#define NAPI_H
12
13
int n_serverfd;
14
int n_connectionspeed;
15
int n_dataport;
16
17
#define N_DEBUG
18
#define N_DISTRO_SERVER "server.napster.com"
19
#define N_DISTRO_SERVER_PORT 8875
20
21
/* Error faculty */
22
#define n_Error(fmt, args...) \
23
do { \
24
fprintf(stderr, "E:%s:%s():%d:%s:", __FILE__, __FUNCTION__, __LINE__, strerror(errno)); \
25
fprintf(stderr, fmt, ## args); \
26
fprintf(stderr, "\n"); \
27
} while (0)
28
29
/* Debug faculty.....duh? */
30
#ifdef N_DEBUG
31
# define n_Debug(fmt, args...) \
32
do { \
33
fprintf(stderr, "D:%s:%s():%d:", __FILE__, __FUNCTION__, __LINE__); \
34
fprintf(stderr, fmt, ## args); \
35
fprintf(stderr, "\n"); \
36
} while (0)
37
#else
38
# define n_Debug(fmt, args...) (void)0
39
#endif
40
41
typedef struct {
42
char address[100];
43
int port;
44
} _N_SERVER;
45
46
typedef struct {
47
char username[100];
48
char password[100];
49
} _N_AUTH;
50
51
typedef unsigned char _N_CMD;
52
53
typedef struct {
54
_N_CMD cmd[4];
55
char *data;
56
} _N_COMMAND;
57
58
typedef struct {
59
int libraries;
60
int gigs;
61
int songs;
62
} _N_STATS;
63
64
/* Get a napster server */
65
_N_SERVER *n_GetServer(void);
66
67
/* Connect to a napster server */
68
int n_Connect(_N_SERVER *, _N_AUTH *);
69
70
/* nslookup helper function */
71
char *n_nslookup(char *addr);
72
73
/* Send a napster command */
74
void n_SendCommand(_N_CMD, char *, ...);
75
76
/* Send raw napster data */
77
int n_Send(char *, int);
78
79
/* This is the main napster loop */
80
int n_Loop(void);
81
82
/* Command handler */
83
_N_COMMAND *n_GetCommand(void);
84
85
/* Force a read of X bytes */
86
int n_ReadCount(char *, int);
87
88
/* MOTD hook handling */
89
void (*n_HookMotd)(char *);
90
void n_SetMotdHook(void (*)(char *));
91
92
/* Stats hook handling */
93
void (*n_HookStats)(_N_STATS *);
94
void n_SetStatsHook(void (*)(_N_STATS *));
95
96
void n_DoCommand(void);
97
void n_HandleCommand(_N_COMMAND *);
98
99
#endif
100
101