Sponsored Content
Top Forums Programming error: initializer expression list treated as compound expression Post 302145388 by arunchaudhary19 on Wednesday 14th of November 2007 04:47:39 AM
Old 11-14-2007
ok...........here is the section of my code..........

from main I am Calling function.......
setup_ipc("msqueue",1234,INPUT_IPC,LARGE_QUEUE);
and its defination is in another *.cpp file

and here is its defination
int setup_ipc (const char * ipc_name, long base_add, int io_type, int ipc_qtype)
{
char sbuffer[FILENAMELEN + 1];
key_t msg_key;
int msg_flag;
if ((io_type != INPUT_IPC && io_type != OUTPUT_IPC) ||
(ipc_qtype != SMALL_QUEUE && ipc_qtype != LARGE_QUEUE &&
ipc_qtype != PRI_QUEUE && ipc_qtype != MAIL_BOX &&
ipc_qtype != SOCKET_QUEUE)) {return(-1);}

if (!(*ipc_name)) {return(-1);}

/** look for the end of ipc_tbl **/
lipc_tbl = &ipc_lhead;
for (ipc_tbl = ipc_lhead.ipc_nextent; ipc_tbl;lipc_tbl = ipc_tbl, ipc_tbl = ipc_tbl->ipc_nextent);

ipc_tbl = (struct ipc_ent *) malloc(sizeof(struct ipc_ent));
if ( !ipc_tbl ) {return(-1);}

/** init table entry variables **/
strncpy(sbuffer, ipc_name, FILENAMELEN);
sbuffer[FILENAMELEN - 1] = '\0';
sprintf(ipc_tbl->fname, "%s", sbuffer);
ipc_tbl->ipc_tag = ++ipc_ecnt;
ipc_tbl->io_type = io_type;
ipc_tbl->vlmsg_id = -1;
ipc_tbl->sockfd = -1;
ipc_tbl->vlkey_id = base_add;
ipc_tbl->qtype = ipc_qtype;
ipc_tbl->ipc_nextent = NULL;

/** open message queue **/
if (ipc_qtype != SOCKET_QUEUE)
{
msg_key = ipc_tbl->vlkey_id;
if (io_type == INPUT_IPC)
msg_flag = IPC_CREAT | IPC_EXCL | 0666;
else
msg_flag = 0666;

errno = 0;
while ((ipc_tbl->vlmsg_id = msgget(msg_key, msg_flag)) < 0 && errno == EEXIST)
{
errno = 0;
msg_key++;
}

if (errno != 0)
{ // error other than EEXIST occurs
free(ipc_tbl);
return(-1);
}

ipc_tbl->vlkey_id = msg_key;
}
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compound expression in unix

I am using the code below to write a command to launch a script only if the number of users on the system is less than 10. The code below isn't working. Any suggestions? HELP.. if && ; then frizzle ; fi (3 Replies)
Discussion started by: spalmer
3 Replies

2. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies

3. Shell Programming and Scripting

One more expression syntax error

HI again, still working on the assignment, which is really hard given we just started unix 4 weeks ago. This script should change the permission for the user depending if its x, w or r, to the opposite. When i try to run it, I am getting expression error. Can you spot where the problem is? I really... (3 Replies)
Discussion started by: morava
3 Replies

4. Shell Programming and Scripting

Error with Expression

Hi All, am trying to add two Inputs i.e., $1 and $2, Code #!/bin/sh $num_sum=`expr $1+$2` echo "Sum = $num_sum" am giving statement sh arithemetic.sh 20 10 am getting error arithemetic.sh: line 2: =20+10: command not found Sum = I want Output as Sum = 30, (5 Replies)
Discussion started by: sunnix
5 Replies

5. Shell Programming and Scripting

if expression syntax error

#! /bin/csh set umr=UMR foreach i ( `ls`) set file_nm=$i set bh_nm=`echo $file_nm | cut -d"_" -f2` if($bh_nm !=$umr) then { set bh_ext=`echo $file_nm | cut -d"_" -f4` set bh_num_nm="$bh_nm $bh_ext a .txt" mv $file_nm $bh_num_nm } ... (1 Reply)
Discussion started by: jdsignature88
1 Replies

6. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

7. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

8. Shell Programming and Scripting

Getting error in this expression: value of value

HI , I have a variable "TYPE" which may contain different values. and another variable $TYPE"_SOURCE" I am using ${$TYPE"_SOURCE"} to get the value TYPE_SOURCE for eg. TYPE=ABC ABC_SOURCE=/abc/xyz On using above command I am getting error : BAD SUBSTITUTION eval is not installed... (2 Replies)
Discussion started by: aashish.sharma8
2 Replies

9. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

10. Shell Programming and Scripting

Why Relational Expression is Writing to a Expression?

Hello All, Not sure why this is happening... When the following If Statement is evaluated for some reason it is creating a file in the CWD called '0'. I've seen this happen before, just not in an If Statement... CODE: if then DIR_NAME="$1" DIR_SIZE=0 STATUS="" else... (3 Replies)
Discussion started by: mrm5102
3 Replies
msgget(2)							   System Calls 							 msgget(2)

NAME
msgget - get message queue SYNOPSIS
#include <sys/msg.h> int msgget(key_t key, int msgflg); DESCRIPTION
The msgget() argument returns the message queue identifier associated with key. A message queue identifier and associated message queue and data structure (see intro(2)) are created for key if one of the following are true: o key is IPC_PRIVATE. o key does not already have a message queue identifier associated with it, and (msgflg&IPC_CREAT) is true. On creation, the data structure associated with the new message queue identifier is initialized as follows: o msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid are set to the effective user ID and effective group ID, respectively, of the calling process. o The low-order 9 bits of msg_perm.mode are set to the low-order 9 bits of msgflg. o msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set to 0. o msg_ctime is set to the current time. o msg_qbytes is set to the system limit. See NOTES. RETURN VALUES
Upon successful completion, a non-negative integer representing a message queue identifier is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The msgget() function will fail if: EACCES A message queue identifier exists for key, but operation permission (see intro(2)) as specified by the low-order 9 bits of msgflg would not be granted. EEXIST A message queue identifier exists for key but (msgflg&IPC_CREAT) and (msgflg&IPC_EXCL) are both true. ENOENT A message queue identifier does not exist for key and (msgflg&IPC_CREAT) is false. ENOSPC A message queue identifier is to be created but the system-imposed limit on the maximum number of allowed message queue identifiers system wide would be exceeded. See NOTES. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
rctladm(1M), intro(2), msgctl(2), msgrcv(2), msgsnd(2), setrctl(2), ftok(3C), attributes(5), standards(5) NOTES
The system-defined limit used to initialize msg_qbytes is the minimum enforced value of the calling process's process.max-msg-qbytes resource control. The system-imposed limit on the number of message queue identifiers is maintained on a per-project basis using the project.max-msg-ids resource control. See rctladm(1M) and setrctl(2) for information about using resource controls. SunOS 5.10 11 Feb 2003 msgget(2)
All times are GMT -4. The time now is 02:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy