Exemple #1
0
void do_recv(int s){
	int fd;
	int yes = 1;

	for (;;) {
		if (listen(s, 1) < 0) {
			perror("listen");
			exit(1);
		}
		printf("Waiting for connection...\n");
		if ((fd = accept(s, 0, 0)) < 0) {
			perror("accept");
			exit(1);
		}

		printf("Got connection...\n");
		
		//OpenSSL
		SSL_set_fd(ssl, fd);	
		printf("SSL Accept: %d\n",SSL_accept(ssl));
		bio = SSL_get_wbio(ssl);		
		//SSL_set_accept_state(ssl);
		////////////
		
		setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
		
		//while (do_copy(fd))
		do_copy(fd);
		printf("Connection closed...\n");
	}
}
Exemple #2
0
/*===========================================================================*
 *				sys_task				     *
 *===========================================================================*/
PUBLIC sys_task()
{
/* Main entry point of sys_task.  Get the message and dispatch on type. */

  register int r;

  while (TRUE) {
	receive(ANY, &m);

	switch (m.m_type) {	/* which system call */
	    case SYS_FORK:	r = do_fork(&m);	break;
	    case SYS_NEWMAP:	r = do_newmap(&m);	break;
	    case SYS_EXEC:	r = do_exec(&m);	break;
	    case SYS_XIT:	r = do_xit(&m);		break;
	    case SYS_GETSP:	r = do_getsp(&m);	break;
	    case SYS_TIMES:	r = do_times(&m);	break;
	    case SYS_ABORT:	r = do_abort(&m);	break;
	    case SYS_SIG:	r = do_sig(&m);		break;
	    case SYS_COPY:	r = do_copy(&m);	break;
	    default:		r = E_BAD_FCN;
	}

	m.m_type = r;		/* 'r' reports status of call */
	send(m.m_source, &m);	/* send reply to caller */
  }
}
Exemple #3
0
int main(int argc, char* argv[])
{
	int  ch;
	acl::string path_from, path_to;
	acl::log::stdout_open(true);

	while ((ch = getopt(argc, argv, "hf:t:")) > 0)
	{
		switch (ch)
		{
		case 'h':
			usage(argv[0]);
			return 0;
		case 'f':
			path_from = optarg;
			break;
		case  't':
			path_to = optarg;
			break;
		default:
			break;
		}
	}

	if (path_from.empty() || path_to.empty())
	{
		usage(argv[0]);
		return 1;
	}

	if (path_from == path_to)
	{
		logger_error("path_from(%s) == path_to(%s)", path_from.c_str(),
			path_to.c_str());
		usage(argv[0]);
		return 1;
	}

	if (chdir(path_from.c_str()) == -1)
	{
		logger_error("chdir to %s error: %s",
			path_from.c_str(), acl::last_serror());
		return 1;
	}

	char path[256];
	if (getcwd(path, sizeof(path)) == NULL)
	{
		logger_error("getcwd error: %s", path);
		return 1;
	}
	logger("current path: %s", path);

	do_copy(".", path_to);

	logger("enter any key to exit");
	getchar();

	return (0);
}
Exemple #4
0
/*===========================================================================*
 *				sys_task				     *
 *===========================================================================*/
PUBLIC void sys_task()
{
/* Main entry point of sys_task.  Get the message and dispatch on type. */

  register int r;

  while (TRUE) {
	receive(ANY, &m);

	switch (m.m_type) {	/* which system call */
	    case SYS_FORK:	r = do_fork(&m);	break;
	    case SYS_NEWMAP:	r = do_newmap(&m);	break;
	    case SYS_EXEC:	r = do_exec(&m);	break;
	    case SYS_XIT:	r = do_xit(&m);		break;
	    case SYS_GETSP:	r = do_getsp(&m);	break;
	    case SYS_TIMES:	r = do_times(&m);	break;
	    case SYS_ABORT:	r = do_abort(&m);	break;
#if (CHIP == M68000)
	    case SYS_FRESH:	r = do_fresh(&m);	break;
#endif
	    case SYS_SIG:	r = do_sig(&m);		break;
	    case SYS_KILL:	r = do_kill(&m);	break;
	    case SYS_COPY:	r = do_copy(&m);	break;
	    case SYS_GBOOT:	r = do_gboot(&m);	break;
	    case SYS_UMAP:	r = do_umap(&m);	break;
	    case SYS_MEM:	r = do_mem(&m);		break;
	    case SYS_TRACE:	r = do_trace(&m);	break;
	    default:		r = E_BAD_FCN;
	}

	m.m_type = r;		/* 'r' reports status of call */
	send(m.m_source, &m);	/* send reply to caller */
  }
}
int doCopy(int argc, char **argv){
  struct location *dest, *src;
  int i;
  int r;
  if(opts(argc,argv)<0)
    return EXIT_FAILURE;
  dest=parse_location(destination);
  if(open_location(dest,WRITE)<0)
    return EXIT_FAILURE;
  for(i=0;i<nsources;++i){
    src=parse_location(sources[i]);
    if(open_location(src,READ)<0){
      return EXIT_FAILURE;
    }
    if(do_copy(src,dest,0) < 0){
        break;
    }
  }
  if(dest->is_ssh){
          r=ssh_scp_close(dest->scp);
          if(r == SSH_ERROR){
                  fprintf(stderr,"Error closing scp: %s\n",ssh_get_error(dest->session));
                  ssh_scp_free(dest->scp);
                  dest->scp=NULL;
                  return -1;
          }
  } else {
          fclose(dest->file);
          dest->file=NULL;
  }
  ssh_disconnect(dest->session);
  ssh_finalize();
  return 0;
}
int
keyring_insert_keyblock (KEYRING_HANDLE hd, KBNODE kb)
{
    int rc;
    const char *fname;

    if (!hd)
        fname = NULL;
    else if (hd->found.kr)
        fname = hd->found.kr->fname;
    else if (hd->current.kr)
        fname = hd->current.kr->fname;
    else 
        fname = hd->resource? hd->resource->fname:NULL;

    if (!fname)
        return G10ERR_GENERAL; 

    /* close this one otherwise we will lose the position for
     * a next search.  Fixme: it would be better to adjust the position
     * after the write opertions.
     */
    iobuf_close (hd->current.iobuf);
    hd->current.iobuf = NULL;

    /* do the insert */
    rc = do_copy (1, fname, kb, hd->secret, 0, 0 );
    if (!rc && !hd->secret && kr_offtbl)
      {
        update_offset_hash_table_from_kb (kr_offtbl, kb, 0);
      }
      
    return rc;
}
Exemple #7
0
int main(int argc, char** argv) {
  Opts    options;
  int     out_start = argc;
  Input   in = { 0, -1, 0 };
  Output *outputs = malloc((argc - 1) * sizeof(Output));
  int    *regular = malloc((argc - 1) * sizeof(int));
  int    *pipes   = malloc((argc - 1) * sizeof(int));
  SpillControl spillage = { NULL, NULL, NULL, NULL,
			    0, 0, 0, 0, 0, 0, 0, 0 };  /* Spillage info. */
  int     nregular = 0, npipes = 0;
  struct sigaction sig;

  if (NULL == outputs || NULL == regular || NULL == pipes) {
    perror("malloc");
    return EXIT_FAILURE;
  }

  /* Ignore SIGPIPEs, we want write(2) to get EPIPE instead. */
  sig.sa_handler = SIG_IGN;
  if (0 != sigaction(SIGPIPE, &sig, NULL)) {
    perror("sigaction");
    return EXIT_FAILURE;
  }

  if (0 != get_options(argc, argv, &options, &out_start)) {
    return EXIT_FAILURE;
  }

  if (verbosity > 0) {
    fprintf(stderr, "%.3f Started.\n", get_time());
  }

  if (0 != open_input(&options, &in, &spillage)) {
    return EXIT_FAILURE;
  }

  if (out_start >= argc) {
    fprintf(stderr, "No output files specified\n");
    return EXIT_FAILURE;
  }

  /* Open the output files */
  if (open_outputs(argc - out_start, argv + out_start, outputs,
		   regular, pipes, &nregular, &npipes) != 0) {
    return EXIT_FAILURE;
  }
  
  /* Copy input to all outputs */
  if (do_copy(&options, &in, argc - out_start, outputs,
	      nregular, regular, npipes, pipes, &spillage) != 0) {
    return EXIT_FAILURE;
  }

  if (verbosity > 0) {
    fprintf(stderr, "%.3f Finished.\n", get_time());
  }

  return EXIT_SUCCESS;
}
Exemple #8
0
void
gconf_defaults_set_system (GConfDefaults          *mechanism,
			   const char            **includes,
			   const char            **excludes,
			   DBusGMethodInvocation  *context)
{
	do_copy (mechanism, FALSE, includes, excludes, NULL, context, set_system_changes, NULL, NULL);
}
Exemple #9
0
void
gconf_defaults_set_mandatory (GConfDefaults          *mechanism,
                              const char            **includes,
                              const char            **excludes,
                              DBusGMethodInvocation  *context)
{
	do_copy (mechanism, TRUE, includes, excludes, NULL, context, NULL, NULL, NULL);
}
Exemple #10
0
void
copy_cb (GtkWidget * widget, gpointer data)
{
  sw_view * view = (sw_view *)data;
  sw_sample * s = view->sample;

  do_copy (s);
}
void VectorImpl::_do_copy(void* dest, const void* from, size_t num) const
{
    if (!(mFlags & HAS_TRIVIAL_COPY)) {
        do_copy(dest, from, num);
    } else {
        memcpy(dest, from, num*itemSize());
    }
}
bool Copy_to_Secure_from_temp(char *tempfile)
{
IniFile myIniFile_In;
IniFile myIniFile_Out;
myIniFile_Out.IniFileSetSecure();
myIniFile_In.IniFileSetTemp(tempfile);

return do_copy(myIniFile_In, myIniFile_Out);
}
Exemple #13
0
bool SpecialisedMover::do_rename(FileName const & from, FileName const & to,
				 string const & latex) const
{
	if (command_.empty())
		return Mover::do_rename(from, to, latex);

	if (!do_copy(from, to, latex))
		return false;
	return from.removeFile();
}
Exemple #14
0
int main(int argc,const char* argv[])
{
    if(argc <3 )
    {
        fprintf(stderr,"Usage : %s <src file> <dest fiel>f",argv[0]);
        return 0;
    }
    do_copy(argv[1],argv[2]);

    return 0;
}
Exemple #15
0
/* If called without arguments, listen for connections.  Otherwise make a
 * connection to the specified first argument.
 */
int main(int argc, char *argv[]) {
    int inport = atoi(argv[1]);
    int outport = atoi(argv[2]);

    int input = do_connect("localhost", inport);
    int output = do_connect("localhost", outport);

    (void)argc;

    do_copy(input, output);
    return 0;
}
Exemple #16
0
int main(int argc, char **argv) {
    struct location *dest, *src;
    int i;
    int r;
    if (opts(argc, argv) < 0) {
        r = EXIT_FAILURE;
        goto end;
    }

    dest = parse_location(destination);
    if (dest == NULL) {
        r = EXIT_FAILURE;
        goto end;
    }

    if (open_location(dest, WRITE) < 0) {
        location_free(dest);
        r = EXIT_FAILURE;
        goto end;
    }

    for (i = 0; i < nsources; ++i) {
        src = parse_location(sources[i]);
        if (src == NULL) {
            r = EXIT_FAILURE;
            goto close_dest;
        }

        if (open_location(src, READ) < 0) {
            location_free(src);
            r = EXIT_FAILURE;
            goto close_dest;
        }

        if (do_copy(src, dest, 0) < 0) {
            close_location(src);
            location_free(src);
            break;
        }

        close_location(src);
        location_free(src);
    }

    r = 0;

close_dest:
    close_location(dest);
    location_free(dest);
end:
    return r;
}
Exemple #17
0
void
gconf_defaults_set_system (GConfDefaults          *mechanism,
			   const char            **includes,
			   const char            **excludes,
			   DBusGMethodInvocation  *context)
{
	GConfChangeSet *changes = NULL;

	do_copy (mechanism, FALSE, includes, excludes, context, &changes);

	emit_system_set_signal (mechanism, changes);
	gconf_change_set_unref (changes);
}
Exemple #18
0
int
main(int argc, char **argv) {

    bool interactive = false;
    parse_option(argc,argv,&interactive);

    argc -= optind;
    argv += optind;

    check_operand(argc,argv);

    do_copy(argc,argv,interactive,data_copy);
	return EXIT_SUCCESS;
}
Exemple #19
0
void
gconf_defaults_set_mandatory_value (GConfDefaults         *mechanism,
                                    const char            *path,
                                    const char            *value,
                                    DBusGMethodInvocation *context)
{
	GConfValue *gvalue;
 	const char *includes[] = { NULL, NULL };

	gvalue = gconf_value_decode (value);
	if (gvalue) {
		includes[0] = path;
		do_copy (mechanism, TRUE, includes, NULL, gvalue, context, NULL, NULL, NULL);
	}
}
Exemple #20
0
void
piglit_init(int argc, char *argv[])
{
	if (piglit_get_gl_version() < 15) {
		printf("Requires OpenGL 1.5\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	piglit_require_extension("GL_ARB_vertex_buffer_object");
	piglit_require_extension("GL_ARB_copy_buffer");

	memset(src_data, 0xff, COPY_BUFFER_SIZE);

	piglit_report_result(do_copy());
}
Exemple #21
0
	virtual Vasp *tx_work(const Argument &arg) 
	{ 
		OpParam p(thisName(),0);													
		
		if(arg.CanbeVasp()) {
			CVasp dst(arg.GetAVasp());
			Vasp *ret = do_copy(p,dst);
			ToOutVasp(1,dst);
			return ret;
		}
		else {
			post("%s - argument is not a valid vasp!",thisName());  // \todo check earlier!
			return NULL;
		}
	}
Exemple #22
0
static int
oo_copy_pkt_to_iovec_no_adv(ci_netif* ni, const ci_ip_pkt_fmt* pkt,
                            ci_iovec_ptr* piov, int bytes_to_copy)
{
  /* Copy data from [pkt] to [piov], following [pkt->frag_next] as
   * necessary.  Does not modify [pkt].  May or may not advance [piov].
   * The packet must contain at least [bytes_to_copy] of data in the
   * [pkt->buf].  [piov] may contain an arbitrary amount of space.
   *
   * Returns number of bytes copied on success, or -EFAULT otherwise.
   */
  int n, pkt_left, pkt_off = 0;
  int bytes_copied = 0;

  while( 1 ) {
    pkt_left = oo_offbuf_left(&pkt->buf) - pkt_off;
    n = CI_MIN(pkt_left, CI_IOVEC_LEN(&piov->io));
    n = CI_MIN(n, bytes_to_copy);
    if(CI_UNLIKELY( do_copy(CI_IOVEC_BASE(&piov->io),
                            oo_offbuf_ptr(&pkt->buf) + pkt_off, n) != 0 ))
      return -EFAULT;

    bytes_copied += n;
    pkt_off += n;
    if( n == bytes_to_copy )
      return bytes_copied;

    bytes_to_copy -= n;
    if( n == pkt_left ) {
      /* Caller guarantees that packet contains at least [bytes_to_copy]. */
      ci_assert(OO_PP_NOT_NULL(pkt->frag_next));
      ci_iovec_ptr_advance(piov, n);
      pkt = PKT_CHK_NNL(ni, pkt->frag_next);
      pkt_off = 0;
      /* We're unlikely to hit end-of-pkt-buf and end-of-iovec at the same
       * time, and if we do, just go round the loop again.
       */
      continue;
    }

    ci_assert_equal(n, CI_IOVEC_LEN(&piov->io));
    if( piov->iovlen == 0 )
      return bytes_copied;
    piov->io = *piov->iov++;
    --piov->iovlen;
  }
}
Exemple #23
0
int main(int argc, char *argv[])
{
	if (argc < 3) 
	{
		perror("Usage: icp source dest\n");
		exit(1);
	}
	
	int i;
	for (i = 1; i < argc - 1; i++) 
	{
		do_copy(argv[i], argv[argc-1]);
	}

	printf("Finish...\n");
	
	return 0;
}
Exemple #24
0
int
keyring_insert_keyblock (KEYRING_HANDLE hd, KBNODE kb)
{
	printf("starting keyring_insert_keyblock\n" );
    int rc;
    const char *fname;

    if (!hd)
        fname = NULL;
    else if (hd->found.kr)
      {
        fname = hd->found.kr->fname;
        if (hd->found.kr->readonly)
          return gpg_error (GPG_ERR_EACCES);
      }
    else if (hd->current.kr)
      {
        fname = hd->current.kr->fname;
        if (hd->current.kr->readonly)
          return gpg_error (GPG_ERR_EACCES);
      }
    else
        fname = hd->resource? hd->resource->fname:NULL;

    if (!fname)
        return G10ERR_GENERAL;

    /* Close this one otherwise we will lose the position for
     * a next search.  Fixme: it would be better to adjust the position
     * after the write opertions.
     */
    iobuf_close (hd->current.iobuf);
    hd->current.iobuf = NULL;
    printf("before do copy\n");
    /* do the insert */
    rc = do_copy (1, fname, kb, hd->secret, 0, 0 );
    printf("after do copy\n");
    if (!rc && !hd->secret && kr_offtbl)
      {
        update_offset_hash_table_from_kb (kr_offtbl, kb, 0);
      }
	printf("finish keyring_insert_keyblock\n" );
    return rc;
}
Exemple #25
0
void flush_aplog(e_aplog_file_t file, const char *mode, int *dir, const char *ts) {
    char log_boot_name[512] = { '\0', };
    int status;

    switch (file) {
    case APLOG:
#ifndef CONFIG_APLOG
        if (file_exists(APLOG_FILE_0)) {
            remove(APLOG_FILE_0);
        }
        status = system("/system/bin/logcat -b system -b main -b radio -b events -v threadtime -d -f " LOGS_DIR "/aplog");
        if (status != 0)
            LOGE("dump logcat returns status: %d.\n", status);
        do_chown(APLOG_FILE_0, PERM_USER, PERM_GROUP);
#endif
        break;

    case APLOG_BOOT:
        if ((mode == NULL) || (dir == NULL) || (ts == NULL)) {
            LOGE("invalid parameters\n");
            return;
        }

        snprintf(log_boot_name, sizeof(log_boot_name)-1, "%s%d/%s_%s_%s",
                CRASH_DIR, *dir, strrchr(APLOG_FILE_BOOT,'/')+1, mode, ts);

        status = system("/system/bin/logcat -b system -b main -b radio -b events -v threadtime -d -f " LOGS_DIR "/aplog_boot");
        if (status != 0) {
            LOGE("flush ap log from boot returns status: %d.\n", status);
            return;
        }

        if(file_exists(APLOG_FILE_BOOT)) {
            do_copy(APLOG_FILE_BOOT, log_boot_name, MAXFILESIZE);
            remove(APLOG_FILE_BOOT);
        }
        break;

    default:
        LOGE("invalid logfile parameter\n");
        break;
    }
}
Exemple #26
0
int main(int argv, char* args[]){

	disk = open("/dev/fd0",O_RDWR);
	if (argv > 1){
		if (strcmp(format, args[1]) == 0)
			do_format();
		else if (strcmp(mkdir, args[1]) == 0){
			if (argv > 2)
				do_mkdir(args[2]);
			else 
				printf("Usage: mkdir dir\n");
		}
		else if (strcmp(chdir, args[1]) == 0){
			if (argv > 2)
				do_chdir(args[2]);
			else 
				printf("Usage: chdir dir\n");
		}
		else if (strcmp(copy, args[1]) == 0) {
			do_copy(args[2], args[3], args[4]);
		}
		else if (strcmp(dir, args[1]) == 0)
			do_dir(args[2]);
		else if (strcmp("info", args[1]) == 0){
			info(args[2]);
			}
		else if (strcmp("freeblock", args[1]) == 0)
			free_block();
		else if (strcmp("checkblock", args[1]) == 0)
			check_block(args[2]);



		else
			printf("Unknown dtool command.\n");



	}


	return 0;
}
Exemple #27
0
int
keyring_insert_keyblock (KEYRING_HANDLE hd, KBNODE kb)
{
    int rc;
    const char *fname;

    if (!hd)
        fname = NULL;
    else if (hd->found.kr)
      {
        fname = hd->found.kr->fname;
        if (hd->found.kr->read_only)
          return gpg_error (GPG_ERR_EACCES);
      }
    else if (hd->current.kr)
      {
        fname = hd->current.kr->fname;
        if (hd->current.kr->read_only)
          return gpg_error (GPG_ERR_EACCES);
      }
    else
        fname = hd->resource? hd->resource->fname:NULL;

    if (!fname)
        return GPG_ERR_GENERAL;

    /* Close this one otherwise we will lose the position for
     * a next search.  Fixme: it would be better to adjust the position
     * after the write opertions.
     */
    iobuf_close (hd->current.iobuf);
    hd->current.iobuf = NULL;

    /* do the insert */
    rc = do_copy (1, fname, kb, 0, 0 );
    if (!rc && key_present_hash)
      {
        key_present_hash_update_from_kb (key_present_hash, kb);
      }

    return rc;
}
Exemple #28
0
int
keyring_update_keyblock (KEYRING_HANDLE hd, KBNODE kb)
{
    int rc;

    if (!hd->found.kr)
        return -1; /* no successful prior search */

    if (hd->found.kr->readonly)
      return gpg_error (GPG_ERR_EACCES);

    if (!hd->found.n_packets) {
        /* need to know the number of packets - do a dummy get_keyblock*/
        rc = keyring_get_keyblock (hd, NULL);
        if (rc) {
            log_error ("re-reading keyblock failed: %s\n", g10_errstr (rc));
            return rc;
        }
        if (!hd->found.n_packets)
            BUG ();
    }

    /* The open iobuf isn't needed anymore and in fact is a problem when
       it comes to renaming the keyring files on some operating systems,
       so close it here */
    iobuf_close(hd->current.iobuf);
    hd->current.iobuf = NULL;

    /* do the update */
    rc = do_copy (3, hd->found.kr->fname, kb, hd->secret,
                  hd->found.offset, hd->found.n_packets );
    if (!rc) {
      if (!hd->secret && kr_offtbl)
        {
          update_offset_hash_table_from_kb (kr_offtbl, kb, 0);
        }
      /* better reset the found info */
      hd->found.kr = NULL;
      hd->found.offset = 0;
    }
    return rc;
}
Exemple #29
0
int
keyring_delete_keyblock (KEYRING_HANDLE hd)
{
    int rc;

    if (!hd->found.kr)
        return -1; /* no successful prior search */

    if (hd->found.kr->readonly)
      return gpg_error (GPG_ERR_EACCES);

    if (!hd->found.n_packets) {
        /* need to know the number of packets - do a dummy get_keyblock*/
        rc = keyring_get_keyblock (hd, NULL);
        if (rc) {
            log_error ("re-reading keyblock failed: %s\n", g10_errstr (rc));
            return rc;
        }
        if (!hd->found.n_packets)
            BUG ();
    }

    /* close this one otherwise we will lose the position for
     * a next search.  Fixme: it would be better to adjust the position
     * after the write opertions.
     */
    iobuf_close (hd->current.iobuf);
    hd->current.iobuf = NULL;

    /* do the delete */
    rc = do_copy (2, hd->found.kr->fname, NULL, hd->secret,
                  hd->found.offset, hd->found.n_packets );
    if (!rc) {
        /* better reset the found info */
        hd->found.kr = NULL;
        hd->found.offset = 0;
        /* Delete is a rare operations, so we don't remove the keys
         * from the offset table */
    }
    return rc;
}
Exemple #30
0
void do_recv(int s){
	int fd;
	for (;;) {
		if (listen(s, 1) < 0) {
			perror("listen");
			exit(1);
		}
		printf("Waiting for connection...\n");
		if ((fd = accept(s, 0, 0)) < 0) {
			perror("accept");
			exit(1);
		}
		//OpenSSL
		SSL_set_fd(ssl, fd);
		SSL_accept(ssl);
		////////////
		printf("Got connection...\n");
		do_copy(fd);
		printf("Connection closed...\n");
	}
}