[NEWSboard IBMi Forum]

Thema: QHFRDDR

  1. #1
    Registriert seit
    Apr 2003
    Beiträge
    18

    Angry QHFRDDR

    Kann mir jemand einen Tip geben ob das QHFRDDR - API die selben Informationen wie der Befehl DSPDIRE liefert? Gibt es vielleicht ein kleines Beispiel?

    Danke!!
    Willi

  2. #2
    Registriert seit
    Dec 2000
    Beiträge
    450

    Post

    Hallo Willi,

    DSPDIRE liefert Informationen über Einträge im Systemverteilerverzeichnis, QHFRDDR ist ein API für das Hierarchical File System. Und das sind zwei ganz unterschiedliche Stiefel.

    Aber was hast du denn überhaupt vor?

    Gruß
    Bruno

  3. #3
    Registriert seit
    Apr 2003
    Beiträge
    18

    Unhappy

    Hi Bruno,
    ja es ist mir schon ein bisschen komisch vorgekommen. Ich möchte gerne die Informationen, die man mit DSPDIRE und DPSUSRPRF bekommt, in einem Windows-Programm (C++ oder ?) über API's auslesen und am Bildschirm (Window) ausgeben.
    Mehr nicht.
    Grüsse willi

  4. #4
    Registriert seit
    May 2002
    Beiträge
    2.642

    Wink

    Hallo Willi,
    hier ein Häufchen Informationen:

    All of the listing and attribute API's are detailed in the AS/400 Information center.
    The API's I think you are looking for are listed in: Programming/CL and API's/OS400 API's/API's by category/Hierarchical File System API's
    Directory entry information APIs
    The directory entry information APIs allow you to work with the directory entries for files and directories in hierarchical file systems. The directory entry information APIs include the following:
    Open Directory (QHFOPNDR)
    Read Directory Entry (QHFRDDR)
    Retrieve Directory Entry Attributes (QHFRTVAT)
    Change Directory Entry Attributes (QHFCHGAT)
    Close Directory (QHFCLODR)

    Und hier ein Beispiel:
    Listing Subdirectories
    You should call this program with only one parameter, the parameter that represents the directory you want to list.


    /************************************************** ****************/
    /************************************************** ****************/
    /* FUNCTION: List the subdirectories of the path passed to the */
    /* program to a spooled file. */
    /* */
    /* LANGUAGE: ILE C */
    /* */
    /* */
    /* APIs USED: QHFOPNDR, QHFRDDR, QHFCLODR */
    /* */
    /************************************************** ****************/
    /************************************************** ****************/

    /************************************************** ****************/
    /* INCLUDE FILES */
    /************************************************** ****************/
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <qhfopndr.h>
    #include <qhfrddr.h>
    #include <qhfclodr.h>
    #include <qusec.h>

    char write_string[100];
    FILE *stream;

    void print_subdir(char name[100], int numtabs)
    {

    /************************************************** ****************/
    /* Parameters for QHFOPNDR */
    /************************************************** ****************/
    char dir_handle[16]; /* Directory handle */
    int namelen; /* Length of path name */
    char openinfo[6]; /* Open information */

    typedef struct {
    Qhf_Attr_Selec_Tbl_t fixed;
    int att_len;
    char att_name[8];
    } selection_struct;

    selection_struct select;
    int selectionlen;

    /************************************************** ****************/
    /* Error Code Structure */
    /* */
    /* This shows how the user can define the variable length */
    /* portion of error code for the exception data. */
    /* */
    /************************************************** ****************/
    typedef struct {
    Qus_EC_t ec_fields;
    char Exception_Data[100];
    } error_code_t;

    error_code_t error_code;

    /************************************************** ****************/
    /* Parameters for QHFRDDR */
    /************************************************** ****************/
    /* The directory handle is the same as for QHFOPNDR */

    typedef struct {
    Qhf_Data_Buffer_t fixed;
    int num_att;
    int offsets[2];
    char attinfo[180];
    } read_buffer;

    read_buffer buffer;
    int result_count;
    int bytes_returned;

    /************************************************** ****************/
    /* Parameters for QHFCLODR */
    /************************************************** ****************/
    /* No additional ones need to be declared */

    /************************************************** ****************/
    /* Other declarations */
    /************************************************** ****************/
    char *att;
    char attname[30];
    char attval[30];
    int attnamelen;
    int attvallen;
    char newname[30];
    int newnamelen;
    int filesize;
    char fileatt[10];
    char tab[5];
    int bytes_used;
    int i, j;
    char charbin4[4];
    char tempname[100];

    error_code.ec_fields.Bytes_Provided = 0;

    /************************************************** **************/
    /* Build the attribute selection table for QHFOPNDR. */
    /************************************************** **************/
    select.fixed.Number_Attributes = 1;
    select.fixed.Offset_First_Attr = 8;
    select.att_len = 8;
    memcpy(select.att_name, "QFILATTR", 8);
    selectionlen = 20;
    memcpy(openinfo, "10 ", 6);
    memcpy(tab," ", 5);

    /************************************************** **************/
    /* Find the length of the directory name. */
    /************************************************** **************/
    for(i=0;i<100;i++)
    {
    if((name[i] == ' ') || (name[i] == '\x00'))
    break;
    }
    namelen = i;

    /************************************************** **************/
    /* Open the directory. */
    /************************************************** **************/
    QHFOPNDR(dir_handle, name, namelen, openinfo, &select, selectionlen,
    &error_code);

    /************************************************** **************/
    /* Read one entry from the directory. */
    /************************************************** **************/
    QHFRDDR(dir_handle, &buffer, 200, 1, &result_count, &bytes_returned,
    &error_code);

    fprintf(stream,"\n");
    for(i=0;i<numtabs;i++)
    fprintf(stream, tab);
    fprintf(stream, name);

    while(result_count > 0)
    {
    memcpy(attname," ",30);
    memcpy(attval," ",30);
    att = buffer.attinfo;
    bytes_used = 12;

    /************************************************** ************/
    /* Loop for the number of attributes in the entry. */
    /************************************************** ************/
    for(i=0;i<buffer.num_att;i++)
    {
    memcpy(charbin4, att, 4);
    attnamelen = *(int *)charbin4;
    att += 4;
    bytes_used += 4;
    memcpy(charbin4, att, 4);
    attvallen = *(int *)charbin4;
    att += 8;
    bytes_used += 8;
    memcpy(attname, att, attnamelen);
    att += attnamelen;
    bytes_used += attnamelen;
    memcpy(attval, att, attvallen);
    att += attvallen;
    bytes_used += attvallen;

    /************************************************** **********/
    /* Update att so that its first character is the first */
    /* character of the next attribute entry. */
    /************************************************** **********/
    if ((bytes_used == buffer.offsets[i+1]) &&
    ((i+1) == buffer.num_att))
    att += (buffer.offsets[i] - bytes_used);

    /************************************************** **********/
    /* If the attribute is QNAME, then set newname and */
    /* newnamelen just in case the entry is a directory. */
    /************************************************** **********/
    if(!memcmp(attname, "QNAME", 5))
    {
    memcpy(newname, attval, attvallen);
    newnamelen = attvallen;
    }

    /************************************************** **********/
    /* Else the attribute was QFILATTR, so set fileatt. */
    /************************************************** **********/
    else
    memcpy(fileatt, attval, 10);
    }

    /************************************************** ************/
    /* If the entry was a directory, construct new path name and */
    /* print_subdir to print the subdirectory. */
    /************************************************** ************/
    if(fileatt[3] == '1')
    {
    memcpy(tempname, name, 100);
    strcat(name, "/");
    strcat(name, newname);
    memcpy(newname, name, namelen + newnamelen + 1);
    print_subdir(newname, numtabs + 1);
    memcpy(name, tempname, 100);
    }

    QHFRDDR(dir_handle, &buffer, 200, 1, &result_count, &bytes_returned,
    &error_code);

    } /* while */

    /************************************************** **************/
    /* Close the directory. */
    /************************************************** **************/
    QHFCLODR(dir_handle, &error_code);

    }/* print_subdir */


    main(int argc, char *argv)
    {
    char dir_name[100];

    /************************************************** **************/
    /* Make sure we received the correct number of parameters. The */
    /* argc parameter will contain the number of parameters that */
    /* was passed to this program. This number also includes the */
    /* program itself, so we need to evaluate argc-1. */
    /************************************************** **************/

    if (((argc - 1) < 1) || ((argc - 1 > 1)))
    /************************************************** **************/
    /* We did not receive all of the required parameters, or */
    /* received too many. Exit from the program. */
    /************************************************** **************/
    {
    exit(1);
    }

    /************************************************** **************/
    /* Open QPRINT file so that data can be written to it. If the */
    /* file cannot be opened, print a message and exit. */
    /************************************************** **************/
    if((stream = fopen("QPRINT", "wb")) == NULL)
    {
    printf("File could not be opened\n");
    exit(1);
    }

    memset(dir_name, ' ', 100);
    memcpy(dir_name, argv[1], 100);
    if(!memcmp(dir_name, " ", 1))
    {
    fprintf(stream,"No directory specified");
    }
    else
    {
    fprintf(stream,"Directory substructure starting at %.100s", dir_name);
    print_subdir(dir_name, 0);
    }

    fclose(stream);

    } /* main */


    Dies alles wurde gefunden im Informationscenter der IBM mit dem
    Suchkriterium "QHFRDDR"

    Und hier noch die Links dazu: http://as400bks.rochester.ibm.com/pu...is/qhfrddr.htm
    Gruss TARASIK

    [Dieser Beitrag wurde von TARASIK am 27. Mai 2003 editiert.]

    [Dieser Beitrag wurde von TARASIK am 27. Mai 2003 editiert.]

    [Dieser Beitrag wurde von TARASIK am 27. Mai 2003 editiert.]

  5. #5
    Registriert seit
    Apr 2003
    Beiträge
    18

    Wink

    Hi TARASIK,
    danke für Deinen Input, ich werde mal mein Glück versuchen.
    Güsse Willi

  6. #6
    Registriert seit
    Jun 2001
    Beiträge
    727

    Post

    Hallo Willi und Tarasik,
    das wird so nicht funktionieren.
    Die QHFxxx APIs betreffen nur einen Teil des IFS - QDLS, QOPT, User written File System mit QHFRGFS API.

    Besser sind die IFS-APIs.
    Siehe hier : http://as400bks.rochester.ibm.com/is...apis/unix2.htm

    Einige Beispiele findest bei :
    IBM

    ftp://testcase.boulder.ibm.com/as400/fromibm/ApiSamples/

    Craig Rutledge http://home.alltel.net/craigru/jcrifs.zip

    Sven

    [Dieser Beitrag wurde von Sven Schneider am 27. Mai 2003 editiert.]

  7. #7
    Registriert seit
    Dec 2000
    Beiträge
    450

    Post

    Hallo Willi,

    für DSPUSRPRF kannst du den API QSYRUSRI verwenden. Für DSPDIRE kenne ich keinen API. Da gibts die Möglichkeit mit OUTPUT(*OUTFILE) in eine Datei zu schreiben und die dann auszulesen.

    Gruß
    Bruno

  8. #8
    Registriert seit
    Apr 2003
    Beiträge
    18

    Cool

    Euch allen vielen Dank für die Hilfe. Ich bin am testen. Kann mir vielleicht noch jemand sagen, wie man diese API's aus einem Windows-Programm (C++ oder VRPG)aufruft? Aus einem CL funktioniert es schon.
    Ich weiss ich bin unverschämt, aber besser fragen als zwei Wochen probieren.
    Danke nochmals!
    Willi

  9. #9
    Registriert seit
    Jan 2001
    Beiträge
    833

    Post

    Hallo Willi,

    bei C++ kann ich Dir nicht weiterhelfen, aber
    bei VARPG könntest Du einfach ein CALL auf ein CL machen und damit die Parameter übergeben.
    Du kannst die API'S im VRPG auch direkt aufrufen.
    Gruss Michael

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •