LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-08-2017, 09:27 AM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
does anyone know what this method of defining a function call is called


Hello,

In this one c file I am using to learn by example.
they have a switch and the function calls written as such.
Code:
switch (bgmode) {
 case BG_MODE_TILE:
	feh_wm_set_bg(NULL, NULL, 0, 0, 0, 0, 1);
	break;
 case BG_MODE_SCALE:
	feh_wm_set_bg(NULL, NULL, 0, 1, 0, 0, 1);
	break;
 case BG_MODE_FILL:
	feh_wm_set_bg(NULL, NULL, 0, 0, 1, 0, 1);
	break;
 case BG_MODE_MAX:
	feh_wm_set_bg(NULL, NULL, 0, 0, 2, 0, 1);
	break;
 default:
	feh_wm_set_bg(NULL, NULL, 1, 0, 0, 0, 1);
	break;
}
does anyone know what that is called or can lead me to where I can read up on it or explain it if it is not too involved.

How would one know when to use a NULL in place for the real type of data that is suppose to be in there, and what are the numbers denoting, and why some are zeros and some are a number and when to know what number to use to in place of the real data type that is suppose to be in there?

So I can eliminate some pot shooting until I get it to work, and still not fully understand what I am doing.

Code:
feh_wm_set_bg(NULL, NULL, 1, 0, 0, 0, 1);
the full function call is this.
Code:
static void feh_wm_set_bg_scaled(Pixmap pmap, Imlib_Image im, int use_filelist, int x, int y, int w, int h)
So the NULL would be used for data types that are like a class whereas the others are real types , int and chars?

and why the different numbers?

when, where, and why would one use them(these types of function calls)?

oh yes this is also being used in conjunction with a link list if that has anything to do with it.

Last edited by BW-userx; 08-08-2017 at 09:29 AM.
 
Old 08-08-2017, 10:32 AM   #2
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: Debian, Crux, LFS, AntiX, NuTyX
Posts: 1,360
Blog Entries: 1

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
The functions aren't being defined; they're being called. The definition is in your third bit of code.

NULL is always used for pointers that point to nothing. Pixmap and Imlib_Image are clearly structures of some kind. You should find them defined in one of the program headers. I would guess that Imlib_Image is probably declared in the header that goes with the imlib/imlib2 library.

Structures are nearly always handled by declaring a pointer to them rather than declaring the structure itself.

I don't know what the integer variable use_filelist stands for, but my guess is that it's a boolean (1 if a file list is used, 0 if it isn't). x,y,w and h are the standard names for the coordinates of windows and other rectangles: x and y coordinate of the top left hand corner, width and height.

Last edited by hazel; 08-08-2017 at 10:39 AM.
 
Old 08-08-2017, 06:46 PM   #3
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Original Poster
Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
Quote:
Originally Posted by hazel View Post
The functions aren't being defined; they're being called. The definition is in your third bit of code.

NULL is always used for pointers that point to nothing. Pixmap and Imlib_Image are clearly structures of some kind. You should find them defined in one of the program headers. I would guess that Imlib_Image is probably declared in the header that goes with the imlib/imlib2 library.

Structures are nearly always handled by declaring a pointer to them rather than declaring the structure itself.

I don't know what the integer variable use_filelist stands for, but my guess is that it's a boolean (1 if a file list is used, 0 if it isn't). x,y,w and h are the standard names for the coordinates of windows and other rectangles: x and y coordinate of the top left hand corner, width and height.
Thanks, I'm not in need of it after all, I just found it strikingly interesting. Back when I was in NAM I'd come across some similar code like that and when I had informed the Master General Lieutenant Sargent on post of this , well ... just kidding.
 
Old 08-09-2017, 09:28 AM   #4
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Original Poster
Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
Quote:
Originally Posted by hazel View Post
The functions aren't being defined; they're being called. The definition is in your third bit of code.
yeah I need to brush up on my programming jargon, but...

I think I figured it out, finally, while not even looking for it.

Code:
           //feh_wm_set_bg(NULL,         NULL,             0,         0,          0,            0,        1);
extern void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, int fill, int desktop, int for_screen);
then ints are being used a boolean or enum I haven't looked - but I say enum because they are using 0,1,2 = 3 numbers so that cancels out the first thought being boolean.

Last edited by BW-userx; 08-09-2017 at 09:31 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is input_handler's call back function "event" and "connect" called georgewhr Programming 0 04-19-2014 09:44 AM
C++: Call super class virtual method from replacement method hydraMax Programming 4 05-01-2013 10:34 AM
probe method on bus and device driver not being called kunice Linux - Hardware 0 02-24-2008 11:47 AM
Defining a non-inline function inside class definition (tm) Programming 6 05-11-2005 09:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration