as argument introducers. in 0.4-pre10, these were changed
from foo to -foo and this broke many clients. This change
should fix that and be backward/forward compatible.
+ Added a noop function to the protocol. This is useful for writing
shell script clients of LCDproc.
+ Changed the shared sock_send_string function to NOT send the
ending NUL ('\0') byte with the string. This was confusing
in Perl clients which saw NUL's as the first character of
each reply. WARNING: The LCDPROC client depended on this
behavior, your client may too. Use the newline instead.
See the code in clients/lcdproc/main.c (look for "switch(buf[i])")
to see one way to handle this. This should allow new clients
to connect to old servers and vice-versa.
+ Messed with include structure in .c files. It should no longer
be necessary to specify ../.. to get to shared code headers.
Also, since we are using automake, the global config.h can be
found with just #include "config.h" as it's location is included
in a -I to the compilers. As a result "make distcheck" now works.
90 lines
1.6 KiB
C
90 lines
1.6 KiB
C
/*
|
|
client_data.c
|
|
|
|
Creates and destroys a client's data structures. These are mainly
|
|
its name, screen list, and menu list.
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "shared/debug.h"
|
|
|
|
#include "client_data.h"
|
|
#include "screen.h"
|
|
#include "screenlist.h"
|
|
|
|
int
|
|
client_data_init (client_data * d)
|
|
{
|
|
if (!d)
|
|
return -1;
|
|
|
|
d->ack = 0;
|
|
d->name = NULL;
|
|
d->client_keys = NULL;
|
|
|
|
d->screenlist = LL_new ();
|
|
if (!d->screenlist) {
|
|
fprintf (stderr, "client_data_init: Error allocating screenlist\n");
|
|
return -1;
|
|
}
|
|
/* TODO: this section... (client menus)
|
|
d->menulist = LL_new();
|
|
if(!d->menulist)
|
|
{
|
|
fprintf(stderr, "client_data_init: Error allocating menulist\n");
|
|
return -1;
|
|
}
|
|
*/
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
client_data_destroy (client_data * d)
|
|
{
|
|
screen *s;
|
|
|
|
debug ("client_data_destroy\n");
|
|
|
|
if (!d)
|
|
return -1;
|
|
|
|
d->ack = 0;
|
|
|
|
// Clean up the name...
|
|
if (d->name)
|
|
free (d->name);
|
|
|
|
// Clean up the key list...
|
|
if (d->client_keys)
|
|
free (d->client_keys);
|
|
|
|
// Clean up the screenlist...
|
|
debug ("client_data_destroy: Cleaning screenlist\n");
|
|
LL_Rewind (d->screenlist);
|
|
do {
|
|
s = (screen *) LL_Get (d->screenlist);
|
|
if (s) {
|
|
debug ("client_data_destroy: removing screen %s\n", s->id);
|
|
|
|
// FIXME? This shouldn't be handled here...
|
|
// Now, remove it from the screenlist...
|
|
if (screenlist_remove_all (s) < 0) {
|
|
// Not a serious error..
|
|
fprintf (stderr, "client_data_destroy: Error dequeueing screen\n");
|
|
return 0;
|
|
}
|
|
// Free its memory...
|
|
screen_destroy (s);
|
|
}
|
|
} while (LL_Next (d->screenlist) == 0);
|
|
LL_Destroy (d->screenlist);
|
|
|
|
// TODO: clean up the rest of the data...
|
|
|
|
return 0;
|
|
}
|