pno
is a typedef to pointer to struct client_t
.
typedef struct client_t client_t, *pno;
means the same as:
typedef struct client_t client_t;
typedef struct client_t *pno;
So client_t
means the same as struct client_t
and pno
means the same as struct client_t *
. Let's substitute them in your code.
struct client_t
{
pid_t pid;
char password[TAM_MAX]; // -> 50 chars
struct client_t *next;
struct client_t *(*AddClient)(struct client_t *);
};
struct client_t *client_t_AddClient(client_t *self) { /* code */ }
int main()
{
struct client_t client;
client.AddClient = client_t_AddClient; // probably really done in some init fn
//code ..
client.AddClient(&client);
}
So struct client_t
has a member called next
that is a pointer to struct client_t
- classic linked list. The struct client_t *(*AddClient)(struct client_t *);
is a function pointer declaration, that takes a pointer to struct client_t
and returns a pointer to struct client_t
- judging from the name, it adds next client to the current item, but I don't know what does it return because it hasn't been explained.
I discourage using typedef
s to hide pointers - it makes your code less readable.
But how does the additional *pno work, what is it doing?
The additional *pno
defines additional identifier pno
to be a typedef to struct client_t *
type.
Why is next never used?
Because you did not show where it's used. (?) It's impossible to answer that question without knowing the context.
Where does *self come from?
It's the identifier given the argument in the function client_t_AddClient
definition. I believe it "comes" from writer of this code - he decided to name the argument to this function as "self". I guess it means it refers to the current object, as to mimic self
keyword for example from python.