Waht does thou mean, old C code


 
Thread Tools Search this Thread
Top Forums Programming Waht does thou mean, old C code
# 1  
Old 01-11-2007
Waht does thou mean, old C code

ok...
Take a look at the snippets below.
What does it mean a construct like:
void function()
type var;
{
funct code...
}

hmmm.. i dont get it. my compiler either.


void log_message(filename,message)
char *filename;
char *message;
{
FILE *logfile;
logfile=fopen(filename,"a");
if(!logfile) return;
fprintf(logfile,"%s\n",message);
fclose(logfile);
}

void signal_handler(sig)
int sig;
{
switch(sig) {
case SIGHUP:
log_message(LOG_FILE,"hangup signal catched");
break;
case SIGTERM:
log_message(LOG_FILE,"terminate signal catched");
exit(0);
break;
}
}
# 2  
Old 01-11-2007
sorry

sorry guys my "c" compiler gots it, i was too quick asking, i tried compile on C++ compiler.

But anyway i've never seen sth. like that, help me quick?
# 3  
Old 01-11-2007
Quote:
Originally Posted by heck
ok...
Take a look at the snippets below.
What does it mean a construct like:
void function()
type var;
{
funct code...
}
Code tags for code please. They make them readable as opposed to, not.

This is an old, depreciated method of declaring functions. Like, really old -- I only see it in code from the 80's. This snippet is equivalent to:
Code:
void function(type var)
{
  funct code...
}

I'll translate the rest:
Code:
void log_message(char *filename, char *message)
{
  FILE *logfile;
  logfile=fopen(filename,"a");
  if(!logfile) return;
  fprintf(logfile,"%s\n",message);
  fclose(logfile);
}

void signal_handler(int sig)
{
  switch(sig) {
  case SIGHUP:
    log_message(LOG_FILE,"hangup signal catched");
    break;
  case SIGTERM:
    log_message(LOG_FILE,"terminate signal catched");
    exit(0);
    break;
  }
}

# 4  
Old 01-11-2007
Your code is Kernighan & Ritchie (K&R) dialect of C.
Now we are using Ansi C.
Conversion between them is possible with protoize/unprotoize.

Last edited by odys; 01-12-2007 at 12:16 PM..
# 5  
Old 01-11-2007
Quote:
Originally Posted by Corona688
This is an old, depreciated method of declaring functions. Like, really old -- I only see it in code from the 80's.
Actually, the C compiler that comes with HP-UX allows only this method.

Writing this:
Code:
void do_fsmon(fsnode *curnode)

produces a clear error saying that ANSI C type declarations are not supported (or some such - don't have access to HP C right now).

Due to this, I end up writing all my functions like this:
Code:
void do_fsmon(curnode)
fsnode* curnode;

# 6  
Old 01-12-2007
Thanks a lot

Thanks a lot folks. I mean i assumed it to be like this. But i can assume everything. now i know it. Thank you!
K&R cool.
Poor HP-UX developers, but you get used to nearly everything.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

2. Shell Programming and Scripting

Block of code replacement in Java source code through Unix script

Hi, I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory. finally { if (null != hibernateSession && hibernateSession.isOpen()) { //hibernateSession.close(); } } It would be great if the script has... (2 Replies)
Discussion started by: hareeshram
2 Replies

3. UNIX for Dummies Questions & Answers

If ‘922’ Code does not exist on ‘03’ Record, ‘901’ Code will be there instead, move ‘03’ R

01,011600033,011600033,110516,0834,2,90,,2/ 02,011600033,011103093,1,110317,0834,,2/ 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+000000 00354,,/ 03,113806,,015,+00000559618,,,901,+00000000096,,,922,+000000 00621,,/ 88,902,+0000000025218,,/... (1 Reply)
Discussion started by: sgoud
1 Replies

4. Programming

how i prepare a c++ code(c code) for implementing my own protocol format

helo my protocol format is given below { destno,mode,no.of packet,pktsize,,pktno,textsize,CRC} description:- { is starting flag destno - 4bytes mode - 1 byte no.of pkt - 4byes pktsize - 6 bytes ... (1 Reply)
Discussion started by: amitpansuria
1 Replies

5. Programming

pause? where art thou?

ok, im somewhat of an advanced programmer for the windows-side of C/C++, and the system command to pause the console is 'system("pause");'.... i just recently transfered over to Slackware 3.3 (yes, its old, but i <3 text), and pause is not the command for pausing the command line. is there any... (3 Replies)
Discussion started by: 01000101
3 Replies

6. IP Networking

waht's resume password for router

I want discuss several subjects about resume router password,we take about cisco. resume process : <1>router boot-strap,press Ctrl£«Break in 30 second. <2>input command£º ">o/r 0x142". <3>router have been initialization <4>system restat,screen is showing system configure dialog box :... (1 Reply)
Discussion started by: Yeliu
1 Replies
Login or Register to Ask a Question