RexxUtil.DLL - OS2

This is a discussion on RexxUtil.DLL - OS2 ; /************************************************** *********************** * Function: SysQueryClassList * * * * Syntax: call SysQueryClassList stem * * * * Params: stem - name of a stem variable in which the list of * * classes will be saved * * * * ...

+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6
Results 101 to 110 of 110

Thread: RexxUtil.DLL

  1. Re: RexxUtil.DLL - SysQueryClassList

    /************************************************** ***********************
    * Function: SysQueryClassList *
    * *
    * Syntax: call SysQueryClassList stem *
    * *
    * Params: stem - name of a stem variable in which the list of *
    * classes will be saved *
    * *
    * Return: WinSetFileIcon API return code. Possible values are 1 *
    * if the icon was set successfully, or 0 otherwise *
    ************************************************** ***********************/

    unsigned long SysQueryClassList(unsigned char *name,
    unsigned long numargs,
    RXSTRING args[],
    char *queuename,
    RXSTRING *retstr)
    {
    int countClass = 0;

    bool firstStruct = TRUE;

    char *szStemName;
    char *pszStemIdx;
    char *szValue;

    unsigned long rc;
    unsigned long objSize = 0;

    POBJCLASS ClassBuffer;
    POBJCLASS ptrBuffer;

    /* Only one argument accepted */
    if (numargs != 1 || !RXVALIDSTRING(args[0]) ||
    args[0].strlength > 255) return INVALID_ROUTINE;

    /* remember stem name */
    szStemName = alloca(256);
    memset(szStemName, 0, 256);
    strcpy(szStemName, args[0].strptr);
    strupr(szStemName);

    // check for '.' and if not there make it so
    if (szStemName[args[0].strlength-1] != '.')
    szStemName[args[0].strlength] = '.';

    // pointer to the index part of stem
    pszStemIdx = &(szStemName[strlen(szStemName)]);

    // get size of buffer required
    if(!WinEnumObjectClasses(NULL, &objSize)) RETVAL(0)

    // make buffers
    ClassBuffer = alloca( objSize );

    // get classes
    if(!WinEnumObjectClasses(ClassBuffer, &objSize)) RETVAL(0)

    // setup and clear
    szValue = alloca( objSize );
    memset(szValue, 0, objSize);

    ptrBuffer = ClassBuffer;

    while(1) {

    if(!firstStruct) ptrBuffer = ptrBuffer->pNext;
    else firstStruct = FALSE;

    itoa(++countClass, pszStemIdx, 10);

    sprintf(szValue, "%s %s",
    ptrBuffer->pszClassName, ptrBuffer->pszModName);

    rc = SetRexxVariable(szStemName, szValue);

    if ((rc != RXSHV_OK) && (rc != RXSHV_NEWV)) RETVAL(0)

    if(ptrBuffer->pNext == NULL) break;
    }

    // setup the 0 index with number of classes
    strcpy(pszStemIdx, "0"); // index
    sprintf(szValue, "%ld", countClass); // value

    rc = SetRexxVariable(szStemName, szValue);

    RETVAL(!(rc>RXSHV_NEWV))
    }

  2. Re: RexxUtil.DLL

    Sorry,

    Finally, why I had SetRexxVariable function - I start with a testcase
    and then move into dll. The following compiles with wcl386 -wx file.c if
    the following is saved as file.c.



    #define INCL_WINWORKPLACE

    #include
    #include
    #include
    #include
    #include
    #include


    int main( void )
    {
    int countClass = 0;

    char *szStemName;
    char *pszStemIdx;
    char *szValue;

    // unsigned long rc;
    unsigned long objSize = 0;

    POBJCLASS ClassBuffer;
    POBJCLASS ptrBuffer = NULL;

    /* remember stem name */
    szStemName = alloca(256);
    memset(szStemName, 0, 256);

    // *** fake stem name ***
    strcpy(szStemName, "test.");
    // strcpy(szStemName, args[0].strptr);
    strupr(szStemName);

    // pointer to the index part of stem
    pszStemIdx = &(szStemName[strlen(szStemName)]);

    // get size of buffer required
    // return if error
    if(!WinEnumObjectClasses(NULL, &objSize)) return 0;

    // make buffer
    ClassBuffer = alloca( objSize );

    // get the class list in the buffer
    // return if error
    if(!WinEnumObjectClasses(ClassBuffer, &objSize)) return 0;

    // setup and clear
    szValue = alloca( objSize );
    memset(szValue, 0, objSize);

    ptrBuffer = ClassBuffer;

    while(ptrBuffer) {

    itoa(++countClass, pszStemIdx, 10);

    sprintf(szValue, "%s %s",
    ptrBuffer->pszClassName, ptrBuffer->pszModName);

    // I guess put in a call to the example call:
    // int SetRexxVariable(char *name, char *value);
    // or just put the code block here, for the example
    // just print
    printf("%s\n", szStemName);
    printf("%s\n", szValue);

    ptrBuffer = ptrBuffer->pNext;
    }

    strcpy(pszStemIdx, "0");
    sprintf(szValue, "%ld", countClass);

    // same as above
    printf("%s\n", szStemName);
    printf("%s\n", szValue);

    return 0;
    }

  3. Re: RexxUtil.DLL - SysRegisterObjectClass - SysDeregisterObjectClass

    Are your functions the same?

    unsigned long SysRegisterObjectClass(unsigned char *name,
    unsigned long numargs,
    RXSTRING args[],
    char *queuename,
    RXSTRING *retstr)
    {
    if (numargs != 2 || !RXVALIDSTRING(args[0]) ||
    !RXVALIDSTRING(args[1])) return INVALID_ROUTINE;

    RETVAL( WinRegisterObjectClass(args[0].strptr, args[1].strptr)?1:0)
    }

    unsigned long SysDeregisterObjectClass(unsigned char *name,
    unsigned long numargs,
    RXSTRING args[],
    char *queuename,
    RXSTRING *retstr)
    {
    if (numargs != 1 || !RXVALIDSTRING(args[0]) return INVALID_ROUTINE;

    RETVAL(WinDeregisterObjectClass(args[0].strptr)?1:0)
    }

  4. Re: RexxUtil.DLL - SysRegisterObjectClass - SysDeregisterObjectClass


    > Are your functions the same?


    > SysRegisterObjectClass
    > SysDeregisterObjectClass


    Yes, essentially. Written, but not tested yet. That'll mainly apply
    to the args[]-checking, e.g. with or without RXZEROLENGTHSTRING()
    and so on.

    > WinRegisterObjectClass(args[0].strptr, args[1].strptr)?1:0


    I may have used "!" or "!!" instead, if needed, to ensure a 0 or
    1 is returned. Hardly worth mentioning...


    BTW, preventing us from getting flamed: with the class listing you
    now used 255/256. Use e.g. #define MAX 256, MAX and MAX-1 instead,
    and/or the real maximum length of a file specification. That ought
    to be easier to maintain when such a number ever changes.




    ---

  5. Re: RexxUtil.DLL


    >> When you call both the original function and yours e.g. 10 times in
    >> a row, can you notice an obvious difference in execution speed, or
    >> causes using RexxVariablePool() a zillion times no harm (it has an
    >> advantage, no alloc'ing and having to call the OS API 3 times for
    >> an extra count)?


    > I'll have to try this to find out.


    Underlying consideration, obviously: if it's easy to notice that
    it's far slower, waist a few kB's of memory to do it it one pass
    using the unliked pointers to the next SHVBLOCK.

    But if the speed hardly matters, I'ld prefer to not waist memory
    and then stick with your solution. After all, one may use this on
    a Warp-pc with a very limited amount of RAM installed.



    ---

  6. Re: RexxUtil.DLL


    >> Your szValue is too small. It may be MAXPATHLENGTH+space+length_ of_
    >> classname. Use 2*MAX here?


    > What if I just alloca( ) the same size buffer as returned by the
    > first WinEnumObjectClasses? There is no way it would be too small
    > then.


    512 bytes should be enough. If not, both the full file specification
    and the name have to be extremely long. Too large has no advantages.

    >> What happens here, if the number of classes with your version
    >> is 0?


    > Hmmm... there is always going to be at least >1 class


    Why? If e.g. the *.INI file is corrupted, the function should return
    stem.0=0 found instead of crash. There are more ways to check such
    situations, so you don't have to use the beloved linked list.

    > SysQueryClassList does not return a meaningful value.


    Then don't add/change it? stem.0=0 is the way to check the result.
    Adding an meaningful value has no use, and breaks compatibility.
    If I'ld use your version, this may work:

    IF SysQueryClassList('stem.')=0 THEN SAY 'Okay!' ELSE EXIT

    But if I run that using an older version returning 17063183, it
    fails without a valid reason:

    IF SysQueryClassList('stem.')=0 THEN SAY 'Okay!' ELSE EXIT

    > But a good return of 0 or 1 sounds good.


    This sounds even better, and should work with all versions with a
    SysQueryClassList():

    CALL SysQueryClassList 'stem.'
    IF stem.0>0 THEN SAY 'Okay!;' ELSE EXIT

    >> When you call both the original function and yours e.g. 10 times in
    >> a row, can you notice an obvious difference in execution speed, or
    >> causes using RexxVariablePool() a zillion times no harm (it has an
    >> advantage, no alloc'ing and having to call the OS API 3 times for
    >> an extra count)?


    > I'll have to try this to find out.


    ISTR RexxVariablePool() is slow. If one can notice that clearly, it
    may be required to use RexxVariablePool() just once.



    ---

  7. Re: RexxUtil.DLL - SysElapsedTime

    My SysElapsedTime testcase, any suggestions for improvements?

    #define INCL_DOSPROFILE
    #include
    #include
    #include
    #include
    #include
    #include
    #include


    // these move to final
    #define TIMER_ELAPSE 0
    #define TIMER_RESET 1

    unsigned long TimeFreq = 0;
    double TimeStart = 0;
    // end

    int TimeTest( char *Option, char *Buffer );

    int main(int argc, char *argv[])
    {
    char *Buffer = alloca(30);
    char *Buffer1 = alloca(30);

    memset(Buffer, 0, 30);
    memset(Buffer1, 0, 30);


    TimeTest("E", Buffer);
    printf("1: %s\n", Buffer);

    sleep(2);

    TimeTest("E", Buffer);
    printf("2: %s\n", Buffer);

    sleep(3);

    TimeTest("R", Buffer);
    printf("3: %s\n", Buffer);

    sleep(2);

    TimeTest("E", Buffer);
    printf("4: %s\n", Buffer);

    TimeTest("R", Buffer);
    TimeTest("E", Buffer1);

    printf("5: %s %s\n", Buffer, Buffer1);


    return 1;
    }

    int TimeTest( char *Option, char *Buffer )
    {
    int flags = TIMER_ELAPSE; // default

    double TimeCurrent;
    double TimeDiff;

    QWORD Ticks;



    // requires 0 or 1 args
    // if (numargs > 1) return INVALID_ROUTINE;


    // handle flags passed first
    // switch (toupper(args[0].strptr[0])) {

    switch (toupper(Option[0])) { // TMP

    case 'E':
    flags = TIMER_ELAPSE;
    break;

    case 'R':
    flags = TIMER_RESET;
    break;

    default:
    return 0; //INVALID_ROUTINE;
    }

    // if this is the first call to SysElapsedTime
    // get the frequency of the IRQ0 high resolution
    // timer and set TimeStart
    if(!TimeFreq) {
    DosTmrQueryFreq(&TimeFreq);
    DosTmrQueryTime(&Ticks);
    TimeStart = ((long long int)Ticks.ulHi <<32) + Ticks.ulLo;
    TimeDiff = 0;
    } else {
    DosTmrQueryTime(&Ticks);
    TimeCurrent = ((long long int)Ticks.ulHi <<32) + Ticks.ulLo;
    TimeDiff = (TimeCurrent - TimeStart)/TimeFreq;

    // reset
    if(flags == TIMER_RESET) TimeStart = TimeCurrent;
    }

    // retstr->strlength = sprintf(Buffer, "%.6f", TimeDiff);
    // return VALID_ROUTINE;


    sprintf(Buffer, "%.6f", TimeDiff); // TMP
    return 1; // TMP
    }

  8. Re: RexxUtil.DLL

    ML wrote:
    >
    > >> When you call both the original function and yours e.g. 10 times in
    > >> a row, can you notice an obvious difference in execution speed, or
    > >> causes using RexxVariablePool() a zillion times no harm (it has an
    > >> advantage, no alloc'ing and having to call the OS API 3 times for
    > >> an extra count)?

    >
    > > I'll have to try this to find out.

    >
    > ISTR RexxVariablePool() is slow. If one can notice that clearly, it
    > may be required to use RexxVariablePool() just once.
    >


    I understand what you are saying. I did a couple more fixes to my elapse
    time function integrated and ran this script with my query class and the
    eCS rexxutil.dll:

    DO i = 1 TO 10
    call SysElapsedTime 'R'

    DO x = 1 TO 10
    call SysQueryClassList names
    END

    say SysElapsedTime('E' )
    END

    I have 180 classes register on this system and it is a SMP 2.8gig P4
    system. Here are a summary of the results:


    My eCS 2.0
    function rexxutil

    0.010253 0.011162
    0.009968 0.010868
    0.009978 0.010802
    0.009963 0.010796
    0.009957 0.010865
    0.009989 0.010876
    0.009968 0.010816
    0.009973 0.010825
    0.009999 0.010841
    0.009962 0.010849
    0.010288 0.011128
    0.010083 0.010899
    0.009986 0.016325
    0.010034 0.010903
    0.010057 0.011115
    0.010022 0.010878
    0.010086 0.010856
    0.010016 0.010887
    0.009992 0.010874
    0.010070 0.010869
    0.010244 0.011117
    0.009967 0.010966
    0.009955 0.010894
    0.010004 0.010912
    0.009991 0.010986
    0.009978 0.010935
    0.009968 0.010905
    0.009993 0.010945
    0.009985 0.010930
    0.009967 0.010937

    Mike

  9. Re: RexxUtil.DLL - Paul Ratcliffe

    Paul,

    For SysShutDownSystem is there a way to query whether xworkplace is
    installed and how can I call the xworklace shutdown?

    Mike

  10. Re: RexxUtil.DLL - Paul Ratcliffe

    On Sat, 12 Jan 2008 09:27:06 -0500, Michael Greene wrote:

    > For SysShutDownSystem is there a way to query whether xworkplace is
    > installed and how can I call the xworklace shutdown?


    I guess one is to check is to query the WPS class list and look for XFolder.
    To shutdown, you can invoke the "XSHUTDOWNNOW=DEFAULT" setup string on the
    WP_DESKTOP object (as it says in the XWP User Guide!!!).

+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6