mirror of
https://github.com/imapsync/imapsync.git
synced 2025-08-05 00:11:31 +02:00
1.920
This commit is contained in:
parent
62531f58cd
commit
852d9695d6
76 changed files with 55631 additions and 0 deletions
0
W/learn/+ZyhnUA-
Normal file
0
W/learn/+ZyhnUA-
Normal file
10
W/learn/bug_Mail-IMAPClient-3.40_connect
Executable file
10
W/learn/bug_Mail-IMAPClient-3.40_connect
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict ;
|
||||
use warnings ;
|
||||
use Mail::IMAPClient ;
|
||||
|
||||
my $imap = Mail::IMAPClient->new( ) ;
|
||||
$imap->connect( ) ;
|
||||
print "I hope I'm not dead but...\n" ;
|
||||
|
38
W/learn/bug_io_prompt_local_ARGV
Executable file
38
W/learn/bug_io_prompt_local_ARGV
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IO::Prompt;
|
||||
|
||||
# The defect is when used with a pipe, like the following on the command line example,
|
||||
# prompt() does not print the prompt string 'Say something: '
|
||||
# however the variable @ARGV is locally empty.
|
||||
# The output is then only:
|
||||
#
|
||||
# $ echo bla bla bla | ./bug_io_prompt_local_ARGV param1 param2
|
||||
# ARGV are param1 param2
|
||||
# You said: bla bla bla
|
||||
|
||||
# I tried also
|
||||
# prompt( \*STDOUT, 'Say something: ');
|
||||
|
||||
# The behavior is ok without the pipe:
|
||||
# ./bug_io_prompt_local_ARGV param1 param2
|
||||
|
||||
print "$IO::Prompt::VERSION\n" ;
|
||||
print "ARGV are @ARGV\n" ;
|
||||
|
||||
my $input = get_stdin();
|
||||
|
||||
print "You said: $input\n" ;
|
||||
|
||||
sub get_stdin
|
||||
{
|
||||
local(@ARGV) ;
|
||||
my $input = prompt(
|
||||
-prompt => 'Say it: ',
|
||||
-echo => '*',
|
||||
-newline => "\nGot it\n"
|
||||
) ;
|
||||
return $input ;
|
||||
}
|
44
W/learn/bug_io_prompter_local_ARGV
Executable file
44
W/learn/bug_io_prompter_local_ARGV
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IO::Prompter;
|
||||
|
||||
# The defect is when used with a pipe, like the following on the command line example,
|
||||
# prompt() does not print the prompt string 'Say something: '
|
||||
# however the variable @ARGV is locally empty.
|
||||
# The output is then only:
|
||||
#
|
||||
# $ echo bla bla bla | ./bug_io_prompt_local_ARGV param1 param2
|
||||
# ARGV are param1 param2
|
||||
# You said: bla bla bla
|
||||
|
||||
# I tried also
|
||||
# prompt( \*STDOUT, 'Say something: ');
|
||||
|
||||
# The behavior is ok without the pipe:
|
||||
# ./bug_io_prompt_local_ARGV param1 param2
|
||||
|
||||
# echo input | { echo -n "prompt: " ; read stdin ; echo "got $stdin" ; }
|
||||
# { echo -n "prompt: " ; read stdin ; echo "got $stdin" ; }
|
||||
|
||||
|
||||
print "$IO::Prompter::VERSION\n" ;
|
||||
print "ARGV are @ARGV\n" ;
|
||||
|
||||
my $input = get_stdin();
|
||||
|
||||
print "You said: $input\n" ;
|
||||
|
||||
sub get_stdin
|
||||
{
|
||||
#local(@ARGV) ;
|
||||
my $prompt = 'Say something: ' ;
|
||||
my $input = prompt(
|
||||
-prompt => $prompt,
|
||||
-echo => '*',
|
||||
-in => *STDIN,
|
||||
-out => *STDOUT,
|
||||
);
|
||||
return $input ;
|
||||
}
|
67
W/learn/file_append
Executable file
67
W/learn/file_append
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use English;
|
||||
use Mail::IMAPClient;
|
||||
|
||||
my $rcs = '$Id: append,v 1.1 2011/07/14 16:49:02 gilles Exp gilles $ ';
|
||||
|
||||
|
||||
main();
|
||||
|
||||
sub main {
|
||||
$ARGV[4] or die "usage: $0 host user password folder file\n";
|
||||
|
||||
my $host = $ARGV[0];
|
||||
my $user = $ARGV[1];
|
||||
my $password = $ARGV[2];
|
||||
my $folder = $ARGV[3];
|
||||
my $file = $ARGV[4];
|
||||
|
||||
my $imap = Mail::IMAPClient->new();
|
||||
$imap->Debug(1);
|
||||
$imap->Server($host);
|
||||
#$imap->Ssl(1);
|
||||
$imap->connect() or die;
|
||||
$imap->User($user);
|
||||
$imap->Password($password);
|
||||
$imap->login() or die;
|
||||
$imap->Uid(1);
|
||||
$imap->Peek(1);
|
||||
$imap->Clear(0);
|
||||
|
||||
print map {"$_\n"} $imap->folders();
|
||||
|
||||
$imap->select($folder) or $imap->create($folder) or die;
|
||||
$imap->select($folder) ;
|
||||
my @msgs = $imap->messages ;
|
||||
print "LIST: @msgs\n";
|
||||
|
||||
my $msgtext = file_to_string( $file ) || die ;
|
||||
|
||||
my $new_id_1b = $imap->append_string( $folder, $msgtext ) ;
|
||||
print "==== OK 1b $new_id_1b\n" if $new_id_1b ;
|
||||
@msgs = $imap->messages ;
|
||||
print "LIST: @msgs\n";
|
||||
|
||||
$imap->close();
|
||||
}
|
||||
|
||||
sub file_to_string {
|
||||
my $file = shift ;
|
||||
if ( ! $file ) { return ; }
|
||||
if ( ! -e $file ) { return ; }
|
||||
if ( ! -f $file ) { return ; }
|
||||
if ( ! -r $file ) { return ; }
|
||||
my @string ;
|
||||
if ( open my $FILE, '<', $file ) {
|
||||
@string = <$FILE> ;
|
||||
close $FILE ;
|
||||
return( join q{}, @string ) ;
|
||||
}else{
|
||||
myprint( "Error reading file $file : $OS_ERROR\n" ) ;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
24
W/learn/here_comment
Executable file
24
W/learn/here_comment
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict ;
|
||||
use warnings ;
|
||||
|
||||
|
||||
0 and <<'COMMENT';
|
||||
This is a multiline comment.
|
||||
Based on David Carter discussion, to do:
|
||||
* Call parameters stay the same.
|
||||
* Now always "return( $string, $error )". Descriptions below.
|
||||
OK * Still capture STDOUT via "1> $output_tmpfile" to finish in $string and "return( $string, $error )"
|
||||
OK * Now also capture STDERR via "2> $error_tmpfile" to finish in $error and "return( $string, $error )"
|
||||
OK * in case of CHILD_ERROR, return( undef, $error )
|
||||
and print $error, with folder/UID/maybeSubject context,
|
||||
on console and at the end with the final error listing. Count this as a sync error.
|
||||
* in case of good command, take final $string as is, unless void. In case $error with value then print it.
|
||||
* in case of good command and final $string empty, consider it like CHILD_ERROR =>
|
||||
return( undef, $error ) and print $error, with folder/UID/maybeSubject context,
|
||||
on console and at the end with the final error listing. Count this as a sync error.
|
||||
COMMENT
|
||||
# End of multiline comment.
|
||||
|
||||
|
5
W/learn/imap_gbk_Q_decode
Normal file
5
W/learn/imap_gbk_Q_decode
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
perl -E 'use open qw(:std :utf8);
|
||||
use Encode;
|
||||
say Encode::decode("MIME-Header", "Subject: Re: =?gbk?Q?=C3=C9=B9=C5=CF=EE=C4=BF=D0=CD=D6=C6=D7=F7=B7=BD=B0=B8?=");'
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue