rpm  5.4.15
url.c
Go to the documentation of this file.
1 
5 #include "system.h"
6 
7 #include <netinet/in.h>
8 
9 #include <rpmmacro.h>
10 #include <rpmcb.h>
11 #include <rpmio_internal.h>
12 #ifdef WITH_NEON
13 #include <rpmdav.h>
14 #endif
15 
16 #include "debug.h"
17 
18 /*@access FD_t@*/ /* XXX compared with NULL */
19 /*@access urlinfo@*/
20 
21 #ifdef __cplusplus
22 GENfree(urlinfo *)
23 GENfree(rpmop)
24 #endif /* __cplusplus */
25 
26 #ifndef IPPORT_FTP
27 #define IPPORT_FTP 21
28 #endif
29 #ifndef IPPORT_HTTP
30 #define IPPORT_HTTP 80
31 #endif
32 #ifndef IPPORT_HTTPS
33 #define IPPORT_HTTPS 443
34 #endif
35 #ifndef IPPORT_PGPKEYSERVER
36 #define IPPORT_PGPKEYSERVER 11371
37 #endif
38 #ifndef IPPORT_MONGO
39 #define IPPORT_MONGO 27017
40 #endif
41 
42 #ifdef NOTYET
43 #define URL_IS_GIT
44 #define URL_IS_SVN
45 #define URL_IS_SQLITE
46 #define URL_IS_MYSQL
47 #define URL_IS_POSTGRES
48 #define URL_IS_SQLSERVER
49 #endif
50 
53 /*@-redecl@*/
54 int (*urlNotify) (const urlinfo u, unsigned status)
55  /*@*/;
56 /*@=redecl@*/
57 
60 /*@unchecked@*/ /*@null@*/
61 void * urlNotifyArg;
62 
65 /*@unchecked@*/
67 
70 /*@unchecked@*/
71 int _url_debug = 0;
72 
73 #define URLDBG(_f, _m, _x) if ((_url_debug | (_f)) & (_m)) fprintf _x
74 
75 #define URLDBGIO(_f, _x) URLDBG((_f), RPMURL_DEBUG_IO, _x)
76 #define URLDBGREFS(_f, _x) URLDBG((_f), RPMURL_DEBUG_REFS, _x)
77 
80 /*@unchecked@*/
81 /*@only@*/ /*@null@*/
83 
84 static void urlFini(void * _u)
85  /*@globals fileSystem, internalState @*/
86  /*@modifies _u, fileSystem, internalState @*/
87 {
88  urlinfo u = (urlinfo) _u;
89  int xx;
90 
91  if (u->ctrl) {
92 #ifndef NOTYET
93  void * fp = fdGetFp(u->ctrl);
94  if (fp) {
95  fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */
96  xx = Fclose(u->ctrl);
97  } else if (fdFileno(u->ctrl) >= 0)
98  xx = fdio->close(u->ctrl);
99 #else
100  xx = Fclose(u->ctrl);
101 #endif
102 
103 /*@-usereleased@*/
104  u->ctrl = (FD_t)rpmioFreePoolItem((rpmioItem)u->ctrl, "persist ctrl (urlFree)", __FILE__, __LINE__);
105  if (u->ctrl)
106  fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"),
107  u, u->ctrl, (u->host ? u->host : ""),
108  (u->scheme ? u->scheme : ""));
109 /*@=usereleased@*/
110  }
111  if (u->data) {
112 #ifndef NOTYET
113  void * fp = fdGetFp(u->data);
114  if (fp) {
115  fdPush(u->data, fpio, fp, -1); /* Push fpio onto stack */
116  xx = Fclose(u->data);
117  } else if (fdFileno(u->data) >= 0)
118  xx = fdio->close(u->data);
119 #else
120  xx = Fclose(u->ctrl);
121 #endif
122 
123 /*@-usereleased@*/
124  u->data = (FD_t)rpmioFreePoolItem((rpmioItem)u->data, "persist data (urlFree)", __FILE__, __LINE__);
125  if (u->data)
126  fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"),
127  u, u->data, (u->host ? u->host : ""),
128  (u->scheme ? u->scheme : ""));
129 /*@=usereleased@*/
130  }
131 #ifdef WITH_NEON
132  xx = davFree(u);
133 #endif
134  u->etag = _free(u->etag);
135  u->location = _free(u->location);
136  u->rop = _free(u->rop);
137  u->sop = _free(u->sop);
138  u->top = _free(u->top);
139  u->buf = _free(u->buf);
140  u->url = _free(u->url);
141  u->scheme = _free(u->scheme);
142  u->user = _free(u->user);
143  u->password = _free(u->password);
144  u->host = _free(u->host);
145  u->portstr = _free(u->portstr);
146  u->query = _free(u->query);
147  u->fragment = _free(u->fragment);
148  u->proxyu = _free(u->proxyu);
149  u->proxyh = _free(u->proxyh);
150 }
151 
154 /*@unchecked@*/
155 int _url_count = 0;
156 
157 /*@unchecked@*/ /*@only@*/ /*@null@*/
159 
160 static urlinfo urlGetPool(/*@null@*/ rpmioPool pool)
161  /*@globals _urlPool, fileSystem @*/
162  /*@modifies pool, _urlPool, fileSystem @*/
163 {
164  urlinfo u;
165 
166  if (_urlPool == NULL) {
167  _urlPool = rpmioNewPool("u", sizeof(*u), -1, _url_debug,
168  NULL, NULL, urlFini);
169  pool = _urlPool;
170  }
171  u = (urlinfo) rpmioGetPool(pool, sizeof(*u));
172  memset(((char *)u)+sizeof(u->_item), 0, sizeof(*u)-sizeof(u->_item));
173  return u;
174 }
175 
176 urlinfo XurlNew(const char *msg, const char *fn, unsigned ln)
177 {
178  urlinfo u = urlGetPool(_urlPool);
179 
180  u->proxyp = -1;
181  u->port = -1;
182  u->ut = URL_IS_UNKNOWN;
183  u->ctrl = NULL;
184  u->data = NULL;
185  u->location = NULL;
186  u->etag = NULL;
187  u->notify = urlNotify;
188 /*@-assignexpose@*/
189  u->arg = urlNotifyArg;
190 /*@=assignexpose@*/
191  u->rop = (rpmop) xcalloc(1, sizeof(*u->rop));
192  u->sop = (rpmop) xcalloc(1, sizeof(*u->sop));
193  u->top = (rpmop) xcalloc(1, sizeof(*u->top));
194  u->bufAlloced = 0;
195  u->buf = NULL;
197  u->httpVersion = 0;
198  u->magic = URLMAGIC;
199  return (urlinfo) rpmioLinkPoolItem((rpmioItem)u, msg, fn, ln);
200 }
201 
202 void urlFreeCache(void)
203 {
204  if (_url_cache) {
205  int i;
206  for (i = 0; i < _url_count; i++) {
207  if (_url_cache[i] == NULL) continue;
208  _url_cache[i] = urlFree(_url_cache[i], "_url_cache");
209  if (_url_cache[i] == NULL)
210  continue;
211  yarnPossess(_url_cache[i]->_item.use);
212  fprintf(stderr,
213  _("warning: _url_cache[%d] %p nrefs(%ld) != 1 (%s %s)\n"),
214  i, _url_cache[i], yarnPeekLock(_url_cache[i]->_item.use),
215  (_url_cache[i]->host ? _url_cache[i]->host : ""),
216  (_url_cache[i]->scheme ? _url_cache[i]->scheme : ""));
217  yarnRelease(_url_cache[i]->_item.use);
218  }
219  }
220  _url_cache = _free(_url_cache);
221  _url_count = 0;
222 }
223 
224 static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2)
225  /*@*/
226 {
227  if (str1)
228  if (str2)
229  return strcmp(str1, str2);
230  if (str1 != str2)
231  return -1;
232  return 0;
233 }
234 
235 /*@-mods@*/
236 static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
237  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
238  /*@modifies *uret, rpmGlobalMacroContext, fileSystem, internalState @*/
239 {
240  urlinfo u;
241  int ucx;
242  int i = 0;
243 
244  if (uret == NULL)
245  return;
246 
247  u = *uret;
248  URLSANE(u);
249 
250  ucx = -1;
251  for (i = 0; i < _url_count; i++) {
252  urlinfo ou = NULL;
253  if (_url_cache == NULL || (ou = _url_cache[i]) == NULL) {
254  if (ucx < 0)
255  ucx = i;
256  continue;
257  }
258 
259  /* Check for cache-miss condition. A cache miss is
260  * a) both items are not NULL and don't compare.
261  * b) either of the items is not NULL.
262  */
263  if (urlStrcmp(u->scheme, ou->scheme))
264  continue;
265  if (urlStrcmp(u->host, ou->host))
266  continue;
267  if (urlStrcmp(u->user, ou->user))
268  continue;
269  if (urlStrcmp(u->portstr, ou->portstr))
270  continue;
271  break; /* Found item in cache */
272  }
273 
274  if (i == _url_count) {
275  if (ucx < 0) {
276  ucx = _url_count++;
277  _url_cache = (urlinfo *) xrealloc(_url_cache, sizeof(*_url_cache) * _url_count);
278  }
279  if (_url_cache) /* XXX always true */
280  _url_cache[ucx] = urlLink(u, "_url_cache (miss)");
281  u = urlFree(u, "urlSplit (urlFind miss)");
282  } else {
283  ucx = i;
284  u = urlFree(u, "urlSplit (urlFind hit)");
285  }
286 
287  /* This URL is now cached. */
288 
289  if (_url_cache) /* XXX always true */
290  u = urlLink(_url_cache[ucx], "_url_cache");
291  *uret = u;
292  /*@-usereleased@*/
293  u = urlFree(u, "_url_cache (urlFind)");
294  /*@=usereleased@*/
295 assert(u != NULL);
296 
297  /* Zap proxy host and port in case they have been reset */
298  u->proxyp = -1;
299  u->proxyh = _free(u->proxyh);
300 
301  /* Perform one-time FTP initialization */
302  if (u->ut == URL_IS_FTP) {
303 
304  if (mustAsk || (u->user != NULL && u->password == NULL)) {
305  const char * host = (u->host ? u->host : "");
306  const char * user = (u->user ? u->user : "");
307  char * prompt;
308  prompt = (char *) alloca(strlen(host) + strlen(user) + 256);
309  sprintf(prompt, _("Password for %s@%s: "), user, host);
310  u->password = _free(u->password);
311 /*@-dependenttrans -moduncon @*/
312  u->password = Getpass(prompt);
313 /*@=dependenttrans =moduncon @*/
314  if (u->password)
315  u->password = xstrdup(u->password);
316  }
317 
318  if (u->proxyh == NULL) {
319  const char *proxy = rpmExpand("%{?_ftpproxy}", NULL);
320  if (proxy && *proxy != '\0') {
321 /*@observer@*/
322  const char * host = (u->host ? u->host : "");
323  const char *uu = (u->user ? u->user : "anonymous");
324  char *nu = (char *)xmalloc(strlen(uu) + sizeof("@") + strlen(host));
325  (void) stpcpy( stpcpy( stpcpy(nu, uu), "@"), host);
326  u->proxyu = nu;
327  u->proxyh = xstrdup(proxy);
328  }
329  proxy = _free(proxy);
330  }
331 
332  if (u->proxyp < 0) {
333  const char *proxy = rpmExpand("%{?_ftpport}", NULL);
334  if (proxy && *proxy != '\0') {
335  char *end = NULL;
336  int port = strtol(proxy, &end, 0);
337  if (!(end && *end == '\0')) {
338  fprintf(stderr, _("error: %sport must be a number\n"),
339  (u->scheme ? u->scheme : ""));
340  proxy = _free(proxy);
341  return;
342  }
343  u->proxyp = port;
344  }
345  proxy = _free(proxy);
346  }
347  }
348 
349  /* Perform one-time HTTP initialization */
350  if (u->ut == URL_IS_HTTP || u->ut == URL_IS_HTTPS || u->ut == URL_IS_HKP) {
351 
352  if (u->proxyh == NULL) {
353  const char *proxy = rpmExpand("%{?_httpproxy}", NULL);
354  if (proxy && *proxy != '\0')
355  u->proxyh = xstrdup(proxy);
356  proxy = _free(proxy);
357  }
358 
359  if (u->proxyp < 0) {
360  const char *proxy = rpmExpand("%{?_httpport}", NULL);
361  if (proxy && *proxy != '\0') {
362  char *end;
363  int port = strtol(proxy, &end, 0);
364  if (!(end && *end == '\0')) {
365  fprintf(stderr, _("error: %sport must be a number\n"),
366  (u->scheme ? u->scheme : ""));
367  return;
368  }
369  u->proxyp = port;
370  }
371  proxy = _free(proxy);
372  }
373 
374  }
375 
376  return;
377 }
378 /*@=mods@*/
379 
382 /*@observer@*/ /*@unchecked@*/
383 static struct urlstring {
384 /*@observer@*/ /*@null@*/
385  const char *leadin;
386  size_t len;
388 } urlstrings[] = {
389  { "file://", sizeof("file://")-1, URL_IS_PATH },
390  { "ftp://", sizeof("ftp://")-1, URL_IS_FTP },
391  { "hkp://", sizeof("hkp://")-1, URL_IS_HKP },
392  { "http://", sizeof("http://")-1, URL_IS_HTTP },
393  { "https://", sizeof("https://")-1, URL_IS_HTTPS },
394  { "mongo://", sizeof("mongo://")-1, URL_IS_MONGO },
395  { "mongodb://", sizeof("mongodb://")-1, URL_IS_MONGO },
396 
397  { "git://", sizeof("git://")-1, URL_IS_GIT },
398  { "svn://", sizeof("svn://")-1, URL_IS_SVN },
399  { "sqlite://", sizeof("sqlite://")-1, URL_IS_SQLITE },
400  { "mysql://", sizeof("mysql://")-1, URL_IS_MYSQL },
401  { "postgres://", sizeof("postgres://")-1, URL_IS_POSTGRES },
402  { "mssql://", sizeof("mssql://")-1, URL_IS_SQLSERVER },
403  { "sqlserver://", sizeof("sqlserver://")-1, URL_IS_SQLSERVER },
404 
405  { "-", sizeof("-")-1, URL_IS_DASH },
406  { NULL, 0, URL_IS_UNKNOWN }
407 };
408 
409 urltype urlIsURL(const char * url)
410 {
411  struct urlstring *us;
412  urltype ut = URL_IS_UNKNOWN;;
413 
414  if (url && *url && *url != '/')
415  for (us = urlstrings; us->leadin != NULL; us++) {
416  if (strncmp(url, us->leadin, us->len))
417  continue;
418  ut = us->ret;
419  break;
420  }
421  return ut;
422 }
423 
424 urltype urlType(void * _u)
425 {
426  return (_u != NULL ? ((urlinfo)_u)->ut : URL_IS_UNKNOWN);
427 }
428 
429 /* Return path portion of url (or pointer to NUL if url == NULL) */
430 urltype urlPath(const char * url, const char ** pathp)
431 {
432  static const char empty[] = "";
433  const char *path = (url ? url : empty);
434  urltype ut = URL_IS_UNKNOWN;
435 
436  if (*path != '\0' && *path != '/') {
437  struct urlstring *us;
438  for (us = urlstrings; us->leadin != NULL; us++) {
439  if (strncmp(url, us->leadin, us->len))
440  continue;
441  if ((path = strchr(url+us->len, '/')) == NULL)
442  path = empty;
443  ut = us->ret;
444  break;
445  }
446  }
447 /*@-observertrans@*/
448  if (pathp)
449  *pathp = path;
450 /*@=observertrans@*/
451  return ut;
452 }
453 
457 static const char * urlStrdup(const char * url)
458  /*@*/
459 {
460  size_t nb = strlen(url);
461  char * t = (char *) xmalloc(nb + 1 + 1);
462  const char * nurl = t;
463  while (*url != '\0')
464  *t++ = *url++;
465  *t = '\0';
466  return nurl;
467 }
468 
469 /*
470  * Split URL into components. The URL can look like
471  * scheme://user:password@host:port/path
472  * or as in RFC2732 for IPv6 address
473  * service://user:password@[ip:v6:ad:dr:es:s]:port/path?query#fragment
474  */
475 /*@-modfilesys@*/
476 int urlSplit(const char * url, urlinfo *uret)
477 {
478  urlinfo u;
479  char *myurl;
480  char *s, *se, *f, *fe;
481 
482  if (uret == NULL)
483  return -1;
484  if ((u = urlNew("urlSplit")) == NULL)
485  return -1;
486 
487  myurl = xstrdup(url);
488  if ((se = strrchr(myurl, '#')) != NULL) {
489  *se++ = '\0';
490  u->fragment = xstrdup(se);
491  }
492  if ((se = strrchr(myurl, '?')) != NULL) {
493  *se++ = '\0';
494  u->query = xstrdup(se);
495  }
496 
497  u->url = urlStrdup(myurl); /* XXX +1 byte for pesky trailing '/' */
498  u->ut = urlIsURL(myurl);
499 
500  se = s = myurl;
501  while (1) {
502  /* Point to end of next item */
503  while (*se && *se != '/') se++;
504  /* Item was scheme. Save scheme and go for the rest ...*/
505  if (*se && (se != s) && se[-1] == ':' && se[0] == '/' && se[1] == '/') {
506  se[-1] = '\0';
507  u->scheme = xstrdup(s);
508  se += 2; /* skip over "//" */
509  s = se++;
510  continue;
511  }
512 
513  /* Item was everything-but-path. Continue parse on rest */
514  *se = '\0';
515  break;
516  }
517 
518  /* Look for ...@host... */
519  fe = f = s;
520  while (*fe && *fe != '@') fe++;
521  if (*fe == '@') {
522  s = fe + 1;
523  *fe = '\0';
524  /* Look for user:password@host... */
525  while (fe > f && *fe != ':') fe--;
526  if (*fe == ':') {
527  *fe++ = '\0';
528  u->password = xstrdup(fe);
529  }
530  u->user = xstrdup(f);
531  }
532 
533  /* Look for ...host:port or [v6addr]:port*/
534  fe = f = s;
535  if (strchr(fe, '[') && strchr(fe, ']')) {
536  fe = strchr(f, ']');
537  *f++ = '\0';
538  *fe++ = '\0';
539  }
540 assert(fe != NULL); /* XXX can't happen */
541  while (*fe && *fe != ':') fe++;
542  if (*fe == ':') {
543  *fe++ = '\0';
544  u->portstr = xstrdup(fe);
545  if (u->portstr != NULL && u->portstr[0] != '\0') {
546  char *end;
547  u->port = strtol(u->portstr, &end, 0);
548  if (!(end && *end == '\0')) {
549  rpmlog(RPMLOG_ERR, _("url port must be a number\n"));
550  myurl = _free(myurl);
551  u = urlFree(u, "urlSplit (error #3)");
552  return -1;
553  }
554  }
555  }
556  u->host = xstrdup(f);
557 
558  if (u->port < 0 && u->scheme != NULL) {
559  struct servent *serv;
560 /*@-multithreaded -moduncon @*/
561  /* HACK hkp:// might lookup "pgpkeyserver" */
562  serv = getservbyname(u->scheme, "tcp");
563 /*@=multithreaded =moduncon @*/
564  if (serv != NULL)
565  u->port = (int) ntohs(serv->s_port);
566  else if (u->ut == URL_IS_FTP)
567  u->port = IPPORT_FTP;
568  else if (u->ut == URL_IS_HKP)
570  else if (u->ut == URL_IS_HTTP)
571  u->port = IPPORT_HTTP;
572  else if (u->ut == URL_IS_HTTPS)
573  u->port = IPPORT_HTTPS;
574  else if (u->ut == URL_IS_MONGO)
575  u->port = IPPORT_MONGO;
576 
577 #ifdef NOTYET
578 #define URL_IS_GIT
579 #define URL_IS_SVN
580 #define URL_IS_SQLITE
581 #define URL_IS_MYSQL
582 #define URL_IS_POSTGRES
583 #endif
584 
585  }
586 
587  myurl = _free(myurl);
588  if (uret) {
589  *uret = u;
590 /*@-globs -mods @*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
591  urlFind(uret, 0);
592 /*@=globs =mods @*/
593  }
594  return 0;
595 }
596 /*@=modfilesys@*/
597 
598 int urlGetFile(const char * url, const char * dest)
599 {
600  int rc;
601  FD_t sfd = NULL;
602  FD_t tfd = NULL;
603  const char * sfuPath = NULL;
604  int urlType = urlPath(url, &sfuPath);
605  char *result;
606 
607  if (*sfuPath == '\0')
608  return FTPERR_UNKNOWN;
609 
610  if (dest == NULL) {
611  if ((dest = strrchr(sfuPath, '/')) != NULL)
612  dest++;
613  else
614  dest = sfuPath;
615  }
616  if (dest == NULL)
617  return FTPERR_UNKNOWN;
618 
619 /*@-globs -mods@*/ /* Avoid including <rpmmacro.h> everywhere for now */
620  if (rpmExpandNumeric("%{?__urlgetfile:1}%{!?__urlgetfile:0}")) {
621  result = rpmExpand("%{__urlgetfile ", url, " ", dest, "}", NULL);
622  if (result != NULL && strcmp(result, "OK") == 0)
623  rc = 0;
624  else {
625  rpmlog(RPMLOG_DEBUG, D_("failed to fetch URL %s via external command\n"), url);
626  rc = FTPERR_UNKNOWN;
627  }
628  result = _free(result);
629  goto exit;
630  }
631 /*@=globs =mods@*/
632 
633  sfd = Fopen(url, "r.ufdio");
634  if (sfd == NULL || Ferror(sfd)) {
635  rpmlog(RPMLOG_DEBUG, D_("failed to open %s: %s\n"), url, Fstrerror(sfd));
636  rc = FTPERR_UNKNOWN;
637  goto exit;
638  }
639 
640  /* XXX this can fail if directory in path does not exist. */
641  tfd = Fopen(dest, "w");
642 if (_url_debug)
643 fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : NULL), dest);
644  if (tfd == NULL || Ferror(tfd)) {
645  rpmlog(RPMLOG_DEBUG, D_("failed to create %s: %s\n"), dest, Fstrerror(tfd));
646  rc = FTPERR_UNKNOWN;
647  goto exit;
648  }
649 
650  switch (urlType) {
651  case URL_IS_HTTPS:
652  case URL_IS_HTTP:
653  case URL_IS_HKP:
654  case URL_IS_FTP:
655  case URL_IS_PATH:
656  case URL_IS_DASH:
657  case URL_IS_UNKNOWN:
658  if ((rc = ufdGetFile(sfd, tfd))) {
659  (void) Unlink(dest);
660  /* XXX FIXME: sfd possibly closed by copyData */
661  /*@-usereleased@*/ (void) Fclose(sfd) /*@=usereleased@*/ ;
662  }
663  sfd = NULL; /* XXX Fclose(sfd) done by ufdGetFile */
664  break;
665  case URL_IS_MONGO: /* XXX FIXME */
666  default:
667  rc = FTPERR_UNKNOWN;
668  break;
669  }
670 
671 exit:
672  if (tfd)
673  (void) Fclose(tfd);
674  if (sfd)
675  (void) Fclose(sfd);
676 
677  return rc;
678 }
FDIO_t fdio
Definition: rpmio.c:578
int(* urlNotify)(const urlinfo u, unsigned status)
Definition: url.c:54
urlinfo * _url_cache
Definition: url.c:82
const char * scheme
Definition: rpmurl.h:57
rpmop sop
Definition: rpmurl.h:109
FD_t data
Definition: rpmurl.h:80
const char int port
Definition: mongo.h:251
static void * fdGetFp(FD_t fd)
const char * password
Definition: rpmurl.h:61
const char * user
Definition: rpmurl.h:59
enum urltype_e urltype
Supported URL types.
static const char * urlStrdup(const char *url)
Copy a URL, adding extra byte for the pesky trailing '/'.
Definition: url.c:457
void yarnPossess(yarnLock bolt)
Definition: yarn.c:262
struct urlinfo_s * urlinfo
Definition: rpmurl.h:37
long yarnPeekLock(yarnLock bolt)
Definition: yarn.c:325
char * xstrdup(const char *str)
Definition: rpmmalloc.c:321
void * urlNotifyArg
Definition: url.c:61
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
Definition: rpmio.c:2840
URL control structure.
Definition: rpmurl.h:52
urlinfo urlNew(const char *msg)
Create a URL control structure instance.
#define RPMURL_SERVER_HASRANGE
Definition: rpmurl.h:119
rpmioItem rpmioLinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Increment a pool item refcount.
Definition: rpmmalloc.c:165
#define URL_IS_GIT
Definition: rpmurl.h:25
int _url_iobuf_size
Definition: url.c:66
void * rpmioFreePoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Free a pool item.
Definition: rpmmalloc.c:186
#define RPMURL_IOBUF_SIZE
Definition: rpmurl.h:147
static void fdPush(FD_t fd, FDIO_t io, void *fp, int fdno)
static void urlFind(urlinfo *uret, int mustAsk)
Definition: url.c:236
static void rpmlog(int code, const char *fmt,...)
Definition: rpmlog.h:299
const char * location
Definition: rpmurl.h:90
const char * portstr
Definition: rpmurl.h:65
static struct urlstring urlstrings[]
const char * host
Definition: rpmurl.h:63
#define IPPORT_PGPKEYSERVER
Definition: url.c:36
const char * query
Definition: rpmurl.h:67
char * alloca()
int port
Definition: rpmurl.h:75
const char * url
Definition: rpmurl.h:55
const char * Fstrerror(FD_t fd)
strerror(3) clone.
Definition: rpmio.c:2401
void * xcalloc(size_t nmemb, size_t size)
Definition: rpmmalloc.c:300
const char * proxyu
Definition: rpmurl.h:71
fdio_close_function_t close
Definition: rpmio.h:115
struct _FD_s * FD_t
Definition: rpmio.h:47
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
Definition: rpmmalloc.c:220
int davFree(urlinfo u)
Free persistent neon session state.
#define IPPORT_FTP
Definition: url.c:27
urltype urlIsURL(const char *url)
Return type of URL.
Definition: url.c:409
int _url_count
Definition: url.c:155
void * arg
Definition: rpmurl.h:96
rpmop rop
Definition: rpmurl.h:107
The FD_t File Handle data structure.
const char const char * user
Definition: mongo.h:828
struct rpmioItem_s _item
Definition: rpmurl.h:53
int allow
Definition: rpmurl.h:118
int bufAlloced
Definition: rpmurl.h:113
char * buf
Definition: rpmurl.h:115
FD_t ctrl
Definition: rpmurl.h:78
urltype urlType(void *_u)
Definition: url.c:424
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Definition: macro.c:3252
struct rpmop_s * rpmop
Definition: rpmsw.h:24
#define IPPORT_HTTP
Definition: url.c:30
int proxyp
Definition: rpmurl.h:74
urltype ret
Definition: url.c:387
const char * proxyh
Definition: rpmurl.h:73
#define URL_IS_SQLSERVER
Definition: rpmurl.h:30
const char * host
Definition: mongo.h:251
urltype ut
Definition: rpmurl.h:76
size_t len
Definition: url.c:386
static int fdFileno(void *cookie)
int Fclose(FD_t fd)
fclose(3) clone.
Definition: rpmio.c:2534
Cumulative statistics for an operation.
Definition: rpmsw.h:39
void yarnRelease(yarnLock bolt)
Definition: yarn.c:270
int ufdGetFile(FD_t sfd, FD_t tfd)
Definition: rpmio.c:1661
static urlinfo urlGetPool(rpmioPool pool)
Definition: url.c:160
rpmioPool _urlPool
Definition: url.c:158
int Ferror(FD_t fd)
ferror(3) clone.
Definition: rpmio.c:2951
const char const int i
Definition: bson.h:778
int urlSplit(const char *url, urlinfo *uret)
Parse URL string into a control structure.
Definition: url.c:476
int _url_debug
Definition: url.c:71
unsigned magic
Definition: rpmurl.h:127
int httpVersion
Definition: rpmurl.h:117
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
Definition: rpmmalloc.c:109
char * stpcpy(char *dest, const char *src)
int urlGetFile(const char *url, const char *dest)
Copy data from URL to local file.
Definition: url.c:598
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: rpmiotypes.h:756
const char * leadin
Definition: url.c:385
static int urlStrcmp(const char *str1, const char *str2)
Definition: url.c:224
#define URL_IS_POSTGRES
Definition: rpmurl.h:29
#define URL_IS_SVN
Definition: rpmurl.h:26
int(* notify)(const urlinfo u, unsigned status)
Definition: rpmurl.h:94
#define URLSANE(u)
Definition: rpmurl.h:33
Definition: url.c:383
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
Definition: url.c:430
#define URL_IS_SQLITE
Definition: rpmurl.h:27
#define _(Text)
Definition: system.h:29
const char * fragment
Definition: rpmurl.h:69
const char * etag
Definition: rpmurl.h:92
#define xmalloc
Definition: system.h:32
#define IPPORT_MONGO
Definition: url.c:39
#define IPPORT_HTTPS
Definition: url.c:33
#define D_(Text)
Definition: system.h:526
urlinfo urlFree(urlinfo u, const char *msg)
Dereference a URL control structure instance.
#define URL_IS_MYSQL
Definition: rpmurl.h:28
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3326
void urlFreeCache(void)
Free cached URL control structures.
Definition: url.c:202
urlinfo XurlNew(const char *msg, const char *fn, unsigned ln)
Definition: url.c:176
#define xrealloc
Definition: system.h:35
rpmop top
Definition: rpmurl.h:111
static void urlFini(void *_u)
Definition: url.c:84
FDIO_t fpio
Definition: rpmio.c:3395
char *(* Getpass)(const char *prompt)
Return a password.
Definition: rpmku.c:154
int Unlink(const char *path)
unlink(2) clone.
Definition: rpmrpc.c:397
urlinfo urlLink(urlinfo u, const char *msg)
Reference a URL control structure instance.
#define URLMAGIC
Definition: rpmurl.h:32