Sponsored Content
Top Forums Programming Combine GetOpt And Variadic Function In C Post 303031155 by Azrael on Friday 22nd of February 2019 08:14:16 AM
Old 02-22-2019
I guess I didn't explain things well. I assumed using a variadic function would be the only way to get optional and required parameters. I tried to implement the code from Corona688 in my own, but could not get it to work. I did more searching and came back to example 2 on this page I had been to before:

CS 417 Documents

From that example I was able to see the flags in the switch case that could make arguments required.
Code:
$ ./basic -dp -s "more stuff" blah
./basic: missing -f option
usage: ./basic [-dmp] -f fname [-s sname] name [name ...]

Thank you for the response.
This User Gave Thanks to Azrael For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

question about getopt()

I'm using getopt() to get command line options.One the optons accepts and argument.The argument is and offset.I was wondering how can I scecify that it's argument is of the type off_t.I've something like this "offset=(off_t)optarg" and it don't work. (1 Reply)
Discussion started by: angelfly
1 Replies

2. Shell Programming and Scripting

getopt help

scriptname i have made a script to perform so tasks and i managed to complete the tasks for all the options the problem i am facing is that i can run the scripts individually but i would like to make it such that it can accept multiple options and give me the appropriate output e.g.... (1 Reply)
Discussion started by: problems
1 Replies

3. Shell Programming and Scripting

getopt

#!/bin/sh set -- `getopt "abco:" "$@"` a= b= c= o= while : do case "$1" in -a) a=1;; -b) b=1;; -c) c=1;; -o) shift; o="$1";; --) break;; esac shift done shift # get rid of -- # rest of script... # e.g. ls -l $@ (6 Replies)
Discussion started by: Hitori
6 Replies

4. Shell Programming and Scripting

getopt help

I m trying to use getopt This is my script, but it doesn't take argument in variable, Please help. set - - `getopt mscl: $*` if then echo "Exiting...." exit 2 fi for i in $* do case $i in -m) MAIL="$i"; shift;; -s) SCRIPT=$OPTARG; shift;; -c) COB=$OPTARG; shift;;... (2 Replies)
Discussion started by: darshakraut
2 Replies

5. Shell Programming and Scripting

getopt help

:) Can anybody help me about how to use getopt in shell scripting. (3 Replies)
Discussion started by: darshakraut
3 Replies

6. Solaris

use of getopt command

Hi All, Could anyone tell me how to use getopt command.....? Thanks, Pintu (2 Replies)
Discussion started by: pintupatro
2 Replies

7. Shell Programming and Scripting

Help with getopt

Hi, I want to use the getopt function to parse some arguments for a script. while getopts "i:f:r:" OPTION do case $OPTION in i) iter=$OPTARG;; f) frame=$OPTARG;; r) roi=$OPTARG;; ?) echo Usage: ...... exit 2;; esac done However, I... (5 Replies)
Discussion started by: giorgos193
5 Replies

8. HP-UX

Variadic macros compilation error HP C on HP-UX

I have a macro defined like this: #define MM7_RETURN(errorNr, ...) \ { \ if(errorNr != MM7_RS_NoError) \ { ... (1 Reply)
Discussion started by: Marzullo
1 Replies

9. Shell Programming and Scripting

getopt in CSH

I am struggling to understand how getopt can be used in a csh script. can anybody post a csh script using getopt. Please! (4 Replies)
Discussion started by: animesharma
4 Replies

10. Shell Programming and Scripting

Getopt Help

Hi All, An old work friend wrote a script which I've been trying to understand how a section of it currently works and work out how i can add some command line switches which i can use later in the script to append the output depending on the command line arguements. Currently it works by... (1 Reply)
Discussion started by: mutley2202
1 Replies
Ns_ConnReturn(3aolserver)				   AOLserver Library Procedures 				 Ns_ConnReturn(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_ConnRedirect - Internally redirect a request to a new local url SYNOPSIS
#include "ns.h" int Ns_ConnRedirect(conn, url) ARGUMENTS
Ns_Conn conn (in) Pointer to open connection. char *url (in) Pointer to string of local url. _________________________________________________________________ DESCRIPTION
This routine can be used to internally redirect to a new, local url on the server. The url paramter specifies a path relative to the server, i.e., without the leading "http://host:port" portion. The server will reset the Ns_Request structure in the open connection pointed to by conn and restart connection handling, including authorization checks. The result is a standard AOLserver request procedure result code, either from an underlying call to Ns_ConnRunRequest or the result of one of the authorization response routines such as Ns_ConnReturnForbidden. Filter callbacks, if any, are not run again with the updated connection. The Ns_ConnRedirect routine is used internally in the server to support the basic file serving code (i.e., "fastpath") to redirect to spe- cific files when a directory is opened and by the Ns_RegisterRedirect routine to map standard reponse routines to user-provided local url's. EXAMPLE
The following example demonstrates redirecting to an ADP help page within a custom C-level request callback whenever a ?help=topic query argument is present: int MyRequest(void *arg, Ns_Conn *conn) { Ns_Set *query = Ns_ConnGetQuery(conn); /* Redirect to help.adp for /myrequest?help=topic calls. */ if (Ns_SetGet(query, "help")) != NULL) { return Ns_ConnReturnRedirect(conn, "/help.adp"); } ... handle non-help requests ... } SEE ALSO
Ns_RegisterRedirct(3), Ns_ConnRunRequest(3), Ns_AuthorizeRequest(3) KEYWORDS
connection, redirect AOLserver 4.0 Ns_ConnReturn(3aolserver)
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy