[Info-vax] C... the only winning move is not to play...
VAXman- at SendSpamHere.ORG
VAXman- at SendSpamHere.ORG
Mon Feb 10 09:03:25 EST 2014
In article <ldahtm$34$1 at reader1.panix.com>, JohnF <john at please.see.sig.for.email.com> writes:
>VAXman- wrote:
>> I've encountered a VMS library call prototype that is incorrect.
>> How can I override/overwrite the prototype in my source
>> to make it correct?
>>
>> OK. The function is STR$CONCAT.
>> somewhere VMS pre-V8.*, where it's WRONG, WRONG, WRONG...
>> #define str$concat STR$CONCAT
>> #ifdef __NEW_STARLET
>> unsigned int str$concat(
>> void *destination_string,
>> void *source_string);
>>
>> and later VMS versions, where it's workable,...
>> #define str$concat STR$CONCAT
>> #ifdef __NEW_STARLET
>> unsigned int str$concat(
>> void *destination_string,
>> void *source_string_1,
>> __optional_params);
>> Now, if you can include <str$routines.h> and make this go away,
>> I'm wanting.
>
>Is that actual entry point uppercase?
>You might (or might not) be able to get away with
>something like
>#define STR$CONCAT dummy
>#include <str$routines.h>
>whereby the prototype refers to a dummy() func.
>Then
>#undef STR$CONCAT
>#redefine str$concat STR$CONCAT
>and prototype the actual func any way you like.
Thanks John. Here's the KLUDGE written in KLUDGE, errr... C.
#define STR$CONCAT STR$CONCAT_is_badly_prototyped_in_STR$ROUTINES_header
#include <str$routines.h> // OpenVMS STR$ RTL prototype definitions
#undef STR$CONCAT
#define str$concat STR$CONCAT
unsigned int str$concat(struct dsc$descriptor_s*, struct dsc$descriptor_s*, __optional_params);
>But I've got to ask: why would you/anybody use vms-specific
>library stuff for ansi-standard functionality?
ANSI standard? ANSI-C standard? confusion?
>Besides job security, that is?
>I recall some code I became responsible for, where after
>reading through several pages of rms stuff, it dawned on
>me the guy could just have done an fopen()/fprintf()'s.
>It was ridiculous to write it the way he did.
Maybe he wanted files that weren't streams? Index files? Perhaps, wanted
to avoid the wrapper overhead to the real services below? I don't know nor
do I care. *I* an writing VERY OpenVMS specific code. I don't want nor do
I need the *IXisms.
> I'm too lazy to look up what those optional args
>might be doing for you, but the "real solution" here
>is to replace str$concat() with ansi-standard strcat()
>wherever possible. Modulo job security, that is.
This has ABSOLUTELY NOTHING to do with JOB SECURITY. What's so difficult
to fathom about OpenVMS STR$CONCAT that you'd have to resort to strcat()?
And, FWIW, your beloved strcat() is really only STR$APPEND. STR$CONCAT is
capable of concatenating a number of strings into on string which is what
the poorly prototyped STR$CONCAT definition is causing your beloved "C" to
vomit.
When KLUDGE, errr... C, supports *dynamic* string descriptors and or the
whole of the OpenVMS infrastructure used null terminated strings a la *IX,
then, maybe, I'll use #include <strings.h>. OpenVMS code should/must use
OpenVMS interfaces. I don't need wrappers of KLUDGE, errr... C making the
code look *IX to appease the mindset that all the worlds the plain vanilla
of *IX.
The John way:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
char *a = {"a"};
char *is = {"is"};
char *space = {" "};
char *f_bomb = {"fucking"};
char *C = {"kludge"};
char *kludge = {"C"};
char *exclamations = {"!!!"};
char *dynstr;
int length = strlen(kludge);
length += strlen(space);
length += strlen(is);
length += strlen(space);
length += strlen(a);
length += strlen(space);
length += strlen(f_bomb);
length += strlen(space);
length += strlen(C);
length += strlen(exclamations);
dynstr = malloc (++length);
strcat(dynstr,kludge);
strcat(dynstr,space);
strcat(dynstr,is);
strcat(dynstr,space);
strcat(dynstr,a);
strcat(dynstr,space);
strcat(dynstr,f_bomb);
strcat(dynstr,space);
strcat(dynstr,C);
strcat(dynstr,exclamations);
printf("%s\n",dynstr);
}
The OpenVMS and VAXman way:
#define __NEW_STARLET new_and_improved_aint_that_much_better
#include <descrip.h>
#include <lib$routines.h>
#define STR$CONCAT STR$CONCAT_is_badly_prototyped_in_STR$ROUTINES_header
#include <str$routines.h> // OpenVMS STR$ RTL prototype definitions
#undef STR$CONCAT
#define str$concat STR$CONCAT
unsigned int str$concat(struct dsc$descriptor_s*, struct dsc$descriptor_s*, __optional_params);
main()
{
$DESCRIPTOR(a,"a");
$DESCRIPTOR(is,"is");
$DESCRIPTOR(space," ");
$DESCRIPTOR(f_bomb,"fucking");
$DESCRIPTOR(C,"kludge");
$DESCRIPTOR(kludge,"C");
$DESCRIPTOR(exclamations,"!!!");
struct dsc$descriptor_s dynstr = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0 };
STR$CONCAT(&dynstr,&kludge,&space,&is,&space,&a,&space,&f_bomb,&space,&C,&exclamations);
LIB$PUT_OUTPUT(&dynstr);
}
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG
Well I speak to machines with the voice of humanity.
More information about the Info-vax
mailing list