]> cygwin.com Git - cygwin-apps/setup.git/blob - package_source.cc
2001-11-26 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[cygwin-apps/setup.git] / package_source.cc
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
16 /* this is the parent class for all package source (not source code - installation
17 * source as in http/ftp/disk file) operations.
18 */
19
20 #if 0
21 static const char *cvsid =
22 "\n%%% $Id$\n";
23 #endif
24
25 #include <stdlib.h>
26 #include <strings.h>
27 #include "package_source.h"
28
29 void
30 packagesource::set_canonical (char const *fn)
31 {
32 canonical = new char[strlen (fn) + 1];
33 strcpy (canonical,fn);
34
35 /* The base is from the last '/' to the first following '.' */
36 char const *bstart = strchr (fn, '/');
37 char const *tmp;
38 while (bstart && (tmp = strchr (bstart, '/')))
39 bstart = tmp;
40
41 if (!bstart)
42 bstart = fn;
43 char const *bend = strchr (bstart, '.');
44 if (!bend)
45 bend = strchr (bstart, '\0');
46 char const *end = strchr (fn ,'\0');
47 base = new char [bend-bstart+1];
48 memcpy (base,bstart, bend-bstart);
49 base [bend-bstart] = '\0';
50
51 filename = new char [end - bstart+1];
52 memcpy (filename, bstart, end-bstart);
53 filename[end-bstart] = '\0';
54
55 if (cached)
56 delete cached;
57 cached = 0;
58 }
59
This page took 0.040989 seconds and 6 git commands to generate.