Would it be possible to add a new -v option to ksh93's builtin to return the 
version number of a plugin?
Here is a quick prototype I put together to demonstrate the functionality:
Modify ../src/cmd/ksh93/bltins/typeset.c
810c810<       register int n, r=0, flag=0;--->       register int n, r=0, 
flag=0, vflag=0;839a840,842>             case 'v':>                 vflag=1;>   
              break;858a862,868>>         /* display plugin version number */>  
       if (vflag && *argv) {>             r = dllversion(*argv);>             
return (r);>         }>
and ../src/cmd/ksh93/data/builtins.c
392d391> "[v?Display plugin version number.]"
Add following function to any of the files in ../src/lib/libdll (or create new 
source code file)I put it in dllcheck.c.
extern intdllversion(const char* path){        unsigned long           v;       
 void *                 dll;        Dll_plugin_version_f    pvf;
        if (dll = dllopen(path, RTLD_LAZY|RTLD_GLOBAL|RTLD_PARENT))        {    
          if (!(pvf = (Dll_plugin_version_f)dlllook(dll, "plugin_version")))    
          {                  dlclose(dll);                  sfprintf(sfstderr, 
"plugin_version() not found\n");                  return 0;              }      
        v = (*pvf)();              sfprintf(sfstdout, "%lu" , v);              
dlclose(dll);              return 1;        }
        return 0;}
Here is the output for the example hash plugin I detailed in an earlier message.
$ version=$(builtin -v ./libhash.so)$ echo $version20100601$ version=$(builtin 
-v libhash.so)$ echo $version
$
- Finnbarr                                        
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to