Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Joshua Cope <cope@star.enet.dec.com>
Subject: Re: Q: VMS "CLD"/programming problem
Date: 1998/11/04	[thread overview]
Message-ID: <3640C4EA.FABBF5F5@star.enet.dec.com> (raw)
In-Reply-To: 364095AC.1119@nswc.navy.mil

David W. Fisher wrote:

> I've written a program in c. Using argc and argv it can determine what's
> coming into main. The tricky thing is the c-program is being called via
> a verb setup in a ".CLD" file. Consequently, argv[0] contains the name
> of my c-program and not the verb the user typed-in at the command line.
> How can I determine what the user typed-in (i.e., the verb)?

I don't think you can, using ANSI C - argv[0] is defined as the filename
currently being run. If you don't mind it being VMS specific (and
considering you're using a CLD file, that may be a reasonable assumption),
take a look at the CLI$GET_VALUE routine, using the special label $VERB -
see below:

$ type verb.c,verb.cld
#include <cli$routines>
#include <clidef>
#include <stdio>
#include <stdlib>
#include <descrip>

int main (int argc, char **argv) {
  char verb[255];
  int status;
  struct  dsc$descriptor_s verb_dsc =
{255,DSC$K_DTYPE_T,DSC$K_CLASS_S,verb};
  $DESCRIPTOR(vd,"$VERB");

  status = CLI$GET_VALUE (&vd,&verb_dsc,&verb_dsc.dsc$w_length);
  if (!(status & 1)) return (status);
  verb[verb_dsc.dsc$w_length] = 0;              /* Null-terminate the string
*/

  printf ("argv[0] = '%s'\n", argv[0]);
  printf ("Verb    = '%s'\n", verb);
  return 1;
}

DISK$USERS:[JOSH.TEMP]VERB.CLD;1

define verb doit
        image verb

$ doit_note_that_only_4_characters_matter_to_DCL
argv[0] = '$4$dka400:[josh.temp]verb.exe;5'
Verb    = 'DOIT'
$

------------------------------------------------------------
The above opinions and information are not necessarily
those of Compaq Computer Corporation.
------------------------------------------------------------





  reply	other threads:[~1998-11-04  5:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-04  5:00 Q: VMS "CLD"/programming problem David W. Fisher
1998-11-04  5:00 ` Joshua Cope [this message]
1998-11-05  5:00 ` Ferry Bolhar
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox