Esempio n. 1
0
File: pe.c Progetto: HarryR/sanos
static struct import_symbol *pe_add_import(struct pe_info *pe, int sym_index) {
  int i;
  int dll_index;
  struct pe_import_info *p;
  struct import_symbol *s;

  dll_index = ((Elf32_Sym *) pe->s1->dynsymtab_section->data + sym_index)->st_value;
  if (dll_index == 0) return NULL;

  i = dynarray_assoc((void **) pe->imp_info, pe->imp_count, dll_index);
  if (i != -1) {
    p = pe->imp_info[i];
    goto found_dll;
  }
  p = tcc_mallocz(sizeof *p);
  p->dll_index = dll_index;
  dynarray_add((void ***) &pe->imp_info, &pe->imp_count, p);

found_dll:
  i = dynarray_assoc((void **) p->symbols, p->sym_count, sym_index);
  if (i != -1) return p->symbols[i];

  s = tcc_mallocz(sizeof *s);
  dynarray_add((void ***) &p->symbols, &p->sym_count, s);
  s->sym_index = sym_index;
  return s;
}
Esempio n. 2
0
void out_blk_mustgen(out_ctx *octx, out_blk *blk, char *force_lbl)
{
	if(force_lbl)
		blk->force_lbl = force_lbl;

	dynarray_add(&octx->mustgen, blk);
}
Esempio n. 3
0
static struct variant *new_variant(struct list_mgt *mgt, int bandwidth, const char *url, const char *base)
{
    struct variant *var = av_mallocz(sizeof(struct variant));
    if (!var)
        return NULL;

    var->bandwidth = bandwidth;
    char* ptr = NULL;
    int has_prefix = 0;
    if(!av_strstart(url,"https://",ptr)) {
        if(base!=NULL&&av_strstart(base,"https://",ptr)) { //change to  shttps for using android streaming framework.
            snprintf(var->url,1,"s");
            has_prefix = 1;
        }
        if(has_prefix>0) {
            ff_make_absolute_url(var->url+1, sizeof(var->url)-1, base, url);
        } else {
            ff_make_absolute_url(var->url, sizeof(var->url), base, url);
        }
    } else { //change to  shttps for using android streaming framework.
        snprintf(var->url,sizeof(var->url),"s%s",url);
    }
    //av_log(NULL,AV_LOG_INFO,"returl=%s\nbase=%s\nurl=%s\n",var->url,base,url);
    dynarray_add(&mgt->variants, &mgt->n_variants, var);
    return var;
}
Esempio n. 4
0
File: enum.c Progetto: mtexier/ucc
enum_st *enum_add( enum_st ***ens, char *spel, enum_st *en)
{
	st_en_set_spel(&en->spel, spel, "enum");

	dynarray_add((void ***)ens, en);
	return en;
}
Esempio n. 5
0
PRIVATE_EXTERN RTADVSocketRef
RTADVSocketCreate(interface_t * if_p)
{
    RTADVSocketRef		sock;
    RTADVSocketGlobalsRef	globals;

    globals = RTADVSocketGetGlobals();
    if (globals == NULL) {
	my_log(LOG_NOTICE, "RTADVSocketCreate: could not allocate globals");
	return (NULL);
    }
    sock = RTADVSocketFind(if_link_index(if_p));
    if (sock != NULL) {
	my_log(LOG_NOTICE, "RTADVSocketCreate(%s): socket already allocated",
	       if_name(if_p));
	return (NULL);
    }
    sock = malloc(sizeof(*sock));
    if (sock == NULL) {
	return (NULL);
    }
    bzero(sock, sizeof(*sock));
    if (dynarray_add(&globals->sockets, sock) == FALSE) {
	free(sock);
	return (NULL);
    }
    sock->if_p = if_p;
    return (sock);
}
Esempio n. 6
0
/**operator */
TkWord * tkword_direct_insert(TkWord *tp){
    int keyno;
    dynarray_add(&tktable,tp);
    keyno = elf_hash(tp->spelling);
    tp->next = tk_hashtable[keyno];
    tk_hashtable[keyno] = tp;
    return tp;
}
Esempio n. 7
0
static struct variant *new_variant(HLSContext *c, int bandwidth,
                                   const char *url, const char *base)
{
    struct variant *var;
    struct playlist *pls;

    pls = new_playlist(c, url, base);
    if (!pls)
        return NULL;

    var = av_mallocz(sizeof(struct variant));
    if (!var)
        return NULL;

    var->bandwidth = bandwidth;
    dynarray_add(&c->variants, &c->n_variants, var);
    dynarray_add(&var->playlists, &var->n_playlists, pls);
    return var;
}
Esempio n. 8
0
File: enum.c Progetto: mtexier/ucc
void enum_vals_add(enum_st *en, char *sp, expr *e)
{
	enum_member *mem = umalloc(sizeof *mem);
	if(!e)
		e = (expr *)-1;

	mem->spel = sp;
	mem->val  = e;

	dynarray_add((void ***)&en->members, mem);
}
Esempio n. 9
0
static struct playlist *new_playlist(HLSContext *c, const char *url,
                                     const char *base)
{
    struct playlist *pls = av_mallocz(sizeof(struct playlist));
    if (!pls)
        return NULL;
    reset_packet(&pls->pkt);
    ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
    dynarray_add(&c->playlists, &c->n_playlists, pls);
    return pls;
}
Esempio n. 10
0
static int new_active_thread(thread_list_t *act_th, pthread_t *th)
{
	pthread_mutex_lock(&act_th->mutex);
	
	/* append hls_obj_th to global struct thread_list, need a mutex lock */
	dynarray_add(&act_th->th, &act_th->n_ths, th);
	
	pthread_mutex_unlock(&act_th->mutex);
	
	return 0;
}
Esempio n. 11
0
/* ------------------------------------------------------------- */
PUB_FN int pe_load_def_file(TCCState *s1, int fd)
{
    DLLReference *dllref;
    int state = 0, ret = -1;
    char line[400], dllname[80], *p;
    FILE *fp = fdopen(dup(fd), "rb");

    if (NULL == fp)
        goto quit;

    for (;;) {
        p = get_line(line, sizeof line, fp);
        if (NULL == p)
            break;
        if (0 == *p || ';' == *p)
            continue;
        switch (state) {
        case 0:
            if (0 != strnicmp(p, "LIBRARY", 7))
                goto quit;
            strcpy(dllname, trimfront(p+7));
            ++state;
            continue;

        case 1:
            if (0 != stricmp(p, "EXPORTS"))
                goto quit;
            ++state;
            continue;

        case 2:
            dllref = tcc_malloc(sizeof(DLLReference) + strlen(dllname));
            strcpy(dllref->name, dllname);
            dllref->level = 0;
            dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref);
            ++state;

        default:
            add_elf_sym(s1->dynsymtab_section,
                s1->nb_loaded_dlls, 0,
                ELF32_ST_INFO(STB_GLOBAL, STT_FUNC), 0,
                text_section->sh_num, p);
            continue;
        }
    }
    ret = 0;
quit:
    if (fp)
        fclose(fp);
    if (ret)
        error_noabort("unrecognized export definition file format");
    return ret;
}
Esempio n. 12
0
static struct variant *new_variant(HLSContext *c, int bandwidth,
                                   const char *url, const char *base)
{
    struct variant *var = av_mallocz(sizeof(struct variant));
    if (!var)
        return NULL;
    reset_packet(&var->pkt);
    var->bandwidth = bandwidth;
    ff_make_absolute_url(var->url, sizeof(var->url), base, url);
    dynarray_add(&c->variants, &c->n_variants, var);
    return var;
}
Esempio n. 13
0
File: pe.c Progetto: HarryR/sanos
int pe_load_def_file(TCCState *s1, int fd) {
  DLLReference *dllref;
  int state = 0, ret = -1, hint;
  char line[400], dllname[80], *p, *ordinal;
  FILE *fp = fdopen(dup(fd), "rb");
  if (fp == NULL) goto quit;

  for (;;) {
    p = get_line(line, sizeof line, fp);
    if (p == NULL) break;
    if (*p == 0 || *p == ';') continue;
    switch (state) {
      case 0:
        if (strncasecmp(p, "LIBRARY", 7) != 0) goto quit;
        strcpy(dllname, trimfront(p + 7));
        ++state;
        continue;

      case 1:
        if (strcasecmp(p, "EXPORTS") != 0) goto quit;
        ++state;
        continue;

      case 2:
        dllref = tcc_malloc(sizeof(DLLReference) + strlen(dllname));
        strcpy(dllref->name, dllname);
        dllref->level = 0;
        dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref);
        ++state;

      default:
        hint = 0;
        ordinal = strchr(p, '@');
        if (ordinal) {
          *ordinal = 0;
          trimback(p, ordinal);
          ordinal++;
          hint = atoi(ordinal);
        }
        add_elf_sym(s1->dynsymtab_section, s1->nb_loaded_dlls, 0, 
                    ELF32_ST_INFO(STB_GLOBAL, STT_FUNC), hint, 
                    text_section->sh_num, p);
        continue;
    }
  }
  ret = 0;

quit:
  if (fp) fclose(fp);
  if (ret) error_noabort("unrecognized export definition file format");
  return ret;
}
Esempio n. 14
0
void decl_replace_with(decl *to, decl *from)
{
	attribute **i;

	/* XXX: memleak of .ref */
	memcpy_safe(&to->where, &from->where);
	to->ref      = from->ref;
	to->spel_asm = from->spel_asm, from->spel_asm = NULL;
	/* no point copying bitfield stuff */
	memcpy_safe(&to->bits, &from->bits);

	for(i = from->attr; i && *i; i++)
		dynarray_add(&to->attr, RETAIN(*i));
}
Esempio n. 15
0
/*
 *	adds an event-reference to the given set of event references
 *	returns 0 on success (ref added), 1 if reference already here, < 0 on error
 */
int traceslang_addtorefset (traceslang_erefset_t *erset, tnode_t **eventp)
{
	int i;

	for (i=0; i<DA_CUR (erset->events); i++) {
		tnode_t **evp = DA_NTHITEM (erset->events, i);

		if (eventp == evp) {
			/* same reference */
			return 1;
		}
	}
	dynarray_add (erset->events, eventp);
	return 0;
}
Esempio n. 16
0
File: outcoff.c Progetto: 7ym0n/note
/*********************************************************** 
 * 功能:			新建节
 * name:			节名称
 * Characteristics:	节属性
 * 返回值:			新增加节
 **********************************************************/
Section * section_new(char *name, int Characteristics)
{
	Section *sec;
	int initsize = 8;
	sec = mallocz(sizeof(Section));
	strcpy(sec->sh.Name,name);
	sec->sh.Characteristics = Characteristics;
	sec->index = sections.count + 1; //one-based index
    sec->data = mallocz(sizeof(char)*initsize);
	sec->data_allocated = initsize;
	if(!(Characteristics & IMAGE_SCN_LNK_REMOVE))
		nsec_image++;
    dynarray_add(&sections, sec);
	return sec;
}
Esempio n. 17
0
void fold_stmt_goto(stmt *s)
{
	if(!symtab_func(s->symtab))
		die_at(&s->where, "goto outside of a function");

	if(s->expr){
		FOLD_EXPR(s->expr, s->symtab);
	}else{
		(s->bits.lbl.label =
		 symtab_label_find_or_new(
			 s->symtab, s->bits.lbl.spel, &s->where))
			->uses++;

		dynarray_add(&s->bits.lbl.label->jumpers, s);
	}
}
Esempio n. 18
0
static struct variant *new_variant(struct list_mgt *mgt, int bandwidth,
                                   const char *url, const char *base)
{
	struct variant *var = av_mallocz(sizeof(struct variant));
	if (!var)
		return NULL;

	var->bandwidth = bandwidth;
  
	if(base){
		av_strlcpy(var->url, base, sizeof(var->url));
	}
	av_strlcat(var->url, url, sizeof(var->url));	
	dynarray_add(&mgt->variants, &mgt->n_variants, var);
	return var;
}
Esempio n. 19
0
static MpegTSService *new_service(MpegTSContext *ts, int sid, 
                                  char *provider_name, char *name)
{
    MpegTSService *service;

#ifdef DEBUG_SI
    printf("new_service: sid=0x%04x provider='%s' name='%s'\n", 
           sid, provider_name, name);
#endif

    service = av_mallocz(sizeof(MpegTSService));
    if (!service)
        return NULL;
    service->sid = sid;
    service->provider_name = provider_name;
    service->name = name;
    dynarray_add(&ts->services, &ts->nb_services, service);
    return service;
}
Esempio n. 20
0
const out_val *gen_expr_funcall(const expr *e, out_ctx *octx)
{
	const out_val *fn_ret;

	if(0){
		out_comment(octx, "start manual __asm__");
		ICE("same");
#if 0
		fprintf(cc_out[SECTION_TEXT], "%s\n", e->funcargs[0]->data_store->data.str);
#endif
		out_comment(octx, "end manual __asm__");
	}else{
		/* continue with normal funcall */
		const out_val *fn, **args = NULL;

		fn = gen_expr(e->expr, octx);

		if(e->funcargs){
			expr **aiter;

			for(aiter = e->funcargs; *aiter; aiter++){
				expr *earg = *aiter;
				const out_val *arg;

				/* should be of size int or larger (for integral types)
				 * or double (for floating types)
				 */
				arg = gen_expr(earg, octx);
				dynarray_add(&args, arg);
			}
		}

		/* consumes fn and args */
		fn_ret = gen_call(e->expr, NULL, fn, args, octx, &e->expr->where);

		dynarray_free(const out_val **, args, NULL);

		if(!expr_func_passable(GEN_CONST_CAST(expr *, e)))
			out_ctrl_end_undefined(octx);
	}

	return fn_ret;
}
Esempio n. 21
0
/*
 *	adds an event to the given event set
 *	returns 0 on success (added), 1 if already here, < 0 on error
 */
int traceslang_addtoset (traceslang_eset_t *eset, tnode_t *event)
{
	int i;

	if (!eset || !event) {
		nocc_internal ("traceslang_addtoset(): NULL set or event!");
		return -1;
	}
	for (i=0; i<DA_CUR (eset->events); i++) {
		tnode_t *ev = DA_NTHITEM (eset->events, i);

		if (!traceslang_isequal (ev, event)) {
			/* same event */
			return 1;
		}
	}
	dynarray_add (eset->events, event);
	return 0;
}
Esempio n. 22
0
ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
{
	const char *ext;
	int ret;

	/* find source file type with extension */
	ext = tcc_fileextension (filename);
	if (ext[0]) {
		ext++;
	}

	/* open the file */
	ret = tcc_open (s1, filename);
	if (ret < 0) {
		if (flags & AFF_PRINT_ERROR) {
			tcc_error ("file '%s' not found", filename);
		}
		return ret;
	}

	/* update target deps */
	dynarray_add ((void ***) &s1->target_deps, &s1->nb_target_deps,
		strdup (filename));

	if (flags & AFF_PREPROCESS) {
		ret = tcc_preprocess (s1);
		goto the_end;
	}

	if (!ext[0] || !PATHCMP (ext, "c") || !PATHCMP (ext, "h") || !PATHCMP (ext, "cparse")) {
		/* C file assumed */
		ret = tcc_compile (s1);
		goto the_end;
	}
	if (ret < 0) {
		tcc_error ("unrecognized file type");
	}

the_end:
	tcc_close ();
	return ret;
}
Esempio n. 23
0
static void rtp_parse_addr_list(URLContext *h, char *buf,
                                struct sockaddr_storage ***address_list_ptr,
                                int *address_list_size_ptr)
{
    struct addrinfo *ai = NULL;
    struct sockaddr_storage *source_addr;
    char tmp = '\0', *p = buf, *next;

    /* Resolve all of the IPs */

    while (p && p[0]) {
        next = strchr(p, ',');

        if (next) {
            tmp = *next;
            *next = '\0';
        }

        ai = rtp_resolve_host(p, 0, SOCK_DGRAM, AF_UNSPEC, 0);
        if (ai) {
            source_addr = av_mallocz(sizeof(struct sockaddr_storage));
            if (!source_addr) {
                freeaddrinfo(ai);
                break;
            }

            memcpy(source_addr, ai->ai_addr, ai->ai_addrlen);
            freeaddrinfo(ai);
            dynarray_add(address_list_ptr, address_list_size_ptr, source_addr);
        } else {
            av_log(h, AV_LOG_WARNING, "Unable to resolve %s\n", p);
        }

        if (next) {
            *next = tmp;
            p = next + 1;
        } else {
            p = NULL;
        }
    }
}
Esempio n. 24
0
/* 
 * Function: DHCPLeaseListUpdateLease
 *
 * Purpose:
 *   Update the lease entry for the given lease in the in-memory lease database.
 */
void
DHCPLeaseListUpdateLease(DHCPLeaseListRef list_p, struct in_addr our_ip,
			 struct in_addr router_ip,
			 const uint8_t * router_hwaddr,
			 int router_hwaddr_length,
			 absolute_time_t lease_start,
			 dhcp_lease_time_t lease_length,
			 const uint8_t * pkt, int pkt_size,
			 CFStringRef ssid)
{
    int			count;
    int			i;
    DHCPLeaseRef	lease_p;
    boolean_t		private_ip = ip_is_private(our_ip);

    lease_p = DHCPLeaseCreate(our_ip, router_ip,
			      router_hwaddr, router_hwaddr_length,
			      lease_start, lease_length, pkt, pkt_size,
			      ssid);
    /* scan lease list to eliminate NAK'd, incomplete, and duplicate leases */
    count = dynarray_count(list_p);
    for (i = 0; i < count; i++) {
	DHCPLeaseRef	scan_p = dynarray_element(list_p, i);

	if (DHCPLeaseShouldBeRemoved(scan_p, lease_p, private_ip)) {
	    dynarray_free_element(list_p, i);
	    i--;
	    count--;
	}
    }
    dynarray_add(list_p, lease_p);
    if (G_IPConfiguration_verbose) {
	my_log(LOG_DEBUG, "Saved lease for " IP_FORMAT,
	       IP_LIST(&lease_p->our_ip));
	if (G_IPConfiguration_verbose) {
	    DHCPLeaseListLog(list_p);
	}
    }
    return;
}
Esempio n. 25
0
TkWord * tkword_insert(char *p){
    TkWord * tp;
    int keyno;
    char * s;
    char * end;
    int length;
    keyno = elf_hash(p);
    tp = tkword_find(p,keyno);
    if(tp != NULL) return tp;
    length = strlen(p);
    tp = (TkWord *) mallocz(sizeof(TkWord) + length + 1);
    tp->next = tk_hashtable[keyno];
    tk_hashtable[keyno] = tp;
    dynarray_add(&tktable,tp);
    tp->tkcode = tktable.count - 1; /// it is a hole
    s=(char *)tp + sizeof(TkWord);
    tp->spelling = s;
    for(end = p + length;p < end;)
        *s++ = *p++;
    *s = '\0';
    return tp;
}
Esempio n. 26
0
/* 
 * Function: DHCPLeaseListRead
 *
 * Purpose:
 *   Read the single DHCP lease for the given interface/client_id into a
 *   DHCPLeaseList structure.  This lease is marked as "tentative" because
 *   we have no idea whether the lease is still good or not, since another
 *   version of the OS (or another OS) could have had additional communication
 *   with the DHCP server, invalidating our notion of the lease.  It also
 *   affords a simple, self-cleansing mechanism to clear out the set of
 *   leases we keep track of.
 */
void
DHCPLeaseListRead(DHCPLeaseListRef list_p,
		  const char * ifname, bool is_wifi,
		  uint8_t cid_type, const void * cid, int cid_length)
{
    char			filename[PATH_MAX];
    CFDictionaryRef		lease_dict = NULL;
    DHCPLeaseRef		lease_p;
    struct in_addr		lease_ip;

    DHCPLeaseListInit(list_p);
    if (DHCPLeaseListGetPath(ifname, cid_type, cid, cid_length,
			     filename, sizeof(filename)) == FALSE) {
	goto done;
    }
    lease_dict = my_CFPropertyListCreateFromFile(filename);
    if (isA_CFDictionary(lease_dict) == NULL) {
	goto done;
    }
    lease_p = DHCPLeaseCreateWithDictionary(lease_dict, is_wifi);
    if (lease_p == NULL) {
	goto done;
    }
    lease_p->tentative = TRUE;
    dynarray_add(list_p, lease_p);
    if (G_IPConfiguration_verbose) {
	DHCPLeaseListLog(list_p);
    }
    lease_ip = lease_p->our_ip;
    DHCPLeaseListRemoveStaleLeases(list_p);
    if (DHCPLeaseListCount(list_p) == 0) {
	remove_unused_ip(ifname, lease_ip);
    }

 done:
    my_CFRelease(&lease_dict);
    return;
}
Esempio n. 27
0
/*
 *	does a structure copy on a traceslang tree -- duplicates structural nodes, but leaves others intact
 *	returns new tree on success, NULL on failure
 */
