repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
|---|---|---|
openwengo/qmail-ldap
|
ipalloc.c
|
<reponame>openwengo/qmail-ldap<gh_stars>10-100
#include "alloc.h"
#include "gen_allocdefs.h"
#include "ip.h"
#include "ipalloc.h"
GEN_ALLOC_readyplus(ipalloc,struct ip_mx,ix,len,a,i,n,x,10,ipalloc_readyplus)
GEN_ALLOC_append(ipalloc,struct ip_mx,ix,len,a,i,n,x,10,ipalloc_readyplus,ipalloc_append)
|
openwengo/qmail-ldap
|
auto_qmail.h
|
<filename>auto_qmail.h<gh_stars>10-100
#ifndef AUTO_QMAIL_H
#define AUTO_QMAIL_H
extern char auto_qmail[];
#endif
|
openwengo/qmail-ldap
|
ip.h
|
#ifndef IP_H
#define IP_H
struct ip_address { unsigned char d[4]; } ;
extern unsigned int ip_fmt(char *, struct ip_address *);
#define IPFMT 19
extern unsigned int ip_scan(const char *, struct ip_address *);
extern unsigned int ip_scanbracket(const char *, struct ip_address *);
#endif
|
openwengo/qmail-ldap
|
readsubdir.h
|
<reponame>openwengo/qmail-ldap
#ifndef READSUBDIR_H
#define READSUBDIR_H
#include "direntry.h"
typedef struct readsubdir
{
DIR *dir;
unsigned int pos;
const char *name;
void (*pause)();
}
readsubdir;
extern void readsubdir_init(readsubdir *, const char *, void (*)());
extern int readsubdir_next(readsubdir *, unsigned long *);
#define READSUBDIR_NAMELEN 10
#endif
|
openwengo/qmail-ldap
|
auto_usera.h
|
<gh_stars>10-100
#ifndef AUTO_USERA_H
#define AUTO_USERA_H
extern char auto_usera[];
#endif
|
openwengo/qmail-ldap
|
condredirect.c
|
<reponame>openwengo/qmail-ldap<filename>condredirect.c
#include <unistd.h>
#include "sig.h"
#include "readwrite.h"
#include "exit.h"
#include "env.h"
#include "error.h"
#include "fork.h"
#include "wait.h"
#include "seek.h"
#include "qmail.h"
#include "strerr.h"
#include "substdio.h"
#include "fmt.h"
#define FATAL "condredirect: fatal: "
struct qmail qqt;
int mywrite(fd,buf,len) int fd; char *buf; int len;
{
qmail_put(&qqt,buf,len);
return len;
}
char inbuf[SUBSTDIO_INSIZE];
char outbuf[1];
substdio ssin = SUBSTDIO_FDBUF(subread,0,inbuf,sizeof inbuf);
substdio ssout = SUBSTDIO_FDBUF(mywrite,-1,outbuf,sizeof outbuf);
char num[FMT_ULONG];
int main(argc,argv)
int argc;
char **argv;
{
char *sender;
char *dtline;
int pid;
int wstat;
const char *qqx;
if (!argv[1] || !argv[2])
strerr_die1x(100,"condredirect: usage: condredirect newaddress program [ arg ... ]");
pid = fork();
if (pid == -1)
strerr_die2sys(111,FATAL,"unable to fork: ");
if (pid == 0) {
execvp(argv[2],argv + 2);
if (error_temp(errno)) _exit(111);
_exit(100);
}
if (wait_pid(&wstat,pid) == -1)
strerr_die2x(111,FATAL,"wait failed");
if (wait_crashed(wstat))
strerr_die2x(111,FATAL,"child crashed");
switch(wait_exitcode(wstat)) {
case 0: break;
case 111: strerr_die2x(111,FATAL,"temporary child error");
default: _exit(0);
}
if (seek_begin(0) == -1)
strerr_die2sys(111,FATAL,"unable to rewind: ");
sig_pipeignore();
sender = env_get("SENDER");
if (!sender) strerr_die2x(100,FATAL,"SENDER not set");
dtline = env_get("DTLINE");
if (!dtline) strerr_die2x(100,FATAL,"DTLINE not set");
if (qmail_open(&qqt) == -1)
strerr_die2sys(111,FATAL,"unable to fork: ");
qmail_puts(&qqt,dtline);
if (substdio_copy(&ssout,&ssin) != 0)
strerr_die2sys(111,FATAL,"unable to read message: ");
substdio_flush(&ssout);
num[fmt_ulong(num,qmail_qp(&qqt))] = 0;
qmail_from(&qqt,sender);
qmail_to(&qqt,argv[1]);
qqx = qmail_close(&qqt);
if (*qqx) strerr_die2x(*qqx == 'D' ? 100 : 111,FATAL,qqx + 1);
strerr_die2x(99,"condredirect: qp ",num);
/* NOTREACHED */
return 1;
}
|
openwengo/qmail-ldap
|
constmap.c
|
<filename>constmap.c<gh_stars>10-100
#include "constmap.h"
#include "alloc.h"
#include "case.h"
static constmap_hash hash(s,len)
const char *s;
unsigned int len;
{
unsigned char ch;
constmap_hash h;
h = 5381;
while (len > 0) {
ch = *s++ - 'A';
if (ch <= 'Z' - 'A') ch += 'a' - 'A';
h = ((h << 5) + h) ^ ch;
--len;
}
return h;
}
const char *constmap(cm,s,len)
struct constmap *cm;
const char *s;
unsigned int len;
{
constmap_hash h;
int pos;
h = hash(s,len);
pos = cm->first[h & cm->mask];
while (pos != -1) {
if (h == cm->hash[pos])
if (len == cm->inputlen[pos])
if (!case_diffb(cm->input[pos],len,s))
return cm->input[pos] + cm->inputlen[pos] + 1;
pos = cm->next[pos];
}
return 0;
}
int constmap_init(cm,s,len,flagcolon)
struct constmap *cm;
const char *s;
unsigned int len;
int flagcolon;
{
unsigned int i;
unsigned int j;
unsigned int k;
int pos;
constmap_hash h;
cm->num = 0;
for (j = 0;j < len;++j) if (!s[j]) ++cm->num;
if (cm->num < 0) return 0;
h = 64;
while (h && (h < cm->num)) h += h; /* XXX why is num an int */
cm->mask = h - 1;
cm->first = (int *) alloc(sizeof(int) * h);
if (cm->first) {
cm->input = (const char **) alloc(sizeof(char *) * cm->num);
if (cm->input) {
cm->inputlen = (unsigned int *) alloc(sizeof(unsigned int) * cm->num);
if (cm->inputlen) {
cm->hash = (constmap_hash *) alloc(sizeof(constmap_hash) * cm->num);
if (cm->hash) {
cm->next = (int *) alloc(sizeof(int) * cm->num);
if (cm->next) {
for (h = 0;h <= cm->mask;++h)
cm->first[h] = -1;
pos = 0;
i = 0;
for (j = 0;j < len;++j)
if (!s[j]) {
k = j - i;
if (flagcolon) {
for (k = i;k < j;++k)
if (s[k] == ':')
break;
if (k >= j) { i = j + 1; continue; }
k -= i;
}
cm->input[pos] = s + i;
cm->inputlen[pos] = k;
h = hash(s + i,k);
cm->hash[pos] = h;
h &= cm->mask;
cm->next[pos] = cm->first[h];
cm->first[h] = pos;
++pos;
i = j + 1;
}
return 1;
}
alloc_free(cm->hash);
}
alloc_free(cm->inputlen);
}
alloc_free(cm->input);
}
alloc_free(cm->first);
}
return 0;
}
void constmap_free(cm)
struct constmap *cm;
{
alloc_free(cm->next);
alloc_free(cm->hash);
alloc_free(cm->inputlen);
alloc_free(cm->input);
alloc_free(cm->first);
cm->num = 0;
}
|
openwengo/qmail-ldap
|
myctime.h
|
<filename>myctime.h<gh_stars>10-100
#ifndef MYCTIME_H
#define MYCTIME_H
#include "datetime.h"
extern char *myctime(datetime_sec);
#endif
|
openwengo/qmail-ldap
|
rcpthosts.h
|
<reponame>openwengo/qmail-ldap
#ifndef RCPTHOSTS_H
#define RCPTHOSTS_H
extern int rcpthosts_init(void);
extern int rcpthosts(char *, unsigned int, int);
extern int localhosts(char *, unsigned int);
#endif
|
openwengo/qmail-ldap
|
byte_zero.c
|
#include "byte.h"
void byte_zero(s,n)
void *s;
register unsigned int n;
{
char *S = (char *)s;
for (;;) {
if (!n) break; *S++ = 0; --n;
if (!n) break; *S++ = 0; --n;
if (!n) break; *S++ = 0; --n;
if (!n) break; *S++ = 0; --n;
}
}
|
openwengo/qmail-ldap
|
hfield.h
|
#ifndef HFIELD_H
#define HFIELD_H
extern unsigned int hfield_skipname(char *, unsigned int);
extern int hfield_known(char *, unsigned int);
extern int hfield_valid(char *, unsigned int);
#define H_SENDER 1
#define H_FROM 2
#define H_REPLYTO 3
#define H_TO 4
#define H_CC 5
#define H_BCC 6
#define H_DATE 7
#define H_MESSAGEID 8
#define H_SUBJECT 9
#define H_R_SENDER 10
#define H_R_FROM 11
#define H_R_REPLYTO 12
#define H_R_TO 13
#define H_R_CC 14
#define H_R_BCC 15
#define H_R_DATE 16
#define H_R_MESSAGEID 17
#define H_RETURNRECEIPTTO 18
#define H_ERRORSTO 19
#define H_APPARENTLYTO 20
#define H_RECEIVED 21
#define H_RETURNPATH 22
#define H_DELIVEREDTO 23
#define H_CONTENTLENGTH 24
#define H_CONTENTTYPE 25
#define H_CONTENTTRANSFERENCODING 26
#define H_NOTICEREQUESTEDUPONDELIVERYTO 27
#define H_MAILFOLLOWUPTO 28
#define H_NUM 29
#endif
|
openwengo/qmail-ldap
|
tryulong32.c
|
void main()
{
unsigned long u;
u = 1;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
if (!u) _exit(0);
_exit(1);
}
|
openwengo/qmail-ldap
|
str_len.c
|
<filename>str_len.c
#include "str.h"
unsigned int str_len(s)
register const char *s;
{
register const char *t;
t = s;
for (;;) {
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
}
}
|
openwengo/qmail-ldap
|
control.h
|
#ifndef CONTROL_H
#define CONTROL_H
#include "stralloc.h"
extern int control_init(void);
extern int control_readline(stralloc *, const char *);
extern int control_rldef(stralloc *, const char *, int, const char *);
extern int control_readint(int *, const char *);
extern int control_readulong(unsigned long *, const char *);
extern int control_readfile(stralloc *, const char *, int);
extern int control_readrawfile(stralloc *, const char *);
#endif
|
openwengo/qmail-ldap
|
sig_term.c
|
<reponame>openwengo/qmail-ldap<filename>sig_term.c
#include <signal.h>
#include "sig.h"
void sig_termblock(void) { sig_block(SIGTERM); }
void sig_termunblock(void) { sig_unblock(SIGTERM); }
void sig_termcatch(f) void (*f)(); { sig_catch(SIGTERM,f); }
void sig_termdefault(void) { sig_catch(SIGTERM,SIG_DFL); }
|
openwengo/qmail-ldap
|
fd_copy.c
|
<reponame>openwengo/qmail-ldap<gh_stars>10-100
#include <fcntl.h>
#include <unistd.h>
#include "fd.h"
int fd_copy(to,from)
int to;
int from;
{
if (to == from) return 0;
if (fcntl(from,F_GETFL,0) == -1) return -1;
close(to);
if (fcntl(from,F_DUPFD,to) == -1) return -1;
return 0;
}
|
openwengo/qmail-ldap
|
subfdout.c
|
#include "readwrite.h"
#include "substdio.h"
#include "subfd.h"
char subfd_outbuf[SUBSTDIO_OUTSIZE];
static substdio it = SUBSTDIO_FDBUF(subwrite,1,subfd_outbuf,SUBSTDIO_OUTSIZE);
substdio *subfdout = ⁢
|
openwengo/qmail-ldap
|
constmap.h
|
#ifndef CONSTMAP_H
#define CONSTMAP_H
typedef unsigned long constmap_hash;
struct constmap {
int num;
constmap_hash mask;
constmap_hash *hash;
int *first;
int *next;
const char **input;
unsigned int *inputlen;
} ;
extern int constmap_init(struct constmap *, const char *, unsigned int, int);
extern void constmap_free(struct constmap *);
extern const char *constmap(struct constmap *, const char *, unsigned int);
#endif
|
openwengo/qmail-ldap
|
trysyslog.c
|
<filename>trysyslog.c
#include <sys/types.h>
#include <sys/time.h>
#include <syslog.h>
main()
{
openlog("foo",0,LOG_MAIL);
syslog(0,"foo");
}
|
openwengo/qmail-ldap
|
datetime_un.c
|
#include "datetime.h"
/* roughly 100x faster than mktime() */
datetime_sec datetime_untai(dt)
struct datetime *dt;
{
int year;
int day;
int mon;
year = dt->year + 1900;
mon = dt->mon;
if (mon >= 2) { mon -= 2; }
else { mon += 10; --year; }
day = (dt->mday - 1) * 10 + 5 + 306 * mon;
day /= 10;
if (day == 365) { year -= 3; day = 1460; }
else { day += 365 * (year % 4); }
year /= 4;
day += 1461 * (year % 25);
year /= 25;
if (day == 36524) { year -= 3; day = 146096; }
else { day += 36524 * (year % 4); }
year /= 4;
day += 146097 * (year - 5);
day += 11017;
return ((day * 24 + dt->hour) * 60 + dt->min) * 60 + dt->sec;
}
|
openwengo/qmail-ldap
|
digest_rmd160.h
|
/* digest_rmd160.h for QLDAP modified to use djb's stuff */
/* */
/* RMD160 */
/* */
/********************************************************************\
*
* FILE: rmd160.h
*
* CONTENTS: Header file for a sample C-implementation of the
* RIPEMD-160 hash-function.
* TARGET: any computer with an ANSI C compiler
*
* AUTHOR: <NAME>, ESAT-COSIC
* DATE: 1 March 1996
* VERSION: 1.0
*
* Copyright (c) <NAME>
* 1996, All Rights Reserved
*
\********************************************************************/
#ifndef _RMD160_H /* make sure this file is read only once */
#define _RMD160_H
/********************************************************************/
#include "uint32.h"
/* structure definitions */
typedef struct {
uint32 state[5]; /* state (ABCDE) */
uint32 length[2]; /* number of bits */
unsigned char bbuffer[64]; /* overflow buffer */
uint32 buflen; /* number of chars in bbuffer */
} RMD160_CTX;
/********************************************************************/
#define RMD160_LEN 20
/* function prototypes */
void RMD160Init(RMD160_CTX *);
void RMD160Update(RMD160_CTX *, const unsigned char *, size_t);
void RMD160Final(unsigned char [RMD160_LEN], RMD160_CTX *);
#endif /* _RMD160_H */
|
openwengo/qmail-ldap
|
received.h
|
<filename>received.h<gh_stars>10-100
#ifndef RECEIVED_H
#define RECEIVED_H
#include "qmail.h"
extern void received(struct qmail *, const char *, const char *, const char *,
const char *, const char *, const char *, const char *, const char *);
#endif
|
openwengo/qmail-ldap
|
commands.h
|
#ifndef COMMANDS_H
#define COMMANDS_H
#include "substdio.h"
struct commands {
const char *text;
void (*fun)();
void (*flush)();
} ;
extern int commands(substdio *, struct commands *);
#endif
|
openwengo/qmail-ldap
|
substdio.h
|
#ifndef SUBSTDIO_H
#define SUBSTDIO_H
typedef struct substdio {
char *x;
unsigned int p;
unsigned int n;
int fd;
int (*op)(int, void *, int);
} substdio;
#define SUBSTDIO_FDBUF(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
extern void substdio_fdbuf(substdio *, int (*)(int, void *, int), int, char *, unsigned int);
extern int substdio_flush(substdio *);
extern int substdio_put(substdio *, const char *, unsigned int);
extern int substdio_bput(substdio *, const char *, unsigned int);
extern int substdio_putflush(substdio *, const char *, unsigned int);
extern int substdio_puts(substdio *, const char *);
extern int substdio_bputs(substdio *, const char *);
extern int substdio_putsflush(substdio *, const char *);
extern int substdio_get(substdio *, char *, unsigned int);
extern int substdio_bget(substdio *, char *, unsigned int);
extern int substdio_feed(substdio *);
extern char *substdio_peek(substdio *);
extern void substdio_seek(substdio *, unsigned int);
#define substdio_fileno(s) ((s)->fd)
#define SUBSTDIO_INSIZE 8192
#define SUBSTDIO_OUTSIZE 8192
#define substdio_PEEK(s) ( (s)->x + (s)->n )
#define substdio_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
#define substdio_BPUTC(s,c) \
( ((s)->n != (s)->p) \
? ( (s)->x[(s)->p++] = (c), 0 ) \
: substdio_bput((s),&(c),1) \
)
extern int substdio_copy(substdio *, substdio *);
#endif
|
openwengo/qmail-ldap
|
sig_bug.c
|
<filename>sig_bug.c
#include <signal.h>
#include "sig.h"
void sig_bugcatch(f) void (*f)();
{
sig_catch(SIGILL,f);
sig_catch(SIGABRT,f);
sig_catch(SIGFPE,f);
sig_catch(SIGBUS,f);
sig_catch(SIGSEGV,f);
#ifdef SIGSYS
sig_catch(SIGSYS,f);
#endif
#ifdef SIGEMT
sig_catch(SIGEMT,f);
#endif
}
|
openwengo/qmail-ldap
|
spawn.c
|
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "readwrite.h"
#include "alloc.h"
#include "sig.h"
#include "wait.h"
#include "substdio.h"
#include "byte.h"
#include "str.h"
#include "stralloc.h"
#include "select.h"
#include "exit.h"
#include "coe.h"
#include "open.h"
#include "error.h"
#include "auto_qmail.h"
#include "auto_uids.h"
#include "auto_spawn.h"
extern unsigned int truncreport;
extern int spawn();
extern void report();
extern void initialize();
int flagreinit = 0;
struct delivery
{
int used;
int fdin; /* pipe input */
int pid; /* zero if child is dead */
int wstat; /* if !pid: status of child */
int fdout; /* pipe output, -1 if !pid; delays eof until after death */
stralloc output;
#ifdef DEBUG
stralloc log;
#endif
}
;
struct delivery *d;
void sigchld()
{
int wstat;
int pid;
unsigned int i;
while ((pid = wait_nohang(&wstat)) > 0)
for (i = 0;i < auto_spawn;++i) if (d[i].used)
if (d[i].pid == pid)
{
close(d[i].fdout); d[i].fdout = -1;
d[i].wstat = wstat; d[i].pid = 0;
}
}
int flagwriting = 1;
int okwrite(fd,buf,n) int fd; char *buf; int n;
{
int w;
if (!flagwriting) return n;
w = write(fd,buf,n);
if (w != -1) return w;
if (errno == error_intr) return -1;
flagwriting = 0; close(fd);
return n;
}
int flagreading = 1;
char outbuf[1024]; substdio ssout;
int stage = 0; /* reading 0:delnum 1:delnum2 2:messid 3:sender 4:recip */
int flagabort = 0; /* if 1, everything except delnum is garbage */
unsigned int delnum;
stralloc messid = {0};
stralloc sender = {0};
stralloc recip = {0};
void err(s) char *s;
{
unsigned char ch;
ch = delnum; substdio_put(&ssout,&ch,1);
ch = delnum >> 8; substdio_put(&ssout,&ch,1);
substdio_puts(&ssout,s); substdio_putflush(&ssout,"",1);
}
void docmd()
{
int f;
unsigned int i;
unsigned int j;
int fdmess;
int pi[2];
struct stat st;
/* SIGHUP HANDLING */
if (delnum == 0xbeef)
if (*messid.s == '\0' && *sender.s == '\0' && *recip.s == '\0') {
#if 0
err("HHUP received\n");
#endif
flagreinit = 1;
return;
}
if (flagabort) { err("Zqmail-spawn out of memory. (#4.3.0)\n"); return; }
#if 0 /* no longer possible, delnum is unsigned */
if (delnum < 0) { err("ZInternal error: delnum negative. (#4.3.5)\n"); return; }
#endif
if (delnum >= auto_spawn) { err("ZInternal error: delnum too big. (#4.3.5)\n"); return; }
if (d[delnum].used) { err("ZInternal error: delnum in use. (#4.3.5)\n"); return; }
for (i = 0;i < messid.len;++i)
if (messid.s[i])
if (!i || (messid.s[i] != '/'))
if ((unsigned char) (messid.s[i] - '0') > 9)
{ err("DInternal error: messid has nonnumerics. (#5.3.5)\n"); return; }
if (messid.len > 100) { err("DInternal error: messid too long. (#5.3.5)\n"); return; }
if (!messid.s[0]) { err("DInternal error: messid too short. (#5.3.5)\n"); return; }
if (!stralloc_copys(&d[delnum].output,""))
{ err("Zqmail-spawn out of memory. (#4.3.0)\n"); return; }
j = byte_rchr(recip.s,recip.len,'@');
if (j >= recip.len) { err("DSorry, address must include host name. (#5.1.3)\n"); return; }
fdmess = open_read(messid.s);
if (fdmess == -1) { err("Zqmail-spawn unable to open message. (#4.3.0)\n"); return; }
if (fstat(fdmess,&st) == -1)
{ close(fdmess); err("Zqmail-spawn unable to fstat message. (#4.3.0)\n"); return; }
if ((st.st_mode & S_IFMT) != S_IFREG)
{ close(fdmess); err("ZSorry, message has wrong type. (#4.3.5)\n"); return; }
if (st.st_uid != auto_uidq) /* aaack! qmailq has to be trusted! */
/* your security is already toast at this point. damage control... */
{ close(fdmess); err("ZSorry, message has wrong owner. (#4.3.5)\n"); return; }
if (pipe(pi) == -1)
{ close(fdmess); err("Zqmail-spawn unable to create pipe. (#4.3.0)\n"); return; }
coe(pi[0]);
f = spawn(fdmess,pi[1],sender.s,recip.s,j);
close(fdmess);
if (f == -1)
{ close(pi[0]); close(pi[1]); err("Zqmail-spawn unable to fork. (#4.3.0)\n"); return; }
d[delnum].fdin = pi[0];
d[delnum].fdout = pi[1]; coe(pi[1]);
d[delnum].pid = f;
d[delnum].used = 1;
}
char cmdbuf[1024];
void getcmd()
{
int i;
int r;
unsigned char ch;
r = read(0,cmdbuf,sizeof(cmdbuf));
if (r == 0)
{ flagreading = 0; return; }
if (r == -1)
{
if (errno != error_intr)
flagreading = 0;
return;
}
for (i = 0;i < r;++i)
{
ch = cmdbuf[i];
switch(stage)
{
case 0:
delnum = ch;
stage = 1; break;
case 1:
delnum += (unsigned int)ch << 8;
messid.len = 0; stage = 2; break;
case 2:
if (!stralloc_append(&messid,&ch)) flagabort = 1;
if (ch) break;
sender.len = 0; stage = 3; break;
case 3:
if (!stralloc_append(&sender,&ch)) flagabort = 1;
if (ch) break;
recip.len = 0; stage = 4; break;
case 4:
if (!stralloc_append(&recip,&ch)) flagabort = 1;
if (ch) break;
docmd();
flagabort = 0; stage = 0; break;
}
}
}
char inbuf[128];
int main(argc,argv)
int argc;
char **argv;
{
unsigned char ch;
unsigned int i;
int r;
fd_set rfds;
int nfds;
if (chdir(auto_qmail) == -1) _exit(111);
if (chdir("queue/mess") == -1) _exit(111);
if (!stralloc_copys(&messid,"")) _exit(111);
if (!stralloc_copys(&sender,"")) _exit(111);
if (!stralloc_copys(&recip,"")) _exit(111);
d = (struct delivery *) alloc((auto_spawn + 10) * sizeof(struct delivery));
if (!d) _exit(111);
substdio_fdbuf(&ssout,okwrite,1,outbuf,sizeof(outbuf));
sig_pipeignore();
sig_childcatch(sigchld);
initialize(argc,argv);
ch = auto_spawn; substdio_put(&ssout,&ch,1);
ch = auto_spawn >> 8; substdio_putflush(&ssout,&ch,1);
for (i = 0;i < auto_spawn;++i) {
d[i].used = 0;
d[i].output.s = 0;
#ifdef DEBUG
d[i].log.s = 0;
#endif
}
for (;;)
{
if (flagreinit) {
initialize(argc,argv);
flagreinit = 0;
}
if (!flagreading)
{
for (i = 0;i < auto_spawn;++i) if (d[i].used) break;
if (i >= auto_spawn) _exit(0);
}
sig_childunblock();
FD_ZERO(&rfds);
if (flagreading) FD_SET(0,&rfds);
nfds = 1;
for (i = 0;i < auto_spawn;++i) if (d[i].used)
{ FD_SET(d[i].fdin,&rfds); if (d[i].fdin >= nfds) nfds = d[i].fdin + 1; }
r = select(nfds,&rfds,(fd_set *) 0,(fd_set *) 0,(struct timeval *) 0);
sig_childblock();
if (r != -1)
{
if (flagreading)
if (FD_ISSET(0,&rfds))
getcmd();
for (i = 0;i < auto_spawn;++i) if (d[i].used)
if (FD_ISSET(d[i].fdin,&rfds))
{
r = read(d[i].fdin,inbuf,128);
if (r == -1)
continue; /* read error on a readable pipe? be serious */
if (r == 0)
{
unsigned char c; c = i; substdio_put(&ssout,&c,1);
c = i >> 8; substdio_put(&ssout,&c,1);
report(&ssout,d[i].wstat,d[i].output.s,d[i].output.len);
substdio_put(&ssout,"",1);
substdio_flush(&ssout);
close(d[i].fdin); d[i].used = 0;
continue;
}
#ifdef DEBUG
# define IS_LOG(x) ( d[(x)].used & 0x8 )
# define LOGON(x) ( d[(x)].used |= 0x8 )
# define LOGOFF(x) ( d[(x)].used = 1 )
{
unsigned int j;
unsigned int b;
unsigned int t;
for (j=0, b=0; j < (unsigned int)r; j++) {
if (inbuf[j] == 15) {
while (!stralloc_readyplus(&d[i].output,j-b)) sleep(10); /*XXX*/
byte_copy(d[i].output.s + d[i].output.len,j-b,inbuf+b);
d[i].output.len += j-b;
LOGON(i);
b = j+1;
} else if ( inbuf[j] == 16 ) {
while (!stralloc_readyplus(&d[i].log,j-b)) sleep(10); /*XXX*/
byte_copy(d[i].log.s + d[i].log.len,j-b,inbuf+b);
d[i].log.len += j-b;
b = j+1;
LOGOFF(i);
if (truncreport > 100)
if (d[i].log.len > truncreport) {
const char *truncmess = "\nError report too long, sorry.\n";
d[i].log.len = truncreport - str_len(truncmess) - 3;
stralloc_cats(&d[i].log,truncmess);
}
ch = i; substdio_put(&ssout,&ch,1);
ch = i >> 8; substdio_put(&ssout,&ch,1);
ch = 'L'; substdio_put(&ssout,&ch,1);
for (t = 0;t < d[i].log.len; ++t) if (!d[i].log.s[t]) break;
substdio_put(&ssout,d[i].log.s,t);
substdio_put(&ssout,"",1);
substdio_flush(&ssout);
d[i].log.len = 0;
}
}
if (b == (unsigned int)r) continue;
if ( IS_LOG(i) )
{
while (!stralloc_readyplus(&d[i].log,r-b)) sleep(10); /*XXX*/
byte_copy(d[i].log.s + d[i].log.len,r-b,inbuf+b);
d[i].log.len += r-b;
}
else
{
while (!stralloc_readyplus(&d[i].output,r-b)) sleep(10); /*XXX*/
byte_copy(d[i].output.s + d[i].output.len,r-b,inbuf+b);
d[i].output.len += r-b;
if (truncreport > 100)
if (d[i].output.len > truncreport)
{
const char *truncmess = "\nError report too long, sorry.\n";
d[i].output.len = truncreport - str_len(truncmess) - 3;
stralloc_cats(&d[i].output,truncmess);
}
}
}
#else
while (!stralloc_readyplus(&d[i].output,r)) sleep(10); /*XXX*/
byte_copy(d[i].output.s + d[i].output.len,r,inbuf);
d[i].output.len += r;
if (truncreport > 100)
if (d[i].output.len > truncreport)
{
const char *truncmess = "\nError report too long, sorry.\n";
d[i].output.len = truncreport - str_len(truncmess) - 3;
stralloc_cats(&d[i].output,truncmess);
}
#endif
}
}
}
/* NOTREACHED */
return 0;
}
|
openwengo/qmail-ldap
|
readsubdir.c
|
<gh_stars>10-100
#include "readsubdir.h"
#include "fmt.h"
#include "scan.h"
#include "str.h"
#include "auto_split.h"
void readsubdir_init(rs,name,pause)
readsubdir *rs;
const char *name;
void (*pause)();
{
rs->name = name;
rs->pause = pause;
rs->dir = 0;
rs->pos = 0;
}
static char namepos[FMT_ULONG + 4 + READSUBDIR_NAMELEN];
int readsubdir_next(rs,id)
readsubdir *rs;
unsigned long *id;
{
direntry *d;
unsigned int len;
if (!rs->dir)
{
if (rs->pos >= auto_split) return 0;
if (str_len(rs->name) > READSUBDIR_NAMELEN) { rs->pos++; return -1; }
len = 0;
len += fmt_str(namepos + len,rs->name);
namepos[len++] = '/';
len += fmt_uint(namepos + len, rs->pos);
namepos[len] = 0;
while (!(rs->dir = opendir(namepos))) rs->pause(namepos);
rs->pos++;
return -1;
}
d = readdir(rs->dir);
if (!d) { closedir(rs->dir); rs->dir = 0; return -1; }
if (str_equal(d->d_name,".")) return -1;
if (str_equal(d->d_name,"..")) return -1;
len = scan_ulong(d->d_name,id);
if (!len || d->d_name[len]) return -2;
return 1;
}
|
openwengo/qmail-ldap
|
auto_split.h
|
#ifndef AUTO_SPLIT_H
#define AUTO_SPLIT_H
extern unsigned int auto_split;
#endif
|
openwengo/qmail-ldap
|
date822fmt.h
|
#ifndef DATE822FMT_H
#define DATE822FMT_H
#include "datetime.h"
extern unsigned int date822fmt(char *, struct datetime *);
#define DATE822FMT 60
#endif
|
openwengo/qmail-ldap
|
lock.h
|
#ifndef LOCK_H
#define LOCK_H
extern int lock_ex(int);
extern int lock_un(int);
extern int lock_exnb(int);
#endif
|
openwengo/qmail-ldap
|
alloc.c
|
<filename>alloc.c
#include <stdlib.h>
#include "alloc.h"
#include "error.h"
/*@null@*//*@out@*/void *alloc(n)
unsigned int n;
{
void *x;
x = malloc(n);
if (!x) errno = error_nomem;
return x;
}
void alloc_free(x)
void *x;
{
free(x);
}
|
openwengo/qmail-ldap
|
sig_pipe.c
|
<gh_stars>10-100
#include <signal.h>
#include "sig.h"
void sig_pipeignore(void) { sig_catch(SIGPIPE,SIG_IGN); }
void sig_pipedefault(void) { sig_catch(SIGPIPE,SIG_DFL); }
|
openwengo/qmail-ldap
|
sig_hup.c
|
#include <signal.h>
#include "sig.h"
void sig_hangupblock(void) { sig_block(SIGHUP); }
void sig_hangupunblock(void) { sig_unblock(SIGHUP); }
void sig_hangupcatch(f) void (*f)(); { sig_catch(SIGHUP,f); }
void sig_hangupdefault(void) { sig_catch(SIGHUP,SIG_DFL); }
|
openwengo/qmail-ldap
|
subfdouts.c
|
<filename>subfdouts.c
#include "readwrite.h"
#include "substdio.h"
#include "subfd.h"
char subfd_outbufsmall[256];
static substdio it = SUBSTDIO_FDBUF(subwrite,1,subfd_outbufsmall,256);
substdio *subfdoutsmall = ⁢
|
openwengo/qmail-ldap
|
timeoutconn.h
|
#ifndef TIMEOUTCONN_H
#define TIMEOUTCONN_H
struct ip_address;
extern int timeoutconn(int, struct ip_address *,
struct ip_address *, unsigned int, int);
#endif
|
openwengo/qmail-ldap
|
remoteinfo.h
|
#ifndef REMOTEINFO_H
#define REMOTEINFO_H
struct ip_address;
extern char *remoteinfo_get(struct ip_address *, unsigned long,
struct ip_address *, unsigned long, int);
#endif
|
openwengo/qmail-ldap
|
token822.c
|
#include "stralloc.h"
#include "alloc.h"
#include "str.h"
#include "token822.h"
#include "gen_allocdefs.h"
static struct token822 comma = { TOKEN822_COMMA };
void token822_reverse(ta)
token822_alloc *ta;
{
unsigned int i;
unsigned int n;
struct token822 temp;
if (ta->len == 0) return;
n = ta->len - 1;
for (i = 0;i + i < n;++i)
{
temp = ta->t[i];
ta->t[i] = ta->t[n - i];
ta->t[n - i] = temp;
}
}
GEN_ALLOC_ready(token822_alloc,struct token822,t,len,a,i,n,x,30,token822_ready)
GEN_ALLOC_readyplus(token822_alloc,struct token822,t,len,a,i,n,x,30,token822_readyplus)
GEN_ALLOC_append(token822_alloc,struct token822,t,len,a,i,n,x,30,token822_readyplus,token822_append)
static int needspace(t1,t2)
int t1;
int t2;
{
if (!t1) return 0;
if (t1 == TOKEN822_COLON) return 1;
if (t1 == TOKEN822_COMMA) return 1;
if (t2 == TOKEN822_LEFT) return 1;
switch(t1)
{
case TOKEN822_ATOM: case TOKEN822_LITERAL:
case TOKEN822_QUOTE: case TOKEN822_COMMENT:
switch(t2)
{
case TOKEN822_ATOM: case TOKEN822_LITERAL:
case TOKEN822_QUOTE: case TOKEN822_COMMENT:
return 1;
}
}
return 0;
}
static int atomok(ch)
char ch;
{
switch(ch)
{
case ' ': case '\t': case '\r': case '\n':
case '(': case '[': case '"':
case '<': case '>': case ';': case ':':
case '@': case ',': case '.':
return 0;
}
return 1;
}
static void atomcheck(t)
struct token822 *t;
{
unsigned int i;
char ch;
for (i = 0;i < t->slen;++i)
{
ch = t->s[i];
if ((ch < 32) || (ch > 126) || (ch == ')') || (ch == ']') || (ch == '\\'))
{
t->type = TOKEN822_QUOTE;
return;
}
}
}
int token822_unparse(sa,ta,linelen)
stralloc *sa;
token822_alloc *ta;
unsigned int linelen;
{
struct token822 *t;
unsigned int len;
int ch;
unsigned int i;
unsigned int j;
int lasttype;
int newtype;
char *s;
char *lineb;
char *linee;
len = 0;
lasttype = 0;
for (i = 0;i < ta->len;++i)
{
t = ta->t + i;
newtype = t->type;
if (needspace(lasttype,newtype))
++len;
lasttype = newtype;
switch(newtype)
{
case TOKEN822_COMMA:
len += 3; break;
case TOKEN822_AT: case TOKEN822_DOT: case TOKEN822_LEFT: case TOKEN822_RIGHT:
case TOKEN822_SEMI: case TOKEN822_COLON:
++len; break;
case TOKEN822_ATOM: case TOKEN822_QUOTE: case TOKEN822_LITERAL: case TOKEN822_COMMENT:
if (t->type != TOKEN822_ATOM) len += 2;
for (j = 0;j < t->slen;++j)
switch(ch = t->s[j])
{
case '"': case '[': case ']': case '(': case ')':
case '\\': case '\r': case '\n': ++len;
default: ++len;
}
break;
}
}
len += 2;
if (!stralloc_ready(sa,len))
return -1;
s = sa->s;
lineb = s;
linee = 0;
lasttype = 0;
for (i = 0;i < ta->len;++i)
{
t = ta->t + i;
newtype = t->type;
if (needspace(lasttype,newtype))
*s++ = ' ';
lasttype = newtype;
switch(newtype)
{
case TOKEN822_COMMA:
*s++ = ',';
#define NSUW \
s[0] = '\n'; s[1] = ' '; \
if (linee && (!linelen || ((unsigned long)(s - lineb) <= linelen))) \
{ while (linee < s) { linee[0] = linee[2]; ++linee; } linee -= 2; } \
else { if (linee) lineb = linee + 1; linee = s; s += 2; }
NSUW
break;
case TOKEN822_AT: *s++ = '@'; break;
case TOKEN822_DOT: *s++ = '.'; break;
case TOKEN822_LEFT: *s++ = '<'; break;
case TOKEN822_RIGHT: *s++ = '>'; break;
case TOKEN822_SEMI: *s++ = ';'; break;
case TOKEN822_COLON: *s++ = ':'; break;
case TOKEN822_ATOM: case TOKEN822_QUOTE: case TOKEN822_LITERAL: case TOKEN822_COMMENT:
if (t->type == TOKEN822_QUOTE) *s++ = '"';
if (t->type == TOKEN822_LITERAL) *s++ = '[';
if (t->type == TOKEN822_COMMENT) *s++ = '(';
for (j = 0;j < t->slen;++j)
switch(ch = t->s[j])
{
case '"': case '[': case ']': case '(': case ')':
case '\\': case '\r': case '\n': *s++ = '\\';
default: *s++ = ch;
}
if (t->type == TOKEN822_QUOTE) *s++ = '"';
if (t->type == TOKEN822_LITERAL) *s++ = ']';
if (t->type == TOKEN822_COMMENT) *s++ = ')';
break;
}
}
NSUW
--s;
sa->len = s - sa->s;
return 1;
}
int token822_unquote(sa,ta)
stralloc *sa;
token822_alloc *ta;
{
struct token822 *t;
unsigned int len;
unsigned int i;
unsigned int j;
char *s;
len = 0;
for (i = 0;i < ta->len;++i)
{
t = ta->t + i;
switch(t->type)
{
case TOKEN822_COMMA: case TOKEN822_AT: case TOKEN822_DOT: case TOKEN822_LEFT:
case TOKEN822_RIGHT: case TOKEN822_SEMI: case TOKEN822_COLON:
++len; break;
case TOKEN822_LITERAL:
len += 2;
case TOKEN822_ATOM: case TOKEN822_QUOTE:
len += t->slen;
}
}
if (!stralloc_ready(sa,len))
return -1;
s = sa->s;
for (i = 0;i < ta->len;++i)
{
t = ta->t + i;
switch(t->type)
{
case TOKEN822_COMMA: *s++ = ','; break;
case TOKEN822_AT: *s++ = '@'; break;
case TOKEN822_DOT: *s++ = '.'; break;
case TOKEN822_LEFT: *s++ = '<'; break;
case TOKEN822_RIGHT: *s++ = '>'; break;
case TOKEN822_SEMI: *s++ = ';'; break;
case TOKEN822_COLON: *s++ = ':'; break;
case TOKEN822_ATOM: case TOKEN822_QUOTE: case TOKEN822_LITERAL:
if (t->type == TOKEN822_LITERAL) *s++ = '[';
for (j = 0;j < t->slen;++j)
*s++ = t->s[j];
if (t->type == TOKEN822_LITERAL) *s++ = ']';
break;
case TOKEN822_COMMENT: break;
}
}
sa->len = s - sa->s;
return 1;
}
int token822_parse(ta,sa,buf)
token822_alloc *ta;
stralloc *sa;
stralloc *buf;
{
unsigned int i;
unsigned int salen;
unsigned int level;
struct token822 *t;
unsigned int numtoks;
unsigned int numchars;
char *cbuf;
salen = sa->len;
numchars = 0;
numtoks = 0;
for (i = 0;i < salen;++i)
switch(sa->s[i])
{
case '.': case ',': case '@': case '<': case '>': case ':': case ';':
++numtoks; break;
case ' ': case '\t': case '\r': case '\n': break;
case ')': case ']': return 0;
/* other control chars and non-ASCII chars are also bad, in theory */
case '(':
level = 1;
while (level)
{
if (++i >= salen) return 0;
switch(sa->s[i])
{
case '(': ++level; break;
case ')': --level; break;
case '\\': if (++i >= salen) return 0;
default: ++numchars;
}
}
++numtoks;
break;
case '"':
level = 1;
while (level)
{
if (++i >= salen) return 0;
switch(sa->s[i])
{
case '"': --level; break;
case '\\': if (++i >= salen) return 0;
default: ++numchars;
}
}
++numtoks;
break;
case '[':
level = 1;
while (level)
{
if (++i >= salen) return 0;
switch(sa->s[i])
{
case ']': --level; break;
case '\\': if (++i >= salen) return 0;
default: ++numchars;
}
}
++numtoks;
break;
default:
do
{
if (sa->s[i] == '\\') if (++i >= salen) break;
++numchars;
if (++i >= salen)
break;
}
while (atomok(sa->s[i]));
--i;
++numtoks;
}
if (!token822_ready(ta,numtoks))
return -1;
if (!stralloc_ready(buf,numchars))
return -1;
cbuf = buf->s;
ta->len = numtoks;
t = ta->t;
for (i = 0;i < salen;++i)
switch(sa->s[i])
{
case '.': t->type = TOKEN822_DOT; ++t; break;
case ',': t->type = TOKEN822_COMMA; ++t; break;
case '@': t->type = TOKEN822_AT; ++t; break;
case '<': t->type = TOKEN822_LEFT; ++t; break;
case '>': t->type = TOKEN822_RIGHT; ++t; break;
case ':': t->type = TOKEN822_COLON; ++t; break;
case ';': t->type = TOKEN822_SEMI; ++t; break;
case ' ': case '\t': case '\r': case '\n': break;
case '(':
t->type = TOKEN822_COMMENT; t->s = cbuf; t->slen = 0;
level = 1;
while (level)
{
++i; /* assert: < salen */
switch(sa->s[i])
{
case '(': ++level; break;
case ')': --level; break;
case '\\': ++i; /* assert: < salen */
default: *cbuf++ = sa->s[i]; ++t->slen;
}
}
++t;
break;
case '"':
t->type = TOKEN822_QUOTE; t->s = cbuf; t->slen = 0;
level = 1;
while (level)
{
++i; /* assert: < salen */
switch(sa->s[i])
{
case '"': --level; break;
case '\\': ++i; /* assert: < salen */
default: *cbuf++ = sa->s[i]; ++t->slen;
}
}
++t;
break;
case '[':
t->type = TOKEN822_LITERAL; t->s = cbuf; t->slen = 0;
level = 1;
while (level)
{
++i; /* assert: < salen */
switch(sa->s[i])
{
case ']': --level; break;
case '\\': ++i; /* assert: < salen */
default: *cbuf++ = sa->s[i]; ++t->slen;
}
}
++t;
break;
default:
t->type = TOKEN822_ATOM; t->s = cbuf; t->slen = 0;
do
{
if (sa->s[i] == '\\') if (++i >= salen) break;
*cbuf++ = sa->s[i]; ++t->slen;
if (++i >= salen)
break;
}
while (atomok(sa->s[i]));
atomcheck(t);
--i;
++t;
}
return 1;
}
static int gotaddr(taout,taaddr,callback)
token822_alloc *taout;
token822_alloc *taaddr;
int (*callback)();
{
unsigned int i;
if (callback(taaddr) != 1)
return 0;
if (!token822_readyplus(taout,taaddr->len))
return 0;
for (i = 0;i < taaddr->len;++i)
taout->t[taout->len++] = taaddr->t[i];
taaddr->len = 0;
return 1;
}
int token822_addrlist(taout,taaddr,ta,callback)
token822_alloc *taout;
token822_alloc *taaddr;
token822_alloc *ta;
int (*callback)();
{
struct token822 *t;
struct token822 *beginning;
int ingroup;
int wordok;
taout->len = 0;
taaddr->len = 0;
if (!token822_readyplus(taout,1)) return -1;
if (!token822_readyplus(taaddr,1)) return -1;
ingroup = 0;
wordok = 1;
beginning = ta->t + 2;
t = ta->t + ta->len - 1;
/* rfc 822 address lists are easy to parse from right to left */
#define FLUSH if (taaddr->len) if (!gotaddr(taout,taaddr,callback)) return -1;
#define FLUSHCOMMA if (taaddr->len) { \
if (!gotaddr(taout,taaddr,callback)) return -1; \
if (!token822_append(taout,&comma)) return -1; }
#define ADDRLEFT if (!token822_append(taaddr,t--)) return -1;
#define OUTLEFT if (!token822_append(taout,t--)) return -1;
while (t >= beginning)
{
switch(t->type)
{
case TOKEN822_SEMI:
FLUSHCOMMA
if (ingroup) return 0;
ingroup = 1;
wordok = 1;
break;
case TOKEN822_COLON:
FLUSH
if (!ingroup) return 0;
ingroup = 0;
while ((t >= beginning) && (t->type != TOKEN822_COMMA))
OUTLEFT
if (t >= beginning)
OUTLEFT
wordok = 1;
continue;
case TOKEN822_RIGHT:
FLUSHCOMMA
OUTLEFT
while ((t >= beginning) && (t->type != TOKEN822_LEFT))
ADDRLEFT
/* important to use address here even if it's empty: <> */
if (!gotaddr(taout,taaddr,callback)) return -1;
if (t < beginning) return 0;
OUTLEFT
while ((t >= beginning) && ((t->type == TOKEN822_COMMENT) || (t->type == TOKEN822_ATOM) || (t->type == TOKEN822_QUOTE) || (t->type == TOKEN822_AT) || (t->type == TOKEN822_DOT)))
OUTLEFT
wordok = 0;
continue;
case TOKEN822_ATOM: case TOKEN822_QUOTE: case TOKEN822_LITERAL:
if (!wordok)
FLUSHCOMMA
wordok = 0;
ADDRLEFT
continue;
case TOKEN822_COMMENT:
/* comment is lexically a space; shouldn't affect wordok */
break;
case TOKEN822_COMMA:
FLUSH
wordok = 1;
break;
default:
wordok = 1;
ADDRLEFT
continue;
}
OUTLEFT
}
FLUSH
++t;
while (t > ta->t)
if (!token822_append(taout,--t)) return -1;
token822_reverse(taout);
return 1;
}
|
openwengo/qmail-ldap
|
trysgprm.c
|
<filename>trysgprm.c
#include <signal.h>
void main()
{
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss,SIGCHLD);
sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0);
}
|
openwengo/qmail-ldap
|
byte_diff.c
|
<reponame>openwengo/qmail-ldap
#include "byte.h"
int byte_diff(s,n,t)
const void *s;
register unsigned int n;
const void *t;
{
register const char *S = (const char *)s;
register const char *T = (const char *)t;
for (;;) {
if (!n) return 0; if (*S != *T) break; ++S; ++T; --n;
if (!n) return 0; if (*S != *T) break; ++S; ++T; --n;
if (!n) return 0; if (*S != *T) break; ++S; ++T; --n;
if (!n) return 0; if (*S != *T) break; ++S; ++T; --n;
}
return ((int)(unsigned int)(unsigned char) *S)
- ((int)(unsigned int)(unsigned char) *T);
}
|
openwengo/qmail-ldap
|
trynpbg1.c
|
<reponame>openwengo/qmail-ldap
#include "select.h"
#include "open.h"
#include "fifo.h"
#define FN "temp-trynpbg1.fifo"
void main()
{
int flagbug;
struct timeval instant;
fd_set rfds;
flagbug = 0;
if (fifo_make(FN,0600) != -1) {
close(0);
if (open_read(FN) == 0) {
FD_ZERO(&rfds);
FD_SET(0,&rfds);
instant.tv_sec = instant.tv_usec = 0;
if (select(1,&rfds,(fd_set *) 0,(fd_set *) 0,&instant) > 0)
flagbug = 1;
}
unlink(FN);
}
_exit(!flagbug);
}
|
openwengo/qmail-ldap
|
headerbody.h
|
<reponame>openwengo/qmail-ldap<gh_stars>10-100
#ifndef HEADERBODY_H
#define HEADERBODY_H
#include "stralloc.h"
#include "substdio.h"
extern int headerbody(substdio *,
void (*)(stralloc *), void (*)(void), void (*)(stralloc *));
#endif
|
openwengo/qmail-ldap
|
sig_alarm.c
|
#include <signal.h>
#include "sig.h"
void sig_alarmblock(void) { sig_block(SIGALRM); }
void sig_alarmunblock(void) { sig_unblock(SIGALRM); }
void sig_alarmcatch(f) void (*f)(); { sig_catch(SIGALRM,f); }
void sig_alarmdefault(void) { sig_catch(SIGALRM,SIG_DFL); }
|
openwengo/qmail-ldap
|
trymkffo.c
|
<filename>trymkffo.c
#include <sys/types.h>
#include <sys/stat.h>
void main()
{
mkfifo("temp-trymkffo",0);
}
|
openwengo/qmail-ldap
|
byte_copy.c
|
<reponame>openwengo/qmail-ldap
#include "byte.h"
void byte_copy(to,n,from)
void *to;
register unsigned int n;
const void *from;
{
register char *t = (char *)to;
register const char *f = (const char *)from;
for (;;) {
if (!n) return; *t++ = *f++; --n;
if (!n) return; *t++ = *f++; --n;
if (!n) return; *t++ = *f++; --n;
if (!n) return; *t++ = *f++; --n;
}
}
|
openwengo/qmail-ldap
|
timeoutconn.c
|
<gh_stars>10-100
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "ndelay.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
#include "ip.h"
#include "byte.h"
#include "timeoutconn.h"
int timeoutconn(int s, struct ip_address *ip, struct ip_address *outip,
unsigned int port, int timeout)
{
char ch;
struct sockaddr_in s_in;
char *x;
fd_set wfds;
struct timeval tv;
if (ndelay_on(s) == -1) return -1;
/* bind() an outgoing ipaddr */
byte_zero(&s_in,sizeof(s_in));
byte_copy(&s_in.sin_addr.s_addr,4,outip);
s_in.sin_family = AF_INET;
if (bind(s,(struct sockaddr *) &s_in,sizeof(s_in)) == -1) return -1;
byte_zero(&s_in,sizeof(s_in));
byte_copy(&s_in.sin_addr,4,ip);
x = (char *) &s_in.sin_port;
x[1] = port; port >>= 8; x[0] = port;
s_in.sin_family = AF_INET;
if (connect(s,(struct sockaddr *) &s_in,sizeof(s_in)) == 0) {
ndelay_off(s);
return 0;
}
if ((errno != error_inprogress) && (errno != error_wouldblock)) return -1;
FD_ZERO(&wfds);
FD_SET(s,&wfds);
tv.tv_sec = timeout; tv.tv_usec = 0;
if (select(s + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1) return -1;
if (FD_ISSET(s,&wfds)) {
int dummy;
dummy = sizeof(s_in);
if (getpeername(s,(struct sockaddr *) &s_in,&dummy) == -1) {
subread(s,&ch,1);
return -1;
}
ndelay_off(s);
return 0;
}
errno = error_timeout; /* note that connect attempt is continuing */
return -1;
}
|
openwengo/qmail-ldap
|
fifo.c
|
<gh_stars>10-100
#include <sys/types.h>
#include <sys/stat.h>
#include "hasmkffo.h"
#include "fifo.h"
#ifdef HASMKFIFO
int fifo_make(fn,mode) const char *fn; int mode; { return mkfifo(fn,mode); }
#else
int fifo_make(fn,mode) const char *fn; int mode; { return mknod(fn,S_IFIFO | mode,0); }
#endif
|
openwengo/qmail-ldap
|
maildir2mbox.c
|
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include "readwrite.h"
#include "prioq.h"
#include "env.h"
#include "stralloc.h"
#include "subfd.h"
#include "substdio.h"
#include "getln.h"
#include "error.h"
#include "open.h"
#include "lock.h"
#include "gfrom.h"
#include "str.h"
#include "exit.h"
#include "myctime.h"
#include "maildir.h"
char *mbox;
char *mboxtmp;
stralloc filenames = {0};
prioq pq = {0};
prioq pq2 = {0};
stralloc line = {0};
stralloc ufline = {0};
char inbuf[SUBSTDIO_INSIZE];
char outbuf[SUBSTDIO_OUTSIZE];
#define FATAL "maildir2mbox: fatal: "
#define WARNING "maildir2mbox: warning: "
void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); }
int main()
{
substdio ssin;
substdio ssout;
struct prioq_elt pe;
int fdoldmbox;
int fdnewmbox;
int fd;
int match;
int fdlock;
umask(077);
mbox = env_get("MAIL");
if (!mbox) strerr_die2x(111,FATAL,"MAIL not set");
mboxtmp = env_get("MAILTMP");
if (!mboxtmp) strerr_die2x(111,FATAL,"MAILTMP not set");
if (maildir_chdir() == -1)
strerr_die1(111,FATAL,&maildir_chdir_err);
maildir_clean(&filenames);
if (maildir_scan(&pq,&filenames,1,1) == -1)
strerr_die1(111,FATAL,&maildir_scan_err);
if (!prioq_min(&pq,&pe)) _exit(0); /* nothing new */
fdlock = open_append(mbox);
if (fdlock == -1)
strerr_die4sys(111,FATAL,"unable to lock ",mbox,": ");
if (lock_ex(fdlock) == -1)
strerr_die4sys(111,FATAL,"unable to lock ",mbox,": ");
fdoldmbox = open_read(mbox);
if (fdoldmbox == -1)
strerr_die4sys(111,FATAL,"unable to read ",mbox,": ");
fdnewmbox = open_trunc(mboxtmp);
if (fdnewmbox == -1)
strerr_die4sys(111,FATAL,"unable to create ",mboxtmp,": ");
substdio_fdbuf(&ssin,subread,fdoldmbox,inbuf,sizeof(inbuf));
substdio_fdbuf(&ssout,subwrite,fdnewmbox,outbuf,sizeof(outbuf));
switch(substdio_copy(&ssout,&ssin))
{
case -2: strerr_die4sys(111,FATAL,"unable to read ",mbox,": ");
case -3: strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
}
while (prioq_min(&pq,&pe))
{
prioq_delmin(&pq);
if (!prioq_insert(&pq2,&pe)) die_nomem();
fd = open_read(filenames.s + pe.id);
if (fd == -1)
strerr_die4sys(111,FATAL,"unable to read $MAILDIR/",filenames.s + pe.id,": ");
substdio_fdbuf(&ssin,subread,fd,inbuf,sizeof(inbuf));
if (getln(&ssin,&line,&match,'\n') != 0)
strerr_die4sys(111,FATAL,"unable to read $MAILDIR/",filenames.s + pe.id,": ");
if (!stralloc_copys(&ufline,"From XXX ")) die_nomem();
if (match)
if (stralloc_starts(&line,"Return-Path: <"))
{
if (line.s[14] == '>')
{
if (!stralloc_copys(&ufline,"From MAILER-DAEMON ")) die_nomem();
}
else
{
unsigned int i;
if (!stralloc_ready(&ufline,line.len)) die_nomem();
if (!stralloc_copys(&ufline,"From ")) die_nomem();
for (i = 14;i < line.len - 2;++i)
if ((line.s[i] == ' ') || (line.s[i] == '\t'))
ufline.s[ufline.len++] = '-';
else
ufline.s[ufline.len++] = line.s[i];
if (!stralloc_cats(&ufline," ")) die_nomem();
}
}
if (!stralloc_cats(&ufline,myctime(pe.dt))) die_nomem();
if (substdio_put(&ssout,ufline.s,ufline.len) == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
while (match && line.len)
{
if (gfrom(line.s,line.len))
if (substdio_puts(&ssout,">") == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
if (substdio_put(&ssout,line.s,line.len) == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
if (!match)
{
if (substdio_puts(&ssout,"\n") == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
break;
}
if (getln(&ssin,&line,&match,'\n') != 0)
strerr_die4sys(111,FATAL,"unable to read $MAILDIR/",filenames.s + pe.id,": ");
}
if (substdio_puts(&ssout,"\n"))
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
close(fd);
}
if (substdio_flush(&ssout) == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
if (fsync(fdnewmbox) == -1)
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
if (close(fdnewmbox) == -1) /* NFS dorks */
strerr_die4sys(111,FATAL,"unable to write to ",mboxtmp,": ");
if (rename(mboxtmp,mbox) == -1)
strerr_die6(111,FATAL,"unable to move ",mboxtmp," to ",mbox,": ",&strerr_sys);
while (prioq_min(&pq2,&pe))
{
prioq_delmin(&pq2);
if (unlink(filenames.s + pe.id) == -1)
strerr_warn4(WARNING,"$MAILDIR/",filenames.s + pe.id," will be delivered twice; unable to unlink: ",&strerr_sys);
}
return 0;
}
|
openwengo/qmail-ldap
|
qsmhook.c
|
#include <unistd.h>
#include "fd.h"
#include "stralloc.h"
#include "readwrite.h"
#include "sgetopt.h"
#include "wait.h"
#include "env.h"
#include "byte.h"
#include "str.h"
#include "alloc.h"
#include "exit.h"
#include "fork.h"
#include "case.h"
#include "subfd.h"
#include "error.h"
#include "substdio.h"
#include "sig.h"
void die(e,s) int e; char *s; { substdio_putsflush(subfderr,s); _exit(e); }
void die_usage() { die(100,"qsmhook: fatal: incorrect usage\n"); }
void die_temp() { die(111,"qsmhook: fatal: temporary problem\n"); }
void die_read() { die(111,"qsmhook: fatal: unable to read message\n"); }
void die_badcmd() { die(100,"qsmhook: fatal: command not found\n"); }
int flagrpline = 0; char *rpline;
int flagufline = 1; char *ufline;
int flagdtline = 0; char *dtline;
char *host;
char *sender;
char *recip;
stralloc newarg = {0};
substdio ssout;
char outbuf[SUBSTDIO_OUTSIZE];
substdio ssin;
char inbuf[SUBSTDIO_INSIZE];
int main(argc,argv)
int argc;
char **argv;
{
int pid;
int wstat;
int pi[2];
int opt;
char **arg;
char *x;
unsigned int i;
int flagesc;
sig_pipeignore();
if (!(dtline = env_get("DTLINE"))) die_usage();
if (!(rpline = env_get("RPLINE"))) die_usage();
if (!(ufline = env_get("UFLINE"))) die_usage();
if (!(recip = env_get("LOCAL"))) die_usage();
if (!(host = env_get("HOST"))) die_usage();
if (!(sender = env_get("SENDER"))) die_usage();
while ((opt = getopt(argc,argv,"DFlMmnPsx:")) != opteof)
switch(opt)
{
case 'D': case 'F': case 'M': break; /* be serious */
case 'l': flagdtline = 1; break; /* also return-receipt-to? blech */
case 'm': break; /* we only handle one recipient anyway */
case 'n': flagufline = 0; break;
case 's': break; /* could call quote() otherwise, i suppose... */
case 'P': flagrpline = 1; break;
case 'x':
if (case_starts(recip,optarg))
recip += str_len(optarg);
break;
default:
_exit(100);
}
argc -= optind;
argv += optind;
if (!*argv) die_usage();
for (arg = argv;(x = *arg);++arg)
{
if (!stralloc_copys(&newarg,"")) die_temp();
flagesc = 0;
for (i = 0;x[i];++i)
if (flagesc)
{
switch(x[i])
{
case '%': if (!stralloc_cats(&newarg,"%")) die_temp(); break;
case 'g': if (!stralloc_cats(&newarg,sender)) die_temp(); break;
case 'h': if (!stralloc_cats(&newarg,host)) die_temp(); break;
case 'u': if (!stralloc_cats(&newarg,recip)) die_temp(); break;
}
flagesc = 0;
}
else
if (x[i] == '%')
flagesc = 1;
else
if (!stralloc_append(&newarg,&x[i])) die_temp();
if (!stralloc_0(&newarg)) die_temp();
i = str_len(newarg.s) + 1;
if (!(x = alloc(i))) die_temp();
byte_copy(x,i,newarg.s);
*arg = x;
}
if (pipe(pi) == -1) die_temp();
switch(pid = fork())
{
case -1:
die_temp();
case 0:
close(pi[1]);
if (fd_move(0,pi[0]) == -1) die_temp();
sig_pipedefault();
execvp(*argv,argv);
if (error_temp(errno)) die_temp();
die_badcmd();
}
close(pi[0]);
substdio_fdbuf(&ssout,subwrite,pi[1],outbuf,sizeof(outbuf));
substdio_fdbuf(&ssin,subread,0,inbuf,sizeof(inbuf));
if (flagufline) substdio_bputs(&ssout,ufline);
if (flagrpline) substdio_bputs(&ssout,rpline);
if (flagdtline) substdio_bputs(&ssout,dtline);
if (substdio_copy(&ssout,&ssin) == -2) die_read();
substdio_flush(&ssout);
close(pi[1]);
if (wait_pid(&wstat,pid) == -1) die_temp();
if (wait_crashed(wstat)) die_temp();
return wait_exitcode(wstat);
}
|
openwengo/qmail-ldap
|
error_temp.c
|
<filename>error_temp.c
#include <errno.h>
#include "error.h"
#define X(n) if (e == n) return 1;
int error_temp(e)
int e;
{
X(error_intr)
X(error_nomem)
X(error_txtbsy)
X(error_io)
X(error_timeout)
X(error_wouldblock)
X(error_again)
#ifdef EDEADLK
X(EDEADLK)
#endif
#ifdef EBUSY
X(EBUSY)
#endif
#ifdef ENFILE
X(ENFILE)
#endif
#ifdef EMFILE
X(EMFILE)
#endif
#ifdef EFBIG
X(EFBIG)
#endif
#ifdef ENOSPC
X(ENOSPC)
#endif
#ifdef ENETDOWN
X(ENETDOWN)
#endif
#ifdef ENETUNREACH
X(ENETUNREACH)
#endif
#ifdef ENETRESET
X(ENETRESET)
#endif
#ifdef ECONNABORTED
X(ECONNABORTED)
#endif
#ifdef ECONNRESET
X(ECONNRESET)
#endif
#ifdef ENOBUFS
X(ENOBUFS)
#endif
#ifdef ETOOMANYREFS
X(ETOOMANYREFS)
#endif
#ifdef ECONNREFUSED
X(ECONNREFUSED)
#endif
#ifdef EHOSTDOWN
X(EHOSTDOWN)
#endif
#ifdef EHOSTUNREACH
X(EHOSTUNREACH)
#endif
#ifdef EPROCLIM
X(EPROCLIM)
#endif
#ifdef EUSERS
X(EUSERS)
#endif
#ifdef EDQUOT
X(EDQUOT)
#endif
#ifdef ESTALE
X(ESTALE)
#endif
#ifdef ENOLCK
X(ENOLCK)
#endif
return 0;
}
|
openwengo/qmail-ldap
|
lock_un.c
|
#include <sys/types.h>
#include <sys/file.h>
#include <fcntl.h>
#include "hasflock.h"
#include "lock.h"
#ifdef HASFLOCK
int lock_un(fd) int fd; { return flock(fd,LOCK_UN); }
#else
int lock_un(fd) int fd; { return lockf(fd,0,0); }
#endif
|
openwengo/qmail-ldap
|
ndelay.h
|
#ifndef NDELAY_H
#define NDELAY_H
extern int ndelay_on(int fd);
extern int ndelay_off(int fd);
#endif
|
openwengo/qmail-ldap
|
ipme.h
|
#ifndef IPME_H
#define IPME_H
#include "ip.h"
#include "ipalloc.h"
extern ipalloc ipme;
extern int ipme_init(void);
extern int ipme_is(struct ip_address *);
#endif
|
openwengo/qmail-ldap
|
coe.c
|
#include <fcntl.h>
#include "coe.h"
int coe(fd)
int fd;
{
return fcntl(fd,F_SETFD,1);
}
|
openwengo/qmail-ldap
|
open_append.c
|
#include <sys/types.h>
#include <fcntl.h>
#include "open.h"
int open_append(fn) const char *fn;
{ return open(fn,O_WRONLY | O_NDELAY | O_APPEND | O_CREAT,0600); }
|
openwengo/qmail-ldap
|
qmail-qmqpd.c
|
#include <unistd.h>
#include "auto_qmail.h"
#include "byte.h"
#include "qmail.h"
#include "received.h"
#include "sig.h"
#include "subfd.h"
#include "substdio.h"
#include "readwrite.h"
#include "exit.h"
#include "now.h"
#include "fmt.h"
#include "env.h"
#include "str.h"
#ifdef QMQP_COMPRESS
#include <zlib.h>
z_stream stream;
char zbuf[4096];
int percent;
int compressed = 0;
extern substdio ssout;
void out(const char *s1, const char *s2, const char *s3)
{
char strnum[FMT_ULONG];
unsigned long len;
len = str_len(s1);
if (s2) len += str_len(s2);
if (s3) len += str_len(s3);
substdio_put(&ssout,strnum,fmt_ulong(strnum,len));
substdio_puts(&ssout,":");
substdio_puts(&ssout,s1);
substdio_puts(subfderr,s1+1);
if (s2) { substdio_puts(&ssout,s2); substdio_puts(subfderr,s2); }
if (s3) { substdio_puts(&ssout,s3); substdio_puts(subfderr,s3); }
substdio_puts(subfderr, "\n");
substdio_flush(subfderr);
substdio_puts(&ssout,",");
substdio_flush(&ssout);
}
void compression_init(int avail)
{
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
stream.avail_in = avail;
stream.next_in = zbuf;
if (inflateInit(&stream) != Z_OK) {
out("ZInitalizing data compression failed: ", stream.msg, " #(4.3.0)");
_exit(111);
}
}
void compression_done(void)
{
if (stream.avail_out != sizeof(zbuf)) {
/* there is some data left, ignore */
}
if (inflateEnd(&stream) != Z_OK) {
out("ZFinishing data compression failed: ", stream.msg, " #(4.3.0)");
_exit(111);
}
percent = 100 - (int)(100.0*stream.total_in/stream.total_out);
}
#endif
void resources() { _exit(111); }
void badproto() { _exit(100); }
int safewrite(int fd, void *buf, int len)
{
int r;
r = write(fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
int saferead(int fd, void *buf,int len)
{
int r;
#ifdef QMQP_COMPRESS
if (compressed == 0) {
int i;
char ch;
r = read(0,zbuf,len);
if (r <= 0) _exit(0);
for (i = 0; i < r; i++) {
ch = zbuf[i];
if (ch >= '0' && ch <= '9') continue;
if (ch == ':') {
byte_copy(buf, r, zbuf);
compressed = -1;
return r;
}
compressed = 1;
compression_init(r);
break;
}
}
if (compressed < 0) goto uncompressed;
if (compressed == 2) _exit(0);
stream.avail_out = len;
stream.next_out = buf;
do {
if (stream.avail_in == 0) {
r = read(fd,zbuf,sizeof(zbuf));
if (r <= 0) _exit(0); /* XXX ??? */
stream.avail_in = r;
stream.next_in = zbuf;
}
r = inflate(&stream, 0);
switch (r) {
case Z_OK:
if (stream.avail_out == 0)
return len;
break;
case Z_STREAM_END:
compression_done();
compressed = 2;
return len - stream.avail_out;
default:
out("ZReceiving compressed data failed: ", stream.msg, " #(4.3.0)");
return -1;
}
if (stream.avail_out == (unsigned int)len) continue;
return len - stream.avail_out;
} while (1);
uncompressed:
#endif
r = read(fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char ssinbuf[512];
substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
char ssoutbuf[256];
substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
unsigned long bytesleft = 100;
void getbyte(ch)
char *ch;
{
if (!bytesleft--) _exit(100);
substdio_get(&ssin,ch,1);
}
unsigned long getlen()
{
unsigned long len = 0;
char ch;
for (;;) {
getbyte(&ch);
if (len > 200000000) resources();
if (ch == ':') return len;
if (ch < '0' || ch > '9') badproto();
len = 10 * len + (ch - '0');
}
}
void getcomma()
{
char ch;
getbyte(&ch);
if (ch != ',') badproto();
}
struct qmail qq;
void identify()
{
const char *remotehost;
const char *remoteinfo;
const char *remoteip;
const char *local;
remotehost = env_get("TCPREMOTEHOST");
if (!remotehost) remotehost = "unknown";
remoteinfo = env_get("TCPREMOTEINFO");
remoteip = env_get("TCPREMOTEIP");
if (!remoteip) remoteip = "unknown";
local = env_get("TCPLOCALHOST");
if (!local) local = env_get("TCPLOCALIP");
if (!local) local = "unknown";
#ifdef QMQP_COMPRESS
if (compressed > 0)
received(&qq,"compressed QMQP",local,remoteip,remotehost,remoteinfo,(char *) 0,(char *) 0,(char *) 0);
else
#endif
received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,(char *) 0,(char *) 0,(char *) 0);
}
char buf[1000 + 20 + FMT_ULONG];
char strnum[FMT_ULONG];
int getbuf(void)
{
unsigned long len;
unsigned long i;
len = getlen();
if (len >= 1000) {
for (i = 0;i < len;++i) getbyte(buf);
getcomma();
buf[0] = 0;
return 0;
}
for (i = 0;i < len;++i) getbyte(buf + i);
getcomma();
buf[len] = 0;
return byte_chr(buf,len,'\0') == len;
}
int flagok = 1;
int main(int argc, char **argv)
{
const char *result;
unsigned long qp;
unsigned long len;
char ch;
sig_pipeignore();
sig_alarmcatch(resources);
alarm(3600);
#ifdef QMQP_COMPRESS
if (env_get("NOCOMPRESS")) compressed = -1;
#endif
bytesleft = getlen();
len = getlen();
if (chdir(auto_qmail) == -1) resources();
if (qmail_open(&qq) == -1) resources();
qp = qmail_qp(&qq);
identify();
while (len > 0) { /* XXX: could speed this up */
getbyte(&ch);
--len;
qmail_put(&qq,&ch,1);
}
getcomma();
if (getbuf())
qmail_from(&qq,buf);
else {
qmail_from(&qq,"");
qmail_fail(&qq);
flagok = 0;
}
while (bytesleft)
if (getbuf())
qmail_to(&qq,buf);
else {
qmail_fail(&qq);
flagok = 0;
}
bytesleft = 1;
getcomma();
result = qmail_close(&qq);
if (!*result) {
len = fmt_str(buf,"Kok ");
len += fmt_ulong(buf + len,(unsigned long) now());
len += fmt_str(buf + len," qp ");
len += fmt_ulong(buf + len,qp);
#ifdef QMQP_COMPRESS
if (compressed > 0) {
len += fmt_str(buf + len, " DDC saved ");
if (percent < 0) {
len += fmt_str(buf + len, "-");
percent *= -1;
}
len += fmt_uint(buf + len, percent);
len += fmt_str(buf + len, " percent");
}
#endif
buf[len] = 0;
result = buf;
}
if (!flagok)
result = "Dsorry, I can't accept addresses like that (#5.1.3)";
substdio_put(&ssout,strnum,fmt_uint(strnum,str_len(result)));
substdio_puts(&ssout,":");
substdio_puts(&ssout,result);
substdio_puts(subfderr,result + 1);
substdio_puts(subfderr, "\n");
substdio_flush(subfderr);
substdio_puts(&ssout,",");
substdio_flush(&ssout);
return 0;
}
|
openwengo/qmail-ldap
|
timeoutread.h
|
#ifndef TIMEOUTREAD_H
#define TIMEOUTREAD_H
extern int timeoutread(int, int, char *, int);
#endif
|
openwengo/qmail-ldap
|
gfrom.h
|
#ifndef GFROM_H
#define GFROM_H
extern int gfrom(char *, int);
#endif
|
openwengo/qmail-ldap
|
stralloc_pend.c
|
#include "alloc.h"
#include "stralloc.h"
#include "gen_allocdefs.h"
GEN_ALLOC_append(stralloc,const char,s,len,a,i,n,x,30,stralloc_readyplus,stralloc_append)
|
openwengo/qmail-ldap
|
exit.h
|
<reponame>openwengo/qmail-ldap
#ifndef EXIT_H
#define EXIT_H
/* XXX unistd.h */
extern void _exit(int);
#endif
|
openwengo/qmail-ldap
|
qmail-tcpto.c
|
/* XXX: this program knows quite a bit about tcpto's internals */
#include <unistd.h>
#include "substdio.h"
#include "subfd.h"
#include "auto_qmail.h"
#include "fmt.h"
#include "ip.h"
#include "lock.h"
#include "error.h"
#include "exit.h"
#include "datetime.h"
#include "now.h"
#include "open.h"
#include "readwrite.h"
#include "byte.h"
void die(n) int n; { substdio_flush(subfdout); _exit(n); }
void warn(s) const char *s;
{
const char *x;
x = error_str(errno);
substdio_puts(subfdout,s);
substdio_puts(subfdout,": ");
substdio_puts(subfdout,x);
substdio_puts(subfdout,"\n");
}
void die_chdir() { warn("fatal: unable to chdir"); die(111); }
void die_open() { warn("fatal: unable to open tcpto"); die(111); }
void die_lock() { warn("fatal: unable to lock tcpto"); die(111); }
void die_read() { warn("fatal: unable to read tcpto"); die(111); }
char tcpto_buf[1024];
char tmp[FMT_ULONG + IPFMT];
int main()
{
int fdlock;
int fd;
int r;
int i;
char *record;
struct ip_address ip;
datetime_sec when;
datetime_sec start;
if (chdir(auto_qmail) == -1) die_chdir();
if (chdir("queue/lock") == -1) die_chdir();
fdlock = open_write("tcpto");
if (fdlock == -1) die_open();
fd = open_read("tcpto");
if (fd == -1) die_open();
if (lock_ex(fdlock) == -1) die_lock();
r = read(fd,tcpto_buf,sizeof(tcpto_buf));
close(fd);
close(fdlock);
if (r == -1) die_read();
r >>= 4;
start = now();
record = tcpto_buf;
for (i = 0;i < r;++i)
{
if (record[4] >= 1)
{
byte_copy(&ip,4,record);
when = (unsigned long) (unsigned char) record[11];
when = (when << 8) + (unsigned long) (unsigned char) record[10];
when = (when << 8) + (unsigned long) (unsigned char) record[9];
when = (when << 8) + (unsigned long) (unsigned char) record[8];
substdio_put(subfdout,tmp,ip_fmt(tmp,&ip));
substdio_puts(subfdout," timed out ");
substdio_put(subfdout,tmp,fmt_ulong(tmp,(unsigned long) (start - when)));
substdio_puts(subfdout," seconds ago; # recent timeouts: ");
substdio_put(subfdout,tmp,fmt_ulong(tmp,(unsigned long) (unsigned char) record[4]));
substdio_puts(subfdout,"\n");
}
record += 16;
}
die(0);
/* NOTREACHED */
return 0;
}
|
openwengo/qmail-ldap
|
tryvfork.c
|
<reponame>openwengo/qmail-ldap
void main()
{
vfork();
}
|
openwengo/qmail-ldap
|
case_starts.c
|
#include "case.h"
int case_starts(s,t)
register const char *s;
register const char *t;
{
register unsigned char x;
register unsigned char y;
for (;;) {
x = *s++ - 'A';
if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
y = *t++ - 'A';
if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
if (!y) return 1;
if (x != y) return 0;
}
}
|
openwengo/qmail-ldap
|
sig_misc.c
|
<reponame>openwengo/qmail-ldap
#include <signal.h>
#include "sig.h"
void sig_miscignore(void)
{
sig_catch(SIGVTALRM,SIG_IGN);
sig_catch(SIGPROF,SIG_IGN);
sig_catch(SIGQUIT,SIG_IGN);
sig_catch(SIGINT,SIG_IGN);
sig_catch(SIGHUP,SIG_IGN);
#ifdef SIGXCPU
sig_catch(SIGXCPU,SIG_IGN);
#endif
#ifdef SIGXFSZ
sig_catch(SIGXFSZ,SIG_IGN);
#endif
}
|
openwengo/qmail-ldap
|
maildirwatch.c
|
<filename>maildirwatch.c
#include <unistd.h>
#include "getln.h"
#include "substdio.h"
#include "subfd.h"
#include "prioq.h"
#include "stralloc.h"
#include "str.h"
#include "exit.h"
#include "hfield.h"
#include "readwrite.h"
#include "open.h"
#include "headerbody.h"
#include "maildir.h"
#define FATAL "maildirwatch: fatal: "
void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); }
stralloc recipient = {0};
stralloc sender = {0};
stralloc fromline = {0};
stralloc text = {0};
void addtext(s,n) char *s; int n;
{
if (!stralloc_catb(&text,s,n)) die_nomem();
if (text.len > 158) text.len = 158;
}
void dobody(h) stralloc *h; { addtext(h->s,h->len); }
void doheader(h) stralloc *h;
{
unsigned int i;
switch(hfield_known(h->s,h->len))
{
case H_SUBJECT:
i = hfield_skipname(h->s,h->len);
addtext(h->s + i,h->len - i);
break;
case H_DELIVEREDTO:
i = hfield_skipname(h->s,h->len);
if (i < h->len)
if (!stralloc_copyb(&recipient,h->s + i,h->len - i - 1)) die_nomem();
break;
case H_RETURNPATH:
i = hfield_skipname(h->s,h->len);
if (i < h->len)
if (!stralloc_copyb(&sender,h->s + i,h->len - i - 1)) die_nomem();
break;
case H_FROM:
if (!stralloc_copyb(&fromline,h->s,h->len - 1)) die_nomem();
break;
}
}
void finishheader() { ; }
stralloc filenames = {0};
prioq pq = {0};
char inbuf[SUBSTDIO_INSIZE];
substdio ssin;
int main()
{
struct prioq_elt pe;
int fd;
unsigned int i;
if (maildir_chdir() == -1)
strerr_die1(111,FATAL,&maildir_chdir_err);
for (;;)
{
maildir_clean(&filenames);
if (maildir_scan(&pq,&filenames,1,0) == -1)
strerr_die1(111,FATAL,&maildir_scan_err);
substdio_putsflush(subfdout,"\033[;H\033[;J");
while (prioq_min(&pq,&pe))
{
prioq_delmin(&pq);
fd = open_read(filenames.s + pe.id);
if (fd == -1) continue;
substdio_fdbuf(&ssin,subread,fd,inbuf,sizeof(inbuf));
if (!stralloc_copys(&sender,"?")) die_nomem();
if (!stralloc_copys(&recipient,"?")) die_nomem();
if (!stralloc_copys(&fromline,"")) die_nomem();
if (!stralloc_copys(&text,"")) die_nomem();
if (headerbody(&ssin,doheader,finishheader,dobody) == -1)
strerr_die2x(111,FATAL,"trouble reading new message");
for (i = 0;i < fromline.len;++i)
if ((fromline.s[i] < 32) || (fromline.s[i] > 126))
fromline.s[i] = '/';
for (i = 0;i < sender.len;++i)
if ((sender.s[i] < 32) || (sender.s[i] > 126))
sender.s[i] = '?';
for (i = 0;i < recipient.len;++i)
if ((recipient.s[i] < 32) || (recipient.s[i] > 126))
recipient.s[i] = '?';
for (i = 0;i < text.len;++i)
if ((text.s[i] < 32) || (text.s[i] > 126))
text.s[i] = '/';
substdio_puts(subfdout,"FROM ");
substdio_put(subfdout,sender.s,sender.len);
substdio_puts(subfdout," TO <");
substdio_put(subfdout,recipient.s,recipient.len);
substdio_puts(subfdout,">\n");
if (fromline.len)
{
substdio_puts(subfdout,"\033[1m");
substdio_put(subfdout,fromline.s,fromline.len);
substdio_puts(subfdout,"\033[0m\n");
}
substdio_put(subfdout,text.s,text.len);
substdio_puts(subfdout,"\n\n");
close(fd);
}
substdio_flush(subfdout);
sleep(30);
}
/* NOTREACHED */
return 1;
}
|
openwengo/qmail-ldap
|
str_cpy.c
|
<reponame>openwengo/qmail-ldap
#include "str.h"
unsigned int str_copy(s,t)
register char *s;
register const char *t;
{
register unsigned int len;
len = 0;
for (;;) {
if (!(*s = *t)) return len; ++s; ++t; ++len;
if (!(*s = *t)) return len; ++s; ++t; ++len;
if (!(*s = *t)) return len; ++s; ++t; ++len;
if (!(*s = *t)) return len; ++s; ++t; ++len;
}
}
|
openwengo/qmail-ldap
|
qsutil.c
|
#include <unistd.h>
#include "stralloc.h"
#include "readwrite.h"
#include "substdio.h"
#include "qsutil.h"
static stralloc foo = {0};
static char errbuf[1];
static struct substdio sserr = SUBSTDIO_FDBUF(subwrite,0,errbuf,1);
void logsa(sa) stralloc *sa; {
substdio_putflush(&sserr,sa->s,sa->len); }
void log1(s1) const char *s1; {
substdio_putsflush(&sserr,s1); }
void log2(s1,s2) const char *s1; const char *s2; {
substdio_putsflush(&sserr,s1);
substdio_putsflush(&sserr,s2); }
void log3(s1,s2,s3) const char *s1; const char *s2; const char *s3; {
substdio_putsflush(&sserr,s1);
substdio_putsflush(&sserr,s2);
substdio_putsflush(&sserr,s3); }
void nomem(void) { log1("alert: out of memory, sleeping...\n"); sleep(10); }
void pausedir(dir) const char *dir;
{ log3("alert: unable to opendir ",dir,", sleeping...\n"); sleep(10); }
static int issafe(ch) char ch;
{
if (ch == '%') return 0; /* general principle: allman's code is crap */
if (ch < 33) return 0;
if (ch > 126) return 0;
return 1;
}
void logsafe(s) const char *s;
{
unsigned int i;
while (!stralloc_copys(&foo,s)) nomem();
for (i = 0; i < foo.len;++i)
if (foo.s[i] == '\n')
foo.s[i] = '/';
else
if (!issafe(foo.s[i]))
foo.s[i] = '_';
logsa(&foo);
}
|
openwengo/qmail-ldap
|
token822.h
|
#ifndef TOKEN822_H
#define TOKEN822_H
struct token822
{
int type;
const char *s;
unsigned int slen;
}
;
#include "gen_alloc.h"
#include "stralloc.h"
GEN_ALLOC_typedef(token822_alloc,struct token822,t,len,a)
extern int token822_parse(token822_alloc *, stralloc *, stralloc *);
extern int token822_addrlist(token822_alloc *, token822_alloc *,
token822_alloc *, int (*)());
extern int token822_unquote(stralloc *, token822_alloc *);
extern int token822_unparse(stralloc *, token822_alloc *, unsigned int);
/* XXX not available in qmail-1.03
extern void token822_free();
*/
extern void token822_reverse(token822_alloc *);
extern int token822_ready(token822_alloc *, unsigned int);
extern int token822_readyplus(token822_alloc *, unsigned int);
extern int token822_append(token822_alloc *, struct token822 *);
#define TOKEN822_ATOM 1
#define TOKEN822_QUOTE 2
#define TOKEN822_LITERAL 3
#define TOKEN822_COMMENT 4
#define TOKEN822_LEFT 5
#define TOKEN822_RIGHT 6
#define TOKEN822_AT 7
#define TOKEN822_COMMA 8
#define TOKEN822_SEMI 9
#define TOKEN822_COLON 10
#define TOKEN822_DOT 11
#endif
|
openwengo/qmail-ldap
|
ipalloc.h
|
#ifndef IPALLOC_H
#define IPALLOC_H
#include "ip.h"
struct ip_mx { struct ip_address ip; int pref; } ;
#include "gen_alloc.h"
GEN_ALLOC_typedef(ipalloc,struct ip_mx,ix,len,a)
extern int ipalloc_readyplus(ipalloc *, unsigned int);
extern int ipalloc_append(ipalloc *, struct ip_mx *);
#endif
|
openwengo/qmail-ldap
|
timeoutread.c
|
<gh_stars>10-100
#include "timeoutread.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
int timeoutread(t,fd,buf,len) int t; int fd; char *buf; int len;
{
fd_set rfds;
struct timeval tv;
tv.tv_sec = t;
tv.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(fd,&rfds);
if (select(fd + 1,&rfds,(fd_set *) 0,(fd_set *) 0,&tv) == -1) return -1;
if (FD_ISSET(fd,&rfds)) return subread(fd,buf,len);
errno = error_timeout;
return -1;
}
|
openwengo/qmail-ldap
|
triggerpull.h
|
<filename>triggerpull.h
#ifndef TRIGGERPULL_H
#define TRIGGERPULL_H
extern void triggerpull(void);
#endif
|
openwengo/qmail-ldap
|
fmt.h
|
#ifndef FMT_H
#define FMT_H
#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */
#define FMT_LEN ((char *) 0) /* convenient abbreviation */
extern unsigned int fmt_uint(char *, unsigned int);
extern unsigned int fmt_uint0(char *, unsigned int, unsigned int);
/* XXX not available in qmail-1.03
extern unsigned int fmt_xint();
extern unsigned int fmt_nbbint();
extern unsigned int fmt_ushort();
extern unsigned int fmt_xshort();
extern unsigned int fmt_nbbshort();
*/
extern unsigned int fmt_ulong(char *, unsigned long);
/* XXX not available in qmail-1.03
extern unsigned int fmt_xlong();
extern unsigned int fmt_nbblong();
extern unsigned int fmt_plusminus();
extern unsigned int fmt_minus();
extern unsigned int fmt_0x();
*/
extern unsigned int fmt_str(char *, const char *);
extern unsigned int fmt_strn(char *, const char *, unsigned int);
#endif
|
openwengo/qmail-ldap
|
fmt_uint0.c
|
#include "fmt.h"
unsigned int fmt_uint0(s,u,n) char *s; unsigned int u; unsigned int n;
{
unsigned int len;
len = fmt_uint(FMT_LEN,u);
while (len < n) { if (s) *s++ = '0'; ++len; }
if (s) fmt_uint(s,u);
return len;
}
|
openwengo/qmail-ldap
|
control.c
|
<reponame>openwengo/qmail-ldap<filename>control.c
#include <unistd.h>
#include "readwrite.h"
#include "open.h"
#include "getln.h"
#include "stralloc.h"
#include "substdio.h"
#include "error.h"
#include "control.h"
#include "alloc.h"
#include "scan.h"
#include "limit.h"
static char inbuf[64];
static stralloc line = {0};
static stralloc me = {0};
static int meok = 0;
static void striptrailingwhitespace(sa)
stralloc *sa;
{
while (sa->len > 0)
switch(sa->s[sa->len - 1])
{
case '\n': case ' ': case '\t':
--sa->len;
break;
default:
return;
}
}
int control_init(void)
{
int r;
r = control_readline(&me,"control/me");
if (r == 1) meok = 1;
return r;
}
int control_rldef(sa,fn,flagme,def)
stralloc *sa;
const char *fn;
int flagme;
const char *def;
{
int r;
r = control_readline(sa,fn);
if (r) return r;
if (flagme) if (meok) return stralloc_copy(sa,&me) ? 1 : -1;
if (def) return stralloc_copys(sa,def) ? 1 : -1;
return r;
}
int control_readline(sa,fn)
stralloc *sa;
const char *fn;
{
substdio ss;
int fd;
int match;
fd = open_read(fn);
if (fd == -1) { if (errno == error_noent) return 0; return -1; }
substdio_fdbuf(&ss,subread,fd,inbuf,sizeof(inbuf));
if (getln(&ss,sa,&match,'\n') == -1) { close(fd); return -1; }
striptrailingwhitespace(sa);
close(fd);
return 1;
}
int control_readint(i,fn)
int *i;
const char *fn;
{
unsigned long u;
switch(control_readline(&line,fn))
{
case 0: return 0;
case -1: return -1;
}
if (!stralloc_0(&line)) return -1;
if (!scan_ulong(line.s,&u)) return 0;
if (u > INT_MAX) {
errno = error_range;
return -1;
}
*i = u;
return 1;
}
int control_readulong(ul,fn)
unsigned long *ul;
const char *fn;
{
unsigned long u;
switch(control_readline(&line,fn))
{
case 0: return 0;
case -1: return -1;
}
if (!stralloc_0(&line)) return -1;
if (!scan_ulong(line.s,&u)) return 0;
*ul = u;
return 1;
}
int control_readfile(sa,fn,flagme)
stralloc *sa;
const char *fn;
int flagme;
{
substdio ss;
int fd;
int match;
if (!stralloc_copys(sa,"")) return -1;
fd = open_read(fn);
if (fd == -1)
{
if (errno == error_noent)
{
if (flagme && meok)
{
if (!stralloc_copy(sa,&me)) return -1;
if (!stralloc_0(sa)) return -1;
return 1;
}
return 0;
}
return -1;
}
substdio_fdbuf(&ss,subread,fd,inbuf,sizeof(inbuf));
for (;;)
{
if (getln(&ss,&line,&match,'\n') == -1) break;
if (!match && !line.len) { close(fd); return 1; }
striptrailingwhitespace(&line);
if (!stralloc_0(&line)) break;
if (line.s[0])
if (line.s[0] != '#')
if (!stralloc_cat(sa,&line)) break;
if (!match) { close(fd); return 1; }
}
close(fd);
return -1;
}
int control_readrawfile(sa,fn)
stralloc *sa;
const char *fn;
{
substdio ss;
int fd;
int match;
if (!stralloc_copys(sa,"")) return -1;
fd = open_read(fn);
if (fd == -1)
{
if (errno == error_noent) return 0;
return -1;
}
substdio_fdbuf(&ss,subread,fd,inbuf,sizeof(inbuf));
for (;;)
{
if (getln(&ss,&line,&match,'\n') == -1) break;
if (!match && !line.len) { close(fd); return 1; }
if (!stralloc_cat(sa,&line)) break;
if (!match) { close(fd); return 1; }
}
close(fd);
return -1;
}
|
openwengo/qmail-ldap
|
chkshsgr.c
|
#include <sys/types.h>
#include <unistd.h>
#include "exit.h"
int main(int argc, char ** argv)
{
short x[4];
x[0] = x[1] = 0;
if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
return 0;
}
|
openwengo/qmail-ldap
|
sig_child.c
|
<reponame>openwengo/qmail-ldap
#include <signal.h>
#include "sig.h"
void sig_childblock(void) { sig_block(SIGCHLD); }
void sig_childunblock(void) { sig_unblock(SIGCHLD); }
void sig_childcatch(f) void (*f)(); { sig_catch(SIGCHLD,f); }
void sig_childdefault(void) { sig_catch(SIGCHLD,SIG_DFL); }
|
openwengo/qmail-ldap
|
qmail-popup.c
|
<gh_stars>10-100
#include <unistd.h>
#include "commands.h"
#include "fd.h"
#include "sig.h"
#include "stralloc.h"
#include "substdio.h"
#include "alloc.h"
#include "wait.h"
#include "str.h"
#include "byte.h"
#include "now.h"
#include "fmt.h"
#include "exit.h"
#include "readwrite.h"
#include "timeoutread.h"
#include "timeoutwrite.h"
void die(void) { _exit(1); }
int saferead(int fd, void *buf, int len)
{
int r;
r = timeoutread(1200,fd,buf,len);
if (r <= 0) die();
return r;
}
int safewrite(int fd, void *buf, int len)
{
int r;
r = timeoutwrite(1200,fd,buf,len);
if (r <= 0) die();
return r;
}
char ssoutbuf[128];
substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
char ssinbuf[128];
substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
void putstr(const char *s)
{
substdio_puts(&ssout,s);
}
void flush(void)
{
substdio_flush(&ssout);
}
void err(const char *s)
{
putstr("-ERR ");
putstr(s);
putstr("\r\n");
flush();
}
void die_usage(void) { err("usage: popup hostname subprogram"); die(); }
void die_nomem(void) { err("out of memory"); die(); }
void die_pipe(void) { err("unable to open pipe"); die(); }
void die_write(void) { err("unable to write pipe"); die(); }
void die_fork(void) { err("unable to fork"); die(); }
void die_childcrashed(void) { err("aack, child crashed"); }
void die_badauth(void) { err("authorization failed"); }
/* checkpassword error exit codes:
* 1 = error in server configuration
* 2 = unable to contact authorization server
* 25= user record incorrect
* 3 = authorization failed
* 4 = account disabled
* 5 = mailhost is unreachable
* 6 = mailbox is corrupted
* 61= mailbox creation failed
* 62= the users mailbox does not exist
* 7 = unable to start subprogram
* 8 = out of memory
*/
void die_1(void) { err("error in server configuration"); die(); }
void die_2(void) { err("unable to contact authorization server"); die(); }
void die_25(void) { err("user record incorrect"); die(); }
void die_3(void) { err("authorization failed"); die(); }
void die_4(void) { err("account disabled"); die(); }
void die_5(void) { err("mailhost is unreachable"); die(); }
void die_6(void) { err("mailbox is corrupted"); die(); }
void die_61(void) { err("mailbox could not be created"); die(); }
void die_62(void) { err("the users mailbox does not exist"); die(); }
void die_7(void) { err("unable to start subprogram"); die(); }
void die_unknown(void) { err("temporary error"); die(); }
void err_syntax(void) { err("syntax error"); }
void err_wantuser(void) { err("USER first"); }
void err_authoriz(void) { err("authorization first"); }
void okay(void) { putstr("+OK \r\n"); flush(); }
void pop3_quit(void) { okay(); die(); }
char unique[FMT_ULONG + FMT_ULONG + 3];
char *hostname;
stralloc username = {0};
int seenuser = 0;
char **childargs;
substdio ssup;
char upbuf[128];
void doanddie(char *user, unsigned int userlen /* including 0 byte */,
char *pass)
{
int child;
int wstat;
int pi[2];
close(3);
if (pipe(pi) == -1) die_pipe();
if (pi[0] != 3) die_pipe();
switch(child = fork()) {
case -1:
die_fork();
case 0:
close(pi[1]);
sig_pipedefault();
execvp(*childargs,childargs);
_exit(1);
}
close(pi[0]);
substdio_fdbuf(&ssup,subwrite,pi[1],upbuf,sizeof upbuf);
if (substdio_put(&ssup,user,userlen) == -1) die_write();
if (substdio_put(&ssup,pass,str_len(pass) + 1) == -1) die_write();
if (substdio_puts(&ssup,"<") == -1) die_write();
if (substdio_puts(&ssup,unique) == -1) die_write();
if (substdio_puts(&ssup,hostname) == -1) die_write();
if (substdio_put(&ssup,">",2) == -1) die_write();
if (substdio_flush(&ssup) == -1) die_write();
close(pi[1]);
byte_zero(pass,str_len(pass));
byte_zero(upbuf,sizeof upbuf);
if (wait_pid(&wstat,child) == -1) die();
if (wait_crashed(wstat)) die_childcrashed();
switch (wait_exitcode(wstat)) {
case 0: die();
case 1: die_1();
case 2: die_2();
case 25: die_25();
case 3: die_3();
case 4: die_4();
case 5: die_5();
case 6: die_6();
case 61: die_61();
case 62: die_62();
case 7: die_7();
case 8: die_nomem();
default: die_unknown();
}
die();
}
void pop3_greet(void)
{
char *s;
s = unique;
s += fmt_uint(s,getpid());
*s++ = '.';
s += fmt_ulong(s,(unsigned long) now());
*s++ = '@';
*s++ = 0;
putstr("+OK <");
putstr(unique);
putstr(hostname);
putstr(">\r\n");
flush();
}
void pop3_user(char *arg)
{
if (!*arg) { err_syntax(); return; }
okay();
seenuser = 1;
if (!stralloc_copys(&username,arg)) die_nomem();
if (!stralloc_0(&username)) die_nomem();
}
void pop3_pass(char *arg)
{
if (!seenuser) { err_wantuser(); return; }
if (!*arg) { err_syntax(); return; }
doanddie(username.s,username.len,arg);
}
void pop3_apop(char *arg)
{
char *space;
space = arg + str_chr(arg,' ');
if (!*space) { err_syntax(); return; }
*space++ = 0;
doanddie(arg,space - arg,space);
}
struct commands pop3commands[] = {
{ "user", pop3_user, 0 }
, { "pass", pop3_pass, 0 }
, { "apop", pop3_apop, 0 }
, { "quit", pop3_quit, 0 }
, { "noop", okay, 0 }
, { 0, err_authoriz, 0 }
} ;
int main(int argc, char **argv)
{
sig_alarmcatch(die);
sig_pipeignore();
hostname = argv[1];
if (!hostname) die_usage();
childargs = argv + 2;
if (!*childargs) die_usage();
pop3_greet();
commands(&ssin,pop3commands);
return 1;
}
|
openwengo/qmail-ldap
|
qmail-qmtpd.c
|
<gh_stars>1-10
#include <unistd.h>
#include "stralloc.h"
#include "substdio.h"
#include "qmail.h"
#include "now.h"
#include "str.h"
#include "fmt.h"
#include "env.h"
#include "sig.h"
#include "rcpthosts.h"
#include "auto_qmail.h"
#include "readwrite.h"
#include "control.h"
#include "received.h"
#include "scan.h"
void badproto() { _exit(100); }
void resources() { _exit(111); }
int safewrite(int fd, void *buf, int len)
{
int r;
r = write(fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char ssoutbuf[256];
substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
int saferead(int fd, void *buf, int len)
{
int r;
substdio_flush(&ssout);
r = read(fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char ssinbuf[512];
substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
unsigned long getlen(void)
{
unsigned long len = 0;
char ch;
for (;;) {
substdio_get(&ssin,&ch,1);
if (len > 200000000) resources();
if (ch == ':') return len;
if (ch < '0' || ch > '9') badproto();
len = 10 * len + (ch - '0');
}
}
void getcomma()
{
char ch;
substdio_get(&ssin,&ch,1);
if (ch != ',') badproto();
}
unsigned long databytes = 0;
unsigned long bytestooverflow = 0;
struct qmail qq;
char buf[1000];
char buf2[100];
const char *remotehost;
const char *remoteinfo;
const char *remoteip;
const char *local;
stralloc failure = {0};
char *relayclient;
unsigned int relayclientlen;
int main()
{
char ch;
unsigned int i;
unsigned long biglen;
unsigned long len;
int flagdos;
int flagsenderok;
int flagbother;
int flagnolocal = 0;
unsigned long qp;
const char *result;
char *x;
sig_pipeignore();
sig_alarmcatch(resources);
alarm(3600);
if (chdir(auto_qmail) == -1) resources();
if (control_init() == -1) resources();
if (rcpthosts_init() == -1) resources();
relayclient = env_get("RELAYCLIENT");
relayclientlen = relayclient ? str_len(relayclient) : 0;
if (control_readulong(&databytes,"control/databytes") == -1) resources();
x = env_get("DATABYTES");
if (x) scan_ulong(x,&databytes);
if (!(databytes + 1)) --databytes;
remotehost = env_get("TCPREMOTEHOST");
if (!remotehost) remotehost = "unknown";
remoteinfo = env_get("TCPREMOTEINFO");
remoteip = env_get("TCPREMOTEIP");
if (!remoteip) remoteip = "unknown";
local = env_get("TCPLOCALHOST");
if (!local) local = env_get("TCPLOCALIP");
if (!local) local = "unknown";
if (env_get("NOLOCAL")) flagnolocal = 1;
flagdos = 0;
for (;;) {
if (!stralloc_copys(&failure,"")) resources();
flagsenderok = 1;
len = getlen();
if (len == 0) badproto();
if (databytes) bytestooverflow = databytes + 1;
if (qmail_open(&qq) == -1) resources();
qp = qmail_qp(&qq);
substdio_get(&ssin,&ch,1);
--len;
if (ch == 10) flagdos = 0;
else if (ch == 13) flagdos = 1;
else badproto();
received(&qq,"QMTP",local,remoteip,remotehost,remoteinfo,(char *) 0,(char *) 0,(char *) 0);
/* XXX: check for loops? only if len is big? */
if (flagdos)
while (len > 0) {
substdio_get(&ssin,&ch,1);
--len;
while ((ch == 13) && len) {
substdio_get(&ssin,&ch,1);
--len;
if (ch == 10) break;
if (bytestooverflow) if (!--bytestooverflow) qmail_fail(&qq);
qmail_put(&qq,"\015",1);
}
if (bytestooverflow) if (!--bytestooverflow) qmail_fail(&qq);
qmail_put(&qq,&ch,1);
}
else {
if (databytes)
if (len > databytes) {
bytestooverflow = 0;
qmail_fail(&qq);
}
while (len > 0) { /* XXX: could speed this up, obviously */
substdio_get(&ssin,&ch,1);
--len;
qmail_put(&qq,&ch,1);
}
}
getcomma();
len = getlen();
if (len >= 1000) {
buf[0] = 0;
flagsenderok = 0;
for (i = 0;i < len;++i)
substdio_get(&ssin,&ch,1);
}
else {
for (i = 0;i < len;++i) {
substdio_get(&ssin,buf + i,1);
if (!buf[i]) flagsenderok = 0;
}
buf[len] = 0;
}
getcomma();
flagbother = 0;
qmail_from(&qq,buf);
if (!flagsenderok) qmail_fail(&qq);
biglen = getlen();
while (biglen > 0) {
if (!stralloc_append(&failure,"")) resources();
len = 0;
for (;;) {
if (!biglen) badproto();
substdio_get(&ssin,&ch,1);
--biglen;
if (len > 200000000) resources();
if (ch == ':') break;
if (ch < '0' || ch > '9') badproto();
len = 10 * len + (ch - '0');
}
if (len >= biglen) badproto();
if (len + relayclientlen >= 1000) {
failure.s[failure.len - 1] = 'L';
for (i = 0;i < len;++i)
substdio_get(&ssin,&ch,1);
}
else {
for (i = 0;i < len;++i) {
substdio_get(&ssin,buf + i,1);
if (!buf[i]) failure.s[failure.len - 1] = 'N';
}
buf[len] = 0;
if (relayclient)
str_copy(buf + len,relayclient);
else
switch(rcpthosts(buf,len,flagnolocal)) {
case -1: resources();
case 0: failure.s[failure.len - 1] = 'D';
}
if (!failure.s[failure.len - 1]) {
qmail_to(&qq,buf);
flagbother = 1;
}
}
getcomma();
biglen -= (len + 1);
}
getcomma();
if (!flagbother) qmail_fail(&qq);
result = qmail_close(&qq);
if (!flagsenderok) result = "Dunacceptable sender (#5.1.7)";
if (databytes) if (!bytestooverflow) result = "Dsorry, that message size exceeds my databytes limit (#5.3.4)";
if (*result)
len = str_len(result);
else {
/* success! */
len = 0;
len += fmt_str(buf2 + len,"Kok ");
len += fmt_ulong(buf2 + len,(unsigned long) now());
len += fmt_str(buf2 + len," qp ");
len += fmt_ulong(buf2 + len,qp);
buf2[len] = 0;
result = buf2;
}
len = fmt_ulong(buf,len);
buf[len++] = ':';
len += fmt_str(buf + len,result);
buf[len++] = ',';
for (i = 0;i < failure.len;++i)
switch(failure.s[i]) {
case 0:
substdio_put(&ssout,buf,len);
break;
case 'D':
substdio_puts(&ssout,"66:Dsorry, that domain isn't in my list of allowed rcpthosts (#5.7.1),");
break;
default:
substdio_puts(&ssout,"46:Dsorry, I can't handle that recipient (#5.1.3),");
break;
}
/* ssout will be flushed when we read from the network again */
}
/* NOTREACHED */
return 0;
}
|
openwengo/qmail-ldap
|
alloc.h
|
<filename>alloc.h
#ifndef ALLOC_H
#define ALLOC_H
extern /*@null@*//*@out@*/void *alloc(unsigned int);
extern void alloc_free(void *);
extern int alloc_re(char **, unsigned int, unsigned int);
#endif
|
openwengo/qmail-ldap
|
auto_spawn.h
|
<filename>auto_spawn.h
#ifndef AUTO_SPAWN_H
#define AUTO_SPAWN_H
extern unsigned int auto_spawn;
#endif
|
openwengo/qmail-ldap
|
gettimeofday.c
|
#include <stdio.h>
#include <sys/time.h>
struct timeval sincepoch = {0,0};
struct timezone notimezone = {0,0};
int main()
{
gettimeofday(&sincepoch, ¬imezone);
printf("%d\n", sincepoch.tv_sec);
return 0;
}
|
openwengo/qmail-ldap
|
subfdins.c
|
<reponame>openwengo/qmail-ldap<gh_stars>10-100
#include "readwrite.h"
#include "substdio.h"
#include "subfd.h"
int subfd_readsmall(fd,buf,len) int fd; void *buf; int len;
{
if (substdio_flush(subfdoutsmall) == -1) return -1;
return subread(fd,buf,len);
}
char subfd_inbufsmall[256];
static substdio it = SUBSTDIO_FDBUF(subfd_readsmall,0,subfd_inbufsmall,256);
substdio *subfdinsmall = ⁢
|
yuchizhong/bubble_game
|
game/Classes/overScene.h
|
<gh_stars>0
#ifndef __OVER_SCENE_H__
#define __OVER_SCENE_H__
#include "cocos2d.h"
#include "bubble.h"
#include "game.h"
#include <list>
using namespace std;
class overScene : public cocos2d::Layer {
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// a selector callback
void startGame(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(overScene);
virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event);
};
#endif
|
yuchizhong/bubble_game
|
game/Classes/mainScene.h
|
#ifndef __MAIN_SCENE_H__
#define __MAIN_SCENE_H__
#include "cocos2d.h"
#include "bubble.h"
#include "game.h"
#include <list>
using namespace std;
#define TIME_RATE 1.0
class mainScene : public cocos2d::Layer {
list<bubble*> bubbles;
cocos2d::LabelTTF *lifeLabel;
cocos2d::LabelTTF *scoreLabel;
cocos2d::LabelTTF *haloLabel;
cocos2d::Sprite *haloButtonGray;
cocos2d::ProgressTimer *haloButton;
cocos2d::Sprite *pauseLabel;
cocos2d::Menu *pauseMenu;
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
void bubbleLogic();
void generateBubble();
void resumeGame(cocos2d::Ref *pSender);
void endGame(cocos2d::Ref *pSender);
// implement the "static create()" method manually
CREATE_FUNC(mainScene);
virtual void update(float tDelta);
virtual void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
void graySprite(cocos2d::Sprite *sprite);
};
#endif
|
yuchizhong/bubble_game
|
game/Classes/game.h
|
<gh_stars>0
//
// bubble.h
// game
//
// Created by <NAME> on 2014-12-02.
//
//
#ifndef __game__game__
#define __game__game__
#define INITED 0
#define INGAME 1
#define GAMEOVER 2
#define PAUSED 3
#define MAXERROR 5
#include <string>
#include "cocos2d.h"
using namespace std;
class game {
public:
int halo;
bool halo_active;
double halo_time_passed;
int status;
long score;
int error_count;
int correct_count;
int difficulty_count;
double time_passed;
static game* sharedGameManager();
void start();
void pause();
void resume();
void correct(int scoreGet);
bool overOnError();
void getError();
void gameOver();
void timePassed(float dt);
void setHalo(int withHalo);
void resetDifficultyCount();
void activateHalo();
void deactivateHalo();
void setHighScore(long high);
long getHighScore();
};
#endif
|
yuchizhong/bubble_game
|
game/Classes/bubble.h
|
<filename>game/Classes/bubble.h
//
// bubble.h
// game
//
// Created by <NAME> on 2014-12-02.
//
//
#ifndef __game__bubble__
#define __game__bubble__
//only 266 pixels radius in 400 file radius
//|edge|---134px---|--------266px--------|center|
#define BUBBLE_RADIUS 266.0
#define BUBBLE_FILE_RADIUS 400.0
//fly to score on touch
#define FLY_TO_SCORE_DURATION 0.5f
#define EXPLOSION_BEGIN_FRAME 7
#define EXPLOSION_END_FRAME 38
#define EXPLOSION_REMOVE_DELAY 1.0f
#define EXPLOSION_NUM_FRAMES (EXPLOSION_END_FRAME - EXPLOSION_BEGIN_FRAME + 1)
#define EXPLOSION_FRAME_DELAY EXPLOSION_REMOVE_DELAY / (float)EXPLOSION_NUM_FRAMES
#define MAX_AGE 2
#include <string>
#include "cocos2d.h"
using namespace std;
class bubble : public cocos2d::Sprite {
public:
int bubble_type;
float current_x, current_y;
float delta_x, delta_y;
float current_r, r_rate;
float current_angle, angle_rate;
float timePassed;
int age; //0, 1, 2
int textureAge;
cocos2d::Node *container;
bool punishUser;
static bubble* create(int type, float x, float y, float startingRadius, float rate, float dx, float dy);
static void startCache();
void setMyRotation(float init_ro, float ro_rate);
void update(float dt);
void onDeath(bool punish);
void onTouch();
void removeFromLayer(float dt);
};
#endif /* defined(__game__bubble__) */
|
yuchizhong/bubble_game
|
game/Classes/startScene.h
|
#ifndef __START_SCENE_H__
#define __START_SCENE_H__
#include "cocos2d.h"
#include "bubble.h"
#include "game.h"
#include <list>
using namespace std;
class startScene : public cocos2d::Layer {
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// a selector callback
void startGame(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(startScene);
virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event);
int selectedHalo;
cocos2d::Sprite *halo[3];
cocos2d::Vec2 haloPosn[3];
cocos2d::LabelTTF *haloLabel[2];
};
extern string haloName[3];
extern string haloDescription[3];
#endif
|
Sodacooky/HDD_Awaker
|
src/Application.h
|
#ifndef __APPLICATION_H__
#define __APPLICATION_H__
#include <string>
class Application
{
public:
int Main();
private:
void __Startup();
void __Running();
private:
std::string m_strSelectedPartition;
};
#endif // __APPLICATION_H__
|
Sodacooky/HDD_Awaker
|
src/StartupWindow.h
|
#ifndef __STARTUPWINDOW_H__
#define __STARTUPWINDOW_H__
#include <nana/gui.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/listbox.hpp>
#include <string>
//启动窗口,选择分区
//自动加载上次设定的分区勾选上
//构造函数传入保存已勾选分区的字符串
class StartupWindow
{
public:
//build window
StartupWindow(std::string &selected_partition);
public:
//阻塞直到窗口关闭(nana::exec)
void Exec();
private:
//扫描存在的分区
void __ScanAvaliablePartition();
//尝试读取配置文件并勾选
void __TryReloadSelection();
//按钮按下回调
//按下开始按钮后,更新“选定的字符串”并写出“上次设定文件”
void __StartButtonCallback();
private:
//存在的盘符字符串
std::string m_strAvaliablePartition;
//选定的字符串
std::string &m_rstrSelectedPartition;
//gui
nana::form m_formWindow;
nana::listbox m_lstbPartitionSelector;
nana::button m_btnStart;
};
#endif // __STARTUPWINDOW_H__
|
Sodacooky/HDD_Awaker
|
src/RunningWindow.h
|
#ifndef __RUNNINGWINDOW_H__
#define __RUNNINGWINDOW_H__
#include <chrono>
#include <nana/gui.hpp>
#include <nana/gui/widgets/label.hpp>
#include <stdint.h>
#include <string>
//运行时窗口,显示运行时间和写入的总数据量
//构造函数传入要工作的分区
//实际写入时仍然会检查分区的存在,若不存在则忽略不写(也不报错)
class RunningWindow
{
public:
RunningWindow(const std::string &selected_partition);
public:
//开始写线程,阻塞直到窗口关闭
void Exec();
private:
//在分离出来的线程上写
void __RunningThread();
//分区是否存在
bool __IsPartitionExist(char partition);
//成功true
bool __TryWriteData(char partition, const void *to_write, size_t to_write_size);
//更新窗口label
void __UpdateLabel();
private:
//
const std::string &m_rstrSelectedPartition;
//thread keep running
bool m_bKeepRunning;
//写入量
uint32_t m_unWrittenBytes;
//程序启动时间
std::chrono::system_clock::time_point m_tpStartTime;
//gui
nana::form m_formWindow;
nana::label m_lbPartitionInfo;
nana::label m_lbRunningState;
};
#endif // __RUNNINGWINDOW_H__
|
hvhbot/DEADCELL-CSGO
|
csgo/features/backtrack/backtrack.h
|
#pragma once
#include "../../inc.h"
struct lag_record_t {
lag_record_t( ) : m_bonecount{ 0 }, m_simtime{ 0.f }, m_lby{ 0.f }{ }
lag_record_t( c_csplayer* player ) : m_priority{ 0 } {
std::memcpy( m_matrix, player->bone_cache( ).base( ), player->get_bone_count( ) * sizeof( matrix3x4_t ) );
m_bonecount = player->get_bone_count( );
m_tickcount = g_csgo.m_global_vars->m_tickcount;
// save all data here.
m_simtime = player->simtime( );
m_origin = player->origin( );
m_angles = player->angles( );
m_lby = player->lby_t( );
m_flags = player->flags( );
m_vel = player->velocity( );
m_mins = player->get_collideable( )->mins( );
m_maxs = player->get_collideable( )->maxs( );
}
bool is_valid( ) const;
int m_priority;
int m_tickcount;
int m_flags;
int m_bonecount;
float m_lby;
float m_simtime;
vec3_t m_origin;
vec3_t m_angles;
vec3_t m_mins;
vec3_t m_maxs;
vec3_t m_vel;
matrix3x4_t m_matrix[ 128 ];
};
struct player_log_t {
c_csplayer *m_player;
std::deque< lag_record_t > m_records;
};
class c_backtrack{
size_t m_max_records{ 12 };
public:
std::array< player_log_t, 64 > m_players;
void log( );
void reset( );
bool restore( c_csplayer *e, lag_record_t &record );
void update_animation_data( c_csplayer *e );
void process_cmd( c_user_cmd* cmd, c_csplayer* e, lag_record_t &record );
player_log_t *get( int index );
};
extern c_backtrack g_backtrack;
|
hvhbot/DEADCELL-CSGO
|
csgo/menu/menu.h
|
<reponame>hvhbot/DEADCELL-CSGO<filename>csgo/menu/menu.h
#pragma once
#include "../inc.h"
class c_menu {
private:
// x axis pos.
int m_control_x_pos;
// y axis pos.
int m_control_y_pos;
OSHGui::Drawing::Color m_primary_colour;
public:
std::shared_ptr< OSHGui::Form > m_form;
std::shared_ptr< OSHGui::Form > m_dangerzone_form;
std::string m_selected_sound_text;
c_menu( );
void init( );
void set_x_pos( int x );
void set_y_pos( int y );
int get_x_pos( ) const;
int get_y_pos( ) const;
void push_x_pos( int x );
void push_y_pos( int y );
};
extern c_menu g_menu;
namespace controls {
using namespace OSHGui::Drawing;
using namespace OSHGui::Misc;
class c_groupbox : public OSHGui::GroupBox {
private:
public:
c_groupbox( const AnsiString &text, int x, int y, int w, int h );
};
class c_checkbox : public OSHGui::CheckBox {
private:
void init( const AnsiString &text, int x, int y, Control *parent, bool *cvar );
public:
c_checkbox( const AnsiString &text, int x, int y, Control *parent, bool *cvar );
c_checkbox( const AnsiString &text, Control *parent, bool *cvar );
};
class c_text_box : public OSHGui::TextBox {
private:
void init( const AnsiString &text, int x, int y, Control *parent ) {
SetFont( g_renderer.m_fonts.at( 0 ) );
SetLocation( x, y );
//SetSize( 220, 30 );
// SetText( text );
parent->AddControl( this );
}
public:
c_text_box( const AnsiString &text, int x, int y, Control *parent ) {
init( text, x, y, parent );
}
// automatic positioning.
c_text_box( const AnsiString &text, Control *parent ) {
// set size here.
Control::SetSize( 160, 20 );
init( text, parent->GetWidth() / 2 - Control::GetWidth() / 2 - 3, g_menu.get_y_pos( ), parent );
g_menu.push_y_pos( 28 );
}
};
class c_label : public OSHGui::Label {
private:
void init( const AnsiString &text, int x, int y, Control *parent, const FontPtr &font, int style, OSHColor colour );
public:
c_label( const AnsiString &text, int x, int y, Control *parent, const FontPtr &font, int style, OSHColor colour );
c_label( const AnsiString &text, int x, int y, Control *parent );
c_label( const AnsiString &text, Control *parent, const FontPtr &font, int style, OSHColor colour );
c_label( const AnsiString &text, Control *parent );
};
class c_combo : public OSHGui::ComboBox {
private:
void init( const AnsiString &text, std::vector< AnsiString > items, int x, int y, Control *parent, int max_items, int *cvar );
public:
c_combo( const AnsiString &text, const std::vector< AnsiString > &items, int x, int y, Control *parent, int max_items, int *cvar );
c_combo( const AnsiString &text, const std::vector< AnsiString > &items, Control *parent, int max_items, int *cvar, int parent_width );
};
class c_sound_combo : public OSHGui::ComboBox {
private:
void init( const AnsiString &text, std::vector<AnsiString> items, int x, int y, Control *parent, int max_items, int *cvar );
public:
c_sound_combo( const AnsiString &text, const std::vector<AnsiString> &items, int x, int y, Control *parent, int max_items, int *cvar );
c_sound_combo( const AnsiString &text, const std::vector<AnsiString> &items, Control *parent, int max_items, int *cvar, int parent_width );
};
class c_slider : public OSHGui::TrackBar {
private:
void init( const AnsiString &text, int x, int y, Control *parent, float min, float max, float *value, int precision, float default_value, std::string append_text );
void init( const AnsiString &text, int x, int y, Control *parent, float min, float max, int *value, int default_value, std::string append_text );
public:
c_slider( const AnsiString &text, int x, int y, Control *parent, float min, float max, int *value, int default_value, std::string append_text = "" );
c_slider( const AnsiString &text, int x, int y, Control *parent, float min, float max, float *value, int precision, float default_value, std::string append_text = "" );
c_slider( const AnsiString &text, Control *parent, float min, float max, int *value, int default_value, std::string append_text = "" );
c_slider( const AnsiString &text, Control *parent, float min, float max, float *value, int precision, float default_value, std::string append_text = "" );
};
class c_colorpicker : public OSHGui::ColorButton {
private:
void init( int x, int y, Control *parent, float *col );
public:
c_colorpicker( Control *parent, Control *control, float *col );
};
class c_button : public OSHGui::Button {
private:
void init( const AnsiString &text, int x, int y, Control *parent ) {
SetForeColor( OSHColor::FromARGB( 255, 201, 201, 201 ) );
SetFont( g_renderer.m_fonts.at( 0 ) );
SetLocation( x, y );
//SetSize( 220, 30 );
SetText( text );
// I'm not sure how to pass a lambda as a function parameter.
// so we'll just have to call AddControl manually.
// parent->AddControl( this );
}
public:
c_button( const AnsiString &text, int x, int y, Control *parent ) {
init( text, x, y, parent );
}
// automatic positioning.
c_button( const AnsiString &text, Control *parent ) {
// set size here.
Control::SetSize( 160, 20 );
init( text, parent->GetWidth() / 2 - Control::GetWidth() / 2 - 3, g_menu.get_y_pos( ), parent );
g_menu.push_y_pos( 28 );
}
};
class c_hotkey : public OSHGui::HotkeyControl {
private:
void init( const AnsiString &text, int x, int y, Control *parent, int *cvar );
public:
c_hotkey( const AnsiString &text, Control *parent, int *cvar, int parent_width );
};
}
class c_main_form : public OSHGui::Form {
private:
std::vector< std::shared_ptr< OSHGui::TabPage > > m_pages;
OSHGui::TabControl *m_tab_control{ };
// tab pages.
enum Pages {
PAGE_RAGEBOT,
PAGE_VISUALS,
PAGE_MISC,
PAGE_CONFIG,
PAGE_PLAYERLIST,
PAGE_MAX
};
// initialize all controls.
void init_component( );
void init_tabs( );
void playerlist_tab( );
void ragebot_tab( );
void misc_tab( );
void visuals_tab( );
void config_tab();
public:
c_main_form( ) {
init_component( );
}
};
class c_dangerzone_form : public OSHGui::Form {
private:
std::vector< std::shared_ptr< OSHGui::TabPage > > m_pages;
OSHGui::TabControl *m_tab_control{ };
// tab pages.
enum Pages {
PAGE_VISUALS,
PAGE_MISC,
PAGE_MAX
};
// initialize all controls.
void init_component( );
void init_tabs( );
void misc_tab( );
void visuals_tab( );
public:
c_dangerzone_form( ) {
init_component( );
}
};
|
hvhbot/DEADCELL-CSGO
|
csgo/sdk/csgo/csgo.h
|
#pragma once
class c_csgo : protected c_interface_mgr {
private:
using command_line_t = i_command_line *( __stdcall * )( );
public:
bool m_interfaces_successful = false;
// modules.
pe::Module m_client_dll;
pe::Module m_engine_dll;
// misc ptrs;
uintptr_t m_d3d9_vmt = 0;
// interfaces.
chl_client *m_client = nullptr;
i_engine_client *m_engine = nullptr;
i_client_mode_shared *m_client_mode = nullptr;
i_client_entity_list *m_entity_list = nullptr;
c_input *m_input = nullptr;
c_global_vars *m_global_vars = nullptr;
i_cvar *m_convar = nullptr;
iv_model_info *m_model_info = nullptr;
i_material_system *m_material_system = nullptr;
iv_render_view *m_render_view = nullptr;
iv_model_render *m_model_render = nullptr;
i_surface *m_surface = nullptr;
iv_debug_overlay *m_debug_overlay = nullptr;
i_panel *m_panel = nullptr;
i_studio_render *m_studio_render = nullptr;
i_engine_trace *m_engine_trace = nullptr;
i_game_movement *m_game_movement = nullptr;
i_prediction *m_prediction = nullptr;
i_move_helper *m_movehelper = nullptr;
i_game_event_manager *m_game_event = nullptr;
i_view_render_beams *m_render_beams = nullptr;
i_weapon_system *m_weapon_system = nullptr;
iv_efx *m_effects = nullptr;
client_state *m_clientstate = nullptr;
c_physics_surface *m_physics_surface = nullptr;
i_localize *m_localize = nullptr;
i_mem_alloc *m_memalloc = nullptr;
i_mdl_cache *m_modelcache = nullptr;
i_view_render *m_viewrender = nullptr;
c_glow_object_mngr *m_glow_obj_manager = nullptr;
i_command_line *m_command_line = nullptr;
c_csgo() { }
bool init( ) {
// modules.
m_client_dll = pe::get_module( CT_HASH32( "client_panorama.dll" ) );
m_engine_dll = pe::get_module( CT_HASH32( "engine.dll" ) );
if( !m_client_dll || !m_engine_dll )
return false;
// misc ptrs.
m_d3d9_vmt = pattern::find( CT_HASH32( "shaderapidx9.dll" ), "A1 ? ? ? ? 50 8B 08 FF 51 0C" );
m_d3d9_vmt = **reinterpret_cast< uintptr_t ** >( m_d3d9_vmt + 1 );
if( !m_d3d9_vmt )
return false;
m_memalloc = *pe::get_export< i_mem_alloc ** >( pe::get_module( "tier0.dll" ), "g_pMemAlloc" );
if( !m_memalloc )
return false;
m_command_line = pe::get_export< command_line_t >( pe::get_module( "tier0.dll" ), "CommandLine" )();
if( !m_command_line )
return false;
// interfaces.
m_client = get_interface< chl_client >( CT_HASH32( "VClient" ) );
if( !m_client )
return false;
m_engine = get_interface< i_engine_client >( CT_HASH32( "VEngineClient" ) );
if( !m_engine )
return false;
m_client_mode = **c_vmt::get_method( m_client, 10 ).add< i_client_mode_shared *** >( 5 );
if( !m_client_mode )
return false;
m_input = c_vmt::get_method( m_client, 20 ).at< c_input * >( 4 );
if( !m_input )
return false;
m_entity_list = get_interface< i_client_entity_list >( CT_HASH32( "VClientEntityList" ) );
if( !m_entity_list )
return false;
m_global_vars = **c_vmt::get_method( m_client, 0 ).add< c_global_vars *** >( 27 );
if( !m_global_vars )
return false;
m_convar = get_interface< i_cvar >( CT_HASH32( "VEngineCvar" ) );
if( !m_convar )
return false;
m_model_info = get_interface< iv_model_info >( CT_HASH32( "VModelInfoClient" ) );
if( !m_model_info )
return false;
m_material_system = get_interface< i_material_system >( CT_HASH32( "VMaterialSystem" ) );
if( !m_material_system )
return false;
m_render_view = get_interface< iv_render_view >( CT_HASH32( "VEngineRenderView" ) );
if( !m_render_view )
return false;
m_model_render = get_interface< iv_model_render >( CT_HASH32( "VEngineModel" ) );
if( !m_model_render )
return false;
m_debug_overlay = get_interface< iv_debug_overlay >( CT_HASH32( "VDebugOverlay" ) );
if( !m_debug_overlay )
return false;
m_panel = get_interface< i_panel >( CT_HASH32( "VGUI_Panel" ) );
if( !m_panel )
return false;
m_surface = get_interface< i_surface >( CT_HASH32( "VGUI_Surface" ) );
if( !m_surface )
return false;
m_studio_render = get_interface< i_studio_render >( CT_HASH32( "VStudioRender" ) );
if( !m_studio_render )
return false;
m_engine_trace = get_interface< i_engine_trace >( CT_HASH32( "EngineTraceClient" ) );
if( !m_engine_trace )
return false;
m_game_movement = get_interface< i_game_movement >( CT_HASH32( "GameMovement" ) );
if( !m_game_movement )
return false;
m_prediction = get_interface< i_prediction >( CT_HASH32( "VClientPrediction" ) );
if( !m_prediction )
return false;
m_viewrender = *c_vmt::get_method( m_client, 28 ).at< i_view_render ** >( 8 );
if( !m_viewrender )
return false;
m_movehelper = **reinterpret_cast< i_move_helper *** >( pattern::find( m_client_dll, "8B 0D ? ? ? ? 8B 45 ? 51 8B D4 89 02 8B 01" ) + 2 );
if( !m_movehelper )
return false;
m_game_event = get_interface< i_game_event_manager >( CT_HASH32( "GAMEEVENTSMANAGER002" ), 0, false );
if( !m_game_event )
return false;
m_render_beams = *pattern::find< i_view_render_beams ** >( m_client_dll, "B9 ? ? ? ? A1 ? ? ? ? FF 10 A1 ? ? ? ? B9", 1 );
if( !m_render_beams )
return false;
m_weapon_system = *pattern::find< i_weapon_system ** >( m_client_dll, "8B 35 ? ? ? ? FF 10 0F B7 C0", 2 );
if( !m_weapon_system )
return false;
m_effects = get_interface< iv_efx >( CT_HASH32( "VEngineEffects" ) );
if( !m_effects )
return false;
m_clientstate = **c_vmt::get_method( m_engine, 12 ).add< client_state*** >( 16 );
if( !m_clientstate )
return false;
m_physics_surface = get_interface< c_physics_surface >( CT_HASH32( "VPhysicsSurfaceProps" ) );
if( !m_physics_surface )
return false;
m_localize = get_interface< i_localize >( CT_HASH32( "Localize_001" ), 0, false );
if( !m_localize )
return false;
m_modelcache = get_interface< i_mdl_cache >( CT_HASH32( "MDLCache" ) );
if( !m_modelcache )
return false;
m_glow_obj_manager = *pattern::find< c_glow_object_mngr ** >( m_client_dll, "0F 11 05 ? ? ? ? 83 C8 01", 3 );
if( !m_glow_obj_manager )
return false;
m_interfaces_successful = true;
return true;
}
};
extern c_csgo g_csgo;
|
hvhbot/DEADCELL-CSGO
|
csgo/features/vars.h
|
#pragma once
class c_vars {
public:
struct rage {
int key;
bool enabled;
int target_selection;
float pointscale = 60.f;
bool prefer_bodyaim;
bool save_fps;
bool selectively_multipoint_records;
bool bodyaim_lethal;
int hitchance;
int min_dmg;
bool auto_fire;
bool silent;
bool autostop;
int autoscope;
bool head;
bool pelvis;
bool legs;
bool arms;
bool teammate;
bool hitbox_head;
bool hitbox_pelvis;
bool hitbox_legs;
bool hitbox_arms;
int primary_hitbox;
bool dynamic_hitbox;
} rage;
struct visuals {
int activation_type;
int activation_key;
bool bbox;
float box_color[ 4 ] = { 220, 255, 0, 0 };
bool name;
float name_color[ 4 ] = { 220, 255, 255, 255 };
bool weapon;
float weapon_color[ 4 ] = { 220, 255, 255, 255 };
bool healthbar;
bool ammo_bar;
float ammo_bar_color[ 4 ] = { 220, 79, 130, 255 };
bool money;
float money_color[ 4 ] = { 200, 149, 184, 6 };
bool flags;
float flag_color[ 4 ] = { 200, 255, 255, 255 };
bool flash_bar;
float flash_bar_color[ 4 ] = { 220, 255, 255, 255 };
bool glow;
float glow_color[4] = { 155, 206, 115, 136 };
int filter;
bool dropped_weapons;
bool dropped_ammo;
float dropped_ammo_color[ 4 ] = { 220, 79, 130, 255 };
bool chicken;
bool projectiles;
bool objectives;
bool dormancy_fade;
bool grenade_pred;
int visualize_spread;
bool hitmarker;
bool impact;
float impact_color[ 4 ] = { 255, 255, 0, 0 };
bool radar;
float visualize_spread_color[ 4 ] = { 70, 113, 59, 198 };
struct chams{
bool teammates;
bool enabled;
bool twopass;
int type;
float alpha;
float reflectivity;
float luminance;
bool blend_scope;
float vis_color[ 4 ] = { 220, 255, 0, 0 };
float hid_color[ 4 ] = { 220, 255, 255, 255 };
bool local;
float local_col[ 4 ] = { 220, 206, 115, 136 };
} chams;
struct misc {
bool no_flash;
bool fog;
int remove_scope;
bool remove_scope_zoom;
bool remove_blur;
float scope_color[ 4 ] = { 220, 0, 0, 0 };
int remove_smoke;
} misc;
struct extra {
bool speclist;
bool antiaim_direction;
float antiaim_direction_color[ 4 ] = { 178, 113, 59, 198 };
bool misc_flags;
bool points;
} extra;
struct effects {
int camera_fov = 90;
int weapon_fov = 64;
} effects;
} visuals;
struct misc {
struct fakelag {
bool enabled;
int type;
int amount = 6;
int lagjump;
} fakelag;
bool bhop;
bool air_strafe;
bool thirdperson;
bool thirdperson_dead;
bool thirdperson_grenade;
int thirdperson_key;
int flashlight_key;
bool autozeus;
bool log_damage;
bool log_purchases;
int nightmode;
int prop_transparency;
bool fast_duck;
bool dangerzone_menu;
int hitmarker_sound;
bool client_hitboxes;
float client_hitboxes_duration = 2.f;
bool bullet_impacts;
float bullet_impacts_duration = 4.f;
} misc;
struct antiaim{
bool enabled;
int yaw;
float jitter;
int fake_yaw;
int pitch;
int left_override_key = 37;
int right_override_key = 39;
int backwards_override_key = 40;
int reset_override_key = 38;
int side_switch_key;
} antiaim;
struct dangerzone{
int max_item_distance;
bool healthshot;
bool drone;
bool turret;
bool cash;
bool safe;
bool weapon_case;
bool tool_case;
bool tablet_upgrade;
bool airdrop;
bool armor;
bool contract;
bool parachute;
bool ammobox;
bool jammer;
bool melee_weapon;
bool breach_charge;
} dz;
};
extern c_vars g_vars;
|
crea7or/EulerPowersConjecture
|
EulerCpp/uint128.h
|
#pragma once
typedef unsigned __int64 uint64;
typedef unsigned __int32 uint32;
#pragma warning(disable : 4244)
// enable multiply via BMI2: https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets
// https://msdn.microsoft.com/en-us/library/hh977022.aspx
// otherwise regular mul via ASM x64
//#define BMI2MUL
//#include <intrin.h>
//#pragma intrinsic(_mul128)
extern "C" inline void Multiply128(uint64, uint64);
//extern "C" inline void Adc128(uint64, uint64);
struct uint128
{
public:
uint128(uint64 hp = 0, uint64 lp = 0)
{
h = hp;
l = lp;
}
uint128(const uint128& v)
{
h = v.h;
l = v.l;
}
uint128(const uint64& v)
{
h = 0;
l = v;
}
uint128(const uint32& v)
{
h = 0;
l = v;
}
operator uint128()
{
return *this;
}
operator uint64()
{
return l;
}
operator uint32()
{
return l;
}
// basic arithmetic operators
uint128& operator= (const uint128& v)
{
h = v.h;
l = v.l;
return *this;
}
uint128& operator= (const uint64& v)
{
h = 0;
l = v;
return *this;
}
uint128& operator= (const uint32& v)
{
h = 0;
l = v;
return *this;
}
bool operator<(const uint128& v) const
{
if (h < v.h)
{
return true;
}
else if (h > v.h)
{
return false;
}
if (l < v.l)
{
return true;
}
return false;
}
bool operator>(const uint128& v) const
{
if (h > v.h)
{
return true;
}
else if (h < v.h)
{
return false;
}
if (l > v.l)
{
return true;
}
return false;
}
friend uint128 operator*(const uint128& s, const uint128& d);
friend uint128 operator+(const uint128& s, const uint128& d);
uint128& operator+= (const uint128& v)
{
uint64 carry = 0;
uint64 tmp = l + v.l;
if (tmp < l)
{
carry = 1;
}
l = tmp;
h = h + v.h + carry;
// Adc128((uint64)this, (uint64)&v);
// intristic use
//unsigned char c = 0;
//c = _addcarry_u64(c, l, v.l, &l);
//_addcarry_u64(c, h, v.h, &h);
return *this;
}
#ifdef BMI2MUL
uint128& operator*= (const uint128& v)
{
// intristic use
uint64 h1 = 0;
uint64 h2 = 0;
uint64 l1 = 0;
uint64 l2 = 0;
l1 = _mulx_u64(l, v.l, &h1);
h1 += _mulx_u64(l, v.h, &h2);
h1 += _mulx_u64(h, v.l, &h2);
l = l1;
h = h1;
return *this;
}
#else
uint128& operator*= (const uint128& v)
{
Multiply128((uint64)this, (uint64)&v);
return *this;
}
#endif
uint128& operator++ ()
{
uint64 carry = 0;
uint64 tmp = l + 1;
if (tmp < l)
{
carry = 1;
}
l = tmp;
h = h + carry;
return *this;
}
uint128 operator++ (int)
{
uint128 temp(h, l);
uint64 carry = 0;
uint64 tmp = l + 1;
if (tmp < l)
{
carry = 1;
}
l = tmp;
h = h + carry;
return temp;
}
// conditions
bool operator==(const uint128 &v) const
{
return ( h == v.h ) && ( l == v.l );
}
uint32 GetHash16() const
{
uint32 h1 = ((uint32)(h >> 32) ^ (uint32)h) ^ ((uint32)(l >> 32) ^ (uint32)l);
return (((h1 >> 16) ^ h1) & 0xFFFF);
}
uint32 GetHash32() const
{
return ((uint32)(h >> 32) ^ (uint32)h) ^ ((uint32)(l >> 32) ^ (uint32)l);
}
uint64 GetHash64() const
{
return h ^ l;
}
uint64 GetH()
{
return h;
}
uint64 GetL()
{
return l;
}
void Set(uint64 hv, uint64 lv)
{
h = hv;
l = lv;
}
void SetH(uint64 hv)
{
h = hv;
}
void SetL(uint64 lv)
{
l = lv;
}
#ifdef BMI2MUL
friend uint128 operator*(const uint128& s, const uint128& d)
{
// intristic use
uint64 h = 0;
uint64 l = 0;
uint64 h2 = 0;
uint64 l2 = 0;
l = _mulx_u64(d.l, s.l, &h);
h += _mulx_u64(d.l, s.h, &h2);
h += _mulx_u64(d.h, s.l, &h2);
return uint128( h, l);
}
#else
friend uint128 operator*(const uint128& s, const uint128& d)
{
uint128 temp(s);
Multiply128((uint64)&temp, (uint64)&d);
return uint128( temp );
}
#endif
friend uint128 operator+(const uint128& s, const uint128& d)
{
uint128 temp(s);
temp += d;
return uint128(temp);
}
#ifdef BMI2MUL
uint128& pow( uint32 pw )
{
if (pw < 2)
{
if (pw == 0)
{
h = 0;
l = 1;
}
return *this;
}
// intristic use
uint64 hp = h;
uint64 lp = l;
uint64 h1 = 0;
uint64 l1 = 0;
uint64 h2 = 0;
uint64 l2 = 0;
while (--pw)
{
l = _mulx_u64(l, lp, &h1);
h1 += _mulx_u64(l, hp, &h2);
h1 += _mulx_u64(h, lp, &h2);
h = h1;
}
return *this;
}
#else
uint128& pow( uint32 pw )
{
// not implt
// uint128 temp(s);
// Multiply128((uint64)&temp, (uint64)&d);
return *this;
}
#endif
private:
uint64 h;
uint64 l;
};
|
adrian-tech-enthusiast/Bot
|
src/messenger/messenger.h
|
/**
* Author : <NAME>.
* Version : 1.0.0
* Copyright : © 2021 <NAME>, All Rights Reserved.
* Title : messenger.h
* Description : Messenger helper functions, sends formatted messages to stdout.
*/
#ifndef MESSENGER_H
#define MESSENGER_H
// Color variables.
#define GREEN "\e[0;32m"
#define YELLOW "\e[0;33m"
#define RED "\e[0;31m"
// Bold high intensity text.
#define BACKGROUND_RED "\e[30;48;5;1m"
#define BACKGROUND_GREEN "\e[30;48;5;40m"
#define BACKGROUND_YELLOW "\e[30;48;5;11m"
// Reset the color.
#define RESET "\e[0m"
/**
* Adds a new info message.
*
* @param const char* message
* The given info message.
*/
void info(const char *message);
/**
* Adds a new success message.
*
* @param const char* message
* The given success message.
*/
void success(const char *message);
/**
* Adds a new error message.
*
* @param const char* message
* The given error message.
*/
void error(const char *message);
/**
* Adds a new warning message.
*
* @param const char* message
* The given warning message.
*/
void warning(const char *message);
#endif
|
adrian-tech-enthusiast/Bot
|
main.c
|
#include "src/bot/bot.h"
/**
* Main controller function.
*
* @param int argc
* The number of arguments passed by the user in the command line.
* @param char* argv
* Array of char, the arguments names passed by the user.
*
* @return int
* The constant EXIT_SUCCESS on Successful exit status, otherwise EXIT_FAILURE.
*/
int main(int argc, char *argv[]) {
return bot_init();;
}
|
adrian-tech-enthusiast/Bot
|
src/question/choice_question.c
|
<reponame>adrian-tech-enthusiast/Bot
/**
* Author : <NAME>.
* Version : 1.0.0
* Copyright : © 2021 <NAME>, All Rights Reserved.
* Title : choice_question.c
* Description : Question helper functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "choice_question.h"
#include "../messenger/messenger.h"
/**
* {@inheritdoc}
*/
choice_option create_choice_option(char *id, char *label) {
size_t storage_amount = sizeof(struct traversable_choice_option);
choice_option option = (choice_option) malloc(storage_amount);
if (option != NULL) {
option->id = id;
option->label = label;
}
return option;
}
/**
* {@inheritdoc}
*/
choice_question create_choice_question(char *label) {
size_t storage_amount = sizeof(struct choice_question_item);
choice_question q = (choice_question) malloc(storage_amount);
if (q != NULL) {
q->label = label;
q->next = NULL;
}
return q;
}
/**
* {@inheritdoc}
*/
void add_choice_option(choice_question question, char *id, char *label) {
// Create the choice option.
choice_option option = create_choice_option(id, label);
// Add the choice option to the question.
if (question->number_of_choices == 0) {
// Choice question is empty.
question->next = option;
} else {
// Choice question is not empty.
choice_option index = question->next;
while (index->next != NULL) {
index = index->next;
}
index->next = option;
}
// Increment the size ot the task manager.
(question->number_of_choices)++;
}
/**
* {@inheritdoc}
*/
char *ask_choice_question(choice_question question) {
// Display the question.
info(question->label);
// Display the choices.
int i, message_length;
int char_size = sizeof(char);
char *message;
choice_option index = question->next;
for (i = 1; i <= question->number_of_choices; ++i) {
// Format choice.
message_length = strlen(index->label);
message = malloc(message_length * char_size);
sprintf(message, "[%i] %s", i, index->label);
// Show choice.
info(message);
// Move to the next choice.
index = index->next;
}
// Get the selected choice.
int selected_choice_index;
scanf("%d", &selected_choice_index);
index = question->next;
for (i = 1; i <= question->number_of_choices; ++i) {
if (i == selected_choice_index) {
return index->id;
}
// Move to the next choice.
index = index->next;
}
index = question->next;
return index->id;
}
|
adrian-tech-enthusiast/Bot
|
src/question/choice_question.h
|
/**
* Author : <NAME>.
* Version : 1.0.0
* Copyright : © 2021 <NAME>, All Rights Reserved.
* Title : choice_question.h
* Description : Question helper functions.
*/
#ifndef CHOICE_QUESTION_H
#define CHOICE_QUESTION_H
/**
* Traversable choice option struct.
*/
struct traversable_choice_option {
/**
* The choice identifier.
*
* @var *char id
*/
char *id;
/**
* The choice label.
*
* @var *char label
*/
char *label;
/**
* Pointer to the next choice item in the list.
*
* @var traversable_choice_option next
*/
struct traversable_choice_option *next;
};
/**
* Definition of the date type choice_option.
*
* @var traversable_task_item choice_option
*/
typedef struct traversable_choice_option *choice_option;
/**
* Choice question item struct.
*/
struct choice_question_item {
/**
* The question to ask.
*
* @var *char[] label
*/
char *label;
/**
* The default choice id.
*
* @var *char[] default_choice_id
*/
char *default_choice_id;
/**
* Pointer to the next choice item.
*
* @var choice_option next
*/
choice_option next;
/**
* Number of choices.
*
* @var int size
*/
volatile int number_of_choices;
};
/**
* Definition of the date type choice question.
*
* @var traversable_task_item choice_question
*/
typedef struct choice_question_item *choice_question;
/**
* Create a new choice option instance.
*
* @param char* id
* The choice identifier.
* @param char* label
* The choice label.
*
* @return choice_option
* The choice option instance.
*/
choice_option create_choice_option(char *id, char *label);
/**
* Create a new choice question instance.
*
* @param char* label
* The question to ask.
*
* @return choice_question
* The question instance.
*/
choice_question create_choice_question(char *label);
/**
* Add a choice to the list in a choice question.
*
* @param choice_question question
* The choice question.
* @param char* id
* The choice identifier.
* @param char* label
* The choice label.
*/
void add_choice_option(choice_question question, char *id, char *label);
/**
* Ask choice question.
*
* @param choice_question question
* The choice question to ask.
*
* @return char const
* The selected choice identifier.
*/
char *ask_choice_question(choice_question question);
#endif
|
adrian-tech-enthusiast/Bot
|
src/tasks/do_fetch_data.c
|
/**
* Author : <NAME>.
* Version : 1.0.0
* Copyright : © 2021 <NAME>, All Rights Reserved.
* Title : fetch_data.c
* Description : Bot Task - fetch data.
*/
#include "do_fetch_data.h"
#include "../messenger/messenger.h"
/**
* {@inheritdoc}
*/
task_response do_fetch_data() {
success("_> Doing Fetch data...");
return task_response_create(1);
}
|
adrian-tech-enthusiast/Bot
|
src/tasks/do_say_hello.h
|
<reponame>adrian-tech-enthusiast/Bot<filename>src/tasks/do_say_hello.h
/**
* Author : <NAME>.
* Version : 1.0.0
* Copyright : © 2021 <NAME>, All Rights Reserved.
* Title : do_say_hello.h
* Description : Bot Task - Say hello.
*/
#ifndef BOT_TASK_SAY_HELLO_H
#define BOT_TASK_SAY_HELLO_H
#include "task_response.h"
/**
* Say hello callback-function.
*/
task_response do_say_hello();
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.