Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

flt_nntp.c File Reference

#include "config.h"
#include "defines.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include "cf_pthread.h"
#include "hashlib.h"
#include "utils.h"
#include "configparser.h"
#include "readline.h"
#include "fo_server.h"
#include "charconvert.h"
#include "serverlib.h"

Go to the source code of this file.

Defines

#define flt_nntp_syntax_error()   writen(sock,"501 command syntax error\015\012",26)
#define flt_nntp_cleanup_req()
#define CtoI(n)   (n-'0')
#define days_in_year(y)   ((y) % 4 ? 365 : (y) % 100 ? 366 : (y) % 400 ? 365 : 366)
#define flt_nntp_is_delim(c)   (isspace(c) || (c) == ':' || (c) == '=')

Functions

u_char * html_decode (const u_char *str)
int flt_nntp_tokenize (u_char *line, u_char ***tokens)
time_t flt_nntp_parse_date (u_char *t1, u_char *t2)
int flt_nntp_set_us_up_the_socket (struct sockaddr_in *addr)
int flt_nntp_get_article_pointer (t_thread **t, t_posting **p, long *anum, long num)
int flt_nntp_count (void)
long flt_nntp_count_newlines (const t_posting *p1)
void flt_nntp_send_body (const t_thread *t, const t_posting *p, int sock, int dot)
void flt_nntp_send_headers (const t_thread *t, const t_posting *p1, int sock, long anum, int newline)
void send_new_news (int sock, time_t date)
void flt_nntp_handle_request (int sock)
int flt_nntp_run (int main_sock)
int flt_nntp_handle_command (t_configfile *cf, t_conf_opt *opt, u_char **args, int argnum)
void flt_nntp_cleanup (void)

Variables

sockaddr_in * NNTP_Addr = NULL
t_conf_opt flt_nntp_config []
t_handler_config flt_nntp_handlers []
t_module_config flt_nntp


Detailed Description

Author:
Christian Kruse Implementation of the NNTP stack for the selfforum

Todo:
Implement good message id parsing

Define posting handling

Implement XOVER

Definition in file flt_nntp.c.


Define Documentation

#define CtoI  )     (n-'0')
 

same as atoi() just for a u_char, not for a u_char *

Definition at line 67 of file flt_nntp.c.

#define days_in_year  )     ((y) % 4 ? 365 : (y) % 100 ? 366 : (y) % 400 ? 365 : 366)
 

calculate how many days the year has

Definition at line 70 of file flt_nntp.c.

 
#define flt_nntp_cleanup_req  ) 
 

Value:

do { \
  while(tnum--) free(tokens[tnum]); \
  free(tokens); \
  free(line); \
} while(0)
free tokens and line

Definition at line 60 of file flt_nntp.c.

#define flt_nntp_is_delim  )     (isspace(c) || (c) == ':' || (c) == '=')
 

check if character is an delimiter

Definition at line 73 of file flt_nntp.c.

 
#define flt_nntp_syntax_error  )     writen(sock,"501 command syntax error\015\012",26)
 

I am lazy...

Definition at line 57 of file flt_nntp.c.


Function Documentation

void flt_nntp_cleanup void   ) 
 

This function cleans up the plugin (e.g. it frees allocated memory, it closes the server socket, etc)

Definition at line 1039 of file flt_nntp.c.

int flt_nntp_count void   ) 
 

This function counts the existing articles

Returns:
The number of existing articles

Definition at line 361 of file flt_nntp.c.

long flt_nntp_count_newlines const t_posting p1  ) 
 

This function counts the newlines in a posting text

Parameters:
p1 A pointer to the posting in which we shall count
Returns:
The number of newlines

Definition at line 388 of file flt_nntp.c.

int flt_nntp_get_article_pointer t_thread **  t,
t_posting **  p,
long *  anum,
long  num
 

This function gets the article pointer specified by the article number

Parameters:
t A pointer to the actual thread structure
p A pointer to the actual posting structure
anum The actual article number
num The wanted article number
Returns:
0 on success, -1 on failure

