Exemplo n.º 1
0
//*******************************************************************
// customEvent                                     PRIVATE inherited
//*******************************************************************
void QBtWorkspace::customEvent( QEvent* const in_event )
{
    const QBtEvent* const event = dynamic_cast< QBtEvent* >( in_event );
    const int type = static_cast<int>( event->type() );

    switch( type ) {
    case QBtEvent::SWITCH_TAB_REQUEST:
        switch_panels();
        break;
    case QBtEvent::F5_KEY:
        copy();
        break;
    case QBtEvent::F9_KEY:
        pack();
        break;
    case QBtEvent::COMPARE_FILES:
        compare_files();
        break;
    case QBtEvent::COMPARE_DIRS:
        compare_dirs();
        break;
    case QBtEvent::SYNC_DIRS:
        sync_dirs();
        break;
    case QBtEvent::JOIN_FILES:
        join_files();
        break;
    case QBtEvent::DIR_TREE:
        dir_tree();
        break;
    case QBtEvent::MD5_CREATE:
        md5_create();
        break;
    case QBtEvent::MD5_CHECK:
        md5_check();
        break;
    case QBtEvent::DATE_TIME:
        date_time();
        break;
    case QBtEvent::DROP_FILES:
        drop_files( event->data(0).toMap() );
        break;
    case QBtEvent::OPEN_OPOSITE:
        open_oposite();
        break;
    case QBtEvent::OPEN_DIR:
        open_dir( event->data(0).toString() );
        break;
    case QBtEvent::OPEN_SHELL:
        open_shell();
        break;
    case QBtEvent::OPEN_TERMINAL:
        open_terminal();
        break;
    case QBtEvent::OPEN_EDITOR:
        open_editor();
        break;
    case QBtEvent::EXECUTE:
        open( event->data(0).toString(), QStringList(), QString() );
        break;
    }
}
Exemplo n.º 2
0
static int test_tigroup()
{
	TigContent *content = NULL;
	TigEntry te = { NULL, 0, { NULL } };
	int ret = -1;

	// SVN can't handle file like 'pépé'. You will have to rename it from pepe to pépé and
	// uncomment line below and another line.
	//char *name = g_filename_from_utf8("tig/p\xC3\xA9p\xC3\xA9.tig", -1, NULL, NULL, NULL);

	char *array[2];
	char files[2][1024];

	printf("--> Testing TiGroup support (r/w)...\n");
	tifiles_file_display_tigroup(PATH("tig/test.tig"));

	content = tifiles_content_create_tigroup(CALC_NONE, 0);
	if (content != NULL)
	{
		ret = tifiles_file_read_tigroup(PATH("tig/test2.tig"), content);
		if (!ret)
		{
			ret = tifiles_file_write_tigroup(PATH("tig/test2_.tig"), content);
		}
		tifiles_content_delete_tigroup(content);
	}

	if (!ret)
	{
		content = tifiles_content_create_tigroup(CALC_NONE, 0);
		if (content != NULL)
		{
			ret = tifiles_file_read_tigroup(PATH("tig/test.tig"), content);
			if (!ret)
			{
				ret = tifiles_file_write_tigroup(PATH("tig/test_.tig"), content);
				if (!ret)
				{
					ret = compare_files(PATH("tig/test.tig"), PATH2("tig/test_.tig"));
				}
			}
			tifiles_content_delete_tigroup(content);
		}
	}

	if (!ret)
	{
		printf("--> Testing add/del from TiGroup support (r/w)...\n");
		ret = tifiles_tigroup_add_file(PATH("tig/C.8Xn"), PATH2("tig/test2.tig"));
		if (!ret)
		{
			ret = tifiles_tigroup_add_file(PATH("tig/D.8Xn"), PATH2("tig/test2.tig"));
			if (!ret)
			{
				te.filename = strdup("C.8Xn");
				ret = tifiles_tigroup_del_file(&te, PATH("tig/test2.tig"));
				if (!ret)
				{
					te.filename = strdup("D.8Xn");
					ret = tifiles_tigroup_del_file(&te, PATH("tig/test2.tig"));
					if (!ret)
					{
						tifiles_file_display_tigroup(PATH("tig/test2.tig"));
						ret = compare_files(PATH("tig/test.tig"), PATH2("tig/test2.tig"));
					}
				}
			}
		}
	}

	if (!ret)
	{
		printf("--> Testing TiGroup support (group/ungroup)...\n");

		strncpy(files[0], PATH("tig/str.89s"), 1023);
		files[0][1023] = 0;
		strncpy(files[1], PATH("tig/ticabfra.89k"), 1023);
		files[1][1023] = 0;
		array[0] = files[0];
		array[1] = files[1];
		ret = tifiles_tigroup_files(array, PATH("tig/test_.tig"));
		if (!ret)
		{
			tifiles_file_display(PATH("tig/test_.tig"));
			ret = tifiles_untigroup_file(PATH("tig/test.tig"), NULL);
			if (!ret)
			{
				move_file("A.8Xn", "tig/AA.8Xn");
				move_file("B.8Xn", "tig/BB.8Xn");
				ret = compare_files(PATH("tig/A.8Xn"), PATH2("tig/AA.8Xn"));
				if (!ret)
				{
					ret = compare_files(PATH("tig/B.8Xn"), PATH2("tig/BB.8Xn"));
				}
			}
		}
	}

	return ret;
}
Exemplo n.º 3
0
Arquivo: cmd.c Projeto: JBurant/mc
static void
compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
{
    int i, j;

    /* No marks by default */
    panel->marked = 0;
    panel->total = 0;
    panel->dirs_marked = 0;

    /* Handle all files in the panel */
    for (i = 0; i < panel->dir.len; i++)
    {
        file_entry_t *source = &panel->dir.list[i];

        /* Default: unmarked */
        file_mark (panel, i, 0);

        /* Skip directories */
        if (S_ISDIR (source->st.st_mode))
            continue;

        /* Search the corresponding entry from the other panel */
        for (j = 0; j < other->dir.len; j++)
        {
            if (strcmp (source->fname, other->dir.list[j].fname) == 0)
                break;
        }
        if (j >= other->dir.len)
            /* Not found -> mark */
            do_file_mark (panel, i, 1);
        else
        {
            /* Found */
            file_entry_t *target = &other->dir.list[j];

            if (mode != compare_size_only)
            {
                /* Older version is not marked */
                if (source->st.st_mtime < target->st.st_mtime)
                    continue;
            }

            /* Newer version with different size is marked */
            if (source->st.st_size != target->st.st_size)
            {
                do_file_mark (panel, i, 1);
                continue;

            }
            if (mode == compare_size_only)
                continue;

            if (mode == compare_quick)
            {
                /* Thorough compare off, compare only time stamps */
                /* Mark newer version, don't mark version with the same date */
                if (source->st.st_mtime > target->st.st_mtime)
                {
                    do_file_mark (panel, i, 1);
                }
                continue;
            }

            /* Thorough compare on, do byte-by-byte comparison */
            {
                vfs_path_t *src_name, *dst_name;

                src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, NULL);
                dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, NULL);
                if (compare_files (src_name, dst_name, source->st.st_size))
                    do_file_mark (panel, i, 1);
                vfs_path_free (src_name);
                vfs_path_free (dst_name);
            }
        }
    }                           /* for (i ...) */
}
Exemplo n.º 4
0
/*
 * The main function
 */
int main(int argc, char *argv[])
{
	/* Read in local files */
	printf("Reading local files...\n");
	DIR *dir;
	struct dirent *ent;

	char cwd[1024];
	char *wd = getcwd(cwd, sizeof(cwd));
	
	char* full_dir = strcat(cwd, "/clientSongs/");

	struct stat st;

	if((dir = opendir(full_dir)) != NULL)
	{
		int count = 0;
		while ((ent = readdir (dir)) != NULL)
		{
			if((strcmp(ent->d_name, ".") != 0) &&
				(strcmp(ent->d_name, "..") != 0) &&
				(strcmp(ent->d_name, ".DS_Store") != 0))
			{
	    		long f_size;

	    		/*stat(ent->d_name, &st);
	    		file_lengths[count] = st.st_size;*/

	    		local_filenames[count] = ent->d_name;
	    		count++;
    		}
    		num_files = count;
		}
	}

	if(argc == 1) {
		/* Command line interface */
		printf("Command line interface:\n");
		switch_state(START_STATE);
	}
	else if(argc == 2)
	{
		/* Direct command */
		printf("Direct command:\n");
		if(strcmp(argv[1], "list") == 0)
		{
			printf("LIST\n");
			send_command(LIST);
		}
		else if(strcmp(argv[1], "diff") == 0)
		{
			printf("DIFF\n");
			send_command(DIFF);
		}
		else if(strcmp(argv[1], "pull") == 0)
		{
			printf("PULL\n");
			send_command(PULL);
		}
		else if(strcmp(argv[1], "leave") == 0)
		{
			printf("LEAVE\n");
			send_command(LEAVE);
		}
		else
		{
			printf("%s", bad_command);
		}
	}
	else if((argc == 3) && (strcmp(argv[1], "-c") == 0))
	{
		printf("Direct command:\n");
		printf("File Comparison\n");
		compare_files(argv[2]);
	}
	else
	{
		printf("%s", bad_number_of_commands);
	}
}
Exemplo n.º 5
0
// Build a portable path for Linux/Win32
static const char* PATH2(const char *path)
{
#if defined(__WIN32__) && !defined(__MINGW32__)
	static char str[1024];
	unsigned int i;

	strcpy(str, "C:\\sources\\roms\\tifiles2\\tests\\");
	strcat(str, path);

	for(i = 0; i < strlen(str); i++)
	{
		if(str[i] == '/')
		{
			str[i] = '\\';
		}

	return str;
#else
	return path;
#endif
}

/*
	About TI formatted file: we can sort calc like this:
	- TI73
	- TI82/83
	- TI83+/TI84+
	- TI85/86
	- TI92
	- TI89/92+/V200

	Testing order:
	- backup
	- regular (single and group)
	- flash
	- grouping
	- ungrouping
*/

/****************************/
/* Generic helper functions */
/****************************/
static int test_tixx_backup_support(const char * message,
                                    CalcModel calculator,
                                    const char * input_file,
                                    const char * output_file)
{
	BackupContent *content;
	int ret = -1;

	printf("%s", message);
	tifiles_file_display(PATH(input_file));

	content = tifiles_content_create_backup(calculator);
	if (content != NULL)
	{
		ret = tifiles_file_read_backup(PATH(input_file), content);
		if (!ret)
		{
			ret = tifiles_file_write_backup(PATH(output_file), content);
			if (!ret)
			{
				ret = compare_files(PATH(input_file), PATH2(output_file));
			}
			tifiles_content_delete_backup(content);
		}
	}

	return ret;
}
Exemplo n.º 6
0
static
bool
run_output_check(const output_check oc, const atf::fs::path& path,
                 const std::string& stdxxx)
{
    bool result;

    if (oc.type == oc_empty) {
        const bool is_empty = file_empty(path);
        if (!oc.negated && !is_empty) {
            std::cerr << "Fail: " << stdxxx << " not empty\n";
            print_diff(atf::fs::path("/dev/null"), path);
            result = false;
        } else if (oc.negated && is_empty) {
            std::cerr << "Fail: " << stdxxx << " is empty\n";
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_file) {
        const bool equals = compare_files(path, atf::fs::path(oc.value));
        if (!oc.negated && !equals) {
            std::cerr << "Fail: " << stdxxx << " does not match golden "
                "output\n";
            print_diff(atf::fs::path(oc.value), path);
            result = false;
        } else if (oc.negated && equals) {
            std::cerr << "Fail: " << stdxxx << " matches golden output\n";
            cat_file(atf::fs::path(oc.value));
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_ignore) {
        result = true;
    } else if (oc.type == oc_inline) {
        atf::fs::path path2 = atf::fs::path(atf::config::get("atf_workdir"))
                              / "inline.XXXXXX";
        temp_file temp(path2);
        temp.write(decode(oc.value));
        temp.close();

        const bool equals = compare_files(path, temp.get_path());
        if (!oc.negated && !equals) {
            std::cerr << "Fail: " << stdxxx << " does not match expected "
                "value\n";
            print_diff(temp.get_path(), path);
            result = false;
        } else if (oc.negated && equals) {
            std::cerr << "Fail: " << stdxxx << " matches expected value\n";
            cat_file(temp.get_path());
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_match) {
        const bool matches = grep_file(path, oc.value);
        if (!oc.negated && !matches) {
            std::cerr << "Fail: regexp " + oc.value + " not in " << stdxxx
                      << "\n";
            cat_file(path);
            result = false;
        } else if (oc.negated && matches) {
            std::cerr << "Fail: regexp " + oc.value + " is in " << stdxxx
                      << "\n";
            cat_file(path);
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_save) {
        INV(!oc.negated);
        std::ifstream ifs(path.c_str(), std::fstream::binary);
        ifs >> std::noskipws;
        std::istream_iterator< char > begin(ifs), end;

        std::ofstream ofs(oc.value.c_str(), std::fstream::binary
                                     | std::fstream::trunc);
        std::ostream_iterator <char> obegin(ofs);

        std::copy(begin, end, obegin);
        result = true;
    } else {
//deduplication.c and wav files should be in the same folder
int main()
{
    char z;
    char path[100];
    char path_temp[100];
    printf("Enter path of folder:\n");
    scanf("%s",path);
//    strcpy(path,"/home/yashasvi/git/Audio-Sample-Generator/Test/");
    strcpy(path_temp,path);
    FILE *f=fopen("input1.txt","w+");
    int a=noof_files(path);
    fprintf(f,"%d",a);
    list_dir(f,path);    
    fclose(f);

    int i,j,x,min;
    int num_tracks;
    //double percentage_matching;
    //printf("Enter number of tracks:\n");
    //scanf("%d", &num_tracks);

    FILE *fp = fopen("input1.txt","r+");
    fscanf(fp,"%d", &num_tracks);
    //int total_results[num_tracks];
    //printf("num_tracks = %d\n",num_tracks);

    char track_names[num_tracks][20];
    char track_txt[num_tracks][20];
    //printf("Enter track names:\n");

    for(i=0;i<num_tracks;i++)
    {
        fscanf(fp,"%s", track_names[i]);
    }

    fclose(fp);

    for(i=0;i<num_tracks;i++)
    {
        strcpy(track_txt[i],trim_wav(track_names[i]));
        //printf("%s\n",track_txt[i]);
        wave_Read(track_names[i],track_txt[i]);
    }
    /*for(i=0;i<num_tracks;i++)
    {
	printf("%d\n",total_results[i]);
    }*/
    for(i=0;i<num_tracks;i++)
    {
        for(j=i+1;j<num_tracks;j++)
        {
            /*if(total_results[i]<total_results[j])
 		min = total_results[i];
	    else
		min = total_results[j];*/

            x = compare_files(track_txt[i],track_txt[j]);
   	        if(x)
            {
	       	    printf("Files %s and %s are matching\n",track_names[i],track_names[j]);
/*                printf("Do you want to delete a file[y/n]?\n");
                scanf("%s",z);
                if(!strcmp(z,"y"))
*/              deleteFile(path);
            }
                
        }
    }
    del_txt(path_temp);

    return 0;
}
Exemplo n.º 8
0
/* (Note: *LAST_SEED is an output parameter.) */
static svn_error_t *
do_random_combine_test(const char **msg,
                       svn_boolean_t msg_only,
                       apr_pool_t *pool,
                       apr_uint32_t *last_seed)
{
  static char msg_buff[256];

  apr_uint32_t seed, bytes_range, maxlen;
  int i, iterations, dump_files, print_windows;
  const char *random_bytes;

  /* Initialize parameters and print out the seed in case we dump core
     or something. */
  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
              &random_bytes, &bytes_range, pool);
  sprintf(msg_buff,
          "random combine delta test, seed = %lu", (unsigned long) seed);
  *msg = msg_buff;

  if (msg_only)
    return SVN_NO_ERROR;
  else
    printf("SEED:  %s\n", msg_buff);

  for (i = 0; i < iterations; i++)
    {
      /* Generate source and target for the delta and its application.  */
      apr_uint32_t subseed_base = svn_test_rand((*last_seed = seed, &seed));
      apr_file_t *source = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *middle = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *target = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *source_copy = copy_tempfile(source, pool);
      apr_file_t *middle_copy = copy_tempfile(middle, pool);
      apr_file_t *target_regen = open_tempfile(NULL, pool);

      svn_txdelta_stream_t *txdelta_stream_A;
      svn_txdelta_stream_t *txdelta_stream_B;
      svn_txdelta_window_handler_t handler;
      svn_stream_t *stream;
      void *handler_baton;

      /* Set up a four-stage pipeline: create two deltas, combine them
         and convert the result to svndiff format, parse that back
         into delta format, and apply it to a copy of the source file
         to see if we get the same target back.  */
      apr_pool_t *delta_pool = svn_pool_create(pool);

      /* Make stage 4: apply the text delta.  */
      svn_txdelta_apply(svn_stream_from_aprfile(source_copy, delta_pool),
                        svn_stream_from_aprfile(target_regen, delta_pool),
                        NULL, NULL, delta_pool, &handler, &handler_baton);

      /* Make stage 3: reparse the text delta.  */
      stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
                                         delta_pool);

      /* Make stage 2: encode the text delta in svndiff format.  */
      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
                              delta_pool);

      /* Make stage 1: create the text deltas.  */

      svn_txdelta(&txdelta_stream_A,
                  svn_stream_from_aprfile(source, delta_pool),
                  svn_stream_from_aprfile(middle, delta_pool),
                  delta_pool);

      svn_txdelta(&txdelta_stream_B,
                  svn_stream_from_aprfile(middle_copy, delta_pool),
                  svn_stream_from_aprfile(target, delta_pool),
                  delta_pool);

      {
        svn_txdelta_window_t *window_A;
        svn_txdelta_window_t *window_B;
        svn_txdelta_window_t *composite;
        apr_pool_t *wpool = svn_pool_create(delta_pool);

        do
          {
            SVN_ERR(svn_txdelta_next_window(&window_A, txdelta_stream_A,
                                            wpool));
            if (print_windows)
              delta_window_print(window_A, "A ", stdout);
            SVN_ERR(svn_txdelta_next_window(&window_B, txdelta_stream_B,
                                            wpool));
            if (print_windows)
              delta_window_print(window_B, "B ", stdout);
            if (!window_B)
              break;
            assert(window_A != NULL || window_B->src_ops == 0);
            if (window_B->src_ops == 0)
              {
                composite = window_B;
                composite->sview_len = 0;
              }
            else
              composite = svn_txdelta_compose_windows(window_A, window_B,
                                                      wpool);
            if (print_windows)
              delta_window_print(composite, "AB", stdout);

            /* The source view length should not be 0 if there are
               source copy ops in the window. */
            if (composite
                && composite->sview_len == 0 && composite->src_ops > 0)
              return svn_error_create
                (SVN_ERR_FS_GENERAL, NULL,
                 "combined delta window is inconsistent");

            SVN_ERR(handler(composite, handler_baton));
            svn_pool_clear(wpool);
          }
        while (composite != NULL);
        svn_pool_destroy(wpool);
      }

      svn_pool_destroy(delta_pool);

      SVN_ERR(compare_files(target, target_regen, dump_files));

      apr_file_close(source);
      apr_file_close(middle);
      apr_file_close(target);
      apr_file_close(source_copy);
      apr_file_close(middle_copy);
      apr_file_close(target_regen);
    }

  return SVN_NO_ERROR;
}
Exemplo n.º 9
0
/* Implements svn_test_driver_t. */
static svn_error_t *
random_test(const char **msg,
            svn_boolean_t msg_only,
            svn_test_opts_t *opts,
            apr_pool_t *pool)
{
  static char msg_buff[256];

  apr_uint32_t seed, bytes_range, maxlen;
  int i, iterations, dump_files, print_windows;
  const char *random_bytes;

  /* Initialize parameters and print out the seed in case we dump core
     or something. */
  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
              &random_bytes, &bytes_range, pool);
  sprintf(msg_buff, "random delta test, seed = %lu", (unsigned long) seed);
  *msg = msg_buff;

  if (msg_only)
    return SVN_NO_ERROR;
  else
    printf("SEED:  %s\n", msg_buff);

  for (i = 0; i < iterations; i++)
    {
      /* Generate source and target for the delta and its application.  */
      apr_uint32_t subseed_base = svn_test_rand(&seed);
      apr_file_t *source = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *target = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *source_copy = copy_tempfile(source, pool);
      apr_file_t *target_regen = open_tempfile(NULL, pool);

      svn_txdelta_stream_t *txdelta_stream;
      svn_txdelta_window_handler_t handler;
      svn_stream_t *stream;
      void *handler_baton;

      /* Set up a four-stage pipeline: create a delta, convert it to
         svndiff format, parse it back into delta format, and apply it
         to a copy of the source file to see if we get the same target
         back.  */
      apr_pool_t *delta_pool = svn_pool_create(pool);

      /* Make stage 4: apply the text delta.  */
      svn_txdelta_apply(svn_stream_from_aprfile(source_copy, delta_pool),
                        svn_stream_from_aprfile(target_regen, delta_pool),
                        NULL, NULL, delta_pool, &handler, &handler_baton);

      /* Make stage 3: reparse the text delta.  */
      stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
                                         delta_pool);

      /* Make stage 2: encode the text delta in svndiff format.  */
      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
                              delta_pool);

      /* Make stage 1: create the text delta.  */
      svn_txdelta(&txdelta_stream,
                  svn_stream_from_aprfile(source, delta_pool),
                  svn_stream_from_aprfile(target, delta_pool),
                  delta_pool);

      SVN_ERR(svn_txdelta_send_txstream(txdelta_stream,
                                        handler,
                                        handler_baton,
                                        delta_pool));

      svn_pool_destroy(delta_pool);

      SVN_ERR(compare_files(target, target_regen, dump_files));

      apr_file_close(source);
      apr_file_close(target);
      apr_file_close(source_copy);
      apr_file_close(target_regen);
    }

  return SVN_NO_ERROR;
}
Exemplo n.º 10
0
static void file_transfer_message(void) {
	char* to;
	LinphoneChatRoom* chat_room;
	LinphoneChatMessage* message;
	LinphoneChatMessageCbs *cbs;
	LinphoneContent* content;
	FILE *file_to_send = NULL;
	size_t file_size;
	char *send_filepath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", liblinphone_tester_file_prefix);
	char *receive_filepath = ms_strdup_printf("%s/receive_file.dump", liblinphone_tester_writable_dir_prefix);
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	reset_counters(&marie->stat);
	reset_counters(&pauline->stat);

	file_to_send = fopen(send_filepath, "rb");
	fseek(file_to_send, 0, SEEK_END);
	file_size = ftell(file_to_send);
	fseek(file_to_send, 0, SEEK_SET);

	/* Globally configure an http file transfer server. */
	linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");

	/* create a chatroom on pauline's side */
	to = linphone_address_as_string(marie->identity);
	chat_room = linphone_core_create_chat_room(pauline->lc,to);
	ms_free(to);
	/* create a file transfer message */
	content = linphone_core_create_content(pauline->lc);
	linphone_content_set_type(content,"image");
	linphone_content_set_subtype(content,"jpeg");
	linphone_content_set_size(content,file_size); /*total size to be transfered*/
	linphone_content_set_name(content,"nowebcamCIF.jpg");
	message = linphone_chat_room_create_file_transfer_message(chat_room, content);
	linphone_chat_message_set_user_data(message, file_to_send);
	cbs = linphone_chat_message_get_callbacks(message);
	{
		int dummy=0;
		wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/
		reset_counters(&marie->stat);
		reset_counters(&pauline->stat);
	}
	linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
	linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send);
	linphone_chat_room_send_chat_message(chat_room,message);
	CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1));
	fclose(file_to_send);
	if (marie->stat.last_received_chat_message ) {
		cbs = linphone_chat_message_get_callbacks(marie->stat.last_received_chat_message);
		linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
		linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
		linphone_chat_message_download_file(marie->stat.last_received_chat_message);
	}
	CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageExtBodyReceived,1));

	CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1);
	CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1);
	CU_ASSERT_TRUE(compare_files(send_filepath, receive_filepath));

	linphone_content_unref(content);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
	ms_free(send_filepath);
	ms_free(receive_filepath);
}
Exemplo n.º 11
0
int main(int argc, char *argv[]) {
	const char *code = argv[1];
	const char *slash = strrchr(code, '/');

	int ret;

	/* stupid automake! */
	if (slash)
		code = slash + 1;

	if (code[0] == '_') {
		struct stat st;
		if (lstat(INPUT_FILE, &st))
			return 77;

		switch (code[1]) {
			case T_BROKEN_SYMLINK:
				ex_linkdest[0]++;
		}
	} else {
		/* XXX: replace tests */
		unlink(INPUT_FILE);
		unlink(OUTPUT_FILE);

		switch (code[0]) {
			case T_REGULAR:
			case T_EMPTY:
				if (!create_input(INPUT_FILE, code[0] == T_REGULAR)) {
					perror("Input creation failed");
					return 2;
				}
				break;
			case T_BROKEN_SYMLINK:
				ex_linkdest[0]++;
			case T_SYMLINK:
				if (symlink(ex_linkdest, INPUT_FILE)) {
					perror("Input symlink creation failed");
					return 77;
				}
				break;
			case T_NAMED_PIPE:
				if (mkfifo(INPUT_FILE, 0700)) {
					perror("Named pipe creation failed");
					return 77;
				}
				break;
			case T_BLK_DEV:
#ifdef S_IFBLK
				if (mknod(INPUT_FILE, 0700 | S_IFBLK, 0xff00)) {
					perror("Block device creation failed");
					return 77;
				}
#else
				fprintf(stderr, "Block devices not supported\n");
				return 77;
#endif
				break;
			case T_CHR_DEV:
#ifdef S_IFCHR
				if (mknod(INPUT_FILE, 0700 | S_IFCHR, 0x0103)) {
					perror("Character device creation failed");
					return 77;
				}
#else
				fprintf(stderr, "Character devices not supported\n");
				return 77;
#endif
				break;
			default:
				fprintf(stderr, "Invalid arg: [%s]\n", code);
				return 3;
		}
	}

	ret = ai_cp_a(INPUT_FILE, OUTPUT_FILE);
	if (ret) {
		fprintf(stderr, "[%s] Copying failed: %s\n",
				code, strerror(errno));
		return 1;
	}

	return compare_files(INPUT_FILE, OUTPUT_FILE, code);
}
Exemplo n.º 12
0
/* Implements svn_test_driver_t. */
static svn_error_t *
random_test(apr_pool_t *pool)
{
  apr_uint32_t seed, maxlen;
  apr_size_t bytes_range;
  int i, iterations, dump_files, print_windows;
  const char *random_bytes;

  /* Initialize parameters and print out the seed in case we dump core
     or something. */
  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
              &random_bytes, &bytes_range, pool);

  for (i = 0; i < iterations; i++)
    {
      /* Generate source and target for the delta and its application.  */
      apr_uint32_t subseed_base = svn_test_rand(&seed);
      apr_file_t *source = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *target = generate_random_file(maxlen, subseed_base, &seed,
                                                random_bytes, bytes_range,
                                                dump_files, pool);
      apr_file_t *source_copy = copy_tempfile(source, pool);
      apr_file_t *target_regen = open_tempfile(NULL, pool);

      svn_txdelta_stream_t *txdelta_stream;
      svn_txdelta_window_handler_t handler;
      svn_stream_t *stream;
      void *handler_baton;

      /* Set up a four-stage pipeline: create a delta, convert it to
         svndiff format, parse it back into delta format, and apply it
         to a copy of the source file to see if we get the same target
         back.  */
      apr_pool_t *delta_pool = svn_pool_create(pool);

      /* Make stage 4: apply the text delta.  */
      svn_txdelta_apply(svn_stream_from_aprfile(source_copy, delta_pool),
                        svn_stream_from_aprfile(target_regen, delta_pool),
                        NULL, NULL, delta_pool, &handler, &handler_baton);

      /* Make stage 3: reparse the text delta.  */
      stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
                                         delta_pool);

      /* Make stage 2: encode the text delta in svndiff format using
                       varying compression levels. */
      svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
                              delta_pool);

      /* Make stage 1: create the text delta.  */
      svn_txdelta2(&txdelta_stream,
                   svn_stream_from_aprfile(source, delta_pool),
                   svn_stream_from_aprfile(target, delta_pool),
                   FALSE,
                   delta_pool);

      SVN_ERR(svn_txdelta_send_txstream(txdelta_stream,
                                        handler,
                                        handler_baton,
                                        delta_pool));

      svn_pool_destroy(delta_pool);

      SVN_ERR(compare_files(target, target_regen, dump_files));

      apr_file_close(source);
      apr_file_close(target);
      apr_file_close(source_copy);
      apr_file_close(target_regen);
    }

  return SVN_NO_ERROR;
}