tin  2.4.4
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.4.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

misc.c File Reference
#include "tin.h"
#include "version.h"
#include "tcurses.h"
#include "trace.h"
#include "policy.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define BACKUP_FILE_EXT   ".b"
 
#define MAILDIR_NEW   "new"
 

Functions

static char * strfpath_cp (char *str, char *tbuf, char *endp)
 
static int _strfpath (const char *format, char *str, size_t maxsize, struct t_group *group, t_bool expand_all)
 
static int gnksa_check_domain (char *domain)
 
static int gnksa_check_domain_literal (char *domain)
 
static int gnksa_check_localpart (const char *localpart)
 
static int gnksa_dequote_plainphrase (char *realname, char *decoded, int addrtype)
 
static int strfeditor (char *editor, int linenum, const char *filename, char *s, size_t maxsize, char *format)
 
static void write_input_history_file (void)
 
char * get_tmpfilename (const char *filename)
 
void append_file (char *old_filename, char *new_filename)
 
void asfail (const char *file, int line, const char *cond)
 
t_bool copy_fp (FILE *fp_ip, FILE *fp_op)
 
t_bool backup_file (const char *filename, const char *backupname)
 
void copy_body (FILE *fp_ip, FILE *fp_op, char *prefix, char *initl, t_bool raw_data)
 
const char * get_val (const char *env, const char *def)
 
t_bool invoke_editor (const char *filename, int lineno, struct t_group *group)
 
void shell_escape (void)
 
void do_shell_escape (void)
 
void tin_done (int ret, const char *fmt,...)
 
int my_mkdir (char *path, mode_t mode)
 
void rename_file (const char *old_filename, const char *new_filename)
 
t_bool invoke_cmd (const char *nam)
 
void draw_percent_mark (long cur_num, long max_num)
 
void base_name (const char *fullpath, char *file)
 
void dir_name (const char *fullpath, char *dir)
 
t_bool mail_check (const char *mailbox_name)
 
const char * eat_re (char *s, t_bool eat_was)
 
int my_isprint (int c)
 
void get_author (t_bool thread, struct t_article *art, char *str, size_t len)
 
void toggle_inverse_video (void)
 
void show_inverse_video_status (void)
 
void create_index_lock_file (char *the_lock_file)
 
int strfquote (const char *group, int respnum, char *s, size_t maxsize, char *format)
 
int strfpath (const char *format, char *str, size_t maxsize, struct t_group *group, t_bool expand_all)
 
char * escape_shell_meta (const char *source, int quote_area)
 
int strfmailer (const char *mail_prog, char *subject, char *to, const char *filename, char *dest, size_t maxsize, const char *format)
 
int get_initials (struct t_article *art, char *s, int maxsize)
 
void get_cwd (char *buf)
 
void make_group_path (const char *name, char *path)
 
void make_base_group_path (const char *base_dir, const char *group_name, char *group_path, size_t group_path_len)
 
void cleanup_tmp_files (void)
 
long file_size (const char *file)
 
long file_mtime (const char *file)
 
char * random_organization (char *in_org)
 
void read_input_history_file (void)
 
char * quote_wild (char *str)
 
char * quote_wild_whitespace (char *str)
 
void strip_name (const char *from, char *address)
 
char * buffer_to_ascii (char *c)
 
void process_charsets (char **line, size_t *max_line_len, const char *network_charset, const char *local_charset, t_bool conv_tex2iso)
 
const char * gnksa_strerror (int errcode)
 
int gnksa_split_from (const char *from, char *address, char *realname, int *addrtype)
 
int gnksa_do_check_from (const char *from, char *address, char *realname)
 
int gnksa_check_from (char *from)
 
int parse_from (const char *from, char *address, char *realname)
 
char * strip_line (char *line)
 
char * idna_decode (char *in)
 
int tin_version_info (FILE *fp)
 
void draw_mark_selected (int i)
 
int tin_gettime (struct t_tintime *tt)
 

Variables

static char gnksa_legal_fqdn_chars [256]
 
static char gnksa_legal_localpart_chars [256]
 
static char gnksa_legal_realname_chars [256]
 

Macro Definition Documentation

◆ BACKUP_FILE_EXT

#define BACKUP_FILE_EXT   ".b"

Definition at line 370 of file misc.c.

◆ MAILDIR_NEW

#define MAILDIR_NEW   "new"

Definition at line 909 of file misc.c.

Function Documentation

◆ _strfpath()

static int _strfpath ( const char *  format,
char *  str,
size_t  maxsize,
struct t_group group,
t_bool  expand_all 
)
static

◆ append_file()

void append_file ( char *  old_filename,
char *  new_filename 
)

Definition at line 120 of file misc.c.

References _, copy_fp(), perror_message(), and txt_cannot_open.

Referenced by post_loop().

◆ asfail()

void asfail ( const char *  file,
int  line,
const char *  cond 
)

Definition at line 142 of file misc.c.

