1 /* $RCSfile: usersub.c,v $$Revision: 4.0.1.1 $$Date: 91/11/11 16:47:17 $
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 4.0.1.1 91/11/11 16:47:17 lwall
9 * patch19: deleted some unused functions from usersub.c
11 * Revision 4.0 91/03/20 01:55:56 lwall
25 * The following is supplied by John Macdonald as a means of decrypting
26 * and executing (presumably proprietary) scripts that have been encrypted
27 * by a (presumably secret) method. The idea is that you supply your own
28 * routine in place of cryptfilter (which is purposefully a very weak
29 * encryption). If an encrypted script is detected, a process is forked
30 * off to run the cryptfilter routine as input to perl.
42 #include "cryptlocal.h"
44 #else /* ndef CRYPTLOCAL */
46 #define CRYPT_MAGIC_1 0xfb
47 #define CRYPT_MAGIC_2 0xf1
54 while( (ch = getc( fil )) != EOF ) {
55 putchar( (ch ^ 0x80) );
59 #endif /* CRYPTLOCAL */
62 static FILE *lastpipefile;
72 mypfiopen(fil,func) /* open a pipe to function call for input */
81 fatal("Can't get pipe for decrypt");
84 /* make sure that the child doesn't get anything extra */
88 while ((pipepid = fork()) < 0) {
89 if (errno != EAGAIN) {
93 fatal("Can't fork for decrypt");
111 str = afetch(fdpid,p[0],TRUE);
112 str->str_u.str_useful = pipepid;
113 return fdopen(p[0], "r");
120 /* cheat on stdio if possible */
121 if (rsfp->_cnt > 0 && (*rsfp->_ptr & 0xff) != CRYPT_MAGIC_1)
125 if (ch == CRYPT_MAGIC_1) {
126 if (getc(rsfp) == CRYPT_MAGIC_2) {
127 if( perldb ) fatal("can't debug an encrypted script");
128 rsfp = mypfiopen( rsfp, cryptfilter );
129 preprocess = 1; /* force call to pclose when done */
132 fatal( "bad encryption format" );
139 #endif /* CRYPTSCRIPT */