Exemple #1
0
/* tests for doing init/finish multiple times. */
static int multi_init(void)
{
    int res1 = ne_sock_init(), res2 = ne_sock_init();
    
    ONV(res1 != res2, ("cached init result changed from %d to %d",
                       res1, res2));
    
    ne_sock_exit();
    ne_sock_exit();
    ne_sock_exit();

    res1 = ne_sock_init();
    ONV(res1 != res2, ("re-init after exit gave %d not %d",
                       res1, res2));
    ne_sock_exit();

    res2 = ne_sock_init();
    
    ONV(res1 != res2, ("second time, cached init result changed from %d to %d",
                       res1, res2));
    
    return OK;
}
Exemple #2
0
void free_S3(S3 *s3)
{
	if(s3) {
		ne_buffer_destroy(s3->key_info.nb_name);
		ne_buffer_destroy(s3->key_info.nb_etag);
		ne_buffer_destroy(s3->key_info.nb_storage_class);
		ne_buffer_destroy(s3->key_info.nb_owner_id);
		ne_buffer_destroy(s3->key_info.nb_owner_display_name);
		memset(s3->access_id,0,64);
		memset(s3->secret_key,0,64);
		ne_sock_exit();
		free(s3);
	}
}
/* close the socket and associated resources
 * used both to recover from errors and go to NULL state */
static gboolean
gst_neonhttp_src_stop (GstBaseSrc * bsrc)
{
  GstNeonhttpSrc *src;

  src = GST_NEONHTTP_SRC (bsrc);

  if (src->iradio_name) {
    g_free (src->iradio_name);
    src->iradio_name = NULL;
  }

  if (src->iradio_genre) {
    g_free (src->iradio_genre);
    src->iradio_genre = NULL;
  }

  if (src->iradio_url) {
    g_free (src->iradio_url);
    src->iradio_url = NULL;
  }

  if (src->icy_caps) {
    gst_caps_unref (src->icy_caps);
    src->icy_caps = NULL;
  }

  src->eos = FALSE;
  src->content_size = -1;
  src->read_position = 0;
  src->seekable = TRUE;

  gst_neonhttp_src_close_session (src);

#ifndef GST_DISABLE_GST_DEBUG
  ne_debug_init (NULL, 0);
#endif
  ne_oom_callback (NULL);
  ne_sock_exit ();

  return TRUE;
}
/* close the socket and associated resources
 * used both to recover from errors and go to NULL state */
