1 /* $RCSfile: usersub.c,v $$Revision: 1.1.1.1 $$Date: 1994/09/10 06:27:34 $
3 * This file contains stubs for routines that the user may define to
4 * set up glue routines for C libraries or to decrypt encrypted scripts
8 * Revision 1.1.1.1 1994/09/10 06:27:34 gclarkii
9 * Initial import of Perl 4.046 bmaked
11 * Revision 1.1.1.1 1993/08/23 21:29:40 nate
14 * Revision 4.0.1.2 92/06/08 16:04:24 lwall
15 * patch20: removed implicit int declarations on functions
17 * Revision 4.0.1.1 91/11/11 16:47:17 lwall
18 * patch19: deleted some unused functions from usersub.c
20 * Revision 4.0 91/03/20 01:55:56 lwall
35 * The following is supplied by John Macdonald as a means of decrypting
36 * and executing (presumably proprietary) scripts that have been encrypted
37 * by a (presumably secret) method. The idea is that you supply your own
38 * routine in place of cryptfilter (which is purposefully a very weak
39 * encryption). If an encrypted script is detected, a process is forked
40 * off to run the cryptfilter routine as input to perl.
52 #include "cryptlocal.h"
54 #else /* ndef CRYPTLOCAL */
56 #define CRYPT_MAGIC_1 0xfb
57 #define CRYPT_MAGIC_2 0xf1
65 while( (ch = getc( fil )) != EOF ) {
66 putchar( (ch ^ 0x80) );
70 #endif /* CRYPTLOCAL */
73 static FILE *lastpipefile;
83 mypfiopen(fil,func) /* open a pipe to function call for input */
92 fatal("Can't get pipe for decrypt");
95 /* make sure that the child doesn't get anything extra */
99 while ((pipepid = fork()) < 0) {
100 if (errno != EAGAIN) {
104 fatal("Can't fork for decrypt");
122 str = afetch(fdpid,p[0],TRUE);
123 str->str_u.str_useful = pipepid;
124 return fdopen(p[0], "r");
132 /* cheat on stdio if possible */
133 if (rsfp->_cnt > 0 && (*rsfp->_ptr & 0xff) != CRYPT_MAGIC_1)
137 if (ch == CRYPT_MAGIC_1) {
138 if (getc(rsfp) == CRYPT_MAGIC_2) {
139 if( perldb ) fatal("can't debug an encrypted script");
140 rsfp = mypfiopen( rsfp, cryptfilter );
141 preprocess = 1; /* force call to pclose when done */
144 fatal( "bad encryption format" );
151 #endif /* CRYPTSCRIPT */