Ok. Well, let me post a section of the original code and then my re-write of it.
Original Code
int main (int argc, char *argv[])
{ /* 01 */
FILE *fd;
char host[20]="xups.uni.edu";
char req[005]="init";
char key[050]="init";
char msg[256]="init";
char nid[256]="Not Found";
char uni_num[256]="Not Found";
char email[256]="Not Found";
char *pt1, *pt2, *pt3, *pt4, *pt5, *pt6;
int *ptr_nid, *ptr_unino, *ptr_email, *ptr_msg, *ptr;
int nid_adr, unino_adr, email_adr, msg_adr;
pt1 = &req[0];
pt2 = &key[0];
pt3 = argv[0];
pt4 = argv[1];
if (argc == 3) {
pt3 = argv[1];
pt4 = argv[2];
}
if (argc == 7) {
pt5 = argv[6];
pt6 = &host[0];
strcpy (pt6,pt5);
}
strcpy ( pt1,pt3);
strcpy ( pt2,pt4);
query_ups(req, key, uni_num, nid, email, msg, host);
Rewrite
main(int argc, char **argv)
{
char nid.256.=" ",
uniID[256] = "",
email[256]="",
employeeID[256] = "",
searchField[256] = "",
searchValue[256] = "",
*cTempPtr = NULL;
int *msgPtr, *nidPtr, *uninoPtr, *emailPtr, *tempPtr;
int doMemOut = 0, echo = 1;
switch(argc)
{
case 3:
if(strcmp(argv[1], "alias") == 0)
{
strncpy(searchValue,argv[2], sizeof(nid) - 1);
strcpy(searchField, "CN");
}
else if(strcmp(argv[1], "unino") == 0)
{
strncpy(searchValue, argv[2], sizeof(uniID) - 1);
strcpy(searchField, "employeeID");
}
else if(strcmp(argv[1], "email") == 0)
{
strncpy(searchValue, argv[2], sizeof(email) - 1);
strcpy(searchField, "uniEduEmailForwardingAddress");
}
else
{
printf("Specify index to search! alias,unino,email\n");
return(1);
}
break;
case 7:
cTempPtr = argv[1];
strcpy(searchField, cTempPtr);
cTempPtr = argv[0];
strcpy(searchValue, cTempPtr);
cTempPtr = NULL;
doMemOut = 1;
echo = 0;
break;
default:
printf("Invalid number of arguments!\n");
return(1);
break;
}
if(query_ups(searchField,searchValue,"uniEduEmailForwardingAddress",email)!=0)
The goal here is to prep the incoming data for the query_ups function. The assembler arguments are as follows.
ARGS DS 0F OMVS CALL ARGUMENTS ADDR LIST 00007700
A1 DS A ARGUMENT 1 ADDR-> LDAP REQ KEY TYPE 00007800
A2 DS A ARGUMENT 2 ADDR-> LDAP KEY 00007900
AA3 DS A ARGUMENT 3 ADDR-> ADDR-> NETWRKID 00008000
AA4 DS A ARGUMENT 4 ADDR-> ADDR-> UNINO 00008100
AA5 DS A ARGUMENT 5 ADDR-> ADDR-> EMAIL 00008200
AA6 DS A ARGUMENT 6 ADDR-> ADDR-> LDAP MESSAGE 00008300
A7 DS A ARGUMENT 7 ADDR-> LDAP SERVER IP ADDRESS 00008400
As you can see, they pull in the data with strcpy originally. I'm just trying to clean it up and make it easier for the next unlucky to look at. To be honest, I don't know how the assembly program is passing the addresses, I don't have access to it. Just the above arg list that was given to me to go off of. I appreciate all of your help. I think the way it is working is basically the same way it was, so I'm assuming it is ok as is. But I guess I won't know until they test it and see if it gets the values from memory like it is supposed to.