Definition at line 295 of file flt_nntp.c.

int flt_nntp_handle_command t_configfile cf,
t_conf_opt opt,
u_char **  args,
int  argnum
 

This function handles a configuration command

Parameters:
cf The configfile structure
opt The configuration option entry
arg1 The first command argument
arg2 The second command argument
arg3 The third command argument
Returns:
!= 0 on failure, 0 on success

Definition at line 1004 of file flt_nntp.c.

void flt_nntp_handle_request int  sock  ) 
 

This function handles a session

Parameters:
sock The client socket

Definition at line 616 of file flt_nntp.c.

time_t flt_nntp_parse_date u_char *  t1,
u_char *  t2
 

This function parses a RFC977 date

Parameters:
t1 The day-month-year piece
t2 The hour-min-sec piece
Returns:
(time_t)-1 on failure, the date on success

Definition at line 172 of file flt_nntp.c.

int flt_nntp_run int  main_sock  ) 
 

This function creates the server socket and initializes the plugin

Parameters:
main_sock The main socket of the server (not needed)
Returns:
FLT_OK on success, FLT_EXIT on failure

Definition at line 967 of file flt_nntp.c.

void flt_nntp_send_body const t_thread t,
const t_posting p,
int  sock,
int  dot
 

This function prepares and sends a posting body

Parameters:
t The thread structure of the posting
p The posting structure of the posting which we shall send
sock The client socket
dot Shall we terminate with a '.'? If yes, 1, if no, 0

Definition at line 404 of file flt_nntp.c.

void flt_nntp_send_headers const t_thread t,
const t_posting p1,
int  sock,
long  anum,
int  newline
 

This function sends the headers of an article

Parameters:
t The thread structure of the article to send
p1 The posting structure of the article to send
sock The client socket
anum The number of the article
newline Shall we terminate the header with an empty line?

Definition at line 496 of file flt_nntp.c.

int flt_nntp_set_us_up_the_socket struct sockaddr_in *  addr  ) 
 

This function creates the socket the server is listening to

Parameters:
addr A pointer to the socket address structure
Returns:
-1 on failure, the socket on success

Definition at line 243 of file flt_nntp.c.

int flt_nntp_tokenize u_char *  line,
u_char ***  tokens
 

This function tokenizes a NNTP command line read from the client

Parameters:
line The line read
tokens A reference to a u_char **; this function will allocated a vector containing all tokens
Returns:
The number of tokens

Definition at line 136 of file flt_nntp.c.

void send_new_news int  sock,
time_t  date
 

This function sends the news specified by a NEWNEWS command

Parameters:
sock The client socket
date The date of the last received posting

Definition at line 579 of file flt_nntp.c.


Variable Documentation

t_module_config flt_nntp
 

Initial value:

Module configuration

Definition at line 1069 of file flt_nntp.c.

t_conf_opt flt_nntp_config[]
 

Initial value:

 {
  { "NNTPPort",      flt_nntp_handle_command, NULL },
  { "NNTPInterface", flt_nntp_handle_command, NULL },
  { "NNTPHost",      flt_nntp_handle_command, NULL },
  { "NNTPMayPost",   flt_nntp_handle_command, NULL },
  { "NNTPGroupName", flt_nntp_handle_command, NULL },
  { NULL, NULL, NULL }
}
The configuration options provided by this plugin

Definition at line 1049 of file flt_nntp.c.

t_handler_config flt_nntp_handlers[]
 

Initial value:

 {
  { INIT_HANDLER, flt_nntp_run },
  { 0, NULL }
}
The handler hooks defined by this plugin

Definition at line 1061 of file flt_nntp.c.

struct sockaddr_in* NNTP_Addr = NULL
 

The address structure the server listens on

Definition at line 82 of file flt_nntp.c.


Generated on Sun Apr 25 16:37:39 2004 for Classic Forum by doxygen 1.3.5