You should be able to compile this with these changes:
1) Change these global declarations from:
extern dsUint32 dsmHandle;
extern dsmApiVersion apiVer; /* application's API version */
dsInt16 rc;
to
dsUint32_t dsmHandle;
dsmApiVersion apiVer; /* application's API version */
dsInt16_t rc;
2) Declare the function rcApiOut function above main():
void rcApiOut (dsUint32_t handle, dsInt16_t rc);
The revised program now looks like this:
==========================
#include <stdio.h>
#include <stdlib.h>
#include "dsmapitd.h" /* ADSM API type definitions */
#include "dsmapifp.h" /* ADSM API function prototypes. */
#include "dsmapips.h" /* ADSM API function prototypes. */
dsUint32_t dsmHandle;
dsmApiVersion apiVer; /* application's API version */
char *node;
char *pw; /* Must allocate space */
char *owner; /* for these pointer variables */
dsInt16_t rc;
void rcApiOut (dsUint32_t handle, dsInt16_t rc);
int main(int argc, char **argv)
{
apiVer.version = DSM_API_VERSION;
apiVer.release = DSM_API_RELEASE;
apiVer.level = DSM_API_LEVEL;
rc = dsmInit(&dsmHandle,
&apiVer,
NULL,NULL,NULL,
NULL,
NULL,NULL);
if (rc)
{
printf("\n*** Init failed: ");
rcApiOut(dsmHandle, rc);
}
printf("\n* It must have worked.*\n\n");
return rc;
}
void rcApiOut (dsUint32_t handle, dsInt16_t rc)
{
char *msgBuf ;
if ((msgBuf = (char *)malloc(DSM_MAX_RC_MSG_LENGTH+1)) == NULL)
{
printf("Abort: Not enough memory.\n") ;
exit(1) ;
}
dsmRCMsg(handle, rc, msgBuf);
printf("%s\n",msgBuf);
free(msgBuf) ;
return;
}
==========================
Andy Raibeck
IBM Storage Systems Division
ADSM Client Development
e-mail: storman AT us.ibm DOT com
Please respond to ADSM-L AT VM.MARIST DOT EDU
To: ADSM-L AT VM.MARIST DOT EDU
cc:
Subject: Help! C API problems
Hi. I am trying to write a program that will attempt to connect to an ADSM
server and then disconnect. The point is to determine if the server is up. I
have been looking at the online API documentation as well as the sample
programs supplied. I'm handicapped because I am not overly fluent in C. I'm
attempting this on AIX 4.1.5 with the version 3 ADSM client. I would
appreciate any help you can provide. The following is the text of the program
as well as the errors I'm receiving while attempting the
compile.
Thanks for your help!!
Craig
catreptow AT equitable-of-iowa DOT com
========================================================
tetons:tcat#cat adsm_up.c
#include <stdio.h>
#include <stdlib.h>
#include "dsmapitd.h" /* ADSM API type definitions */
#include "dsmapifp.h" /* ADSM API function prototypes. */
#include "dsmapips.h" /* ADSM API function prototypes. */
extern dsUint32 dsmHandle;
extern dsmApiVersion apiVer; /* application's API version */
char *node;
char *pw; /* Must allocate space */
char *owner; /* for these pointer variables */
dsInt16 rc;
int main(int argc, char **argv)
{
apiVer.version = DSM_API_VERSION;
apiVer.release = DSM_API_RELEASE;
apiVer.level = DSM_API_LEVEL;
rc = dsmInit(&dsmHandle,
&apiVer,
NULL,NULL,NULL,
NULL,
NULL,NULL);
if (rc)
{
printf("\n*** Init failed: ");
rcApiOut(dsmHandle, rc);
}
printf("\n* It must have worked.*\n\n");
return rc;
}
void rcApiOut (dsUint32_t handle, dsInt16_t rc)
{
char *msgBuf ;
if ((msgBuf = (char *)malloc(DSM_MAX_RC_MSG_LENGTH+1)) == NULL)
{
printf("Abort: Not enough memory.\n") ;
exit(1) ;
}
dsmRCMsg(handle, rc, msgBuf);
printf("%s\n",msgBuf);
free(msgBuf) ;
return;
}
tetons:tcat#
==========================================================
tetons:tcat#cc adsm_up.c -o adsm_up
"adsm_up.c", line 8.9: 1506-166 (S) Definition of function dsUint32 requires
parentheses.
"adsm_up.c", line 8.29: 1506-276 (S) Syntax error: possible missing '{'?
"adsm_up.c", line 18.9: 1506-045 (S) Undeclared identifier apiVer.
"adsm_up.c", line 22.23: 1506-045 (S) Undeclared identifier dsmHandle.
"adsm_up.c", line 22.9: 1506-045 (S) Undeclared identifier rc.
"adsm_up.c", line 38.6: 1506-343 (S) Redeclaration of rcApiOut differs from
previous declaration on line 30 of "adsm_up.c".
"adsm_up.c", line 38.6: 1506-050 (I) Return type "void" in redeclaration is not
compatible with the previous return type "int".
"adsm_up.c", line 38.6: 1506-379 (I) Prototype for function rcApiOut must
contain only promoted types if prototype and nonprototype declarations are
mixed.
"adsm_up.c", line 38.6: 1506-380 (I) Parameter 2 has type "short" which
promotes to "int".
tetons:tcat#
|