static gboolean
gst_neonhttp_src_stop (GstBaseSrc * bsrc)
{
    GstNeonhttpSrc *src;

    src = GST_NEONHTTP_SRC (bsrc);

    src->eos = FALSE;
    src->content_size = -1;
    src->read_position = 0;
    src->seekable = TRUE;

    gst_neonhttp_src_close_session (src);

#ifndef GST_DISABLE_GST_DEBUG
    ne_debug_init (NULL, 0);
#endif
    ne_oom_callback (NULL);
    ne_sock_exit ();

    return TRUE;
}
Exemple #5
0
int main(int argc, char *argv[])
{
    int n, fd, i;
    char *p;
    ne_test *testp;
    
    if ( read_options(argc, argv) == -1){
	Usage(argv[0]);
	exit(-1);	
    }

    if ( pget_option.outfile ){
	if ((fd=open(pget_option.outfile, O_CREAT | O_TRUNC | O_RDWR, 0660)) < 0){
	    perror("open() :");
	    return -1;
	}   

	close(STDOUT_FILENO);
	dup2(fd, STDOUT_FILENO);
    }


    test_argc = argc;
    test_argv = argv;


    if (tests[0].fn == NULL) {
	printf("-> no tests found in `%s'\n", test_suite);
	return -1;
    }

    if (ne_sock_init()) {
	COL("43;01"); printf("WARNING:"); NOCOL;
	printf(" Socket library initalization failed.\n");
    }

    printf("\n");	
    printf("\n");	
    i = 0;
    p = Result_Header[i];
    while (  p != NULL ){
    	printf("%s\n", p);
	i++;
    	p = Result_Header[i];
    }


   testp = &tests[0];
   if ( !strcmp(pget_option.methods, "WebFolder") )
    	testp = &tests2[0];

    for ( n=0; !aborted && testp[n].fn != NULL; n++) {
	int result;


	test_name = testp[n].name;
	have_context = 0;
	test_num = n;
	warned = 0;
	fflush(stdout);

	/* run the test. */
	result = testp[n].fn();


        if (testp[n].flags & T_EXPECT_FAIL) {
            if (result == OK) {
                t_context("test passed but expected failure");
                result = FAIL;
            } else if (result == FAIL)
                result = OK;
        }

	/* align the result column if we've had warnings. */
	if (warned) {
	    printf("    %s ", dots);
	}

    }

    /* discount skipped tests */
    if (skipped) {
	printf("-> %d %s.\n", skipped,
	       skipped==1?"test was skipped":"tests were skipped");
	n -= skipped;
	if (passes + fails != n) {
	    printf("-> ARGH! Number of test results does not match "
		   "number of tests.\n"
		   "-> ARGH! Test Results are INRELIABLE.\n");
	}
    }

    ne_sock_exit();
    
    return fails;
}
Exemple #6
0
static void neon_plugin_fini (void)
{
    ne_sock_exit ();
}
Exemple #7
0
int main(int argc, char *argv[])
{
    int n;
    static const char dots[] = "......................";
    
    /* get basename(argv[0]) */
    test_suite = strrchr(argv[0], '/');
    if (test_suite == NULL) {
	test_suite = argv[0];
    } else {
	test_suite++;
    }

#ifdef HAVE_SETLOCALE
    setlocale(LC_MESSAGES, "");
#endif

    ne_i18n_init(NULL);

#if defined(HAVE_ISATTY) && defined(STDOUT_FILENO)
    if (isatty(STDOUT_FILENO)) {
	use_colour = 1;
    }
#endif

    test_argc = argc;
    test_argv = argv;

    debug = fopen("debug.log", "a");
    if (debug == NULL) {
	fprintf(stderr, "%s: Could not open debug.log: %s\n", test_suite,
		strerror(errno));
	return -1;
    }
    child_debug = fopen("child.log", "a");
    if (child_debug == NULL) {
	fprintf(stderr, "%s: Could not open child.log: %s\n", test_suite,
		strerror(errno));
	fclose(debug);
	return -1;
    }

    if (tests[0].fn == NULL) {
	printf("-> no tests found in `%s'\n", test_suite);
	return -1;
    }

    /* install special SEGV handler. */
    signal(SIGSEGV, parent_segv);
    signal(SIGABRT, parent_segv);

    /* test the "no-debugging" mode of ne_debug. */
    ne_debug_init(NULL, 0);
    NE_DEBUG(TEST_DEBUG, "This message should go to /dev/null");

    /* enable debugging for real. */
    ne_debug_init(debug, TEST_DEBUG);
    NE_DEBUG(TEST_DEBUG | NE_DBG_FLUSH, "Version string: %s\n", 
             ne_version_string());
    
    /* another silly test. */
    NE_DEBUG(0, "This message should also go to /dev/null");

    if (ne_sock_init()) {
	COL("43;01"); printf("WARNING:"); NOCOL;
	printf(" Socket library initalization failed.\n");
    }

    printf("-> running `%s':\n", test_suite);
    
    for (n = 0; !aborted && tests[n].fn != NULL; n++) {
	int result, is_xfail = 0;
#ifdef NEON_MEMLEAK
        size_t allocated = ne_alloc_used;
        int is_xleaky = 0;
#endif

	test_name = tests[n].name;
	printf("%2d. %s%.*s ", n, test_name, 
	       (int) (strlen(dots) - strlen(test_name)), dots);
	have_context = 0;
	test_num = n;
	warned = 0;
	fflush(stdout);
	NE_DEBUG(TEST_DEBUG, "******* Running test %d: %s ********\n", 
		 n, test_name);

	/* run the test. */
	result = tests[n].fn();

#ifdef NEON_MEMLEAK
        /* issue warnings for memory leaks, if requested */
        if ((tests[n].flags & T_CHECK_LEAKS) && result == OK &&
            ne_alloc_used > allocated) {
            t_context("memory leak of %" NE_FMT_SIZE_T " bytes",
                      ne_alloc_used - allocated);
            fprintf(debug, "Blocks leaked: ");
            ne_alloc_dump(debug);
            result = FAIL;
        } else if (tests[n].flags & T_EXPECT_LEAKS && result == OK &&
                   ne_alloc_used == allocated) {
            t_context("expected memory leak not detected");
            result = FAIL;
        } else if (tests[n].flags & T_EXPECT_LEAKS && result == OK) {
            fprintf(debug, "Blocks leaked (expected): ");
            ne_alloc_dump(debug);
            is_xleaky = 1;
        } 
#endif

        if (tests[n].flags & T_EXPECT_FAIL) {
            if (result == OK) {
                t_context("test passed but expected failure");
                result = FAIL;
            } else if (result == FAIL) {
                result = OK;
                is_xfail = 1;
            }
        }

	/* align the result column if we've had warnings. */
	if (warned) {
	    printf("    %s ", dots);
	}

	switch (result) {
	case OK:
            if (is_xfail) {
                COL("32;07"); 
                printf("xfail");
            } else {
                COL("32"); 
                printf("pass"); 
            }
            NOCOL;
	    if (warned) {
		printf(" (with %d warning%s)", warned, (warned > 1)?"s":"");
	    }
#ifdef NEON_MEMLEAK
            if (is_xleaky) {
                printf(" (with expected leak, %" NE_FMT_SIZE_T " bytes)",
                       ne_alloc_used - allocated);
            }
#endif
	    putchar('\n');
	    passes++;
	    break;
	case FAILHARD:
	    aborted = 1;
	    /* fall-through */
	case FAIL:
	    COL("41;37;01"); printf("FAIL"); NOCOL;
	    if (have_context) {
		printf(" (%s)", test_context);
	    }
	    putchar('\n');
	    fails++;
	    break;
	case SKIPREST:
	    aborted = 1;
	    /* fall-through */
	case SKIP:
	    COL("44;37;01"); printf("SKIPPED"); NOCOL;
	    if (have_context) {
		printf(" (%s)", test_context);
	    }
	    putchar('\n');
	    skipped++;
	    break;
	default:
	    COL("41;37;01"); printf("OOPS"); NOCOL;
	    printf(" unexpected test result `%d'\n", result);
	    break;
	}

	reap_server();
    }

    /* discount skipped tests */
    if (skipped) {
	printf("-> %d %s.\n", skipped,
	       skipped==1?"test was skipped":"tests were skipped");
	n -= skipped;
	if (passes + fails != n) {
	    printf("-> ARGH! Number of test results does not match "
		   "number of tests.\n"
		   "-> ARGH! Test Results are INRELIABLE.\n");
	}
    }
    /* print the summary. */
    if (skipped && n == 0) {
	printf("<- all tests skipped for `%s'.\n", test_suite);
    } else {
	printf("<- summary for `%s': "
	       "of %d tests run: %d passed, %d failed. %.1f%%\n",
	       test_suite, n, passes, fails, 100*(float)passes/n);
	if (warnings) {
	    printf("-> %d warning%s issued.\n", warnings, 
		   warnings==1?" was":"s were");
	}
    }

    if (fclose(debug)) {
	fprintf(stderr, "Error closing debug.log: %s\n", strerror(errno));
	fails = 1;
    }
       
    if (fclose(child_debug)) {
	fprintf(stderr, "Error closing child.log: %s\n", strerror(errno));
	fails = 1;
    }

    ne_sock_exit();
    
    return fails;
}
Exemple #8
0
int main(int argc, char *argv[])
{
    int ret = 0;
    char *home = getenv("HOME"), *tmp;

    progname = argv[0];

#ifdef HAVE_SETLOCALE
    setlocale(LC_ALL, "");
#endif

#ifdef ENABLE_NLS
    bindtextdomain(PACKAGE_NAME, LOCALEDIR);
    textdomain(PACKAGE_NAME);
#endif /* ENABLE_NLS */

    ne_debug_init(stderr, 0);
    if (!home) {
	/* Show me the way to go home... */
	printf(_("Environment variable $HOME needs to be set!\n"));
	return -1;
    }

    ne_sock_init();

    memset(&session, 0, sizeof session);

    /* Options before rcfile, so rcfile settings can
     * override defaults */
    tmp = ne_concat(home, "/.cadaver-locks", NULL);
    set_option(opt_lockstore, tmp);
    init_options();
    init_netrc();

    init_signals();
    init_locking();
    
    parse_args(argc, argv);

    ret = init_rcfile();

    init_readline();

    while (ret == 0) {
	char *cmd;
	cmd = read_command();
	if (cmd == NULL) {
	    /* Is it safe to do this... they just closed stdin, so
	     * is it bad to write to stdout? */
	    putchar('\n');
	    ret = 1;
	} else {
#ifdef HAVE_ADD_HISTORY
	    if (strcmp(cmd, "") != 0) add_history(cmd);
#endif
	    ret = execute_command(cmd);
	    free(cmd);
	}
    }

    if (session.connected) {
	close_connection();
    }

    finish_locking();

    ne_sock_exit();

    return 0;
}
Exemple #9
0
int main(int argc, char **argv)
{
    struct dt_dentry *probe;
    struct wdwk_dir curdir;
    int full = 0;
    int lookup = 0;
    char *host;
    int i;
    char *oldtree = NULL;
    FILE *oldfile;
    int port = 0;

    for (i = 1; i < argc; i++) {
        if (argv[i][0] != '-')
            break;
        if (argv[i][1] == '-' && argv[i][2] == 0) {
            i++;
            break;
        }
        switch (argv[i][1]) {
            case 'f':
                full = 1;
                break;
            case 'p':
                port = atoi(&argv[i][2]);
                break;
            case 'l':
                lookup = 1;
                break;
            case 'u':
                i++;
                if (i >= argc)
                    usage(argv[0], ESTAT_FAILURE);
                oldtree = argv[i];
                break;
            case 'h':
                usage(argv[0], ESTAT_SUCCESS);
            default:
                usage(argv[0], ESTAT_FAILURE);
        }
    }
    
    if (i + 1 != argc)
        usage(argv[0], ESTAT_FAILURE);

    ne_debug_init(stderr, 0);
    
    if (ne_sock_init()) {
        LOG_ERR("ne_sock_init() returned non-zero\n");
        exit(ESTAT_NOCONNECT);
    }

    host = argv[i];

    if (wdwk_open(&curdir, host, port) < 0)
        exit(ESTAT_NOCONNECT);

    if (lookup) {
        probe = wdwk_walker.readdir(&curdir);
        wdwk_close(&curdir);
        if (probe != NULL) {
            dt_free(probe);
            exit(ESTAT_SUCCESS);
        }
        else
            exit(ESTAT_FAILURE);
    }

    if (full)
        dt_full(&wdwk_walker, &curdir);
    else if (oldtree) {
        if ((oldfile = fopen(oldtree, "r")) == NULL) {
            LOG_ERRNO("Can't open file %s\n", oldtree);
            exit(ESTAT_FAILURE);
        }
        dt_diff(oldfile, &wdwk_walker, &curdir);
        fclose(oldfile);
    } else
        dt_reverse(&wdwk_walker, &curdir);

    wdwk_close(&curdir);
    ne_sock_exit();

    return ESTAT_SUCCESS;
}