Example #1
0
static char * _path_lookup(CppParser * cp, char const * path, int system)
{
	Cpp * cpp = cp->cpp;
	char const * filename;
	char * p;
	char * q;
	char * r;
	struct stat st;

	if(system != 0)
		return cpp_path_lookup(cpp, path, 1);
	for(; cp->subparser != NULL; cp = cp->subparser);
	for(; cp != NULL; cp = cp->parent)
	{
		filename = parser_get_filename(cp->parser);
		if((p = string_new(filename)) == NULL)
			return NULL;
		q = dirname(p);
		r = string_new_append(q, "/", path, NULL);
		string_delete(p);
		if(r == NULL)
			return NULL;
#ifdef DEBUG
		fprintf(stderr, "DEBUG: stat(\"%s\", %p)\n", r, (void *)&st);
#endif
		if(stat(r, &st) == 0)
			return r;
		error_set("%s: %s", r, strerror(errno));
		string_delete(r);
	}
	return cpp_path_lookup(cpp, path, 0);
}
Example #2
0
static int _configure_load(Prefs * prefs, String const * directory,
		configArray * ca)
{
	int ret = 0;
	Config * config;
	String * path;
	String const * subdirs = NULL;

	if((path = string_new(directory)) == NULL)
		return configure_error(directory, 1);
	if(string_append(&path, "/") != 0
			|| string_append(&path, PROJECT_CONF) != 0
			|| (config = config_new()) == NULL)
	{
		string_delete(path);
		return configure_error(directory, 1);
	}
	config_set(config, "", "directory", directory);
	if(prefs->flags & PREFS_v)
		printf("%s%s%s", "Loading project file ", path, "\n");
	if(config_load(config, path) != 0)
		ret = error_print(PROGNAME);
	else
	{
		array_append(ca, &config);
		subdirs = config_get(config, "", "subdirs");
	}
	string_delete(path);
	if(subdirs == NULL)
		return ret;
	return _load_subdirs(prefs, directory, ca, subdirs);
}
Example #3
0
static int _init_server(OpenSSL * openssl, char const * name)
{
	String * crt;
	struct sockaddr_in sa;

	if((crt = string_new_append(SYSCONFDIR, "/AppServer/", name, ".crt"))
			== NULL)
		return -1;
	if((openssl->ssl_ctx = SSL_CTX_new(SSLv3_server_method())) == NULL
			|| SSL_CTX_set_cipher_list(openssl->ssl_ctx,
				SSL_DEFAULT_CIPHER_LIST) != 1
			|| SSL_CTX_use_certificate_file(openssl->ssl_ctx, crt,
				SSL_FILETYPE_PEM) == 0
			|| SSL_CTX_use_PrivateKey_file(openssl->ssl_ctx, crt,
				SSL_FILETYPE_PEM) == 0)
	{
		string_delete(crt);
		return -_openssl_error_ssl(1);
	}
	string_delete(crt);
	if((openssl->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
		return -_openssl_error("socket", 1);
	sa.sin_family = AF_INET;
	sa.sin_port = htons(4242); /* XXX hard-coded */
	sa.sin_addr.s_addr = htonl(INADDR_ANY);
	if(bind(openssl->fd, (struct sockaddr *)&sa, sizeof(sa)) != 0)
		return -_openssl_error("bind", 1);
	if(listen(openssl->fd, 5) != 0)
		return -_openssl_error("listen", 1);
	event_register_io_read(openssl->helper->event, openssl->fd,
			(EventIOFunc)_openssl_callback_accept, openssl);
	return 0;
}
Example #4
0
void dolines(SQLHSTMT *stmt, SQLSMALLINT ncol, char format)
{
	int j;
	long ans;

	string *str, *tstr;

	char istr[256];
	long sb = 0;

	SQLLEN si;

	str = new_string();
	tstr = new_string();

	for(;;)
	{
		ans = SQLFetch(*stmt);

		/*
		 * I assume error here is EOF...
		 */
		if((ans != SQL_SUCCESS) && ( ans != SQL_SUCCESS_WITH_INFO))
			break;

		for(j=0;j<ncol;j++)
		{

			si = 0;

			for(;;)
			{
				ans = SQLGetData(stmt, j+1, SQL_C_CHAR, istr, 256, &si);
				if(ans == SQL_NO_DATA) break;

				if(si == SQL_NO_TOTAL)
				{
					sb += 255;	
				}
				else
				{
					sb += si;
				}

				string_cat(tstr, istr);
		
				if(si != SQL_NO_TOTAL) break;
			}
			dolitem(str, string_s(tstr), (j == ncol - 1), format);
			string_clear(tstr);
		}
		string_cat_c(str, '\n');
		if(message_send(mes, str, 0, MES_SERVER_TO_CLIENT) < 0) return;
		string_clear(str);
	}
	string_delete(str);
	string_delete(tstr);
	return;
}
Example #5
0
/* cppparser_delete */
void cppparser_delete(CppParser * cp)
{
	string_delete(cp->queue_string);
	if(cp->subparser != NULL)
		cppparser_delete(cp->subparser);
	if(cp->parser != NULL)
		parser_delete(cp->parser);
	string_delete(cp->inject);
	object_delete(cp);
}
Example #6
0
static int _settings_do(Prefs * prefs, Config * config,
		String const * directory, String const * package,
		String const * version, String const * extension)
{
	int ret = 0;
	int i;
	String * filename;
	FILE * fp;

	for(i = 0; i <= ST_LAST; i++)
		if(strcmp(extension, sSettingsType[i]) == 0)
			break;
	if(i > ST_LAST)
	{
		fprintf(stderr, "%s%s%s", "configure: ", extension,
				": Unknown settings type\n");
		return 1;
	}
	if(prefs->flags & PREFS_n)
		return 0;
	if((filename = string_new(directory)) == NULL)
		return 1;
	if(string_append(&filename, "/config.") != 0
			|| string_append(&filename, extension) != 0)
	{
		string_delete(filename);
		return 1;
	}
	if((fp = fopen(filename, "w")) == NULL)
		configure_error(filename, 0);
	string_delete(filename);
	if(fp == NULL)
		return 1;
	if(prefs->flags & PREFS_v)
		printf("%s%s/%s%s\n", "Creating ", directory, "config.",
				extension);
	switch(i)
	{
		case ST_H:
			ret |= _do_h(prefs, config, fp, package, version);
			break;
		case ST_SH:
			ret |= _do_sh(prefs, config, fp, package, version);
			break;
	}
	fclose(fp);
	return ret;
}
Example #7
0
Morpheme * analyse_decomposed_word(Morpho_structures ms, Decomposed_word *decomposed_word){
	Sentence sent;
	Linkage linkage;
	Decomposed_word *node;
	Morpheme *morpheme_list=NULL;
	int num_linkages , i;
	int stem_pos;
	char * diagram;
//	ms->opts->unify_features = FALSE;
	for(node=decomposed_word; node!=NULL; node=node->next){
		sent=sentence_create(node->word, ms->dict);
		if(!sent){
			continue;
		}
		num_linkages = sentence_parse(sent, ms->opts);
		for (i=0; i<num_linkages; i++){
			linkage = linkage_create(i, sent, ms->opts);
			if (PRINT_DIAGRAM){
				linkage = linkage_create(i, sent, ms->opts);
				printf("%s\n", diagram = linkage_print_diagram(linkage));
				string_delete(diagram);
			}
			if ((stem_pos = find_stem(linkage))>=0){
				morpheme_list_add(ms, &morpheme_list,linkage->word[stem_pos], linkage->feature_array[0]);
			}
			linkage_delete(linkage);
		}
		sentence_delete(sent);
	}
	return morpheme_list;
}
Example #8
0
      int main() {

          Dictionary    dict;
          Parse_Options opts;
          Sentence      sent;
          Linkage       linkage;
          char *        diagram;
          int           i, num_linkages;
          char *        input_string[] = {
             "Grammar is useless because there is nothing to say -- Gertrude Stein.",
             "Computers are useless; they can only give you answers -- Pablo Picasso.",
          };

          opts  = parse_options_create();
          dict  = dictionary_create("4.0.dict", "4.0.knowledge", 
                   "4.0.constituent-knowledge", "4.0.affix");

          for (i=0; i<2; ++i) {
              sent = sentence_create(input_string[i], dict);
              num_linkages = sentence_parse(sent, opts);
              if (num_linkages > 0) {
                  linkage = linkage_create(0, sent, opts);
                  printf("%s\n", diagram = linkage_print_diagram(linkage));
                  string_delete(diagram);
                  linkage_delete(linkage);
              }
              sentence_delete(sent);
          }

          dictionary_delete(dict);
          parse_options_delete(opts);
          return 0;
      }
Example #9
0
string *
poly_arr_to_ascii(const fmpz_poly_t **poly_array,
		const uint32_t poly_c,
		const ntru_params *params)
{
	char *string_rep = NULL;
	size_t string_len = 0;
	string *result_string = ntru_malloc(sizeof(*result_string));

	/*
	 * parse the polynomial coefficients into a string
	 */
	string_rep = ntru_malloc(CHAR_SIZE * (params->N * poly_c + 1));
	for (uint32_t i = 0; i < poly_c; i++) {
		string *poly_str;

		poly_str = poly_to_ascii(*poly_array[i], params);

		memcpy(string_rep + string_len,
				poly_str->ptr,
				poly_str->len);
		string_len += poly_str->len;

		string_delete(poly_str);
	}

	result_string->ptr = string_rep;
	result_string->len = string_len;

	return result_string;
}
Example #10
0
string *
bin_poly_arr_to_ascii(const fmpz_poly_t **bin_poly_arr,
		const uint32_t poly_c,
		const ntru_params *params)
{
	char *binary_rep = NULL;
	size_t string_len = 0;
	string *ascii_string = NULL;

	/*
	 * parse the polynomial coefficients into a string
	 */
	binary_rep = ntru_malloc(CHAR_SIZE * (params->N * poly_c + 1));
	for (uint32_t i = 0; i < poly_c; i++) {
		string *single_poly_string = NULL;

		single_poly_string = bin_poly_to_ascii(*bin_poly_arr[i], params);

		memcpy(binary_rep + string_len,
				single_poly_string->ptr,
				single_poly_string->len);

		string_len += single_poly_string->len;

		string_delete(single_poly_string);
	}
	binary_rep[string_len] = '\0';

	ascii_string = get_bin_arr_to_ascii(binary_rep);

	free(binary_rep);

	return ascii_string;
}
Example #11
0
/* cpp_new */
Cpp * cpp_new(CppPrefs * prefs)
{
	Cpp * cpp;
	String * p;
	int r = 0;

	if((cpp = object_new(sizeof(*cpp))) == NULL)
		return NULL;
	memset(cpp, 0, sizeof(*cpp));
	cpp->options = prefs->options;
	cpp->parser = cppparser_new(cpp, NULL, prefs->filename,
			prefs->filters);
	if((p = string_new(prefs->filename)) != NULL)
	{
		r |= cpp_path_add(cpp, dirname(p)); /* FIXME inclusion order */
		string_delete(p);
	}
	if((p = getcwd(NULL, 0)) != NULL)
	{
		r |= cpp_path_add(cpp, p);
		free(p);
	}
	else
		error_set("%s%s", "getcwd: ", strerror(errno));
	if(r != 0 || cpp->parser == NULL || cpp->paths_cnt != 2)
	{
		cpp_delete(cpp);
		return NULL;
	}
	return cpp;
}
Example #12
0
/**
 * Test exporting public key and reading the resulting file.
 */
void test_export_public_key1(void)
{
	keypair pair;
	fmpz_poly_t f, g;
	int f_c[] = { -1, 1, 1, 0, -1, 0, 1, 0, 0, 1, -1 };
	int g_c[] = { -1, 0, 1, 1, 0, 1, 0, 0, -1, 0, -1 };
	ntru_params params;
	string *pub_string;
	char *expected_pub_c_str = "CBkWFAwYDxMMExA=";
	char actual_pub_c_str[512] = "\0";

	params.N = 11;
	params.p = 3;
	params.q = 32;

	poly_new(f, f_c, 11);
	poly_new(g, g_c, 11);

	ntru_create_keypair(&pair, f, g, &params);
	export_public_key("pub.key", pair.pub, &params);

	if ((pub_string = read_file("pub.key"))) {
		memcpy(actual_pub_c_str, pub_string->ptr, pub_string->len);
		actual_pub_c_str[pub_string->len] = '\0';
		string_delete(pub_string);
	}

	remove("pub.key");

	CU_ASSERT_EQUAL(strcmp(expected_pub_c_str, actual_pub_c_str), 0);
}
Example #13
0
static int delete_range (void *dummy, Buffer *buffer, Line *line)

{
  /* Don't even try to delete the [EOB] line */

  if (line == NULL) return (0);

  /* Set current position to beginning of next line after first line deleted */

  if (first) {
    first = 0;
    if (buffer != cur_position.buffer) {
      *buffer_savpos (cur_position.buffer) = cur_position;
      cur_position.buffer = buffer;
    }
    cur_position.line   = line;
    cur_position.offset = 0;
    buffer_dirty (buffer, 1);
  }

  if (cur_position.line == line) cur_position.line = line_next (line);

  /* Delete the line (and your little string, too!) */

  string_delete (line_remove (line));
  count ++;

  /* Keep going */

  return (0);
}
Example #14
0
static void _on_add_filename(gchar const * pathname, gpointer data)
{
	const char scheme[] = "file://";
	Favorites * favorites = data;
	GtkTreeIter iter;
	struct stat st;
	gchar * filename;
	String * path;
	gint size = 24;
	GdkPixbuf * pixbuf;

	/* XXX ignore non-directories */
	if(browser_vfs_stat(pathname, &st) != 0 || !S_ISDIR(st.st_mode))
		return;
	if((filename = g_path_get_basename(pathname)) == NULL)
		return;
	if((path = string_new_append(scheme, pathname, NULL)) == NULL)
		return;
	gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &size, &size);
	if((pixbuf = browser_vfs_mime_icon(favorites->mime, pathname, NULL,
					NULL, &st, size)) == NULL)
		pixbuf = favorites->folder;
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_list_store_insert_with_values(favorites->store, &iter, -1,
#else
	gtk_list_store_append(favorites->store, &iter);
	gtk_list_store_set(favorites->store, &iter,
#endif
			FC_ICON, pixbuf, FC_NAME, filename, FC_PATH, path, -1);
	string_delete(path);
	g_free(filename);
	_favorites_save(favorites);
}
Example #15
0
/**
 * Print out the constituent tree.
 * mode 1: treebank-style constituent tree
 * mode 2: flat, bracketed tree [A like [B this B] A]
 * mode 3: flat, treebank-style tree (A like (B this))
 */
char * linkage_print_constituent_tree(Linkage linkage, ConstituentDisplayStyle mode)
{
	String * cs;
	CNode * root;
	char * p;

	if (!linkage) return NULL;
	if (mode == NO_DISPLAY)
	{
		return NULL;
	}
	else if (mode == MULTILINE || mode == SINGLE_LINE)
	{
		cs = string_new();
		root = linkage_constituent_tree(linkage);
		print_tree(cs, (mode==1), root, 0, 0);
		linkage_free_constituent_tree(root);
		append_string(cs, "\n");
		p = string_copy(cs);
		string_delete(cs);
		return p;
	}
	else if (mode == BRACKET_TREE)
	{
		return print_flat_constituents(linkage);
	}
	prt_error("Warning: Illegal mode %d for printing constituents\n"
	          "Allowed values: %d to %d\n", mode, NO_DISPLAY, MAX_STYLES);
	return NULL;
}
Example #16
0
void dolines(PGresult *pgr, char format)
{
	int i, j, ncol = 0, nrow = 0;

	string *str;
	char *s;

	nrow = PQntuples(pgr);
	ncol = PQnfields(pgr);

	str = new_string();

	for(i=0;i<nrow;i++)
	{
		for(j=0;j<ncol;j++)
		{
			s = PQgetvalue(pgr, i, j);

			dolitem(str, s, (j == ncol - 1), format);
		}
		string_cat_c(str, '\n');
		if(message_send(mes, str, 0, MES_SERVER_TO_CLIENT) < 0) return;
		string_clear(str);
	}
	string_delete(str);
	return;
}
Example #17
0
/**
 * Test error handling of exporting private key.
 */
void test_export_private_key2(void)
{
	keypair pair;
	fmpz_poly_t f, g;
	int f_c[] = { -1, 1, 1, 0, -1, 0, 1, 0, 0, 1, -1 };
	int g_c[] = { -1, 0, 1, 1, 0, 1, 0, 0, -1, 0, -1 };
	ntru_params params;
	string *pub_string;
	char *expected_priv_c_str = "AgEBAgAAAAEAAQE=";
	char actual_priv_c_str[512] = "\0";

	params.N = 11;
	params.p = 3;
	params.q = 32;

	poly_new(f, f_c, 11);
	poly_new(g, g_c, 11);

	ntru_create_keypair(&pair, f, g, &params);
	export_priv_key(".", pair.pub, &params);

	if ((pub_string = read_file("priv.key"))) {
		memcpy(actual_priv_c_str, pub_string->ptr, pub_string->len);
		actual_priv_c_str[pub_string->len] = '\0';
		string_delete(pub_string);
	}

	CU_ASSERT_NOT_EQUAL(strcmp(expected_priv_c_str, actual_priv_c_str), 0);
}
Example #18
0
/* video_destroy */
static void _video_destroy(VideoPhonePlugin * video)
{
	size_t i;

	_video_stop(video);
	if(video->channel != NULL)
	{
		/* XXX we ignore errors at this point */
		g_io_channel_shutdown(video->channel, TRUE, NULL);
		g_io_channel_unref(video->channel);
	}
#if !GTK_CHECK_VERSION(3, 0, 0)
	if(video->pixmap != NULL)
		g_object_unref(video->pixmap);
	if(video->gc != NULL)
		g_object_unref(video->gc);
#endif
	if(video->window != NULL)
		gtk_widget_destroy(video->window);
	if(video->fd >= 0)
		close(video->fd);
	if((char *)video->rgb_buffer != video->raw_buffer)
		free(video->rgb_buffer);
	for(i = 0; i < video->buffers_cnt; i++)
		if(video->buffers[i].start != MAP_FAILED)
			munmap(video->buffers[i].start,
					video->buffers[i].length);
	free(video->buffers);
	free(video->raw_buffer);
	string_delete(video->device);
	object_delete(video);
}
Example #19
0
void dolines(MYSQL_RES *res, char format)
{
	int j;
	unsigned int ncol = 0;

	string *str;
	char *s;

	MYSQL_ROW row;

	ncol = mysql_num_fields(res);

	str = new_string();

	while((row = mysql_fetch_row(res)) != NULL)
	{
		for(j=0;j<ncol;j++)
		{
			s = row[j];
			dolitem(str, s, (j == ncol - 1), format);
		}
		string_cat_c(str, '\n');
		if(message_send(mes, str, 0, MES_SERVER_TO_CLIENT) < 0) return;
		string_clear(str);
	}
	string_delete(str);
	return;
}
Example #20
0
static int _load_subdirs(Prefs * prefs, char const * directory,
		configArray * ca, String const * subdirs)
{
	int ret = 0;
	int i;
	char c;
	String * subdir;
	String * p;

	if((subdir = string_new(subdirs)) == NULL)
		return 1;
	p = subdir;
	for(i = 0; ret == 0; i++)
	{
		if(subdir[i] != ',' && subdir[i] != '\0')
			continue;
		c = subdir[i];
		subdir[i] = '\0';
		ret = _load_subdirs_subdir(prefs, directory, ca, subdir);
		if(c == '\0')
			break;
		subdir += i + 1;
		i = 0;
	}
	string_delete(p);
	return ret;
}
Example #21
0
int settings(Prefs * prefs, Config * config, String const * directory,
		String const * package, String const * version)
{
	int ret = 0;
	String const * p;
	String * q;
	String * r;
	unsigned long i;
	char c;

	if((p = config_get(config, "", "config")) == NULL)
		return 0;
	if((q = string_new(p)) == NULL)
		return 1;
	r = q;
	for(i = 0;; i++)
	{
		if(r[i] != ',' && r[i] != '\0')
			continue;
		c = r[i];
		r[i] = '\0';
		ret |= _settings_do(prefs, config, directory, package, version,
				r);
		if(c == '\0')
			break;
		r+=i+1;
		i = 0;
	}
	string_delete(q);
	return ret;
}
Example #22
0
File: http.c Project: andyn/httpdns
/**
 * HTTP PUT buffer contents to a remote URL
 * @param url URL to PUT the contents to
 * @param buf Buffer whose contents to send
 * @param count Size of buffer (number of bytes to send)
 * @return HTTP status code, 200 for OK. See the HTTP RFC for details.
 */
int http_put_buf(const char *url, const void *buf, size_t count) {
	char *host = url_get_field(url, URL_HOST);
	char *port = url_get_field(url, URL_PORT);
	char *path = url_get_field(url, URL_PATH);

	int response_code = -1;

	if (host && port && path) {
		String *buffer = string_new("");

		string_append_c(buffer, "PUT ");
		string_append_c(buffer, path);
		string_append_c(buffer, " HTTP/1.1\r\n");

		string_append_c(buffer, "Host: ");
		string_append_c(buffer, host);
		string_append_c(buffer, "\r\n");

		string_append_c(buffer, "Content-type: text/plain\r\n");

		if (count > 0) {
			char length_str[16];
			snprintf(length_str, sizeof length_str, "%zu", count);
			string_append_c(buffer, "Content-length: ");
			string_append_c(buffer, length_str);
			string_append_c(buffer, "\r\n");
		}

		string_append_c(buffer, "Connection: close\r\n");
		string_append_c(buffer, "Iam: anilakar\r\n");

		string_append_c(buffer, "\r\n");

		int http_socket = socket_tcp_connect(host, port);
		if (http_socket >= 0) {
			if (-1 == socket_write(http_socket, buffer->c_str, buffer->size) ||
				-1 == socket_write(http_socket, buf, count)) {
				VERBOSE("Could not write to HTTP server.");
			} else {
				char response[512]; // Need only the first line
				int r = socket_read(http_socket, response, sizeof response - 1);
				response[r] = '\0';
				sscanf(response, "HTTP/1.1 %d", &response_code);				
			}
		}
		socket_close(&http_socket);
		string_delete(buffer);

	}
	else {
		VERBOSE("Malformed URL: %s", url);
	}

	free(path);
	free(port);
	free(host);

	VERBOSE("HTTP Response: %d", response_code);
	return response_code;
}
Example #23
0
/* variable_destroy */
static void _variable_destroy(Variable * variable)
{
	switch(variable->type)
	{
		case VT_NULL:
		case VT_BOOL:
		case VT_INT8:
		case VT_UINT8:
		case VT_INT16:
		case VT_UINT16:
		case VT_INT32:
		case VT_UINT32:
		case VT_INT64:
		case VT_UINT64:
		case VT_FLOAT:
		case VT_DOUBLE:
			break;
		case VT_BUFFER:
			buffer_delete(variable->u.buffer);
			break;
		case VT_STRING:
			string_delete(variable->u.string);
			break;
	}
}
Example #24
0
/**
 * Free a NULL-terminated array of Strings
 */
void string_delete_array(String **array) {
	if (array) {
		for (String **array_iter = array; *array_iter; ++array_iter) {
			string_delete(*array_iter);
		}
		free(array);
	}
}
Example #25
0
/* note_set_description */
int note_set_description(Note * note, char const * description)
{
	String * d;

	if((d = string_new_replace(description, "\\", "\\\\")) == NULL)
		return -1;
	if(string_replace(&d, "\n", "\\n") != 0
			|| config_set(note->config, NULL, "description", d)
			!= 0)
	{
		string_delete(d);
		return -1;
	}
	string_delete(note->description);
	note->description = d;
	return 0;
}
Example #26
0
/* note_delete */
void note_delete(Note * note)
{
	string_delete(note->description);
	free(note->filename);
	if(note->config != NULL)
		config_delete(note->config);
	object_delete(note);
}
Example #27
0
static int32_t http_request_delete(void *pdu)
{
    struct string_class *str = pdu;

    string_delete(str);

    return ERR_SUCCESS;
}
Example #28
0
void string_array_delete(array* arr) {
 int i;

 for(i = 0; i < arr->used; i++)
  string_delete((string*)arr->data[i]);

 array_delete_all(arr);
}
Example #29
0
int request_read_integer(int sock, int* i) {
 string str;

 string_init(&str);

 if(socket_readline(sock, &str) == -1 || !str.used) {
  string_delete(&str);

  return 0;
 }

 *i = atoi(str.data);

 string_delete(&str);

 return 1;
}
Example #30
0
/* modem_delete */
void modem_delete(Modem * modem)
{
	if(modem->modem != NULL)
		modem_stop(modem);
	if(modem->plugin != NULL)
		plugin_delete(modem->plugin);
	string_delete(modem->name);
	object_delete(modem);
}