References giveup(), my_fflush, my_fprintf, process_id, sigdisp, tin_progname, and txt_error_asfail.

◆ backup_file()

t_bool backup_file ( const char *  filename,
const char *  backupname 
)

◆ base_name()

void base_name ( const char *  fullpath,
char *  file 
)

Definition at line 868 of file misc.c.

References DIRSEP.

Referenced by dir_name(), expand_save_filename(), main(), and post_process_uud().

◆ buffer_to_ascii()

char* buffer_to_ascii ( char *  c)

Definition at line 2610 of file misc.c.

Referenced by parse_header(), parse_headers(), process_charsets(), and read_overview().

◆ cleanup_tmp_files()

void cleanup_tmp_files ( void  )

Definition at line 2105 of file misc.c.

References batch_mode, lock_file, and unlink.

Referenced by signal_handler(), and tin_done().

◆ copy_body()

void copy_body ( FILE *  fp_ip,
FILE *  fp_op,
char *  prefix,
char *  initl,
t_bool  raw_data 
)

◆ copy_fp()

◆ create_index_lock_file()

void create_index_lock_file ( char *  the_lock_file)

Definition at line 1127 of file misc.c.

References _, atoi(), buf, error_message(), giveup(), process_id, S_IRUSR, S_IWUSR, tin_progname, and txt_filesystem_full.

Referenced by update_index_files().

◆ dir_name()

void dir_name ( const char *  fullpath,
char *  dir 
)

Definition at line 889 of file misc.c.

References base_name(), my_strdup(), and strrstr().

Referenced by dot_lock().

◆ do_shell_escape()

void do_shell_escape ( void  )

◆ draw_mark_selected()

void draw_mark_selected ( int  i)

◆ draw_percent_mark()

void draw_percent_mark ( long  cur_num,
long  max_num 
)

◆ eat_re()

const char* eat_re ( char *  s,
t_bool  eat_was 
)

◆ escape_shell_meta()

char* escape_shell_meta ( const char *  source,
int  quote_area 
)

Definition at line 1727 of file misc.c.

References buf, dbl_quote, no_quote, PATH_LEN, and sgl_quote.

Referenced by expand_mailcap_meta(), process_url(), and strfmailer().

◆ file_mtime()

long file_mtime ( const char *  file)

Definition at line 2136 of file misc.c.

References S_ISREG.

Referenced by mail_loop(), and post_loop().

◆ file_size()

◆ get_author()

void get_author ( t_bool  thread,
struct t_article art,
char *  str,
size_t  len 
)

◆ get_cwd()

void get_cwd ( char *  buf)

Definition at line 2047 of file misc.c.

References buf, and PATH_LEN.

Referenced by msg_write_signature(), rc_update(), read_art_headers(), read_config_file(), and thrashdir().

◆ get_initials()

int get_initials ( struct t_article art,
char *  s,
int  maxsize 
)

Definition at line 1995 of file misc.c.

References art, FALSE, my_malloc, PATH_LEN, STRCPY, and TRUE.

Referenced by build_sline(), build_tline(), mail_to_author(), and post_response().

◆ get_tmpfilename()

char* get_tmpfilename ( const char *  filename)

◆ get_val()

const char* get_val ( const char *  env,
const char *  def 
)

Definition at line 355 of file misc.c.

Referenced by init_selfinfo(), invoke_editor(), nntp_open(), read_keymap_file(), shell_escape(), and usage().

◆ gnksa_check_domain()

◆ gnksa_check_domain_literal()

static int gnksa_check_domain_literal ( char *  domain)
static

◆ gnksa_check_from()

int gnksa_check_from ( char *  from)

Definition at line 3571 of file misc.c.

References gnksa_do_check_from(), and HEADER_LEN.

Referenced by check_article_to_be_posted(), insert_from_header(), and mail_to_author().

◆ gnksa_check_localpart()

static int gnksa_check_localpart ( const char *  localpart)
static

◆ gnksa_dequote_plainphrase()

static int gnksa_dequote_plainphrase ( char *  realname,
char *  decoded,
int  addrtype 
)
static

◆ gnksa_do_check_from()

int gnksa_do_check_from ( const char *  from,
char *  address,
char *  realname 
)

◆ gnksa_split_from()

int gnksa_split_from ( const char *  from,
char *  address,
char *  realname,
int *  addrtype 
)

◆ gnksa_strerror()

◆ idna_decode()

char* idna_decode ( char *  in)

Definition at line 3758 of file misc.c.

References debug, DEBUG_MISC, FreeIfNeeded, my_malloc, my_strdup(), strstr(), and wait_message().

Referenced by cook_article(), draw_page_header(), and get_author().

◆ invoke_cmd()

◆ invoke_editor()

◆ mail_check()

t_bool mail_check ( const char *  mailbox_name)

Definition at line 911 of file misc.c.

References buf, CLOSEDIR, DIR_BUF, FALSE, joinpath(), MAILDIR_NEW, my_malloc, S_IFMT, and TRUE.

Referenced by feed_articles(), and show_title().

◆ make_base_group_path()

void make_base_group_path ( const char *  base_dir,
const char *  group_name,
char *  group_path,
size_t  group_path_len 
)

◆ make_group_path()

void make_group_path ( const char *  name,
char *  path 
)

Definition at line 2067 of file misc.c.

References name.

Referenced by _strfpath(), check_start_save_any_news(), make_base_group_path(), and open_art_fp().

◆ my_isprint()

int my_isprint ( int  c)

Definition at line 986 of file misc.c.

References IS_LOCAL_CHARSET.

Referenced by convert_to_printable(), draw_pager_line(), expand_ctrl_chars(), tin_getline(), and toggle_raw().

◆ my_mkdir()

int my_mkdir ( char *  path,
mode_t  mode 
)

◆ parse_from()

int parse_from ( const char *  from,
char *  address,
char *  realname 
)

Definition at line 3586 of file misc.c.

References gnksa_do_check_from().

Referenced by find_reply_to_addr(), parse_headers(), and read_overview().

◆ process_charsets()

void process_charsets ( char **  line,
size_t *  max_line_len,
const char *  network_charset,
const char *  local_charset,
t_bool  conv_tex2iso 
)

◆ quote_wild()

char* quote_wild ( char *  str)

Definition at line 2304 of file misc.c.

References LEN, tinrc, and t_config::wildcard.

Referenced by add_filter_rule().

◆ quote_wild_whitespace()

char* quote_wild_whitespace ( char *  str)

Definition at line 2340 of file misc.c.

References LEN, tinrc, and t_config::wildcard.

Referenced by add_filter_rule(), and get_search_pattern().

◆ random_organization()

char* random_organization ( char *  in_org)

◆ read_input_history_file()

void read_input_history_file ( void  )

◆ rename_file()

◆ shell_escape()

◆ show_inverse_video_status()

void show_inverse_video_status ( void  )

◆ strfeditor()

static int strfeditor ( char *  editor,
int  linenum,
const char *  filename,
char *  s,
size_t  maxsize,
char *  format 
)
static

Definition at line 1329 of file misc.c.

References PATH_LEN, and STRCPY.

Referenced by invoke_editor().

◆ strfmailer()

int strfmailer ( const char *  mail_prog,
char *  subject,
char *  to,
const char *  filename,
char *  dest,
size_t  maxsize,
const char *  format 
)

◆ strfpath()

◆ strfpath_cp()

static char * strfpath_cp ( char *  str,
char *  tbuf,
char *  endp 
)
static

Definition at line 1439 of file misc.c.

Referenced by _strfpath().

◆ strfquote()

int strfquote ( const char *  group,
int  respnum,
char *  s,
size_t  maxsize,
char *  format 
)

◆ strip_line()

char* strip_line ( char *  line)

◆ strip_name()

void strip_name ( const char *  from,
char *  address 
)

Definition at line 2368 of file misc.c.

References gnksa_do_check_from(), HEADER_LEN, and name.

Referenced by address_in_list(), get_recipients(), and save_and_process_art().

◆ tin_done()

◆ tin_gettime()

int tin_gettime ( struct t_tintime tt)

Definition at line 4134 of file misc.c.

References t_tintime::tv_nsec, and t_tintime::tv_sec.

Referenced by show_progress().

◆ tin_version_info()

int tin_version_info ( FILE *  fp)

Definition at line 3871 of file misc.c.

References _, pcre_version(), PRODUCT, RELEASEDATE, RELEASENAME, and VERSION.

Referenced by mail_bug_report(), and read_cmd_line_options().

◆ toggle_inverse_video()

void toggle_inverse_video ( void  )

Definition at line 1058 of file misc.c.

References bool_not, t_config::draw_arrow, FALSE, t_config::inverse_okay, tinrc, and TRUE.

Referenced by group_page(), selection_page(), show_page(), and thread_page().

◆ write_input_history_file()

static void write_input_history_file ( void  )
static

Variable Documentation

◆ gnksa_legal_fqdn_chars

char gnksa_legal_fqdn_chars[256]
static
Initial value:
= {
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,0,
1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0,
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
}

Definition at line 2735 of file misc.c.

Referenced by gnksa_check_domain().

◆ gnksa_legal_localpart_chars

char gnksa_legal_localpart_chars[256]
static
Initial value:
= {
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,1,0,1, 1,1,1,1, 0,0,1,1, 0,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,0,0, 0,1,0,1,
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
}

Definition at line 2760 of file misc.c.

Referenced by gnksa_check_localpart().

◆ gnksa_legal_realname_chars

char gnksa_legal_realname_chars[256]
static
Initial value:
= {
0,0,0,0, 0,0,0,0, 0,0,1,0, 0,1,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
}

Definition at line 2786 of file misc.c.

Referenced by gnksa_dequote_plainphrase().