Sponsored Content
Top Forums Programming Parameter passing to function with void * as Argument Post 302902776 by rupeshkp728 on Thursday 22nd of May 2014 07:52:47 AM
Old 05-22-2014
Parameter passing to function with void * as Argument

Earlier I had one structure C
Code:
typedef struct c
{
    int cc;
}CS;

I used to call a library function say int GetData(CS *x) which was returning me the above structure C with data.
Code:
GetData(CS *x)

Function call used to be like:
Code:
CS CSobj;
GetData(&CSObj);

Now there are two structures say C and D
Code:
typedef struct c
{
    int cc;
}CS;
CS CSobj;

typedef struct d
{
    int dc;
    int dd;
}DS;
DS DSobj;

Function GetData() has been modified to:
Code:
GetData(void* x)

I have to call the library function say int GetData(void* x) which will be returning me one of the above structures through that void* paramter. The return type of the function tells which structure is returned.

Problem is while calling the function GetData() how and what parameter to pass since I am unaware of which struct the function will return. Any way out of this problem?

Last edited by rupeshkp728; 05-22-2014 at 08:54 AM.. Reason: adding more details
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing Argument to Function

May i know how to pass an argument to a function in a shell script? Sorry, i din stated that it is in a shell script in my previous post. Means: checkStatus() { ........... } read status; I wanna use the status in the function checkstatus, how... (2 Replies)
Discussion started by: AkumaTay
2 Replies

2. Shell Programming and Scripting

Passing a string parameter to a function

I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in. How can I make the function receive the whole string (and not terminate at the first space it encounters)?. part of... (1 Reply)
Discussion started by: fastgoon
1 Replies

3. UNIX for Advanced & Expert Users

Parameter passing in a function

I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in. How can I make the function receive the whole string (and not terminate at the first space it encounters)?. part of... (2 Replies)
Discussion started by: fastgoon
2 Replies

4. Programming

How to return void function pointer

