1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
/* util3.c
*/
/* This software is copyrighted as detailed in the LICENSE file. */
#include <stdio.h>
#include "config.h"
#include "config2.h"
#include "typedef.h"
#include "EXTERN.h"
#include "config.h"
#include "config2.h"
#include "nntpclient.h"
#include "util2.h"
#include "INTERN.h"
#include "util3.h"
char* sh = NULL;
bool export_nntp_fds = FALSE;
#ifdef SUPPORT_NNTP
char* nntp_password;
#endif
int
doshell(sh,cmd)
char* sh;
char* cmd;
{
return system(cmd);
}
void
finalize(num)
int num;
{
#ifdef SUPPORT_NNTP
nntp_close(TRUE);
#endif
exit(num);
}
static char nomem[] = "trn: out of memory!\n";
/* paranoid version of malloc */
#ifndef USE_DEBUGGING_MALLOC
char*
safemalloc(size)
MEM_SIZE size;
{
char* ptr;
ptr = malloc(size ? size : (MEM_SIZE)1);
if (!ptr) {
fputs(nomem,stdout);
finalize(1);
}
return ptr;
}
#endif
/* paranoid version of realloc. If where is NULL, call malloc */
#ifndef USE_DEBUGGING_MALLOC
char*
saferealloc(where,size)
char* where;
MEM_SIZE size;
{
char* ptr;
ptr = realloc(where, size ? size : (MEM_SIZE)1);
if (!ptr) {
fputs(nomem,stdout);
finalize(1);
}
return ptr;
}
#endif
char*
dointerp(dest, destsize, pattern, stoppers, cmd)
char* dest;
int destsize;
char* pattern;
char* stoppers;
char* cmd;
{
extern char* dotdir;
if (*pattern == '%' && pattern[1] == '.') {
int len = strlen(dotdir);
safecpy(dest, dotdir, destsize);
if (len < destsize)
safecpy(dest+len, pattern+2, destsize - len);
}
else
safecpy(dest, pattern, destsize);
return stoppers; /* This is wrong on purpose */
}
#ifdef SUPPORT_NNTP
int
nntp_handle_nested_lists()
{
fputs("Programming error! Nested NNTP calls detected.\n",stderr);
return -1;
}
#endif
#ifdef SUPPORT_NNTP
char*
get_auth_user()
{
extern char* nntp_auth_file;
return read_auth_file(nntp_auth_file, &nntp_password);
}
#endif
#ifdef SUPPORT_NNTP
char*
get_auth_pass()
{
return nntp_password;
}
#endif
#if defined(USE_GENAUTH) && defined(SUPPORT_NNTP)
char*
get_auth_command()
{
return NULL;
}
#endif
|