示例#1
0
static int get_solaris_eeprom_parameter(char *parameter,char *outbuffer) {

    int fd=0,status=0;
    struct openpromio *openprominfo=NULL;

    fd=open("/dev/openprom",O_RDONLY);
    if ( fd == -1 ) {
        snmp_log(LOG_ERR,"cannot open /dev/openprom\n");
        return 1;
    }

    openprominfo=(struct openpromio *)op_malloc(8192);
    if(!openprominfo) return 1;

    strcpy(openprominfo->oprom_array,parameter);

    status=ioctl(fd,OPROMGETOPT,openprominfo);
    if ( status == -1 ) {
        snmp_log(LOG_ERR,"cannot read from /dev/openprom\n");
        close(fd);
        op_free(openprominfo);
        return 1;
    }
    strcpy(outbuffer,openprominfo->oprom_array);

    op_free(openprominfo);

    /* close file */
    close(fd);

    return(0);
}
示例#2
0
void op_rt_exit() {
  /* free storage for plans */
  for (int ip = 0; ip < OP_plan_index; ip++) {
    free(OP_plans[ip].dats);
    free(OP_plans[ip].idxs);
    free(OP_plans[ip].maps);
    free(OP_plans[ip].accs);
    free(OP_plans[ip].inds_staged);
    free(OP_plans[ip].nthrcol);
    free(OP_plans[ip].thrcol);
    free(OP_plans[ip].offset);
    free(OP_plans[ip].ind_offs);
    free(OP_plans[ip].ind_sizes);
    free(OP_plans[ip].nelems);
    free(OP_plans[ip].blkmap);
    free(OP_plans[ip].ind_map);
    free(OP_plans[ip].ind_maps);
    free(OP_plans[ip].nindirect);
    free(OP_plans[ip].loc_map);
    free(OP_plans[ip].loc_maps);
    free(OP_plans[ip].ncolblk);
    free(OP_plans[ip].nsharedCol);
    op_free(OP_plans[ip].col_reord);
    if (OP_plans[ip].col_offsets != NULL) {
      op_free(OP_plans[ip].col_offsets[0]);
      op_free(OP_plans[ip].col_offsets);
    }
  }

  OP_plan_index = 0;
  OP_plan_max = 0;

  free(OP_plans);
  OP_plans = NULL;
}
示例#3
0
RepList::~RepList()
{
    for (int i = 0; i < pos; i++) {
        op_free(dat[i]->pattern);
        op_free(dat[i]->pattern2);
        op_free(dat[i]);
    }
    op_free(dat);
}
示例#4
0
void
Debug::TimeEnd(const char* key, const char* s)
{
	uni_char* ukey = uni_up_strdup(key);
	uni_char* us = uni_up_strdup(s);

	if ( ukey != 0 && us != 0 )
		Debug::TimeEnd(ukey, us);

	op_free(ukey);
	op_free(us);
}
示例#5
0
int
abb_fread(void *mod_priv,
	  uint64_t src_off,
	  uint64_t src_len,
	  struct elasto_data *dest_data)
{
	int ret;
	struct op *op;
	struct apb_fh *apb_fh = mod_priv;

	ret = az_req_blob_get(&apb_fh->path,
			      false,
			      dest_data,
			      src_off,
			      src_len,
			      &op);
	if (ret < 0) {
		goto err_out;
	}

	ret = elasto_fop_send_recv(apb_fh->io_conn, op);
	if (ret < 0) {
		goto err_op_free;
	}
	ret = 0;

err_op_free:
	op->rsp.data = NULL;
	op_free(op);
err_out:
	return ret;
}
示例#6
0
static prMALError 
SDKQuietFile(
	imStdParms			*stdParms, 
	imFileRef			*SDKfileRef, 
	void				*privateData)
{
	// "Quiet File" really means close the file handle, but we're still
	// using it and might open it again, so hold on to any stored data
	// structures you don't want to re-create.

	// If file has not yet been closed
	if(SDKfileRef && *SDKfileRef != imInvalidHandleValue)
	{
		ImporterLocalRec8H ldataH	= reinterpret_cast<ImporterLocalRec8H>(privateData);

		stdParms->piSuites->memFuncs->lockHandle(reinterpret_cast<char**>(ldataH));

		ImporterLocalRec8Ptr localRecP = reinterpret_cast<ImporterLocalRec8Ptr>( *ldataH );


		if(localRecP->vf)
		{
			int clear_err = ov_clear(localRecP->vf);
			
			assert(clear_err == OV_OK);
			
			delete localRecP->vf;
			
			localRecP->vf = NULL;
		}

		if(localRecP->opus)
		{
			op_free(localRecP->opus);
			
			localRecP->opus = NULL;
		}

		if(localRecP->flac)
		{
			localRecP->flac->finish();
			
			delete localRecP->flac;
			
			localRecP->flac = NULL;
		}

		stdParms->piSuites->memFuncs->unlockHandle(reinterpret_cast<char**>(ldataH));

	#ifdef PRWIN_ENV
		CloseHandle(*SDKfileRef);
	#else
		FSCloseFork( CAST_REFNUM(*SDKfileRef) );
	#endif
	
		*SDKfileRef = imInvalidHandleValue;
	}

	return malNoError; 
}
示例#7
0
static void
abb_fwrite_multi_finish_cmpl(evutil_socket_t sock,
			     short flags,
			     void *priv)
{
	int ret;
	struct abb_fwrite_multi_finish_state *finish_state = priv;
	struct abb_io_multi_state *multi_state = finish_state->multi_state;

	ret = elasto_conn_op_rx(finish_state->ev_tx);
	if (ret < 0) {
		dbg(2, "block list put failed: %s\n", strerror(-ret));
		abb_io_multi_error_set(multi_state, ret);
	} else if (finish_state->op->rsp.is_error) {
		ret = elasto_fop_err_code_map(finish_state->op->rsp.err_code);
		dbg(2, "block list put error response: %d\n", ret);
		abb_io_multi_error_set(multi_state, ret);
	}
	elasto_conn_op_free(finish_state->ev_tx);
	op_free(finish_state->op);

	dbg(0, "multipart upload finished\n");

	ret = event_base_loopbreak(multi_state->ev_base);
	if (ret < 0) {
		dbg(0, "failed to break dispatch loop\n");
	}
	/* data_ctx cleanup after event loop exit */
}
示例#8
0
static OP_STATUS LifreqIoctl(PosixNetLookup::Store * carrier, int sock, int type)
{
	struct lifnum ifn;
#ifdef POSIX_SUPPORT_IPV6
	ifn.lifn_family = AF_UNSPEC;
#else
	ifn.lifn_family = AF_INET;
#endif
	ifn.lifn_flags = 0;
	ifn.lifn_count = 0;
	if (1 + ioctl(sock, SIOCGLIFNUM, &ifn) == 0) // ioctl returns -1 on failure
		return OpStatus::ERR;

	if (ifn.lifn_count > 0)
	{
		struct lifreq * buffer = reinterpret_cast<struct lifreq *>(
			op_calloc(ifn.lifn_count, sizeof(struct lifreq)));
		if (!buffer)
			return OpStatus::ERR_NO_MEMORY;

		OP_STATUS res = DigestLifreq(carrier, sock, type, buffer, ifn);
		op_free(buffer);
		RETURN_IF_ERROR(res);
	}

	return OpStatus::OK;
}
示例#9
0
static OP_BOOLEAN
CheckSecurityOveride(const OpSecurityContext& source, const OpSecurityContext& target, BOOL *allowed, OpSecurityCheckCallback* security_callback)
{
	OP_ASSERT((allowed == NULL) != (security_callback == NULL));
	if (DOM_Utils::GetDocument(source.GetRuntime()))
	{
		WindowCommander *wc = DOM_Utils::GetDocument(source.GetRuntime())->GetWindow()->GetWindowCommander();
		URL origin_url= DOM_Utils::GetOriginURL(source.GetRuntime());
		// Can't keep both src and tgt in URL's internal buffer, so one needs to be duplicated.
		uni_char *src = uni_strdup(origin_url.GetAttribute(URL::KUniName_Username_Password_Hidden, TRUE).CStr());
		RETURN_OOM_IF_NULL(src);
		const uni_char *tgt = target.GetURL().GetAttribute(URL::KUniName_Username_Password_Hidden, TRUE).CStr();
		OpDocumentListener::XHRPermission res = wc->GetDocumentListener()->OnXHR(wc, src, tgt);
		op_free(src);
		switch(res)
		{
		case OpDocumentListener::ALLOW:
			if (security_callback)
				security_callback->OnSecurityCheckSuccess(TRUE);
			else
				*allowed = TRUE;
			return OpBoolean::IS_TRUE;
		case OpDocumentListener::DENY:
			if (security_callback)
				security_callback->OnSecurityCheckSuccess(FALSE);
			else
				*allowed = FALSE;
			return OpBoolean::IS_TRUE;
		}
	}
	return OpBoolean::IS_FALSE;
}
示例#10
0
void OpPersona::FreeClearElementsList()
{
	for(UINT32 x = 0; x < m_clear_elements.GetCount(); x++)
	{
		op_free(m_clear_elements.Get(x));
	}
	m_clear_elements.Clear();
}
示例#11
0
Error AudioStreamPlaybackOpus::set_file(const String &p_file) {
	file=p_file;
	stream_valid=false;
	Error err;
	f=FileAccess::open(file,FileAccess::READ,&err);

	if (err) {
		ERR_FAIL_COND_V( err, err );
	}

	int _err;

	opus_file = op_open_callbacks(f,&_op_callbacks,NULL,0,&_err);

	switch (_err) {
		case OP_EREAD: { // - Can't read the file.
			memdelete(f); f=NULL;
			ERR_FAIL_V( ERR_FILE_CANT_READ );
		} break;
		case OP_EVERSION: // - Unrecognized version number.
		case OP_ENOTFORMAT: // - Stream is not Opus data.
		case OP_EIMPL : { // - Stream used non-implemented feature.
			memdelete(f); f=NULL;
			ERR_FAIL_V( ERR_FILE_UNRECOGNIZED );
		} break;
		case OP_EBADLINK: // - Failed to find old data after seeking.
		case OP_EBADTIMESTAMP: // - Timestamp failed the validity checks.
		case OP_EBADHEADER: { // - Invalid or mising Opus bitstream header.
			memdelete(f); f=NULL;
			ERR_FAIL_V( ERR_FILE_CORRUPT );
		} break;
		case OP_EFAULT: { // - Internal logic fault; indicates a bug or heap/stack corruption.
			memdelete(f); f=NULL;
			ERR_FAIL_V( ERR_BUG );
		} break;
	}

	const OpusHead *oinfo = op_head(opus_file,-1);

	stream_channels=oinfo->channel_count;
	pre_skip=oinfo->pre_skip;
	frames_mixed=pre_skip;
	ogg_int64_t len = op_pcm_total(opus_file,-1);
	if(len < 0) {
		length = 0;
	} else {
		length=(len/osrate);
	}

	op_free(opus_file);
	memdelete(f);
	f=NULL;
	stream_valid=true;


	return OK;
}
示例#12
0
/*
 * et_opus_read_file_info:
 * @file: file to read info from
 * @ETFileInfo: ET_File_Info to put information into
 * @error: a GError or %NULL
 *
 * Read header information of an Opus file.
 *
 * Returns: %TRUE if successful otherwise %FALSE
 */
gboolean
et_opus_read_file_info (GFile *gfile, ET_File_Info *ETFileInfo,
                        GError **error)
{
    OggOpusFile *file;
    const OpusHead* head;
    GFileInfo *info;

    g_return_val_if_fail (gfile != NULL && ETFileInfo != NULL, FALSE);
    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

    file = et_opus_open_file (gfile, error);

    if (!file)
    {
        g_assert (error == NULL || *error != NULL);
        return FALSE;
    }

    /* FIXME: Improve error-checking. */
    head = op_head (file, -1);
    /* TODO: Read the vendor string from the Vorbis comment? */
    ETFileInfo->version = head->version;
    ETFileInfo->bitrate = op_bitrate (file, -1) / 1000;
    ETFileInfo->mode = head->channel_count;

    /* All Opus audio is encoded at 48 kHz, but the input sample rate can
     * differ, and then input_sample_rate will be set. */
    if (head->input_sample_rate != 0)
    {
        ETFileInfo->samplerate = head->input_sample_rate;
    }
    else
    {
        ETFileInfo->samplerate = 48000;
    }

    ETFileInfo->duration = op_pcm_total (file, -1) / 48000;
    op_free (file);

    info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_STANDARD_SIZE,
                              G_FILE_QUERY_INFO_NONE, NULL, NULL);

    if (info)
    {
        ETFileInfo->size = g_file_info_get_size (info);
        g_object_unref (info);
    }
    else
    {
        ETFileInfo->size = 0;
    }

    g_assert (error == NULL || *error == NULL);
    return TRUE;
}
示例#13
0
文件: opus.c 项目: brigittebigi/sppas
void
OpusDecoders_dealloc(decoders_OpusDecoder *self)
{
    if (self->opus_file != NULL)
        op_free(self->opus_file);

    Py_XDECREF(self->audiotools_pcm);

    Py_TYPE(self)->tp_free((PyObject*)self);
}
示例#14
0
void cmdMusic(const std::string& args) {
	// terrible hack for testing audio
	// decode the entire file into a big buffer all at once

	OggOpusFile* opusFile;
	if (args.length() == 0) {
		opusFile = op_open_memory(
		    static_cast<const uint8_t*>(EMBED_DATA(Who_Likes_to_Party_Kevin_MacLeod_incompetech_opus)),
		    EMBED_SIZE(Who_Likes_to_Party_Kevin_MacLeod_incompetech_opus),
		    NULL);
	} else {
		opusFile = op_open_file(args.c_str(), NULL);
	}

	if (!opusFile) {
		narf::console->println("Failed to open music file " + args);
		return;
	}

	auto newMusicSize = op_pcm_total(opusFile, -1) * 2; // stereo
	auto newMusicSamples = new float[newMusicSize];

	size_t decoded = 0;
	while (decoded < newMusicSize) {
		auto rc = op_read_float_stereo(opusFile, newMusicSamples + decoded, newMusicSize - decoded);
		if (rc < 0) {
			narf::console->println("opusfile decode failed");
			decoded = 0;
			break;
		}

		decoded += rc * 2; // return code is number of samples per channel, and we are decoding in stereo
	}

	if (decoded != newMusicSize) {
		narf::console->println("opusfile decode returned wrong number of samples (got " + std::to_string(decoded) + ", expected " + std::to_string(newMusicSize) + ")");
		delete[] newMusicSamples;
		newMusicSamples = nullptr;
		newMusicSize = 0;
	}

	SDL_LockMutex(musicMutex);

	if (musicSamples) {
		delete[] musicSamples;
	}

	musicSamples = newMusicSamples;
	musicSize = newMusicSize;
	musicCursor = 0;

	SDL_UnlockMutex(musicMutex);

	op_free(opusFile);
}
示例#15
0
/*
=======================================================================================================================================
S_OggOpus_CodecCloseStream
=======================================================================================================================================
*/
void S_OggOpus_CodecCloseStream(snd_stream_t *stream) {

	// check if input is valid
	if (!stream) {
		return;
	}
	// let the opus codec cleanup its stuff
	op_free((OggOpusFile *)stream->ptr);
	// close the stream
	S_CodecUtilClose(&stream);
}
示例#16
0
void AudioStreamPlaybackOpus::_clear_stream() {
	if(!stream_loaded)
		return;

	op_free(opus_file);
	_close_file();

	stream_loaded=false;
	stream_channels=1;
	playing=false;
}
示例#17
0
static void
abb_fwrite_multi_data_free(struct abb_fwrite_multi_data_ctx *data_ctx)
{
	elasto_conn_op_free(data_ctx->ev_tx);
	if (data_ctx->op != NULL) {
		data_ctx->op->req.data = NULL;
		op_free(data_ctx->op);
	}
	elasto_data_free(data_ctx->this_data);
	free(data_ctx->blk.id);
	free(data_ctx);
}
示例#18
0
Debug::~Debug()
{
	if (do_debugging && g_dbg_tracing)
	{
		Exit();
		g_dbg_level--;

		if (g_dbg_level == 0 && g_dbg_out != NULL)
		{
			g_dbg_out->Close();
			OP_DELETE(g_dbg_out);
			g_dbg_out = NULL;
		}
	}

	op_free(function_name);
	function_name = 0;

	op_free(debugging_key);
	debugging_key = 0;
}
示例#19
0
void OpMemGroup::ReleaseAll(void)
{
	void* ptr = all;

	while ( ptr != 0 )
	{
		void* next = *(void**)ptr;
		op_free(ptr);
		ptr = next;
	}

	Reset();	
}
示例#20
0
static void
xmms_opus_destroy (xmms_xform_t *xform)
{
	xmms_opus_data_t *data;

	g_return_if_fail (xform);

	data = xmms_xform_private_data_get (xform);
	g_return_if_fail (data);

	op_free (data->opusfile);
	g_free (data);
}
示例#21
0
void
OpusDecoders_dealloc(decoders_OpusDecoder *self)
{
    if (self->opus_file != NULL)
        op_free(self->opus_file);

    Py_XDECREF(self->audiotools_pcm);

    if (self->channels != NULL)
        self->channels->del(self->channels);

    self->ob_type->tp_free((PyObject*)self);
}
示例#22
0
/*
 * et_opus_tag_read_file_tag:
 * @filename: file from which to read tags
 * @FileTag: File_Tag to read tag into
 * @error: a GError or %NULL
 *
 * Read file tags and store into File_Tag.
 *
 * Returns: %TRUE if successful otherwise %FALSE
 */
gboolean
et_opus_tag_read_file_tag (GFile *gfile, File_Tag *FileTag,
                           GError **error)
{
    OggOpusFile *file;
    const OpusTags *tags;
    GFileInfo *info;

    g_return_val_if_fail (gfile != NULL && FileTag != NULL, FALSE);
    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

    file = et_opus_open_file (gfile, error);

    if (!file)
    {
        g_assert (error == NULL || *error != NULL);
        return FALSE;
    }

    tags = op_tags (file, 0);
    info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
                              G_FILE_QUERY_INFO_NONE, NULL, error);

    if (!info)
    {
        op_free (file);
        g_assert (error == NULL || *error != NULL);
        return FALSE;
    }

    /* The cast is safe according to the opusfile documentation. */
    et_add_file_tags_from_vorbis_comments ((vorbis_comment *)tags, FileTag,
                                           g_file_info_get_display_name (info));
    g_object_unref (info);
    op_free (file);

    g_assert (error == NULL || *error == NULL);
    return TRUE;
}
示例#23
0
文件: apb_stat.c 项目: ddiss/elasto
static int
apb_fstat_blob(struct apb_fh *apb_fh,
	       struct elasto_fstat *fstat)
{
	int ret;
	struct op *op;
	struct az_rsp_blob_prop_get *blob_prop_get_rsp;

	ret = az_req_blob_prop_get(&apb_fh->path, &op);
	if (ret < 0) {
		goto err_out;
	}

	ret = elasto_fop_send_recv(apb_fh->io_conn, op);
	if (ret < 0) {
		goto err_op_free;
	}

	blob_prop_get_rsp = az_rsp_blob_prop_get(op);
	if (blob_prop_get_rsp == NULL) {
		ret = -ENOMEM;
		goto err_op_free;
	}

	if (!blob_prop_get_rsp->is_page) {
		/* should have been checked on open */
		dbg(0, "blob flagged as block in stat for page blob!\n");
		ret = -EINVAL;
		goto err_op_free;
	}

	fstat->ent_type = ELASTO_FSTAT_ENT_FILE;
	fstat->size = blob_prop_get_rsp->len;
	fstat->blksize = 512;
	if (blob_prop_get_rsp->lease_status == AOP_LEASE_STATUS_UNLOCKED) {
		fstat->lease_status = ELASTO_FLEASE_UNLOCKED;
	} else if (blob_prop_get_rsp->lease_status == AOP_LEASE_STATUS_LOCKED) {
		fstat->lease_status = ELASTO_FLEASE_LOCKED;
	}
	/* flag which values are valid in the stat response */
	fstat->field_mask = (ELASTO_FSTAT_FIELD_TYPE
				| ELASTO_FSTAT_FIELD_SIZE
				| ELASTO_FSTAT_FIELD_BSIZE
				| ELASTO_FSTAT_FIELD_LEASE);
	ret = 0;

err_op_free:
	op_free(op);
err_out:
	return ret;
}
JNIEXPORT void JNICALL Java_com_glester_jopus_JOpusDecodable_jopusClose(JNIEnv* environment, jobject caller)
{
	OpusWrapper* opus;
	jclass callerClass;
	jfieldID metaPointerID;

	// get wrapper data.
	callerClass	= (*environment)->GetObjectClass(environment, caller);
	metaPointerID	= (*environment)->GetFieldID(environment, callerClass, "wrapperPointer", "J");    
	opus 		= (OpusWrapper*)((*environment)->GetLongField(environment, caller, metaPointerID));

	op_free(opus->file);
	free(opus);
}
示例#25
0
int AudioStreamPlaybackOpus::mix(int16_t* p_bufer,int p_frames) {
	if (!playing)
		return 0;

	int total=p_frames;

	while (true) {

		int todo = p_frames;

		if (todo==0 || todo<MIN_MIX) {
			break;
		}

		int ret=op_read(opus_file,(opus_int16*)p_bufer,todo*stream_channels,&current_section);
		if (ret<0) {
			playing = false;
			ERR_EXPLAIN("Error reading Opus File: "+file);
			ERR_BREAK(ret<0);
		} else if (ret==0) { // end of song, reload?
			op_free(opus_file);

			_close_file();

			f=FileAccess::open(file,FileAccess::READ);

			int errv = 0;
			opus_file = op_open_callbacks(f,&_op_callbacks,NULL,0,&errv);
			if (errv!=0) {
				playing=false;
				break; // :(
			}

			if (!has_loop()) {
				playing=false;
				repeats=1;
				break;
			}

			if (loop_restart_time) {
				bool ok = op_pcm_seek(opus_file, (loop_restart_time*osrate)+pre_skip)==0;
				if (!ok) {
					playing=false;
					ERR_PRINT("loop restart time rejected")
				}

				frames_mixed=(loop_restart_time*osrate)+pre_skip;
			} else {
示例#26
0
bool OpusDecoder::Open(FILE* file) {
	finished = false;

	int res;
	OpusFileCallbacks callbacks = {custom_read, custom_seek, custom_tell, custom_close};

	oof = op_open_callbacks(file, &callbacks, nullptr, 0, &res);
	if (res != 0) {
		error_message = "Opus: Error reading file";
		op_free(oof);
		fclose(file);
		return false;
	}

	return true;
}
示例#27
0
Result SoundSourceOpus::open() {
    int error = 0;
    QByteArray qBAFilename = m_qFilename.toLocal8Bit();

    m_ptrOpusFile = op_open_file(qBAFilename.constData(), &error);
    if ( m_ptrOpusFile == NULL ) {
        qDebug() << "opus: Input does not appear to be an Opus bitstream.";
        m_lFilelength = 0;
        return ERR;
    }

    // opusfile lib all ways gives you 48000 samplerate and stereo 16 bit sample
    m_iChannels = 2;
    this->setBitrate((int)op_bitrate_instant(m_ptrOpusFile));
    this->setSampleRate(48000);
    this->setChannels(m_iChannels);


    if (m_iChannels > 2) {
        qDebug() << "opus: No support for more than 2 m_iChannels!";
        op_free(m_ptrOpusFile);
        m_lFilelength = 0;
        return ERR;
    }

    // op_pcm_total returns the total number of frames in the ogg file. The
    // frame is the channel-independent measure of samples. The total samples in
    // the file is m_iChannels * ov_pcm_total. rryan 7/2009 I verified this by
    // hand. a 30 second long 48khz mono ogg and a 48khz stereo ogg both report
    // 1440000 for op_pcm_total.
    qint64 ret = op_pcm_total(m_ptrOpusFile, -1) * 2;

    // qDebug() << m_qFilename << "chan:" << m_iChannels << "sample:" << m_iSampleRate << "LEN:" << ret;


    if (ret >= 0) {
        // We pretend that the file is stereo to the rest of the world.
        m_lFilelength = ret;
    } else { //error
        if (ret == OP_EINVAL) {
            //The file is not seekable. Not sure if any action is needed.
            qDebug() << "opus: file is not seekable " << m_qFilename;
        }
    }

    return OK;
}
示例#28
0
文件: apb_stat.c 项目: ddiss/elasto
static int
apb_fstat_acc(struct apb_fh *apb_fh,
	      struct elasto_fstat *fstat)
{
	int ret;
	struct op *op;
	struct az_mgmt_rsp_acc_prop_get *acc_prop_get_rsp;

	if (apb_fh->mgmt_conn == NULL) {
		dbg(0, "Account stat requires Publish Settings "
		       "credentials\n");
		ret = -EINVAL;
		goto err_out;
	}

	ret = az_mgmt_req_acc_prop_get(apb_fh->sub_id,
				       apb_fh->path.acc,
				       &op);
	if (ret < 0) {
		goto err_out;
	}

	ret = elasto_fop_send_recv(apb_fh->mgmt_conn, op);
	if (ret < 0) {
		goto err_op_free;
	}

	acc_prop_get_rsp = az_mgmt_rsp_acc_prop_get(op);
	if (acc_prop_get_rsp == NULL) {
		ret = -ENOMEM;
		goto err_op_free;
	}

	fstat->ent_type = ELASTO_FSTAT_ENT_DIR;
	fstat->size = 0;
	fstat->blksize = 0;
	/* Azure only supports leases at a container or blob level */
	fstat->lease_status = ELASTO_FLEASE_UNLOCKED;
	fstat->field_mask = ELASTO_FSTAT_FIELD_TYPE;
	ret = 0;

err_op_free:
	op_free(op);
err_out:
	return ret;
}
示例#29
0
void
Debug::SetOutputFile(const uni_char* filename)
{
	if (!g_dbg_filename || !uni_str_eq(filename, g_dbg_filename))
	{
		op_free(g_dbg_filename);
		g_dbg_filename = uni_down_strdup(filename);
		if ( g_dbg_filename == 0 )
		{
			g_dbg_use_file = FALSE;
			return;
		}

		g_dbg_use_file = TRUE;
		SetupOutput();
	}
}
示例#30
0
OP_STATUS SoundUtils::SoundIt(const OpStringC &sndfile, BOOL force, BOOL async)
{
	OP_STATUS rc = OpStatus::OK;

	if ((!g_pcui->GetIntegerPref(PrefsCollectionUI::SoundsEnabled) && !force) || !IsStr(sndfile.CStr()))
		return rc;

	OpString osPrefsNoSound;
	TRAP_AND_RETURN(rc, g_languageManager->GetStringL(Str::SI_NO_SOUND_STRING, osPrefsNoSound));
	if (sndfile.CompareI(osPrefsNoSound) == 0 || sndfile.Compare("None") == 0)
		return OpStatus::ERR;

#if defined(MSWIN)
	rc = ( sndPlaySound(sndfile.CStr(), (async ? SND_ASYNC : SND_SYNC) | SND_NODEFAULT)==TRUE ? OpStatus::OK : OpStatus::ERR);
#elif defined(_UNIX_DESKTOP_)
	if (g_audio_player)
	{
		char *filename = uni_down_strdup(sndfile.CStr());
		if (!filename)
			return OpStatus::ERR_NO_MEMORY;
		WavFile *wav = OP_NEW(WavFile, ());
		if (!wav)
		{
			rc = OpStatus::ERR_NO_MEMORY;
		}
		else
		{
			if (wav->Open(filename))
			{
				g_audio_player->Play(wav);
			}
			else
			{
				OP_DELETE(wav);
				rc = OpStatus::ERR;
			}
		}
		op_free(filename);
	}
#elif defined(_MACINTOSH_)
	rc = (MacPlaySound(sndfile.CStr(), async) == TRUE) ? OpStatus::OK : OpStatus::ERR;
#endif

	return rc;
}