Connecting Tech Pros Worldwide Forums | Help | Site Map

C++ for z/OS, bad return code on rename()

Jerry Orr
Guest
 
Posts: n/a
#1: Jul 22 '05
I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
attempting to rename a dataset; however, when I use the rename()
function, I get a return code of -1. All of the return codes listed in
the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
positive integers, and all of them can be successfully input into
strerror() to get a valid error message. Passing -1 to strerror(),
though, just returns a null string.

Has anyone experienced anything similar to this? I'm not sure why I'd
be getting -1 as a return code, and I've been unable to find anything
about it in the manuals or on the web.

Here's an example of my method:

/* This is the signature for a JNI method */
JNIEXPORT jint JNICALL
Java_DatasetUtilities_nativeRenameDataset
(JNIEnv *env, jclass obj, jstring jfrom, jstring jto)
{
int rc;
/* This is JNI code to convert the ASCII Java strings into EBCDIC */
const char *from = (*env)->GetStringUTFChars(env, jfrom, 0);
const char *to = (*env)->GetStringUTFChars(env, jto, 0);
__atoe(from);
__atoe(to);

/* Here, rename() is returning -1 */
rc = rename(from, to);

/* This is just printing out -1 and an empty string */
printf("rename() error (error code: %i, error message: %s)\n",
rc, strerror(rc));

/* More JNI code */
(*env)->ReleaseStringUTFChars(env, jfrom, from);
(*env)->ReleaseStringUTFChars(env, jto, to);

return rc;
}

Alexander Terekhov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: C++ for z/OS, bad return code on rename()



Jerry Orr wrote:[color=blue]
>
> I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
> attempting to rename a dataset; however, when I use the rename()
> function, I get a return code of -1.[/color]

I have no idea except that you should try asking it on
http://google.com/groups?group=ibm.s...os390.compiler
and/or news://news.software.ibm.com/ibm.software.cpp.z-os (this
one is not available on google yet).

regards,
alexander.
Owen Jacobson
Guest
 
Posts: n/a
#3: Jul 22 '05

re: C++ for z/OS, bad return code on rename()


On Thu, 08 Jul 2004 06:53:35 -0700, Jerry Orr wrote:
[color=blue]
> I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
> attempting to rename a dataset; however, when I use the rename()
> function, I get a return code of -1. All of the return codes listed in
> the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
> positive integers, and all of them can be successfully input into
> strerror() to get a valid error message. Passing -1 to strerror(),
> though, just returns a null string.[/color]

Psst: check the value of errno if the fuction returns -1. This is
somewhat off-topic here; try c.l.c for standard C (which rename () might
be) or a discussion group for z/OS.

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Jack Klein
Guest
 
Posts: n/a
#4: Jul 22 '05

re: C++ for z/OS, bad return code on rename()


On 8 Jul 2004 06:53:35 -0700, orr94@yahoo.com (Jerry Orr) wrote in
comp.lang.c++:
[color=blue]
> I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
> attempting to rename a dataset; however, when I use the rename()
> function, I get a return code of -1. All of the return codes listed in
> the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
> positive integers, and all of them can be successfully input into
> strerror() to get a valid error message. Passing -1 to strerror(),
> though, just returns a null string.
>
> Has anyone experienced anything similar to this? I'm not sure why I'd
> be getting -1 as a return code, and I've been unable to find anything
> about it in the manuals or on the web.[/color]

[snip off-topic java code]

What you have here is not a C++ language issue at all.

You are calling a Java function named remove() in a Java program.
Java is completely off-topic here. Just because Java provides a
function with the name of a standard C and C++ library function does
not make this a C or C++ question.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jerry Orr
Guest
 
Posts: n/a
#5: Jul 22 '05

re: C++ for z/OS, bad return code on rename()


This thread is a little old now, but I just want to make sure anyone
reading this in the future can clearly see that it is you, not I, that
is the idiot.
[color=blue]
> You are calling a Java function named remove() in a Java program.[/color]

No. I am calling the C function remove() from a C program; I just
happen to be using JNI to call my C program from a Java program.
[color=blue]
> Java is completely off-topic here.[/color]

Yes, it is. That, however, is beside the point, as this is not a Java
question. I simply mentioned Java to provide background as to what I
am doing.
[color=blue]
> Just because Java provides a
> function with the name of a standard C and C++ library function does
> not make this a C or C++ question.[/color]

You clearly have no experience in Java, or you would have been able to
quickly realize that the code I displayed was NOT Java, and I'm a
little skeptical about your C/C++ experience if you did not recongnize
that it IS C code.

At any rate, for anyone who may be interested (or for future
seachers), my problem was simply that I was running strerror() on the
return code, when I actually needed to run it on errcode. A silly
mistake that caused me a lot of headache.

Jack Klein <jackklein@spamcop.net> wrote in message news:<c20ve09lideo85srv2gbsbinnnv6mq4kpe@4ax.com>. ..[color=blue]
> On 8 Jul 2004 06:53:35 -0700, orr94@yahoo.com (Jerry Orr) wrote in
> comp.lang.c++:
>[color=green]
> > I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
> > attempting to rename a dataset; however, when I use the rename()
> > function, I get a return code of -1. All of the return codes listed in
> > the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
> > positive integers, and all of them can be successfully input into
> > strerror() to get a valid error message. Passing -1 to strerror(),
> > though, just returns a null string.
> >
> > Has anyone experienced anything similar to this? I'm not sure why I'd
> > be getting -1 as a return code, and I've been unable to find anything
> > about it in the manuals or on the web.[/color]
>
> [snip off-topic java code]
>
> What you have here is not a C++ language issue at all.
>
> You are calling a Java function named remove() in a Java program.
> Java is completely off-topic here. Just because Java provides a
> function with the name of a standard C and C++ library function does
> not make this a C or C++ question.[/color]
Closed Thread