lib/eggdrop/netstring.h File Reference

Go to the source code of this file.

Functions

int netstring_on (int idx)
 Enables the filter on an index.
int netstring_off (int idx)
 Enables the filter on an index.
int netstring_check (int idx)
 Checks if an index is in linebuffered mode.


Function Documentation

int netstring_check ( int  idx  ) 

Checks if an index is in linebuffered mode.

Parameters:
idx the index to check
Returns:
1 if linebuffered, 0 if not linebuffered, -1 on error

Definition at line 210 of file netstring.c.

References sockbuf_get_filter_data(), and sockbuf_isvalid().

Referenced by netstring_on().

00211 {
00212   if (!sockbuf_isvalid(idx)) return -1;
00213   return !sockbuf_get_filter_data(idx, &netstring_filter, 0);
00214 }

int netstring_off ( int  idx  ) 

Enables the filter on an index.

If there is text buffered it's send of immidiatly.

Parameters:
idx the index to disable it for
Returns:
0 on success, -1 on error

Definition at line 182 of file netstring.c.

References netstring_t::data, netstring_t::len, sockbuf_detach_filter(), SOCKBUF_LEVEL_TEXT_BUFFER, and sockbuf_on_read().

00183 {
00184   int ret;
00185   netstring_t *old_data;
00186 
00187   ret = sockbuf_detach_filter(idx, &netstring_filter, &old_data);
00188   if (ret) return ret;
00189   if (old_data) {
00190     if (old_data->data) {
00191       if (old_data->len) {
00192         old_data->data[old_data->len] = 0;
00193         sockbuf_on_read(idx, SOCKBUF_LEVEL_TEXT_BUFFER, old_data->data, old_data->len);
00194         old_data->len = 0;
00195       }
00196       free(old_data->data);
00197     }
00198     free(old_data);
00199   }
00200   return(0);
00201 }

int netstring_on ( int  idx  ) 

Enables the filter on an index.

Parameters:
idx the index to enable it for.
Returns:
0 on success, -1 on error.

Definition at line 160 of file netstring.c.

References netstring_t::data, netstring_t::len, netstring_t::msg_len, netstring_check(), NULL, and sockbuf_attach_filter().

Referenced by do_link(), and idx_on_newclient().

00161 {
00162   netstring_t *old_data;
00163 
00164   if (netstring_check(idx)) return -1;
00165   old_data = malloc(sizeof(*old_data));
00166   old_data->data = NULL;
00167   old_data->len = 0;
00168   old_data->msg_len = 0;
00169   sockbuf_attach_filter(idx, &netstring_filter, old_data);
00170   return(0);
00171 }


Generated on Sun Nov 30 18:43:34 2008 for eggdrop1.9 by  doxygen 1.5.6