aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/preauth-harness
blob: 0bd0d842079c2fb4c0fca494cfd018a71802df6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl

BEGIN { $SIG{'__WARN__'} = sub {};};

$hostname = "criens.u-psud.fr";
$username = "p99dreyf";
$passwd = "xxxxxxxx";
$command = "exec ~/bin/imapd";

use Net::Telnet ();
$host = new Net::Telnet (Timeout => 10,
                         Port => 23,
                         Prompt => '/p99dreyf>\s?$/',
                         Cmd_remove_mode => 1);

$host->option_accept(Dont => &Net::Telnet::TELOPT_ECHO,
                     Wont => &Net::Telnet::TELOPT_ECHO);
                     open (FILE,">log");
$host->dump_log("log2");
$host->input_log("log3");
## Issue some commands.
$host->open($hostname);
#$host->login($username, $passwd);
$host->waitfor('/login:\s?$/');
$host->print("$username");
$host->waitfor('/Password:\s?$/');
$host->print("$passwd");
$host->waitfor('/p99dreyf>\s?$/');

$host->print("$command");
$strip=1;
while ($strip) {
        $greeting=$host->getline();
   if ($greeting=~/^\* PREAUTH.*$/) { print "$greeting"; $strip=0;};
}
    do {
      do {
        $cmd=<STDIN>;
        chop $cmd;
      } while ($cmd !~/[A-Za-z0-9]/);
      $host->print("$cmd");
      print FILE ">>$cmd<<\n";
      do {
        $line=$host->getline();
        chop($line);
        print "$line\n";
        print FILE "<<$line<<\n";
      } while (($line!~/^[A-Za-z0-9]+ (OK|BAD|Expunge).*$/) &&
                ($line!~/^\* BAD.*$/));
      print FILE "--next cmd\n";
    } while ($line!~/^[A-Za-z0-9]+ OK LOGOUT.*$/);

exit;
an class="n">ret | (getc(f) << 24); return ret; } struct image *bmp_open(FILE *f){ struct bmp_t *b; unsigned long headersize; rewind(f); if(getc(f) != 'B' || getc(f) != 'M') return NULL; b = malloc(sizeof(struct bmp_t)); b->f = f; fseek(f, 10, SEEK_SET); b->bitmapoffset = getlong(f); fseek(f, 14, SEEK_SET); headersize = getlong(f); if(headersize == 12){ /* OS/2 v1 */ b->ncolors = 0; fseek(f, 18, SEEK_SET); b->img.bufwidth = getshort(f); b->img.bufheight = getshort(f); b->compression = 0; }else{ fseek(f, 18, SEEK_SET); b->img.bufwidth = getlong(f); b->img.bufheight = getlong(f); fseek(f, 28, SEEK_SET); b->bpp = getshort(f); fseek(f, 30, SEEK_SET); b->compression = getlong(f); fseek(f, 46, SEEK_SET); b->ncolors = getlong(f); } if(!b->ncolors){ b->ncolors = 1 << b->bpp; } if(b->compression){ fprintf(stderr, "unsupported compression method %i\n", b->compression); return NULL; } if(b->bpp >= 16){ b->rowwidth = b->img.bufwidth * b->bpp / 8; b->colours = NULL; }else{ int i; b->colours = malloc(b->ncolors * sizeof(struct rgb_t)); fseek(f, 14+headersize, SEEK_SET); for(i = 0; i < b->ncolors; i++){ b->colours[i].b = getc(f); b->colours[i].g = getc(f); b->colours[i].r = getc(f); if(headersize != 12) getc(f); } b->rowwidth = (b->img.bufwidth * b->bpp + 7) / 8; } if(b->rowwidth & 3){ b->rowwidth += 4 - (b->rowwidth & 3); } b->img.fmt = &bmp; return (struct image *)b; } static void rgb16(unsigned char *buf, unsigned short c){ int i; for(i = 0; i < 3; i++){ *buf++ = ((c >> (i * 5)) & 0x1f) << 3; } } static int readrow(struct image *img, unsigned char *row, unsigned char *buf){ struct bmp_t *b = (struct bmp_t *)img; unsigned int x, i = 0; if(b->bpp == 24 || b->bpp == 32){ for(x = 0; x < img->bufwidth * 3; x+=3){ buf[x + 2] = row[i++]; buf[x + 1] = row[i++]; buf[x + 0] = row[i++]; if(b->bpp == 32) i++; } }else if(b->bpp == 16){ for(x = 0; x < img->bufwidth * 3; x+=3){ unsigned short c; c = row[i++]; c |= row[i++] << 8; rgb16(&buf[x], c); } }else if(b->bpp <= 8){ int mask; int pixelsperbit = 8 / b->bpp; mask = ~((~0) << b->bpp); for(x = 0; x < img->bufwidth; x++){ unsigned char c = ((row[i / pixelsperbit]) >> ((8 - ((i+1) % pixelsperbit) * b->bpp)) % 8) & mask; *buf++ = b->colours[c].r; *buf++ = b->colours[c].g; *buf++ = b->colours[c].b; i++; } }else{ fprintf(stderr, "bad bpp %i\n", b->bpp); return 1; } return 0; } int bmp_read(struct image *img){ struct bmp_t *b = (struct bmp_t *)img; unsigned int i, y; unsigned int dy; unsigned char *row; FILE *f = b->f; row = malloc(b->rowwidth); dy = img->bufwidth * 3; i = img->bufheight * dy; fseek(f, b->bitmapoffset, SEEK_SET); for(y = img->bufheight; y; y--){ i -= dy; if(fread(row, 1, b->rowwidth, f) != b->rowwidth || readrow(img, row, &img->buf[i])){ free(row); return 1; } } free(row); img->state = LOADED; return 0; } void bmp_close(struct image *img){ struct bmp_t *b = (struct bmp_t *)img; free(b->colours); fclose(b->f); } struct imageformat bmp = { bmp_open, NULL, bmp_read, bmp_close };