LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   does anyone know what this method of defining a function call is called (https://www.linuxquestions.org/questions/programming-9/does-anyone-know-what-this-method-of-defining-a-function-call-is-called-4175611557/)

BW-userx 08-08-2017 09:27 AM

does anyone know what this method of defining a function call is called
 
Hello, :D

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.

hazel 08-08-2017 10:32 AM

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.

BW-userx 08-08-2017 06:46 PM

Quote:

Originally Posted by hazel (Post 5746029)
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. ;)

BW-userx 08-09-2017 09:28 AM

Quote:

Originally Posted by hazel (Post 5746029)
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.


All times are GMT -5. The time now is 12:09 PM.