Article delegate-en/991 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]

Newsgroups: mail-lists.delegate-en

[DeleGate-En] Patch to use an external script to rewrite the url
23 Jan 2001 11:49:18 GMT Christian Couder <pyebqbdyi-i3inxho4mzfr.ml@ml.delegate.org>


Hi again,

In my last mail I suggested an option to use an external script to rewrite the url.

Here is a patch to do it.

It is perhaps not very clean, but it works at least for me using pop.

I used 'cvs diff -c' to make this patch so it will be perhaps difficult to apply...

To use this patch you need to call delegated with an option like -Umyurlrewrite.sh where 'myurlrewrite.sh' is a script containing something like:


#!/usr/bin/bash

echo pop://localhost/$1@titi..


Regards,
Christian.

Index: delegated.c
===================================================================
RCS file: /usr/local/cvs-1.11/cvsroot/src/delegate7.0.0/src/delegated.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 delegated.c
*** delegated.c 2001/00/00 00:00:0X     1.1.1.1
--- delegated.c 2001/00/00 00:00:0X
***************
*** 952,957 ****
--- 952,960 ----
                            }
                        }
                        break;
+
+
+               case 'U': pushEnv(P_USCRIPT,val); break;

                case 'v':
                        if( arg[2] == 0 ){
Index: mount.c
===================================================================
RCS file: /usr/local/cvs-1.11/cvsroot/src/delegate7.0.0/src/mount.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 mount.c
*** mount.c     2001/00/00 00:00:0X     1.1.1.1
--- mount.c     2001/00/00 00:00:0X
***************
*** 31,36 ****
--- 31,39 ----
        - reverse matching in left hand (ex. *.gif)

  //////////////////////////////////////////////////////////////////////#*/
+ #include <ctype.h> /* FILE */
+ #include <stdio.h>
+ #include "param.h"
  #include "ystring.h"
  #include "url.h"
  extern char *CTX_clif_hostport();
***************
*** 1185,1196 ****
        if( rmt ) *rmt = mt;
        return mt->u_opts;
  }
  char *CTX_mount_url_to(ctx,myhostport,method,url)
        void *ctx;
        char *myhostport,*method,*url;
  {
!       return mount_url_toX(ctx,myhostport,method,url,U_MOUNT,NULL);
  }
  char *CTX_moved_url_to(ctx,myhostport,method,url)
        void *ctx;
        char *myhostport,*method,*url;
--- 1188,1223 ----
        if( rmt ) *rmt = mt;
        return mt->u_opts;
  }
+
+ static void fmount_url(script, url)
+      char *script, *url;
+ {
+   char command[256];
+   FILE *infp;
+
+   sprintf(command, "%s %s", script, url);
+
+   infp = popen(command, "r");
+
+   fscanf(infp, "%s", url);
+
+   pclose(infp);
+ }
+
  char *CTX_mount_url_to(ctx,myhostport,method,url)
        void *ctx;
        char *myhostport,*method,*url;
  {
!   char *uscript;
!
!   if( uscript = DELEGATE_getEnv(P_USCRIPT)) {
!     fmount_url(uscript, url);
!     return "";
!   } else {
!     return mount_url_toX(ctx,myhostport,method,url,U_MOUNT,NULL);
!   }
  }
+
  char *CTX_moved_url_to(ctx,myhostport,method,url)
        void *ctx;
        char *myhostport,*method,*url;
Index: param.c
===================================================================
RCS file: /usr/local/cvs-1.11/cvsroot/src/delegate7.0.0/src/param.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 param.c
*** param.c     2001/00/00 00:00:0X     1.1.1.1
--- param.c     2001/00/00 00:00:0X
***************
*** 126,131 ****
--- 126,132 ----
  char P_TRACELOG[] = "TRACELOG";
  char P_UMASK[]    = "UMASK";
  char P_URICONV[]  = "URICONV";
+ char P_USCRIPT[]  = "USCRIPT";
  char P_VARDIR[]   = "VARDIR";
  char P_VSAP[]     = "VSAP";
  char P_WORKDIR[]  = "WORKDIR";
Index: param.h
===================================================================
RCS file: /usr/local/cvs-1.11/cvsroot/src/delegate7.0.0/src/param.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 param.h
*** param.h     2001/00/00 00:00:0X     1.1.1.1
--- param.h     2001/00/00 00:00:0X
***************
*** 128,133 ****
--- 128,134 ----
  extern char P_TRACELOG[];
  extern char P_UMASK[];
  extern char P_URICONV[];
+ extern char P_USCRIPT[];
  extern char P_VARDIR[];
  extern char P_VSAP[];
  extern char P_WORKDIR[];




  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V