tnode_t *traceslang_structurecopy (tnode_t *expr)
{
	tnode_t *newtree;
	traceslang_eset_t *fixset;

	/* extract a list of fixpoint names from what we're about to duplicate */
	fixset = traceslang_allfixpoints (expr);
	newtree = tnode_copyoraliastree (expr, trlang_structurecopyfcn);

	if (DA_CUR (fixset->events)) {
		int i;
		traceslang_eset_t *newset = traceslang_newset ();

		/* got some fixpoint names here, duplicate them into a new set of NFIXs */
		for (i=0; i<DA_CUR (fixset->events); i++) {
			char *rfixname = (char *)smalloc (64);
			name_t *sfixname;
			tnode_t *fixname;

			/* create fresh name */
			fixname = tnode_create (traceslang.tag_NFIX, NULL, NULL);
			sprintf (rfixname, "FP%d", anonidcounter++);
			sfixname = name_addname (rfixname, NULL, tnode_create (traceslang.tag_FIXPOINTTYPE, NULL), fixname);
			sfree (rfixname);
			tnode_setnthname (fixname, 0, sfixname);

			/* add to substitution lists */
			dynarray_add (newset->events, fixname);
		}
		newtree = treeops_substitute (newtree, DA_PTR (fixset->events), DA_PTR (newset->events), DA_CUR (fixset->events));

		traceslang_freeset (newset);
	}

	traceslang_freeset (fixset);

	return newtree;
}
Esempio n. 28
0
static void tcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char *in)
{
	const char *p;
	do {
		int c;
		CString str;

		cstr_new (&str);
		for (p = in; c = *p, c != '\0' && c != PATHSEP; ++p) {
			if (c == '{' && p[1] && p[2] == '}') {
				c = p[1], p += 2;
				if (c == 'B') {
					cstr_cat (&str, s->tcc_lib_path);
				}
			} else {
				cstr_ccat (&str, c);
			}
		}
		cstr_ccat (&str, '\0');
		dynarray_add (p_ary, p_nb_ary, str.data);
		in = p + 1;
	} while (*p);
}
DHCPv6SocketRef
DHCPv6SocketCreate(interface_t * if_p)
{
    DHCPv6SocketRef		sock;
    DHCPv6SocketGlobalsRef	globals;

    globals = DHCPv6SocketGetGlobals();
    if (globals == NULL) {
	my_log(LOG_ERR, "DHCPv6SocketCreate: could not allocate globals");
	return (NULL);
    }
    sock = malloc(sizeof(*sock));
    if (sock == NULL) {
	return (NULL);
    }
    bzero(sock, sizeof(*sock));
    if (dynarray_add(&globals->sockets, sock) == FALSE) {
	free(sock);
	return (NULL);
    }
    sock->if_p = if_p;
    return (sock);
}
Esempio n. 30
0
static int parse_playlist(URLContext *h, const char *url)
{
    AppleHTTPContext *s = h->priv_data;
    AVIOContext *in;
    int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
    char line[1024];
    const char *ptr;

    if ((ret = avio_open(&in, url, AVIO_FLAG_READ)) < 0)
        return ret;

    read_chomp_line(in, line, sizeof(line));
    if (strcmp(line, "#EXTM3U"))
        return AVERROR_INVALIDDATA;

    free_segment_list(s);
    s->finished = 0;
    while (!in->eof_reached) {
        read_chomp_line(in, line, sizeof(line));
        if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
            struct variant_info info = {{0}};
            is_variant = 1;
            ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
                               &info);
            bandwidth = atoi(info.bandwidth);
        } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
            s->target_duration = atoi(ptr);
        } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
            s->start_seq_no = atoi(ptr);
        } else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
            s->finished = 1;
        } else if (av_strstart(line, "#EXTINF:", &ptr)) {
            is_segment = 1;
            duration = atoi(ptr);
        } else if (av_strstart(line, "#", NULL)) {
            continue;
        } else if (line[0]) {
            if (is_segment) {
                struct segment *seg = av_malloc(sizeof(struct segment));
                if (!seg) {
                    ret = AVERROR(ENOMEM);
                    goto fail;
                }
                seg->duration = duration;
                ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
                dynarray_add(&s->segments, &s->n_segments, seg);
                is_segment = 0;
            } else if (is_variant) {
                struct variant *var = av_malloc(sizeof(struct variant));
                if (!var) {
                    ret = AVERROR(ENOMEM);
                    goto fail;
                }
                var->bandwidth = bandwidth;
                ff_make_absolute_url(var->url, sizeof(var->url), url, line);
                dynarray_add(&s->variants, &s->n_variants, var);
                is_variant = 0;
            }
        }
    }
    s->last_load_time = av_gettime();

fail:
    avio_close(in);
    return ret;
}