|
Below is a version of the program that works. The major changes I made are:
1. You can't treat the list entries as an array because they're variable
length.
2. For printf, the path name isn't a null-terminated string, so I built one
in allocated storage.
I'm sure there are simpler ways to do it, but this is what worked for me :-)
--Dave
----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <qusec.h>
#include <qusgen.h>
#include <qsnapi.h>
#include <quscrtus.h> //Create User Space
#include <qusdltus.h> //Delete User Space
#include <qusrtvus.h> //Retrieve User Space
#include <qusptrus.h> //Retrieve Pointer to User Space
#include <qsy.h> //QSY Common Structures
#include <qsylobja.h> //List Owned Objects
Qus_EC_t error;
char *char_space;
Qus_Generic_Header_0100_t *space;
Qsy_OBJA0310_List_T *objects310;
Qsy_Path_Info_T *path_ptr;
char *list_section;
char name[20] ="QLIST310 QTEMP ";
char extatr[20] =" ";
char initval[1] =" ";
char aut[10] ="*CHANGE ";
char text[50] ="List all Owned Objects";
char replace[10]="*YES ";
int initsize = 1024;
char usrprf[10];
char format[8] ="OBJA0310";
char objtype[10] ="*ALL ";
char retobj[10] ="*OBJOWN ";
char cnnhandle[20];
char request;
void main(int argc, char *argv[])
{
int i;
char temp[10];
int path_alloc_len;
char *path_alloc;
QsnClrScl(_C_Get_Ssn_Handle(), '0', NULL);
if (argc < 1) printf("Parameter 1 ist hier ... ");
memset(cnnhandle,' ',20);
strcpy(usrprf, argv[1]);
/* Create User Space */
error.Bytes_Provided=0;
QUSCRTUS(name,extatr,initsize, initval, aut,text, replace, &error);
/* List all owned Objects */
error.Bytes_Provided=0;
QSYLOBJA(name,format,usrprf,objtype,retobj, cnnhandle, &error);
/* Retieve Pointer to User Space */
error.Bytes_Provided=0;
QUSPTRUS(name,&space,&error);
char_space = (char *)space;
list_section = char_space;
list_section = list_section + space->Offset_List_Data;
objects310 = (Qsy_OBJA0310_List_T *)list_section;
for(i=0;i<space->Number_List_Entries;i++) {
path_ptr = (Qsy_Path_Info_T *)(char_space + objects310->Path_Offset);
path_alloc_len = path_ptr->Numbytes + 1;
path_alloc = realloc(path_alloc, path_alloc_len);
memcpy(path_alloc, (char *)path_ptr + sizeof(Qsy_Path_Info_T),
path_ptr->Numbytes);
*(path_alloc + path_ptr->Numbytes) = '\0';
printf("Object Type: %s\n", path_alloc);
objects310 = (Qsy_OBJA0310_List_T *)
((char *)path_ptr + objects310->Path_Length);
}
printf("%d\n", space->Number_List_Entries);
free(path_alloc);
QUSDLTUS(name,&error);
}
----------------------------------------------------------
Peter.Daransky@ambos.at wrote:
>
> This is a multipart message in MIME format.
> --
> [ Picked text/plain from multipart/alternative ]
> Hi,
>
> i'm a newbie in C on iSeries. I tryed to do program wich will list all
> User owned objects on IFS ... Now i've something, what don't want to show
> me all data ... It show me somthing but there are not only the files but
> some another information wich i don't need and by end of the programm i
> got this message in my Job Log: Space offset X'00008E00' or teraspace
> offset X'0000000000000000' is outside current limit for object QLIST310.
> Please tell me someone what do i wrong ?!
>
> Best regards
> Peter
>
> #include <string.h>
> #include <qusec.h>
> #include <qusgen.h>
> #include <qsnapi.h>
> #include <quscrtus.h> //Create User Space
> #include <qusdltus.h> //Delete User Space
> #include <qusrtvus.h> //Retrieve User Space
> #include <qusptrus.h> //Retrieve Pointer to User Space
> #include <qsylobja.h> //List Owned Objects
>
> Qus_EC_t error;
> Qus_Generic_Header_0100_t *space;
> // Qsy_OBJA0310_List_T *objects310;
>
> typedef struct {
> Qsy_OBJA0310_List_T obja0310;
> char Path_Name[100];
> } IFS_Struct;
>
> IFS_Struct *xobjects310;
> char *list_section;
>
> char name[20] ="QLIST310 QTEMP ";
> char extatr[20] =" ";
> char initval[1] =" ";
> char aut[10] ="*CHANGE ";
> char text[50] ="List all Owned Objects";
> char replace[10]="*YES ";
> int initsize = 1024;
>
> char usrprf[10];
> char format[8] ="OBJA0310";
> char objtype[10] ="*ALL ";
> char retobj[10] ="*OBJOWN ";
> char cnnhandle[20];
> char request;
>
> void main(int argc, char *argv[])
> {
> int i;
> char temp[10];
> QsnClrScl(_C_Get_Ssn_Handle(), '0', NULL);
> if (argc < 1) printf("Parameter 1 ist hier ... ");
> memset(cnnhandle,' ',20);
> strcpy(usrprf, argv[1]);
>
> /* Create User Space */
> error.Bytes_Provided=0;
> QUSCRTUS(name,extatr,initsize, initval, aut,text, replace, &error);
>
> /* List all owned Objects */
> error.Bytes_Provided=0;
> QSYLOBJA(name,format,usrprf,objtype,retobj, cnnhandle, &error);
>
> /* Retieve Pointer to User Space */
> error.Bytes_Provided=0;
> QUSPTRUS(name,&space,&error);
>
> list_section = (char *) space;
> list_section = list_section + space->Offset_List_Data;
> xobjects310 = (IFS_Struct *) list_section;
>
> for(i=1;i<=space->Number_List_Entries;i++) {
> &xobjects310[i];
> printf("Object Type: %s\n", xobjects310[i].Path_Name); };
>
> printf("%d\n", space->Number_List_Entries);
>
> QUSDLTUS(name,&error);
> }
> _______________________________________________
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.