meATprivacyDOTnet <(E-Mail Removed)> writes:
> Hi,
>
> I am trying to learn some C programming language and network
> programming on Linux by myself.
>
> I am looking for the the source code of a simple POP server in order
> to get a better understanding on how to network functions work.
>
> Even a non-working explame would be great.
>
> Do you where I can find it?
>
> I am not looking for a full-blown POP server (e.g. Courier Mail
> Server), since the source code would be too complex for me (at least
> for now).
>
> Thanks a lot.
Ok, here is a not full-blown POP server. If it's too simple for you
try the sources of qpopper.
#!/bin/bash
printf "+OK POP3 $(hostname -f) v7.64 server ready\r\n"
exit=0
while [ $exit = 0 ] ; do
read key rest ; key=${key:0:4}
case "$key" in
USER|user)
printf -- "+OK User name accepted, password please\r\n"
exit=1
;;
QUIT|quit)
printf -- "+OK Sayonara\r\n"
exit 0
;;
*)
printf -- "-ERR Unknown AUTHORIZATION state command\r\n"
;;
esac
done
exit=0
while [ $exit = 0 ] ; do
read key rest ; key=${key:0:4}
case "$key" in
PASS|pass)
printf -- "+OK Mailbox open, 0 messages\r\n"
exit=1
;;
QUIT|quit)
printf -- "+OK Sayonara\r\n"
exit 0
;;
*)
printf -- "-ERR Unknown command\r\n"
;;
esac
done
while true ; do
read key rest ; key=${key:0:4}
case "$key" in
LIST|list)
printf -- "+OK Mailbox scan listing follows\r\n.\r\n"
;;
QUIT|quit)
printf -- "+OK Sayonara\r\n"
exit 0
;;
*)
printf -- "-ERR Unknown command\r\n"
;;
esac
done
--
__Pascal Bourguignon__
http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush