Sponsored Content
Top Forums Programming How to get the correct exception file/line. Post 302333882 by achenle on Tuesday 14th of July 2009 09:00:02 AM
Old 07-14-2009
Quote:
Originally Posted by SamRoj
achenle,

I can use __LINE__ and __FILE__ , I have a problem in getting the required fine and line. As mentioned above I have to throw the file/line of the function call.

I have mentioned "without using macro" in the sense I should not define a macro function.
That is I should not do some thing like
#define toCopy
.....
...
.
You want values from __FILE__ and __LINE__. Since those are macros evaluated at compile time, you also need something evaluated at compile time.

You have two choices:

1. Explicitly write code so that you use __FILE__ and __LINE__ each and every time you need them, or

2. Write and use a macro.

There's a reason why macros exist: sometimes they're the only way to do what needs to be done.
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

file attributes and exception

hi, I want to know the date the file was created or modified. I can do this using ls, ll -ltr etc... I want to do this in a function (so If the file date is older then a week I can report it), is there a way? another thing... In sql function, I can catch exceptions, is there a way to do this... (1 Reply)
Discussion started by: krem
1 Replies

2. UNIX for Dummies Questions & Answers

getting help on finding exception in running log file

Hi all, I am trying to write a script for an application server log file where i want to put this script as a cron tab entry and it will check the server log file last 1000/500 line for every fifteen minute. i am using the script like this. count=`tail -n 1000 Trace.log | grep -c... (1 Reply)
Discussion started by: senthilkumar_ak
1 Replies

3. Shell Programming and Scripting

Catch a PL/SQL exception in ksh file

Hi all Im trying to call a PL SQl block from a ksh file like this : sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof whenever SQLERROR exit 1 var varError VARCHAR2(200); exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:varError); eof If there is a error then varError will return a... (1 Reply)
Discussion started by: Sam123
1 Replies

4. Shell Programming and Scripting

Shell script to unmonitor the mounts in exception file

I am trying to write a shell script for monitoring the file system mount. command I am using will retrieve a output as shown below. /dev/fsv29 2% /apps/rj/pgl/bslSys I also need to add exception mounts in a file and I would like script to ignore the mount which I specify. If I add the... (6 Replies)
Discussion started by: chandu123
6 Replies

5. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies

6. Shell Programming and Scripting

Line numbers and exception to be caught in logs

Hi Folks, I have just basic queries is that suppose I have to monitor the logs then there is a command , suppose I have to monitor the abc.log which is updating dynamically within seconds so the command will be after going to that directory is .. tail -f abc.log Now please advise what about... (1 Reply)
Discussion started by: punpun66
1 Replies

7. Shell Programming and Scripting

Need correct pattern at end of line

I have some data as below. I need correct it as result. Data: BG1:100+10++II DG1:200+100+1234 DG2:300+200++II CG1:200+100+1111 DG2:400+100++II DG6:200+200+2345 DG2:400+100+2222 Result: BG1:100+10++II DG1:200+100+1234 DG2:300+200++1 CG1:200+100+1111 DG2:400+100++1... (4 Replies)
Discussion started by: mr.awk
4 Replies

8. Shell Programming and Scripting

Compare 2 files using third file as an exception

Hi All, Is it possible to compare 2 files using the contents of a third file as a guide using a bash script? I have 2 files I want t compare (1 and 2 below) the difference between the two is the first line (a) I want my script to ignore this difference if the difference is stored in file... (5 Replies)
Discussion started by: nwalsh88
5 Replies

9. Shell Programming and Scripting

Automatically correct a File Name

Hi All Need a help to understand how one can automatically correct a file name using a shell script even if it is in a completely different format... Ex : adv_OK_0215_mem_rules_firing.txt / advex_0215_OK_me_rule_fire.txt (or in any other format as above) to :... (13 Replies)
Discussion started by: chatwithsaurav
13 Replies

10. UNIX for Dummies Questions & Answers

After Ftp'ing file to destination how to check the file if it is in correct ASCII and not corrupted

Hi Folks, While transferring file from FTP software like Filezilla the files gets corrupted. Is there any way I can check if the recently transferred file is in ASCII and not corrupted. I have tried using file -i filename command which does tell if the file character set is ASCII or binary... (6 Replies)
Discussion started by: Khan28
6 Replies
threads(3)							      OpenSSL								threads(3)

NAME
CRYPTO_set_locking_callback, CRYPTO_set_id_callback, CRYPTO_num_locks, CRYPTO_set_dynlock_create_callback, CRYPTO_set_dynlock_lock_call- back, CRYPTO_set_dynlock_destroy_callback, CRYPTO_get_new_dynlockid, CRYPTO_destroy_dynlockid, CRYPTO_lock - OpenSSL thread support SYNOPSIS
#include <openssl/crypto.h> void CRYPTO_set_locking_callback(void (*locking_function)(int mode, int n, const char *file, int line)); void CRYPTO_set_id_callback(unsigned long (*id_function)(void)); int CRYPTO_num_locks(void); /* struct CRYPTO_dynlock_value needs to be defined by the user */ struct CRYPTO_dynlock_value; void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value * (*dyn_create_function)(char *file, int line)); void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function) (int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function) (struct CRYPTO_dynlock_value *l, const char *file, int line)); int CRYPTO_get_new_dynlockid(void); void CRYPTO_destroy_dynlockid(int i); void CRYPTO_lock(int mode, int n, const char *file, int line); #define CRYPTO_w_lock(type) CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) #define CRYPTO_w_unlock(type) CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) #define CRYPTO_r_lock(type) CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) #define CRYPTO_r_unlock(type) CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) #define CRYPTO_add(addr,amount,type) CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) DESCRIPTION
OpenSSL can safely be used in multi-threaded applications provided that at least two callback functions are set. locking_function(int mode, int n, const char *file, int line) is needed to perform locking on shared data structures. (Note that OpenSSL uses a number of global data structures that will be implicitly shared whenever multiple threads use OpenSSL.) Multi-threaded applications will crash at random if it is not set. locking_function() must be able to handle up to CRYPTO_num_locks() different mutex locks. It sets the n-th lock if mode & CRYPTO_LOCK, and releases it otherwise. file and line are the file number of the function setting the lock. They can be useful for debugging. id_function(void) is a function that returns a thread ID. It is not needed on Windows nor on platforms where getpid() returns a different ID for each thread (most notably Linux). Additionally, OpenSSL supports dynamic locks, and sometimes, some parts of OpenSSL need it for better performance. To enable this, the following is required: o Three additional callback function, dyn_create_function, dyn_lock_function and dyn_destroy_function. o A structure defined with the data that each lock needs to handle. struct CRYPTO_dynlock_value has to be defined to contain whatever structure is needed to handle locks. dyn_create_function(const char *file, int line) is needed to create a lock. Multi-threaded applications might crash at random if it is not set. dyn_lock_function(int mode, CRYPTO_dynlock *l, const char *file, int line) is needed to perform locking off dynamic lock numbered n. Multi- threaded applications might crash at random if it is not set. dyn_destroy_function(CRYPTO_dynlock *l, const char *file, int line) is needed to destroy the lock l. Multi-threaded applications might crash at random if it is not set. CRYPTO_get_new_dynlockid() is used to create locks. It will call dyn_create_function for the actual creation. CRYPTO_destroy_dynlockid() is used to destroy locks. It will call dyn_destroy_function for the actual destruction. CRYPTO_lock() is used to lock and unlock the locks. mode is a bitfield describing what should be done with the lock. n is the number of the lock as returned from CRYPTO_get_new_dynlockid(). mode can be combined from the following values. These values are pairwise exclu- sive, with undefined behaviour if misused (for example, CRYPTO_READ and CRYPTO_WRITE should not be used together): CRYPTO_LOCK 0x01 CRYPTO_UNLOCK 0x02 CRYPTO_READ 0x04 CRYPTO_WRITE 0x08 RETURN VALUES
CRYPTO_num_locks() returns the required number of locks. CRYPTO_get_new_dynlockid() returns the index to the newly created lock. The other functions return no values. NOTE
You can find out if OpenSSL was configured with thread support: #define OPENSSL_THREAD_DEFINES #include <openssl/opensslconf.h> #if defined(THREADS) // thread support enabled #else // no thread support #endif Also, dynamic locks are currently not used internally by OpenSSL, but may do so in the future. EXAMPLES
crypto/threads/mttest.c shows examples of the callback functions on Solaris, Irix and Win32. HISTORY
CRYPTO_set_locking_callback() and CRYPTO_set_id_callback() are available in all versions of SSLeay and OpenSSL. CRYPTO_num_locks() was added in OpenSSL 0.9.4. All functions dealing with dynamic locks were added in OpenSSL 0.9.5b-dev. SEE ALSO
crypto(3) 0.9.7a 2001-11-08 threads(3)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy