Esempio n. 1
0
/*---------------------------------------------------------------------------*/
static uint32_t 
  find_symbol_inflat(const char *symbol, struct relevant_section *have_to_be_sect)
{
  struct elf32_sym* s;
  struct relevant_section *sect;

  s = find_symbol(symbol);
  if ( !s ) {
	if ( FLAG_WARNSYMBOL )
    	PRINTERR(stderr, "Warning: not found '%s' symbol\n", symbol);
    return 0;
  }
  sect = find_section(s->st_shndx);
  if ( sect==0 ) {
	if ( FLAG_WARNSYMBOL )
    	PRINTERR(stderr, "Warning: unknown section of '%s' symbol\n",symbol); 
    return 0;
  }
  if ( have_to_be_sect && have_to_be_sect->number != sect->number ) {
	if ( FLAG_WARNSYMBOL )
    	PRINTERR(stderr, "Warning: wrong section of '%s' symbol - %s while required %s\n", 
				symbol, sect->name, have_to_be_sect->name );
    return 0;
  }

  return sect->flat_offset + s->st_value;
}
static void delete_status_bucket(struct cloudmig_ctx *ctx)
{
    dpl_status_t    dplret;
    dpl_vec_t       *objects = NULL;

    cloudmig_log(DEBUG_LVL, "[Deleting files]: Deleting status bucket...\n");

    dplret = dpl_list_bucket(ctx->src_ctx, ctx->status.bucket_name,
                             NULL, NULL, &objects, NULL);
    if (dplret != DPL_SUCCESS)
    {
        PRINTERR("%s: Could not list bucket %s for deletion : %s\n",
                 __FUNCTION__, ctx->status.bucket_name, dpl_status_str(dplret));
        goto deletebucket;
    }

    dpl_object_t** cur_object = (dpl_object_t**)objects->array;
    for (int i = 0; i < objects->n_items; ++i, ++cur_object)
        delete_file(ctx, ctx->status.bucket_name, (*cur_object)->key);

deletebucket:
    dpl_deletebucket(ctx->src_ctx, ctx->status.bucket_name);
    if (dplret != DPL_SUCCESS)
    {
        PRINTERR("%s: Could not delete bucket %s : %s.\n",
                 __FUNCTION__, ctx->status.bucket_name, dpl_status_str(dplret));
        return ;
    }
    cloudmig_log(DEBUG_LVL, "[Deleting Source] Bucket %s deleted.\n",
                 ctx->status.bucket_name);
}
Esempio n. 3
0
 void addSampleInfo(const std::string &str, const std::vector<chrsize> &gt, const WigType iftype) {
   int32_t binsize(0);  
   std::vector<std::string> v;
   ParseLine(v, str, ',');
     
   if(v.size() >8) {
     std::cerr << "error: sample std::string has ',' more than 8: " << str << std::endl;
     exit(1);
   }
   if(v[0] == "") {
     std::cerr << "please specify ChIP sample: " << str << std::endl;
     exit(1);
   }
   isFile(v[0]);
     
   if(v.size() >4 && v[4] != "") {
     try { binsize = stoi(v[4]); }
     catch (...) { std::cerr << "Warning: invalid binsize " << v[4] << "." << std::endl; }
   }
     
   // ChIP sample
   if(!Exists(v[0])) vsinfo[v[0]] = SampleInfo(v[0], gt, binsize, iftype);
   if(vsinfo[v[0]].getbinsize() <= 0) PRINTERR("please specify binsize.\n");
     
   // Input sample
   if(v.size() >=2 && v[1] != "") {
     if(!Exists(v[1])) vsinfo[v[1]] = SampleInfo(v[1], gt, binsize, iftype);
     if(vsinfo[v[0]].getbinsize() != vsinfo[v[1]].getbinsize()) PRINTERR("binsize of ChIP and Input should be same. " << str);
   }
 }
Esempio n. 4
0
static ALCenum opensl_open_playback(ALCdevice *Device, const ALCchar *deviceName)
{
    osl_data *data = NULL;
    SLresult result;

    if(!deviceName)
        deviceName = opensl_device;
    else if(strcmp(deviceName, opensl_device) != 0)
        return ALC_INVALID_VALUE;

    data = calloc(1, sizeof(*data));
    if(!data)
        return ALC_OUT_OF_MEMORY;

    // create engine
    result = slCreateEngine(&data->engineObject, 0, NULL, 0, NULL, NULL);
    PRINTERR(result, "slCreateEngine");
    if(SL_RESULT_SUCCESS == result)
    {
        result = SLObjectItf_Realize(data->engineObject, SL_BOOLEAN_FALSE);
        PRINTERR(result, "engine->Realize");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = SLObjectItf_GetInterface(data->engineObject, SL_IID_ENGINE, &data->engine);
        PRINTERR(result, "engine->GetInterface");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = SLEngineItf_CreateOutputMix(data->engine, &data->outputMix, 0, NULL, NULL);
        PRINTERR(result, "engine->CreateOutputMix");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = SLObjectItf_Realize(data->outputMix, SL_BOOLEAN_FALSE);
        PRINTERR(result, "outputMix->Realize");
    }

    if(SL_RESULT_SUCCESS != result)
    {
        if(data->outputMix != NULL)
            SLObjectItf_Destroy(data->outputMix);
        data->outputMix = NULL;

        if(data->engineObject != NULL)
            SLObjectItf_Destroy(data->engineObject);
        data->engineObject = NULL;
        data->engine = NULL;

        free(data);
        return ALC_INVALID_VALUE;
    }

    Device->DeviceName = strdup(deviceName);
    Device->ExtraData = data;

    return ALC_NO_ERROR;
}
int
setup_var_pid_and_sock(char *src, char *dst)
{
    char    pid_str[32];
    char    desc_file[64];
    // By using the size of sun_path, we seek to avoid buffer overflows in file
    // names.
    struct sockaddr_un t;
    char    sockfile[sizeof(t.sun_path)];

    // Create the directory
    if (mkdir("/tmp/cloudmig", 0755) == -1)
    {
        if (errno != EEXIST)
        {
            PRINTERR("Could not create /tmp/cloudmig directory : %s.\n",
                     strerror(errno));
            return (EXIT_FAILURE);
        }
    }

    sprintf(pid_str, "/tmp/cloudmig/%hi", getpid());
    if (mkdir(pid_str, 0755) == -1)
    {
        PRINTERR("Could not create %s directory : %s.\n",
                 pid_str, strerror(errno));
        if (rmdir("/tmp/cloudmig") == -1)
        {
            if (errno != ENOTEMPTY)
            {
                PRINTERR("Could not remove /tmp/cloudmig directory : %s. \
                         Please remove it manually.\n",
                         strerror(errno));
            }
        }
        return (EXIT_FAILURE);
    }

    snprintf(desc_file, sizeof(desc_file), "%s/description.txt", pid_str);
    FILE* desc = fopen(desc_file, "w");
    if (desc == NULL)
        return EXIT_FAILURE;
    fprintf(desc, "%s to %s", src, dst);
    fclose(desc);

    snprintf(sockfile, sizeof(sockfile), "%s/display.sock",
             pid_str);
    // First, save the file name into a global string ptr.
    gl_sockfile = strdup(sockfile);
    if (gl_sockfile == NULL)
        return EXIT_FAILURE;

    gl_accept_sock = create_log_socket(sockfile);
    if (gl_accept_sock == -1)
        return (EXIT_FAILURE);

    return (EXIT_SUCCESS);
}
Esempio n. 6
0
/*
 * Main migration function.
 *
 * It manages every step of the migration, and the deletion of old objects
 * if the migration was a success.
 */
int
migrate(struct cloudmig_ctx* ctx)
{
    int                         nb_failures = 0;
    int                         ret;

    cloudmig_log(DEBUG_LVL, "Starting migration...\n");

    for (int i=0; i < ctx->options.nb_threads; ++i)
    {
        ctx->tinfos[i].stop = false;
        if (pthread_create(&ctx->tinfos[i].thr, NULL,
                           (void*(*)(void*))migrate_worker_loop,
                           &ctx->tinfos[i]) == -1)
        {
            PRINTERR("Could not start worker thread %i/%i", i, ctx->options.nb_threads);
            nb_failures = 1;
            // Stop all the already-running threads before attempting to join
            migration_stop(ctx);
            break ;
        }
    }

    /*
     * Join all the threads, and cumulate their error counts
     */
    for (int i=0; i < ctx->options.nb_threads; i++)
    {
        int errcount;
        ret = pthread_join(ctx->tinfos[i].thr, (void**)&errcount);
        if (ret != 0)
            cloudmig_log(WARN_LVL, "Could not join thread %i: %s.\n", i, strerror(errno));
        else
            nb_failures += errcount;
    }

    // In any case, attempt to update the status digest before doing anything else
    (void)status_digest_upload(ctx->status->digest);

    // Check if it was the end of the transfer by checking the number of failures
    if (nb_failures == 0) // 0 == number of failures that occured.
    {
        cloudmig_log(INFO_LVL, "Migration finished with success !\n");
        if (ctx->tinfos[0].config_flags & DELETE_SOURCE_DATA)
            delete_source(ctx);
    }
    else
    {
        PRINTERR("An error occured during the migration."
                 " At least one file could not be transfered\n", 0);
        goto err;
    }

err:

    return nb_failures;
}
Esempio n. 7
0
void *ReadRecordFileAndSendToSocket()
{
    char buf[BUF_MAX];
    int ret = 0;
    //int socket;
    //fd_socket = client_init();
    //socket = client_init();
    struct sockaddr_in client_addr;
    bzero(&client_addr, sizeof(client_addr));
    client_addr.sin_family = AF_INET;
    client_addr.sin_addr.s_addr = htons(INADDR_ANY);
    client_addr.sin_port = htons(0);
    int client_socket = socket(AF_INET, SOCK_STREAM, 0);
    if(client_socket < 0)
        {
            PRINTERR("Creat Socket Failed! \n");
            exit(1);
        }
    if(bind(client_socket, (struct sockaddr*)&client_addr, sizeof(client_addr)))
        {
            PRINTERR("Client bind port failed!\n");
            exit(1);
        }
    struct sockaddr_in server_addr;
    bzero(&server_addr, sizeof(server_addr));
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = inet_addr("192.168.9.95");
    server_addr.sin_port = htons(SERVER_PORT);
    socklen_t server_addr_length = sizeof(server_addr);
    if (connect(client_socket, (struct sockaddr*)&server_addr, server_addr_length)<0)
        {
            PRINTERR("Can not Connect to 192.168.9.189");
            exit(1);
        }

     /* LOGD("In %s", __FUNCTION__); */
    for(;;)
        {
    /* LOGD("In %s", __FUNCTION__); */
            ret = ReadPrinterRecord(&buf[0], BUF_MAX);
            if(ret>0)
                {
                    //SendToServer(socket, buf, ret);
                    printf("Send data length is %d\n", ret);
                    send(client_socket, buf, ret, MSG_DONTWAIT);
                    //fsync(socket);
                }
            else if (ret == 0)
                {
                    sleep(10);
                }
            //else if (ret )
            //sleep(1);
        }
    close(client_socket);
}
Esempio n. 8
0
File: opensl.c Progetto: dns/CLove
static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *name)
{
    ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
    SLresult result;

    if(!name)
        name = opensl_device;
    else if(strcmp(name, opensl_device) != 0)
        return ALC_INVALID_VALUE;

    // create engine
    result = slCreateEngine(&self->mEngineObj, 0, NULL, 0, NULL, NULL);
    PRINTERR(result, "slCreateEngine");
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(self->mEngineObj,Realize)(SL_BOOLEAN_FALSE);
        PRINTERR(result, "engine->Realize");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(self->mEngineObj,GetInterface)(SL_IID_ENGINE, &self->mEngine);
        PRINTERR(result, "engine->GetInterface");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(self->mEngine,CreateOutputMix)(&self->mOutputMix, 0, NULL, NULL);
        PRINTERR(result, "engine->CreateOutputMix");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(self->mOutputMix,Realize)(SL_BOOLEAN_FALSE);
        PRINTERR(result, "outputMix->Realize");
    }

    if(SL_RESULT_SUCCESS != result)
    {
        if(self->mOutputMix != NULL)
            VCALL0(self->mOutputMix,Destroy)();
        self->mOutputMix = NULL;

        if(self->mEngineObj != NULL)
            VCALL0(self->mEngineObj,Destroy)();
        self->mEngineObj = NULL;
        self->mEngine = NULL;

        return ALC_INVALID_VALUE;
    }

    alstr_copy_cstr(&device->DeviceName, name);

    return ALC_NO_ERROR;
}
Esempio n. 9
0
int
Test_CardConnecting()
{
	int trycnt;
	long result;

	printf("==============================================================\n");
	printf("Part B : Card Connect/Disconnect\n");
	printf("==============================================================\n");
	trycnt = 0;
	printf("Testing");
	while(trycnt < 5)
	{
		trycnt++;
		printf("...");
#ifdef LINUX_OS
		fflush(stdout);
#endif
		result = SCardConnect(	 ScardContext,
							 ScardReaderState[CurrentReader].szReader,
							 SCARD_SHARE_EXCLUSIVE,
							 SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
							 &ScardHandle[CurrentReader],
							 &ScardProtocol[CurrentReader]);

		if(result != SCARD_S_SUCCESS)
		{
			MyPrintf(strlen("Testing"), strlen("..."), trycnt * 2 - 1, "Failed\n");
			PRINTERR(("SCardConnect Fail : %08X\n", result));
			return FALSE;
		}
		
		printf("...");
#ifdef LINUX_OS
		fflush(stdout);
#endif
		result = SCardDisconnect(ScardHandle[CurrentReader],
										   SCARD_UNPOWER_CARD);

		if(result != SCARD_S_SUCCESS)
		{
			MyPrintf(strlen("Testing"), strlen("..."), trycnt * 2, "Failed\n");
			PRINTERR(("SCardDisconnect Fail : %08X\n", result));
			return FALSE;
		}
	}
	MyPrintf(strlen("Testing"), strlen("..."), trycnt * 2, "Passed\n");

	printf("\n                Part B Test Successfully\n\n");

	return TRUE;
}
Esempio n. 10
0
void sM_LTE_Paging::start(void)
{
  sM_LteMlDefault::start();

  if( globaldata_base->getUEIdentity(UEIdentity)->IsIMSIpresent() )
  {
    imsi_digits = globaldata_base->getUEIdentity(UEIdentity)->getIMSI();
  }
  else
  {
    imsi_digits = null;
  }

  imsiLength = strlen(imsi_digits);

  DECL_NEW_LTE_RRC_PDU( pagingmsg, PCCH, Paging, xmlPaging.c_str() );

  _CrrcAsp* pagingasp = NEW_ASP_WITH_PCCH_RRC_PDU( pagingmsg, globaldata_lte->getCellConfig(CellNumber)->getCellHandle());
  pagingasp->Choice()->CrrcPcchMessageReq()->RrcCellHandle()->set( globaldata_lte->getCellConfig(CellNumber)->getCellHandle());

  if( imsi_digits != null )
  {
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInfoPresence()->set(MDDB::Lte::Rrc::Crrc::_UeSpecificInfoPresence::UE_SPECIFIC_INFO_PRESENT);
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->setActive_UeSpecificInfo();
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->NumImsiDigits()->set(imsiLength);
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->Imsi()->setElementCount( pagingasp, imsiLength);

    for( int i=0; i<imsiLength; i++ )
    {
      pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->Imsi()->BcdDigit(i)->set((imsi_digits[i]-'0'));
      PRINTERR(("%d",(imsi_digits[i]-'0')));
    }
    PRINTERR(("\n"));
  }

  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->PageRepetitions()->set(NUM_OF_PAGEING_REPTITIONS);
  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->UeSpecificIdleDrxCycleLength()->set(DRX_CYCLE_LENGTH);
  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->ResponseSupervisionDuration()->set(PAGE_RESPONSE_TIMER);

  OUTPUT( SAP_LTE_NET_CRRC, pagingasp );
  PE_PRINT(" UE <- SS  RRC: Paging" );

  GCO_DUMP(pagingasp);

  if (Failure == false )
    notifyCompletion(EV_OK);
  else
    NEXT_STATE ( ReplyState );
}
Esempio n. 11
0
int manager_init(struct manager *self, gchar *bus, gchar *object, gchar *interface)
{
    DBusGConnection *connection;
    DBusGProxy *proxy;
    GError *error;

    /* init Gtype */
    g_type_init();
    error = NULL;
    
    /* conect system connection and get proxy */
    connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
    if (connection == NULL) {
        PRINTERR("get system bus failed: %s\n", error->message);
        g_error_free(error);
        error = NULL;
        return -1;
    }
    DEBUG("get system bus success\n");

    proxy = dbus_g_proxy_new_for_name(connection, bus, object, interface);


    self->state = OFFLINE;
    self->proxy = proxy;
    g_strlcpy(self->bus, bus, BUF_NAME);
    g_strlcpy(self->object, object, BUF_NAME);
    g_strlcpy(self->interface, interface, BUF_NAME);
    
    return 0;
}
Esempio n. 12
0
int
parse_path(const uint8_t **pp, struct ScratchProtocol *sp,
	   char *path, unsigned int len)
{
  if (!json_skip_comma(pp)) {
    PRINTERR("No comma before first parameter");
    native_message_append_str(sp->nm, "0");
    return 0;
  }
  if (!json_parse_string_buffer(pp, (uint8_t*)path, len)) {
    PRINTERR("Failed to parse path to serial device");
    native_message_append_str(sp->nm, "0");
    return 0;
  }
  return 1;
}
Esempio n. 13
0
static void
accept_client(struct cloudmig_ctx *ctx)
{
    struct sockaddr_un      client_addr;
    socklen_t               client_socklen = sizeof(client_addr);

    int client_sock = accept(gl_accept_sock,
                             (struct sockaddr*)&client_addr,
                             &client_socklen);
    if (client_sock == -1)
    {
        PRINTERR("%s: Could not accept viewer connection : %s.\n",
                 __FUNCTION__, strerror);
        return ;
    }

    // If there's already a client, refuse, even thought it should not
    // have happened... (a .lock file should be present)
    if (ctx->viewer_fd != -1)
    {
        shutdown(client_sock, SHUT_RDWR);
        close(client_sock);
        return ;
    }

    // Store it in the ctx for ease of transmission
    ctx->viewer_fd = client_sock;
}
Esempio n. 14
0
  SampleInfo(const std::string &filename,
	     const std::vector<chrsize> gt,
	     const int32_t b,
	     const WigType &type):
    binsize(0), totalreadnum(0), prefix("")
  {
   std::vector<std::string> v;
   ParseLine(v, filename, '.');
   int last(v.size()-1);

   if (type != WigType::NONE) iftype = type;
   else {
     if(v[last] == "wig") iftype = WigType::UNCOMPRESSWIG;    
     else if(v[last] == "gz" && v[last-1] == "wig") {
       iftype = WigType::COMPRESSWIG;
       --last;
     } else if(v[last] == "bedGraph") iftype = WigType::BEDGRAPH;
     else if(v[last] == "bw")         iftype = WigType::BIGWIG;
     //     else if(v[last] == "bin")        iftype = WigType::BINARY;
     else PRINTERR("invalid postfix: " << filename);
   }
   setbinsize(v[last-1], b);
   for (int32_t i=0; i<last; ++i) prefix += v[i] + ".";
   gettotalreadnum(filename, gt);
  }
NVENCSTATUS VideoEncoder::EncodeFrame(EncodeFrameConfig *pEncodeFrame, NV_ENC_PIC_STRUCT picType, bool bFlush)
{
    NVENCSTATUS nvStatus = NV_ENC_SUCCESS;

    if (bFlush)
    {
        FlushEncoder();
        return NV_ENC_SUCCESS;
    }

    assert(pEncodeFrame);

    EncodeBuffer *pEncodeBuffer = m_EncodeBufferQueue.GetAvailable();
    if (!pEncodeBuffer)
    {
        pEncodeBuffer = m_EncodeBufferQueue.GetPending();
        m_pNvHWEncoder->ProcessOutput(pEncodeBuffer);
        // UnMap the input buffer after frame done
        if (pEncodeBuffer->stInputBfr.hInputSurface)
        {
            nvStatus = m_pNvHWEncoder->NvEncUnmapInputResource(pEncodeBuffer->stInputBfr.hInputSurface);
            pEncodeBuffer->stInputBfr.hInputSurface = NULL;
        }
        pEncodeBuffer = m_EncodeBufferQueue.GetAvailable();
    }

    // encode width and height
    unsigned int dwWidth  = pEncodeBuffer->stInputBfr.dwWidth;
    unsigned int dwHeight = pEncodeBuffer->stInputBfr.dwHeight;

    // Here we copy from Host to Device Memory (CUDA)
    cuvidCtxLock(m_ctxLock, 0);
    assert(pEncodeFrame->width == dwWidth && pEncodeFrame->height == dwHeight);

    CUDA_MEMCPY2D memcpy2D  = {0};
    memcpy2D.srcMemoryType  = CU_MEMORYTYPE_DEVICE;
    memcpy2D.srcDevice      = pEncodeFrame->dptr;
    memcpy2D.srcPitch       = pEncodeFrame->pitch;
    memcpy2D.dstMemoryType  = CU_MEMORYTYPE_DEVICE;
    memcpy2D.dstDevice      = (CUdeviceptr)pEncodeBuffer->stInputBfr.pNV12devPtr;
    memcpy2D.dstPitch       = pEncodeBuffer->stInputBfr.uNV12Stride;
    memcpy2D.WidthInBytes   = dwWidth;
    memcpy2D.Height         = dwHeight*3/2;
    __cu(cuMemcpy2D(&memcpy2D));

    cuvidCtxUnlock(m_ctxLock, 0);

    nvStatus = m_pNvHWEncoder->NvEncMapInputResource(pEncodeBuffer->stInputBfr.nvRegisteredResource, &pEncodeBuffer->stInputBfr.hInputSurface);
    if (nvStatus != NV_ENC_SUCCESS)
    {
        PRINTERR("Failed to Map input buffer %p\n", pEncodeBuffer->stInputBfr.hInputSurface);
        return nvStatus;
    }

    m_pNvHWEncoder->NvEncEncodeFrame(pEncodeBuffer, NULL, pEncodeFrame->width, pEncodeFrame->height, picType);
    m_iEncodedFrames++;

    return NV_ENC_SUCCESS;
}
static void delete_source_bucket(struct cloudmig_ctx *ctx,
                                 struct transfer_state *bucket_state)
{
    // Ptr used to change from bucket status filename to bucket name
    // ie: the '.' of "file.cloudmig"
    char                        *dotptr = strrchr(bucket_state->filename, '.');
    struct file_state_entry     *fste = NULL; 
    dpl_status_t                dplret;

    if (dotptr == NULL) // though it should never happen...
        return ;

    cloudmig_log(DEBUG_LVL,
                 "[Deleting Source]: Deleting source bucket"
                 " for status file '%s'...\n",
                 bucket_state->filename);

    // Here the buffer should never be allocated, so map the bucket state.
    if (cloudmig_map_bucket_state(ctx, bucket_state) == EXIT_FAILURE)
        return ;

    *dotptr = '\0';
    // loop on the bucket state for each entry, to delete the files.
    while (bucket_state->next_entry_off < bucket_state->size)
    {
        fste = (void*)(bucket_state->buf + bucket_state->next_entry_off);
        delete_file(ctx, bucket_state->filename, (char*)(fste+1));
        // Next entry...
        bucket_state->next_entry_off += sizeof(*fste) + ntohl(fste->namlen);
    }

    free(bucket_state->buf);

    /*
     * Remove bucket now that all of its files were deleted.
     */
    *dotptr = '\0';
    dplret = dpl_deletebucket(ctx->src_ctx, bucket_state->filename);
    if (dplret != DPL_SUCCESS)
    {
        /*
         * In case of an http 409 error (EEXIST or ENOENT),
         * do not do anything.
         * Maybe files were added in the bucket in the meantime ?
         * The user will have to manage it himself, it's his fault.
         */
        PRINTERR("%s: Could not remove bucket %s : %s.\n"
                 "The bucket may have been tampered with"
                 " since the migration's start.\n", __FUNCTION__,
                 bucket_state->filename, dpl_status_str(dplret));
    }
    else
        cloudmig_log(DEBUG_LVL,
        "[Deleting Source]: Source bucket '%s' deleted successfully.\n",
        bucket_state->filename);

    *dotptr = '.';
}
Esempio n. 17
0
static void opensl_stop_playback(ALCdevice *Device)
{
    osl_data *data = Device->ExtraData;
    SLPlayItf player;
    SLresult result;

    result = VCALL(data->bufferQueueObject,GetInterface)(SL_IID_PLAY, &player);
    PRINTERR(result, "bufferQueue->GetInterface");

    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(player,SetPlayState)(SL_PLAYSTATE_STOPPED);
        PRINTERR(result, "player->SetPlayState");
    }

    free(data->buffer);
    data->buffer = NULL;
    data->bufferSize = 0;
}
Esempio n. 18
0
GUID CNvHWEncoder::GetPresetGUID(char* encoderPreset, int codec)
{
    NVENCSTATUS nvStatus = NV_ENC_SUCCESS;
    GUID presetGUID = NV_ENC_PRESET_DEFAULT_GUID;

    if (encoderPreset && (stricmp(encoderPreset, "hq") == 0))
    {
        presetGUID = NV_ENC_PRESET_HQ_GUID;
    }
    else if (encoderPreset && (stricmp(encoderPreset, "lowLatencyHP") == 0))
    {
        presetGUID = NV_ENC_PRESET_LOW_LATENCY_HP_GUID;
    }
    else if (encoderPreset && (stricmp(encoderPreset, "hp") == 0))
    {
        presetGUID = NV_ENC_PRESET_HP_GUID;
    }
    else if (encoderPreset && (stricmp(encoderPreset, "lowLatencyHQ") == 0))
    {
        presetGUID = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID;
    }
    else if (encoderPreset && (stricmp(encoderPreset, "lossless") == 0))
    {
        presetGUID = NV_ENC_PRESET_LOSSLESS_HP_GUID;
    }
    else
    {
        if (encoderPreset)
            PRINTERR("Unsupported preset guid %s\n", encoderPreset);
        presetGUID = NV_ENC_PRESET_DEFAULT_GUID;
    }

    GUID inputCodecGUID = codec == NV_ENC_H264 ? NV_ENC_CODEC_H264_GUID : NV_ENC_CODEC_HEVC_GUID;
    nvStatus = ValidatePresetGUID(presetGUID, inputCodecGUID);
    if (nvStatus != NV_ENC_SUCCESS)
    {
        presetGUID = NV_ENC_PRESET_DEFAULT_GUID;
        PRINTERR("Unsupported preset guid %s\n", encoderPreset);
    }

    return presetGUID;
}
Esempio n. 19
0
  void setbinsize(std::string &v, const int32_t b) {
    if(b>0) binsize = b;
    else {
      try {
	binsize = stoi(v);
      }catch (...) {
	binsize = 0;
      }
    }
    if(binsize <= 0) PRINTERR("invalid binsize: " << v);
  }
Esempio n. 20
0
 HashOfGeneDataMap getGMP() {
   HashOfGeneDataMap tmp;
   if(!gftype)        tmp = parseRefFlat(genefile);
   else if(gftype==1) tmp = parseGtf(genefile);
   else if(gftype==2) tmp = parseSGD(genefile);
   else PRINTERR("invalid --gftype: " << gftype);
   
   //      printMap(tmp);
   
   return tmp; // hash for transcripts
 }
Esempio n. 21
0
/* this callback handler is called every time a buffer finishes playing */
static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
    ALCdevice *Device = context;
    osl_data *data = Device->ExtraData;
    SLresult result;

    aluMixData(Device, data->buffer, data->bufferSize/data->frameSize);

    result = (*bq)->Enqueue(bq, data->buffer, data->bufferSize);
    PRINTERR(result, "bq->Enqueue");
}
Esempio n. 22
0
/**
 * @brief create select data
 * @return a pointer to struct select_data
 */
struct select_data *select_new(void)
{
    struct select_data *sdata;

    sdata = (struct select_data *)malloc(sizeof(struct select_data));
    if (sdata == NULL) {
        PRINTERR("malloc failed!\n");
        return NULL;
    }

    return sdata;
}
Esempio n. 23
0
    void getGeneLoci(const std::string &genelocifile) {
        std::ifstream in(genelocifile);
	if (!in) PRINTERR("cannot open " << genelocifile);
	
	std::string lineStr;
	while (!in.eof()) {
	  getline(in, lineStr);
	  if (lineStr.empty()) continue;
	  std::vector<std::string> v;
	  ParseLine(v, lineStr, '\t');
	  geneloci[v[0]] = 1;
	}
    }
Esempio n. 24
0
GUID CNvHWEncoder::GetProfileGUID(char* encoderProfile, int codec)
{
    NVENCSTATUS nvStatus = NV_ENC_SUCCESS;
    GUID profileGUID = NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID;

    if (encoderProfile && (stricmp(encoderProfile, "baseline") == 0))
    {
        if(codec==NV_ENC_H264)
            profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
    }
    else if (encoderProfile && (stricmp(encoderProfile, "main") == 0))
    {
        if(codec==NV_ENC_H264)
            profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;
        else
            profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
    }
    else if (encoderProfile && (stricmp(encoderProfile, "high") == 0))
    {
        if(codec==NV_ENC_H264)
            profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;
    }
    else
    {
        if (encoderProfile)
            PRINTERR("Unsupported profile guid %s\n", encoderProfile);
        profileGUID = NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID;
    }

    GUID inputCodecGUID = codec == NV_ENC_H264 ? NV_ENC_CODEC_H264_GUID : NV_ENC_CODEC_HEVC_GUID;
    nvStatus = ValidateProfileGUID(profileGUID, inputCodecGUID);
    if (nvStatus != NV_ENC_SUCCESS)
    {
        profileGUID = NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID;
        PRINTERR("Unsupported profile guid %s\n", encoderProfile);
    }

    return profileGUID;
}
static void delete_file(struct cloudmig_ctx *ctx, char *bucket, char *filename)
{
    dpl_status_t dplret;

    cloudmig_log(DEBUG_LVL, "[Deleting Source]\t Deleting file '%s'...\n",
                 filename);

    dplret = dpl_delete(ctx->src_ctx, bucket, filename, NULL);
    if (dplret != DPL_SUCCESS)
    {
        PRINTERR("%s: Could not delete the file %s" " from the bucket %s : %s",
                 __FUNCTION__, filename, bucket, dpl_status_str(dplret));
    }
}
Esempio n. 26
0
long 
MySCardGetStatusChange(
	SCARDCONTEXT hContext,
    DWORD dwTimeout,
    LPSCARD_READERSTATE rgReaderStates,
    DWORD cReaders)
{
	long result;
	DWORD timecnt;
	DWORD timeslot;
	
	timecnt = 0;

#ifdef LINUX_OS
	fflush(stdout);
#endif

	if(dwTimeout > 100)
		timeslot = 100;
	else
		timeslot = 1;

	do
	{
		result = SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders);

		if(result != SCARD_S_SUCCESS)
		{
			PRINTERR(("SCardGetStatusChange Fail : %08X\n", result));
			return result;
		}

		if(((rgReaderStates->dwCurrentState & SCARD_STATE_PRESENT) && !(rgReaderStates->dwEventState & SCARD_STATE_PRESENT)) ||
			(!(rgReaderStates->dwCurrentState & SCARD_STATE_PRESENT) && (rgReaderStates->dwEventState & SCARD_STATE_PRESENT)) )
		{
			break;
		}
		else
		{
			if(dwTimeout)
			{
				Sleep(timeslot);
				timecnt += timeslot;
			}
		}

	} while(timecnt < dwTimeout || dwTimeout == INFINITE);

	return result;
}
Esempio n. 27
0
static int
create_log_socket(char * filename)
{
    struct sockaddr_un  server_addr;
    int                 listen_fd = -1;

    bzero(&server_addr, sizeof(server_addr));
    server_addr.sun_family = AF_LOCAL;
    strcpy(server_addr.sun_path, filename);

    listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
    if (listen_fd == -1)
    {
        PRINTERR("Could not create listening socket for data display : %s.\n",
                 strerror(errno));
        return (-1);
    }

    if (bind(listen_fd, &server_addr, sizeof(server_addr)) == -1)
    {
        PRINTERR("Could not bind listening socket for data display : %s.\n",
                 strerror(errno));
        close(listen_fd);
        return (-1);
    }

    // The program should never have more than one simultaneous clients
    if (listen(listen_fd, 1) == -1)
    {
        PRINTERR("Could not listen to socket for data display : %s.\n",
                 strerror(errno));
        close(listen_fd);
        return (-1);
    }

    return listen_fd;
}
Esempio n. 28
0
// GCC-LD do not produce ____div0_from_arm in -r mode and because this division work bad
// We add to the end of .text and replace __div0 for specific places with this value. 
int add_div0_arm()
{
  struct elf32_sym* s;
  int rv;
  int symidx;
  
  s = find_symbol("__div0");
  symidx = last_found_symidx;
  if ( !s) return ELFFLT_OK;

  if (s->st_shndx != text.number) {
	PRINTERR(stderr,"__div0 should be .text symbol\n");
	return ELFFLT_UNHANDLED_RELOC;
  }
  
  /*
  if  ( (text.size - s->st_value) != 3 ) {
	PRINTERR(stderr,"Warning! At %s __div0 is not on the end of .text. Doesn't check such case\n", filename_elf);
  }
  */


  // Prepare reloc used in added func
  struct elf32_rela rela;
  rela.r_info = symidx <<8;
  rela.r_info |= R_ARM_ABS32;   
  rela.r_offset = text.size+8;
  rela.r_addend = 0;

  // Append new func to the end of .text
  offs_div0_from_arm = text.size;
  memcpy( flat_buf+text.flat_offset+offs_div0_from_arm, div0_arm, sizeof(div0_arm) );
  text.size+=sizeof(div0_arm);

  // Apply reloc
  rv = apply_realloc( &text, &rela, &text, s, -1);

  // Detect allowed to patch points
  s = find_symbol(".divsi3_skip_div0_test");
  if ( s && s->st_shndx == text.number ) {
	 offs_divsi3_skip_div0_test = text.flat_offset + s->st_value + 0x114;
  }
  s = find_symbol("__aeabi_uidiv");
  if ( s && s->st_shndx == text.number ) {
	 offs__aeabi_uidiv = text.flat_offset + s->st_value + 0xec;
  }

  return rv;
}
Esempio n. 29
0
/* this callback handler is called every time a buffer finishes playing */
static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
    ALCdevice *Device = context;
    osl_data *data = Device->ExtraData;
    ALvoid *buf;
    SLresult result;

    buf = (ALbyte*)data->buffer + data->curBuffer*data->bufferSize;
    aluMixData(Device, buf, data->bufferSize/data->frameSize);

    result = VCALL(bq,Enqueue)(buf, data->bufferSize);
    PRINTERR(result, "bq->Enqueue");

    data->curBuffer = (data->curBuffer+1) % Device->NumUpdates;
}
Esempio n. 30
0
static void opensl_stop_playback(ALCdevice *Device)
{
    osl_data *data = Device->ExtraData;
    SLPlayItf player;
    SLAndroidSimpleBufferQueueItf bufferQueue;
    SLresult result;

    result = VCALL(data->bufferQueueObject,GetInterface)(SL_IID_PLAY, &player);
    PRINTERR(result, "bufferQueue->GetInterface");
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL(player,SetPlayState)(SL_PLAYSTATE_STOPPED);
        PRINTERR(result, "player->SetPlayState");
    }

    result = VCALL(data->bufferQueueObject,GetInterface)(SL_IID_BUFFERQUEUE, &bufferQueue);
    PRINTERR(result, "bufferQueue->GetInterface");
    if(SL_RESULT_SUCCESS == result)
    {
        result = VCALL0(bufferQueue,Clear)();
        PRINTERR(result, "bufferQueue->Clear");
    }
    if(SL_RESULT_SUCCESS == result)
    {
        SLAndroidSimpleBufferQueueState state;
        do {
            althrd_yield();
            result = VCALL(bufferQueue,GetState)(&state);
        } while(SL_RESULT_SUCCESS == result && state.count > 0);
        PRINTERR(result, "bufferQueue->GetState");
    }

    free(data->buffer);
    data->buffer = NULL;
    data->bufferSize = 0;
}