]> cygwin.com Git - cygwin-apps/setup.git/blame - package_source.cc
2002-07-15 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / package_source.cc
CommitLineData
7939f6d1
RC
1/*
2 * Copyright (c) 2001, Robert Collins.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
fa0c0d10
RC
16/* this is the parent class for all package source (not source code - installation
17 * source as in http/ftp/disk file) operations.
7939f6d1
RC
18 */
19
20#if 0
21static const char *cvsid =
22 "\n%%% $Id$\n";
23#endif
bb849dbd
RC
24
25#include <stdlib.h>
26#include <strings.h>
27#include "package_source.h"
28
3c054baf 29site::site (String const &newkey) : key(newkey)
a900d1fa 30{
a900d1fa
RC
31};
32
bb849dbd
RC
33void
34packagesource::set_canonical (char const *fn)
35{
36 if (canonical)
341988b9 37 delete[] canonical;
bb849dbd
RC
38 canonical = new char[strlen (fn) + 1];
39 strcpy (canonical, fn);
40
41 /* The base is from the last '/' to the first '.' following the last - */
42 char const *bstart = strchr (fn, '/');
43 char const *tmp;
44 while (bstart && (tmp = strchr (bstart + 1, '/')))
45 bstart = tmp;
46
47 if (!bstart)
48 bstart = fn;
49 char const *bend = strchr (bstart, '-');
50 while (bend && (tmp = strchr (bend + 1, '-')))
51 bend = tmp;
52 if (bend)
53 bend = strchr (bend, '.');
54 else
55 bend = strchr (bstart, '.');
56
57 if (!bend)
58 bend = strchr (bstart, '\0');
59 char const *end = strchr (fn, '\0');
60 if (base)
341988b9 61 delete[] base;
bb849dbd
RC
62 base = new char[bend - bstart];
63 memcpy (base, bstart + 1, bend - bstart - 1);
64 base[bend - bstart - 1] = '\0';
65
66 if (filename)
341988b9 67 delete[] filename;
071c1c54
RC
68 filename = new char[end - bstart];
69 memcpy (filename, bstart + 1, end - bstart - 1);
70 filename[end - bstart - 1] = '\0';
bb849dbd 71
3c054baf 72 cached = String();
bb849dbd
RC
73}
74
75void
3c054baf 76packagesource::set_cached (String const &fp)
bb849dbd 77{
3c054baf 78 cached = fp;
bb849dbd 79}
This page took 0.037207 seconds and 5 git commands to generate.