Hello all im trying to build function that will return void function pointer what is mean is ( not working ) the main function void * myClass::getFunction(int type){ if(type==1) return &myClass::Test1; if(type==2) return &myClass::Test2; } void myClass::Test1(){... (1 Reply)
Discussion started by: umen
1 Replies

5. Shell Programming and Scripting

Passing more than one argument in a function

Hi All, Calling a function with one argument and storing the return value in a shell script is as below:( so far I know) value="`fun_1 "argument1"`" Its working perfectly for me. Can u help me with passing more than one argument and storing the return value Thnaks in advance JS (1 Reply)
Discussion started by: jisha
1 Replies

6. Shell Programming and Scripting

Passing commandline argument to a function

Hi, I have 2 ksh scripts. Script1.ksh contains function definition. script1.ksh function f1() { while getopts a:c: args do case $args in a) ARG1=$OPTARG ;; c) ARG2=$OPTARG ;; \?) echo "Error no valid Arguments passed" esac done echo $ARG1 echo $ARG2 script2.sh (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

7. Shell Programming and Scripting

Passing sql as parameter to unix function

Hi, I have a function which connects to the db and runs the sql. it works fine when I run it like: function "select empname from emp;" but when I try to pass the sql string to a variable which in turn in fed to the function , it throws error. please advise. Thanks, Arnie. (1 Reply)
Discussion started by: itsarnie
1 Replies

8. Shell Programming and Scripting

passing argument from one function to another

Hi all, In the given script code . I want to pass the maximum value that variable "i" will have in function DivideJobs () to variable $max of function SubmitCondorJob(). Any help? Thanks #!/bin/bash ... (55 Replies)
Discussion started by: nrjrasaxena
55 Replies

9. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

10. Shell Programming and Scripting

Passing command as a function parameter

Hi All, Just trying to implement the below shell script using AIX ksh shell. myfunc { eval "$*" } CMD='ls -la /etc/hosts | awk '{print $9"|"$5}'' myfunc $CMD Keeping getting "|}: not found" errors, any pointers would greatly be appreciated. Kind Regards Ed Please... (2 Replies)
Discussion started by: eo29
2 Replies
isdnctrl(4)							   Special files						       isdnctrl(4)

NAME
isdnctrl - ISDN control device SYNOPSIS
#include <linux/isdn.h> DESCRIPTION
/dev/isdnctrl is a character device with major number 45 and minor numbers 64 to 127. It allows controlling functionality of the Linux ISDN subsystem. IOCTL FUNCTIONS
Currently, the following ioctl calls are supported: IIOCNETAIF Add an ISDN network interface. This function adds a network interface to the kernel's device table. This interface can be used just like normal eth interfaces. Argument: arg should point to a zero terminated string of max. 10 characters. if arg is NULL, the kernel assigns a name. Return: On success, the name of the new interface is copied to arg. and the call returns 0. On failure, an error code is returned. IIOCNETASL Create a slave interface. Creates a slave interface for RAW-device channel-bundling. These devices behave like network-interfaces, execpt they are invisible to user. Only ISDN parameters can be controlled, but no IP-parameters. IP-parameters are inherited from the corresponding master- device. Argument: arg should point to a zero terminated string of max. 21 characters containing two comma-separated names. The first part is the name of an existing ISDN network device, which will be master. The second part will be the name of the new slave inter- face. Return: On success, the name of the new interface is copied to arg. and the call returns 0. On failure, an error code is returned. IIOCNETDIF Delete a network-interface. This call deletes an existing ISDN network interface. Argument: arg should point to a zero terminated string of max. 10 characters naming an existing interface which will be deleted. If the interface is a master interface, all it's slave-interfaces will be deleted also. Return: On success, the call returns 0. On failure, an error code is returned. IIOCNETSCF Set configurable parameters of an ISDN network interface. This call replaces all ISDN related parameters of an interface by the parameters given. Argument: arg shoud point to a struct isdn_net_ioctl_cfg (defined in linux/isdn.h) Return: On success, the call returns 0. On failure, an error code is returned. IIOCNETGCF Get configurable parameters of an ISDN network interface. This call returns all ISDN related parameters of an interface. Argument: arg shoud point to a struct isdn_net_ioctl_cfg (defined in linux/isdn.h) which will be filled by the current setup. Return: On success, the call returns 0 and the interface-setup is copied to *arg. On failure, an error code is returned. IIOCNETANM Add a phone number to an ISDN network interface. This call adds a phone number to an existing network interface. Argument: arg shoud point to a struct isdn_net_ioctl_phone which contains necessary information. Return: On success, the call returns 0 and the phone number is added to either outgoing or incoming number list. On failure, an error code is returned. IIOCNETDNM Delete a phone number from an ISDN network interface. This call deletes a phone number from an existing network interface. Argument: arg shoud point to a struct isdn_net_ioctl_phone which contains necessary information. Return: On success, the call returns 0 and the phone number is deleted from either outgoing or incoming number list. On failure, an error code is returned. IIOCNETGNM Get list of phone numbers from an ISDN network interface. This call returns the list of phone numbers associated to an existing network interface. Argument: arg shoud point to a a union of struct isdn_net_ioctl_phone and a buffer, large enough to hold a concatenated list of strings containing the phone numbers. Return: On success, the call returns 0 and the list of phone numbers is returned as a space-separated list of number-strings termi- nated by a NULL byte. IIOCNETDIL Trigger dialing of an ISDN network interface. This call initiates dialing of an ISDN network interface, if it is not connected. Normally, this ioctl is not needed, because ISDN network interface perform dial on demand by deafult. Argument: arg should point to a zero terminated string of max. 10 characters naming the desired interface. Return: On success, the call returns 0 and the interface starts dialing. IIOCNETHUP Hangup an ISDN network interface. This call initiates hangup of an ISDN network interface, if it is connected. Argument: arg should point to a zero terminated string of max. 10 characters naming the desired interface. Return: On success, the call returns 0 and the interface hangs up. IIOCNETALN Add a link of an MPP-configured ISDN network interface. This call initiates dialing of a Multilink-PPP slave ISDN network interface, if it is not connected. Argument: arg should point to a zero terminated string of max. 10 characters naming the desired interface. Return: On success, the call returns 0 and the interface starts dialing. IIOCNETDLN Hangup an MPP-configured ISDN network interface. This call initiates hangup of an Multilink-PPP ISDN network interface, if it is connected. Argument: arg should point to a zero terminated string of max. 10 characters naming the desired interface. Return: On success, the call returns 0 and the interface hangs up. IIOCNETARU Add a timeout rule to an ISDN network interface. This call adds a timeout rule to an existing interface. Argument: arg should point to a struct isdn_ioctl_timeout_rule containing the necessary parameters. Return: On success, the call returns 0 and the rule is added to the rule list of the interface. IIOCNETDRU Delete a timeout rule from an ISDN network interface. This call deletes a timeout rule from an existing interface. Argument: arg should point to a struct isdn_ioctl_timeout_rule containing the necessary parameters. Return: On success, the call returns 0 and the rule is deleted from the rule list of the interface. IIOCNETGRU Get a timeout rule from an ISDN network interface. This call returns a timeout rule from an existing interface. Argument: arg should point to a struct isdn_ioctl_timeout_rule containing the necessary parameters. Return: On success, the call returns 0 and the struct is filled from the rule list of the interface. IIOCNETBUD Handle budget accounting of an ISDN network interface. Argument and Return: to be defined. IIOCSETVER Set verbosity of link level. Argument: arg is an integer, defining the new verbose value. Return: This call always returns 0. IIOCSETGST Set global stop flag of link level. Argument: arg is an integer, defining the new stop flag value (0 or !0). Return: This call always returns 0. IIOCSETBRJ Set busreject flag of a lowlevel driver. Argument: arg should point to an struct isdn_ioctl_struct containing the driver's ID and the value of the busreject flag. Return: On success, the call returns 0 and the busreject flag of the selected driver is set according the given parameter. IIOCSIGPRF Enable signaling on change of modem profiles. With this call, the calling process is registered to receive a SIGIO on every change of any register of any ttyI. Thus it can read register settings and save them to a file. The calling process has to keep the device open in order to receive notifications. As soon as it closes the device, registration is deleted. Argument: none Return: This call always returns 0. IIOCGETPRF Get all modem register settings. With this call, all modem registers of all ttyI devices can be read. Argument: arg should point to a buffer of length ( ISDN_MODEM_ANZREG + ISDN_MSNLEN ) * ISDN_MAX_CHANNELS. Return: On return, the provided buffer is filled with the register values. IIOCSETPRF Set all modem register settings. With this call, all modem registers of all ttyI devices can be written. Argument: arg should point to a buffer of length ( ISDN_MODEM_ANZREG + ISDN_MSNLEN ) * ISDN_MAX_CHANNELS. filled with the values of all modem registers. Return: On return, the modem registers are set from the contents of the provided buffer. IIOCSETMAP Set Mapping table. This call is used to set EAZ/MSN mapping of a lowlevel driver. Argument: arg should point to a struct isdn_ioctl_struct containing the necessary parameters. Return: On success, the mapping table is set from the given parameters an the call returns 0. IIOCGETMAP Get Mapping table. This call is used to get EAZ/MSN mapping of a lowlevel driver. Argument: arg should point to a struct isdn_ioctl_struct containing the necessary parameters. Return: On success, the current mapping table of the given driver is returned and the call returns 0. IIOCDRVCTL Lowlevel driver ioctl. This call is used for controlling various lowlevel drivers. The ioctl-code for this command is assembled by adding IIOCDRVCTL (128) and the desired driver ioctl-code. Therefore, a lowlevel driver can understand a maximum of 127 different ioctls. Argument: arg should point to a struct isdn_ioctl_struct containing the necessary parameters, especially the driver-Id must be filled correctly. The arg component inside isdn_ioctl_struct is handed down to the driver's ioctl function. Its meaning is not defined here and depends on the lowlevel driver. See documentation for the various lewlevel drivers for information about driver- specific ioctl. Return: The return code depends on the driver's ioctl function. Usually, 0 means no error. AUTHOR
Fritz Elfert <fritz@isdn4linux.de> SEE ALSO
isdninfo(4), icnctrl(4). ISDN 4 Linux 3.13 1999/09/06 isdnctrl(4)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy