Example #1
0
static GF_Err gf_isom_insert_copyright(GF_ISOFile *movie)
{
	u32 i;
	GF_Box *a;
	GF_FreeSpaceBox *_free;
	i=0;
	while ((a = (GF_Box *)gf_list_enum(movie->TopBoxes, &i))) {
		if (a->type == GF_ISOM_BOX_TYPE_FREE) {
			_free = (GF_FreeSpaceBox *)a;
			if (_free->dataSize) {
				if (!strcmp(_free->data, GPAC_ISOM_CPRT_NOTICE)) return GF_OK;
				if (strstr(_free->data, "File Produced with GPAC")) {
					gf_free(_free->data);
					_free->data = gf_strdup(GPAC_ISOM_CPRT_NOTICE);
					_free->dataSize = strlen(_free->data);
					return GF_OK;
				}
			}
		}
	}
	a = gf_isom_box_new(GF_ISOM_BOX_TYPE_FREE);
	if (!a) return GF_OUT_OF_MEM;
	_free = (GF_FreeSpaceBox *)a;
	_free->dataSize = strlen(GPAC_ISOM_CPRT_NOTICE) + 1;
	_free->data = gf_strdup(GPAC_ISOM_CPRT_NOTICE);
	if (!_free->data) return GF_OUT_OF_MEM;
	return gf_list_add(movie->TopBoxes, _free);
}
Example #2
0
int
afr_build_parent_loc (loc_t *parent, loc_t *child, int32_t *op_errno)
{
        int     ret = -1;
        char    *child_path = NULL;

        if (!child->parent) {
                if (op_errno)
                        *op_errno = EINVAL;
                goto out;
        }

        child_path = gf_strdup (child->path);
        if (!child_path) {
                if (op_errno)
                        *op_errno = ENOMEM;
                goto out;
        }

        parent->path = gf_strdup (dirname (child_path));
        if (!parent->path) {
                if (op_errno)
                        *op_errno = ENOMEM;
                goto out;
        }

        parent->inode = inode_ref (child->parent);
	gf_uuid_copy (parent->gfid, child->pargfid);

        ret = 0;
out:
        GF_FREE (child_path);

        return ret;
}
Example #3
0
static void on_dom_node_start(void *cbk, const char *name, const char *ns, const GF_XMLAttribute *attributes, u32 nb_attributes)
{
	u32 i;
	GF_DOMParser *par = (GF_DOMParser *) cbk;
	GF_XMLNode *node;

	if (par->root && !gf_list_count(par->stack)) {
		par->parser->suspended = 1;
		return;
	}

	GF_SAFEALLOC(node, GF_XMLNode);
	node->attributes = gf_list_new();
	for (i=0; i<nb_attributes; i++) {
		GF_XMLAttribute *att;
		GF_SAFEALLOC(att, GF_XMLAttribute);
		att->name = gf_strdup(attributes[i].name);
		att->value = gf_strdup(attributes[i].value);
		gf_list_add(node->attributes, att);
	}
	node->content = gf_list_new();
	node->name = gf_strdup(name);
	if (ns) node->ns = gf_strdup(ns);
	gf_list_add(par->stack, node);
	if (!par->root) par->root = node;
}
Example #4
0
GF_EXPORT
GF_Err gf_cfg_insert_key(GF_Config *iniFile, const char *secName, const char *keyName, const char *keyValue, u32 index)
{
	u32 i;
	IniSection *sec;
	IniKey *key;

	if (!iniFile || !secName || !keyName|| !keyValue) return GF_BAD_PARAM;

	i=0;
	while ( (sec = (IniSection *) gf_list_enum(iniFile->sections, &i) ) ) {
		if (!strcmp(secName, sec->section_name)) break;
	}
	if (!sec) return GF_BAD_PARAM;

	i=0;
	while ( (key = (IniKey *) gf_list_enum(sec->keys, &i) ) ) {
		if (!strcmp(key->name, keyName)) return GF_BAD_PARAM;
	}

	key = (IniKey *) gf_malloc(sizeof(IniKey));
	key->name = gf_strdup(keyName);
	key->value = gf_strdup(keyValue);
	gf_list_insert(sec->keys, key, index);
	iniFile->hasChanged = GF_TRUE;
	return GF_OK;
}
Example #5
0
GF_EXPORT
const char *gf_cfg_get_sub_key(GF_Config *iniFile, const char *secName, const char *keyName, u32 sub_index)
{
	u32 j;
	char *subKeyValue, *returnKey;
	char *keyValue;


	keyValue = gf_strdup(gf_cfg_get_key(iniFile, secName, keyName));
	if (!keyValue) {
		return NULL;
	}

	j = 0;
	subKeyValue = strtok((char*)keyValue,";");
	while (subKeyValue!=NULL) {
		if (j==sub_index) {
			returnKey = gf_strdup(subKeyValue);
			gf_free(keyValue);
			return returnKey;
		}
		j++;
		subKeyValue = strtok (NULL, ";");
	}
	gf_free(keyValue);
	return NULL;
}
Example #6
0
static void xml_sax_parse_entity(GF_SAXParser *parser)
{
	char szName[1024];
	u32 i = 0;
	XML_Entity *ent = (XML_Entity *)gf_list_last(parser->entities);
	char *skip_chars = " \t\n\r";
	i=0;
	if (ent && ent->value) ent = NULL;
	if (ent) skip_chars = NULL;

	while (parser->current_pos+i < parser->line_size) {
		u8 c = parser->buffer[parser->current_pos+i];
		if (skip_chars && strchr(skip_chars, c)) {
			if (c=='\n') parser->line++;
			parser->current_pos++;
			continue;
		}
		if (!ent && (c=='%')) {
			parser->current_pos+=i+1;
			parser->sax_state = SAX_STATE_SKIP_DOCTYPE;
			return;
		}
		else if (!ent && ((c=='\"') || (c=='\'')) ) {
			szName[i] = 0;
			GF_SAFEALLOC(ent, XML_Entity);
			ent->name = gf_strdup(szName);
			ent->namelen = strlen(ent->name);
			ent->sep = c;
			parser->current_pos += 1+i;
			assert(parser->current_pos < parser->line_size);
			xml_sax_swap(parser);
			i=0;
			gf_list_add(parser->entities, ent);
			skip_chars = NULL;
		} else if (ent && c==ent->sep) {
			xml_sax_store_text(parser, i);

			ent->value = xml_get_current_text(parser);
			if (!ent->value) ent->value = gf_strdup("");

			parser->current_pos += 1;
			assert(parser->current_pos < parser->line_size);
			xml_sax_swap(parser);
			parser->sax_state = SAX_STATE_SKIP_DOCTYPE;
			return;
		} else if (!ent) {
			szName[i] = c;
			i++;
		} else {
			i++;
		}
	}
	xml_sax_store_text(parser, i);
}
Example #7
0
GF_EXPORT
GF_Err gf_cfg_set_key(GF_Config *iniFile, const char *secName, const char *keyName, const char *keyValue)
{
	u32 i;
	Bool has_changed = GF_TRUE;
	IniSection *sec;
	IniKey *key;

	if (!iniFile || !secName || !keyName) return GF_BAD_PARAM;

	if (!strnicmp(secName, "temp", 4)) has_changed = GF_FALSE;

	i=0;
	while ((sec = (IniSection *) gf_list_enum(iniFile->sections, &i)) ) {
		if (!strcmp(secName, sec->section_name)) goto get_key;
	}
	/* need a new key */
	sec = (IniSection *) gf_malloc(sizeof(IniSection));
	sec->section_name = gf_strdup(secName);
	sec->keys = gf_list_new();
	if (has_changed) iniFile->hasChanged = GF_TRUE;
	gf_list_add(iniFile->sections, sec);

get_key:
	i=0;
	while ( (key = (IniKey *) gf_list_enum(sec->keys, &i) ) ) {
		if (!strcmp(key->name, keyName)) goto set_value;
	}
	if (!keyValue) return GF_OK;
	/* need a new key */
	key = (IniKey *) gf_malloc(sizeof(IniKey));
	key->name = gf_strdup(keyName);
	key->value = gf_strdup("");
	if (has_changed) iniFile->hasChanged = GF_TRUE;
	gf_list_add(sec->keys, key);

set_value:
	if (!keyValue) {
		gf_list_del_item(sec->keys, key);
		if (key->name) gf_free(key->name);
		if (key->value) gf_free(key->value);
		gf_free(key);
		if (has_changed) iniFile->hasChanged = GF_TRUE;
		return GF_OK;
	}
	/* same value, don't update */
	if (!strcmp(key->value, keyValue)) return GF_OK;

	if (key->value) gf_free(key->value);
	key->value = gf_strdup(keyValue);
	if (has_changed) iniFile->hasChanged = GF_TRUE;
	return GF_OK;
}
Example #8
0
GF_EXPORT
GF_RTSPTransport *gf_rtsp_transport_clone(GF_RTSPTransport *original)
{
	GF_RTSPTransport *tr;

	if (!original) return NULL;

	tr = (GF_RTSPTransport*) gf_malloc(sizeof(GF_RTSPTransport));
	memcpy(tr, original, sizeof(GF_RTSPTransport));
	tr->destination = tr->source = tr->Profile = NULL;
	if (original->destination) tr->destination = gf_strdup(original->destination);
	if (original->source) tr->source = gf_strdup(original->source);
	if (original->Profile) tr->Profile = gf_strdup(original->Profile);
	return tr;
}
Example #9
0
static int
sdfs_build_parent_loc (loc_t *parent, loc_t *child)
{
        int     ret     = -1;
        char    *path   = NULL;

        if (!child->parent) {
                goto out;
        }
        parent->inode = inode_ref (child->parent);
        path = gf_strdup (child->path);
        if (!path) {
                ret = -ENOMEM;
                goto out;
        }

        parent->path = dirname(path);
        if (!parent->path) {
                goto out;
        }

        gf_uuid_copy (parent->gfid, child->pargfid);
        return 0;

out:
        GF_FREE (path);
        return ret;
}
Example #10
0
int
make_export_path (const char *real_path, char **path)
{
    int     ret = -1;
    char   *tmp = NULL;
    char   *export_path = NULL;
    char   *dup = NULL;
    char   *ptr = NULL;
    char   *freeptr = NULL;
    uuid_t  gfid = {0, };

    export_path = GF_CALLOC (1, sizeof (char) * PATH_MAX, 0);
    if (!export_path)
        goto out;

    dup = gf_strdup (real_path);
    if (!dup)
        goto out;

    freeptr = dup;
    ret = solaris_getxattr ("/", GFID_XATTR_KEY, gfid, 16);
    /* Return value of getxattr */
    if (ret == 16) {
        if (__is_root_gfid (gfid)) {
            strcat (export_path, "/");
            ret = 0;
            goto done;
        }
    }

    do {
        ptr = strtok_r (dup, "/", &tmp);
        if (!ptr)
            break;
        strcat (export_path, dup);
        ret = solaris_getxattr (export_path, GFID_XATTR_KEY, gfid, 16);
        if (ret == 16) {
            if (__is_root_gfid (gfid)) {
                ret = 0;
                goto done;
            }
        }
        strcat (export_path, "/");
        dup = tmp;
    } while (ptr);

    goto out;

done:
    if (!ret) {
        *path = export_path;
    }
out:
    if (freeptr)
        GF_FREE (freeptr);
    if (ret && export_path)
        GF_FREE (export_path);

    return ret;
}
Example #11
0
GF_EXPORT
char * gf_cfg_get_filename(GF_Config *iniFile)
{
	if (!iniFile)
		return NULL;
	return iniFile->fileName ? gf_strdup(iniFile->fileName) : NULL;
}
Example #12
0
static char *
generate_uuid ()
{
    char           tmp_str[1024] = {0,};
    char           hostname[256] = {0,};
    struct timeval tv = {0,};
    struct tm      now = {0, };
    char           now_str[32];

    if (gettimeofday (&tv, NULL) == -1) {
        gf_log ("glusterfsd", GF_LOG_ERROR,
                "gettimeofday: failed %s",
                strerror (errno));
    }

    if (gethostname (hostname, 256) == -1) {
        gf_log ("glusterfsd", GF_LOG_ERROR,
                "gethostname: failed %s",
                strerror (errno));
    }

    localtime_r (&tv.tv_sec, &now);
    strftime (now_str, 32, "%Y/%m/%d-%H:%M:%S", &now);
    snprintf (tmp_str, 1024, "%s-%d-%s:%"
#ifdef GF_DARWIN_HOST_OS
              PRId32,
#else
              "ld",
#endif
              hostname, getpid(), now_str, tv.tv_usec);

    return gf_strdup (tmp_str);
}
Example #13
0
static void validator_xvl_open(GF_Validator *validator)
{
	GF_Err e;
	u32 att_index;
	GF_XMLAttribute *att;
	validator->xvl_parser = gf_xml_dom_new();
	e = gf_xml_dom_parse(validator->xvl_parser, validator->xvl_filename, NULL, NULL);
	if (e != GF_OK) {
		gf_xml_dom_del(validator->xvl_parser);
		validator->xvl_parser = NULL;
		return;
	}
	validator->xvl_node = gf_xml_dom_get_root(validator->xvl_parser);
	if (!validator->xvl_node) {
		gf_xml_dom_del(validator->xvl_parser);
		validator->xvl_parser = NULL;
		return;
	}
	att_index = 0;
	while (1) {
		att = gf_list_get(validator->xvl_node->attributes, att_index);
		if (!att) break;
		if (!strcmp(att->name, "content-base")) {
			validator->test_base = gf_strdup(att->value);
		}
		att_index++;
	}
}
Example #14
0
//parse all fields in the header
GF_Err RTSP_ParseResponseHeader(GF_RTSPSession *sess, GF_RTSPResponse *rsp, u32 BodyStart)
{
	char LineBuffer[1024];
	char ValBuf[400];
	char *buffer;
	s32 Pos, ret;
	u32 Size;

	Size = sess->CurrentSize - sess->CurrentPos;
	buffer = sess->TCPBuffer + sess->CurrentPos;

	//parse first line
	ret = gf_token_get_line(buffer, 0, Size, LineBuffer, 1024);
	if (ret < 0)
		return GF_REMOTE_SERVICE_ERROR;
	//RTSP/1.0
	Pos = gf_token_get(LineBuffer, 0, " \t\r\n", ValBuf, 400);
	if (Pos <= 0)
		return GF_REMOTE_SERVICE_ERROR;
	if (strcmp(ValBuf, GF_RTSP_VERSION))
		return GF_SERVICE_ERROR;
	//CODE
	Pos = gf_token_get(LineBuffer, Pos, " \t\r\n", ValBuf, 400);
	if (Pos <= 0)
		return GF_REMOTE_SERVICE_ERROR;
	rsp->ResponseCode = atoi(ValBuf);
	//string info
	Pos = gf_token_get(LineBuffer, Pos, "\t\r\n", ValBuf, 400);
	if (Pos > 0) rsp->ResponseInfo = gf_strdup(ValBuf);

	return gf_rtsp_parse_header(buffer + ret, Size - ret, BodyStart, NULL, rsp);
}
Example #15
0
GF_Err gf_cache_set_etag_on_disk(const DownloadedCacheEntry entry, const char * eTag ) {
	if (!entry)
		return GF_BAD_PARAM;
	if (entry->diskETag)
		gf_free(entry->diskETag);
	entry->diskETag = eTag ? gf_strdup(eTag) : NULL;
	return GF_OK;
}
Example #16
0
GF_Err gf_cache_set_mime_type(const DownloadedCacheEntry entry, const char * mime_type ) {
	if (!entry)
		return GF_BAD_PARAM;
	if (entry->mimeType)
		gf_free(entry->mimeType);
	entry->mimeType = mime_type? gf_strdup( mime_type) : NULL;
	return GF_OK;
}
Example #17
0
GF_EXPORT
GF_Err gf_cfg_set_filename(GF_Config *iniFile, const char * fileName)
{
	if (!fileName) return GF_OK;
	if (iniFile->fileName) gf_free(iniFile->fileName);
	iniFile->fileName = gf_strdup(fileName);
	return iniFile->fileName ? GF_OK : GF_OUT_OF_MEM;
}
Example #18
0
static void svg2bifs_text_content(void *sax_cbck, const char *text_content, Bool is_cdata)
{
    SVG2BIFS_Converter *converter = (SVG2BIFS_Converter *)sax_cbck;
    if (converter->bifs_text_node) {
        M_Text *text = (M_Text *)converter->bifs_text_node;
        gf_sg_vrml_mf_alloc(&text->string, GF_SG_VRML_MFSTRING, 1);
        text->string.vals[0] = gf_strdup(text_content);
    }
}
Example #19
0
GF_Err gf_cache_set_last_modified_on_disk ( const DownloadedCacheEntry entry, const char * newLastModified )
{
	if (!entry)
		return GF_BAD_PARAM;
	if (entry->diskLastModified)
		gf_free(entry->diskLastModified);
	entry->diskLastModified = newLastModified ? gf_strdup(newLastModified) : NULL;
	return GF_OK;
}
Example #20
0
GF_EXPORT
GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 metaType)
{
	char szName[20];
	GF_MetaBox *meta;

	GF_Err e = CanAccessMovie(file, GF_ISOM_OPEN_WRITE);
	if (e) return e;

	meta = gf_isom_get_meta(file, root_meta, track_num);
	if (!meta) {
		if (!metaType) return GF_OK;
		meta = (GF_MetaBox *) meta_New();
		if (root_meta) {
			file->meta = meta;
			gf_list_add(file->TopBoxes, meta);
		} else {
			gf_isom_insert_moov(file);
			if (!track_num) {
				file->moov->meta = meta;
			} else {
				GF_TrackBox *tk = (GF_TrackBox *)gf_list_get(file->moov->trackList, track_num-1);
				if (!tk) {
					gf_isom_box_del((GF_Box *)meta);
					return GF_BAD_PARAM;
				}
				tk->meta = meta;
			}
		}
	} else if (!metaType) {
		if (root_meta) {
			gf_list_del_item(file->TopBoxes, meta);
			gf_isom_box_del((GF_Box *)file->meta);
			file->meta = NULL;
		} else if (file->moov) {
			if (!track_num) {
				gf_isom_box_del((GF_Box *)file->moov->meta);
				file->moov->meta = NULL;
			} else {
				GF_TrackBox *tk = (GF_TrackBox *)gf_list_get(file->moov->trackList, track_num-1);
				if (!tk) return GF_BAD_PARAM;
				gf_isom_box_del((GF_Box *)tk->meta);
				tk->meta = NULL;
			}
		}
		return GF_OK;
	}

	if (!meta->handler)
		meta->handler = (GF_HandlerBox *)hdlr_New();

	if (meta->handler->nameUTF8) gf_free(meta->handler->nameUTF8);
	meta->handler->handlerType = metaType;
	sprintf(szName, "GPAC %s Handler", gf_4cc_to_str(metaType));
	meta->handler->nameUTF8 = gf_strdup(szName);
	return GF_OK;
}
Example #21
0
GF_EXPORT
GF_Thread *gf_th_new(const char *name)
{
	GF_Thread *tmp = (GF_Thread *) gf_malloc(sizeof(GF_Thread));
	memset((void *)tmp, 0, sizeof(GF_Thread));
	tmp->status = GF_THREAD_STATUS_STOP;
#ifndef GPAC_DISABLE_LOG
	if (name) {
		tmp->log_name = gf_strdup(name);
	} else {
		char szN[20];
		sprintf(szN, "0x%08x", (u32) tmp);
		tmp->log_name = gf_strdup(szN);
	}
#endif

	return tmp;
}
Example #22
0
int
gf_sql_update_delete_wind (gf_sql_connection_t  *sql_conn,
                          gfdb_db_record_t     *gfdb_db_record)
{
        int ret = -1;
        char *gfid_str          = NULL;
        char *pargfid_str       = NULL;

        CHECK_SQL_CONN (sql_conn, out);
        GF_VALIDATE_OR_GOTO (GFDB_STR_SQLITE3, gfdb_db_record, out);

        gfid_str = gf_strdup (uuid_utoa(gfdb_db_record->gfid));
        if (!gfid_str) {
                gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
                        LG_MSG_CREATE_FAILED, "Creating gfid string failed.");
                goto out;
        }

        pargfid_str = gf_strdup (uuid_utoa(gfdb_db_record->pargfid));
        if (!pargfid_str) {
                        gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
                                LG_MSG_CREATE_FAILED, "Creating pargfid_str "
                                "string failed.");
                        goto out;
        }

        if (gfdb_db_record->link_consistency) {
                ret = gf_sql_update_link_flags (sql_conn, gfid_str, pargfid_str,
                                        gfdb_db_record->file_name, 1,
                                        _gf_false);
                if (ret) {
                        gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
                                LG_MSG_UPDATE_FAILED,
                                "Failed updating link flags in wind");
                        goto out;
                }
        }

        ret = 0;
out:
        GF_FREE (gfid_str);
        GF_FREE (pargfid_str);
        return ret;
}
Example #23
0
/**
 * __exp_line_opt_key_value_parse -- Parse the key-value options in the options
 *                                   string.
 *
 * Given a string like (sec=sys,anonuid=0,rw), to parse, this function
 * will get called once with 'sec=sys' and again with 'anonuid=0'.
 * It will check for the '=', make sure there is data to be read
 * after the '=' and copy the data into the options struct.
 *
 * @option    : An option string like sec=sys or anonuid=0
 * @opts      : Pointer to an struct export_options that holds all the export
 *              options.
 *
 * @return: success: GF_EXP_PARSE_SUCCESS
 *          failure: GF_EXP_PARSE_ITEM_FAILURE on parse failure,
 *                   -EINVAL on bad args, -ENOMEM on allocation errors.
 *
 * Not for external use.
 */
static int
__exp_line_opt_key_value_parse(char *option, struct export_options *opts)
{
    char *equals = NULL;
    char *right = NULL;
    char *strmatch = option;
    int ret = -EINVAL;

    GF_VALIDATE_OR_GOTO(GF_EXP, option, out);
    GF_VALIDATE_OR_GOTO(GF_EXP, opts, out);

    equals = strchr(option, '=');
    if (!equals) {
        ret = GF_EXP_PARSE_ITEM_FAILURE;
        goto out;
    }

    *equals = 0;
    /* Now that an '=' has been found the left side is the option and
     * the right side is the value. We simply have to compare those and
     * extract it.
     */
    if (strcmp(strmatch, "anonuid") == 0) {
        *equals = '=';
        /* Get the value for this option */
        __exp_line_get_opt_val(right, equals, ret, out);
        opts->anon_uid = gf_strdup(right);
        GF_CHECK_ALLOC(opts->anon_uid, ret, out);
    } else if (strcmp(strmatch, "sec") == 0) {
        *equals = '=';
        /* Get the value for this option */
        __exp_line_get_opt_val(right, equals, ret, out);
        opts->sec_type = gf_strdup(right);
        GF_CHECK_ALLOC(opts->sec_type, ret, out);
    } else {
        *equals = '=';
        ret = GF_EXP_PARSE_ITEM_FAILURE;
        goto out;
    }

    ret = GF_EXP_PARSE_SUCCESS;
out:
    return ret;
}
Example #24
0
static char *validator_get_snapshot_name(char *test_filename, Bool is_reference, u32 number)
{
	char *dot;
	char dumpname[GF_MAX_PATH];
	dot = strrchr(test_filename, '.');
	dot[0] = 0;
	sprintf(dumpname, "%s-%s-%03d.png", test_filename, (is_reference?"reference":"newest"), number);
	dot[0] = '.';
	return gf_strdup(dumpname);
}
Example #25
0
/**
 * A function which pushes argument to a libav codec using its private data.
 * param priv_data
 * param options a list of space separated and ':' affected options (e.g. "a:b c:d e:f"). @options be non NULL.
 */
void build_dict(void *priv_data, const char *options) {
	char *opt = gf_strdup(options);
	char *tok = strtok(opt, "=");
	char *tokval = NULL;
	while (tok && (tokval=strtok(NULL, " "))) {
		if (av_opt_set(priv_data, tok, tokval, 0) < 0)
			GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Unknown custom option \"%s\" with value \"%s\" in %s\n", tok, tokval, options));
		tok = strtok(NULL, "=");
	}
	gf_free(opt);
}
Example #26
0
static char *xml_get_current_text(GF_SAXParser *parser)
{
	char *text, c;
	if (!parser->text_start) return NULL;

	c = parser->buffer[parser->text_end-1];
	parser->buffer[parser->text_end-1] = 0;
	text = gf_strdup(parser->buffer + parser->text_start-1);
	parser->buffer[parser->text_end-1] = c;
	parser->text_start = parser->text_end = 0;
	return text;
}
Example #27
0
int
solaris_xattr_resolve_path (const char *real_path, char **path)
{
    int                    ret  = -1;
    char                   *export_path = NULL;
    char                   xattr_path[PATH_MAX] = {0, };
    struct stat            lstatbuf = {0, };
    struct iatt            stbuf = {0, };
    struct stat            statbuf = {0, };

    ret = lstat (real_path, &lstatbuf);
    if (ret != 0 )
        return ret;
    iatt_from_stat (&stbuf, &lstatbuf);
    if (IA_ISREG(stbuf.ia_type) || IA_ISDIR(stbuf.ia_type))
        return -1;

    ret = make_export_path (real_path, &export_path);
    if (!ret && export_path) {
        strcat (export_path, "/"GF_SOLARIS_XATTR_DIR);
        if (lstat (export_path, &statbuf)) {
            ret = mkdir (export_path, 0777);
            if (ret && (errno != EEXIST)) {
                gf_log (THIS->name, GF_LOG_DEBUG, "mkdir failed,"
                        " errno: %d", errno);
                goto out;
            }
        }

        snprintf(xattr_path, PATH_MAX, "%s%s%lu", export_path,
                 "/", stbuf.ia_ino);

        ret = lstat (xattr_path, &statbuf);

        if (ret) {
            ret = mknod (xattr_path, S_IFREG|O_WRONLY, 0);
            if (ret && (errno != EEXIST)) {
                gf_log (THIS->name, GF_LOG_WARNING,"Failed to create "
                        "mapped file %s, error %d", xattr_path,
                        errno);
                goto out;
            }
        }
        *path = gf_strdup (xattr_path);
    }
out:
    if (export_path)
        GF_FREE (export_path);
    if (*path)
        return 0;
    else
        return -1;
}
Example #28
0
void compositor_init_svg_font_face_uri(GF_Compositor *compositor, GF_Node *node)
{
	GF_Node *par;
	GF_Font *font;
	FontURIStack *stack;
	GF_Err e;
	SVGAllAttributes atts;

	/*check parent is a font-face-src*/
	par = gf_node_get_parent(node, 0);
	if (!par || (gf_node_get_tag(par)!=TAG_SVG_font_face_src)) return;
	/*check parent's parent is a font-face*/
	par = gf_node_get_parent(par, 0);
	if (!par || (gf_node_get_tag(par)!=TAG_SVG_font_face)) return;


	gf_svg_flatten_attributes((SVG_Element*)node, &atts);
	if (!atts.xlink_href) return;

	/*get font familly*/
	gf_svg_flatten_attributes((SVG_Element*)par, &atts);
	if (!atts.font_family) return;

	/*if font with the same name exists, don't load*/
	if (gf_compositor_svg_set_font(compositor->font_manager, atts.font_family->value, 0, 1) != NULL)
		return;

	/*register font to font manager*/
	GF_SAFEALLOC(font, GF_Font);
	e = gf_font_manager_register_font(compositor->font_manager, font);
	if (e) {
		gf_free(font);
		return;
	}
	GF_SAFEALLOC(stack, FontURIStack);
	stack->font = font;
	stack->compositor = compositor;

	font->ft_mgr = compositor->font_manager;

	font->get_glyphs = svg_font_uri_get_glyphs;
	font->load_glyph = svg_font_uri_load_glyph;
	font->get_alias = svg_font_uri_get_alias;
	font->udta = node;
	font->name = gf_strdup(atts.font_family->value);
	gf_node_set_private(node, stack);
	gf_node_set_callback_function(node, svg_traverse_font_face_uri);

	font->not_loaded = 1;
	compositor->fonts_pending++;
	svg_font_uri_check(node, stack);
}
Example #29
0
static void on_dom_text_content(void *cbk, const char *content, Bool is_cdata)
{
	GF_DOMParser *par = (GF_DOMParser *)cbk;
	GF_XMLNode *node;
	GF_XMLNode *last = (GF_XMLNode *)gf_list_last(par->stack);
	if (!last) return;
	assert(last->content);

	GF_SAFEALLOC(node, GF_XMLNode);
	node->type = is_cdata ? GF_XML_CDATA_TYPE : GF_XML_TEXT_TYPE;
	node->name = gf_strdup(content);
	gf_list_add(last->content, node);
}
Example #30
0
GF_EXPORT
GF_Mutex *gf_mx_new(const char *name)
{
	GF_Mutex *tmp = (GF_Mutex *)gf_malloc(sizeof(GF_Mutex));
	if (!tmp) return NULL;
	memset(tmp, 0, sizeof(GF_Mutex));

	tmp->hMutex = new RMutex();
	if( tmp->hMutex->CreateLocal() != KErrNone) {
		gf_free(tmp);
		return NULL;
	}
#ifndef GPAC_DISABLE_LOG
	if (name) {
		tmp->log_name = gf_strdup(name);
	} else {
		char szN[20];
		sprintf(szN, "0x%08x", (u32) tmp);
		tmp->log_name = gf_strdup(szN);
	}
#endif
	return tmp;
}