/[LeafOK_CVS]/pvpgn-1.7.4/src/common/proginfo.c
ViewVC logotype

Contents of /pvpgn-1.7.4/src/common/proginfo.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

1 /*
2 * Copyright (C) 2000 Rob Crittenden (rcrit@greyoak.com)
3 * Copyright (C) 2001 Ross Combs (ross@bnetd.org)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 #include "common/setup_before.h"
20 #include <stdio.h>
21 #ifdef HAVE_STDDEF_H
22 # include <stddef.h>
23 #else
24 # ifndef NULL
25 # define NULL ((void *)0)
26 # endif
27 #endif
28 #ifdef STDC_HEADERS
29 # include <stdlib.h>
30 #endif
31 #include "compat/strtoul.h"
32 #ifdef HAVE_STRING_H
33 # include <string.h>
34 #else
35 # ifdef HAVE_STRINGS_H
36 # include <strings.h>
37 # endif
38 #endif
39 #include "compat/strchr.h"
40 #include "common/proginfo.h"
41 #include "common/setup_after.h"
42
43
44 extern int verparts_to_vernum(unsigned short v1, unsigned short v2, unsigned short v3, unsigned short v4, unsigned long * vernum)
45 {
46 if (!vernum)
47 return -1;
48
49 *vernum = (((unsigned long)v4)<<24) |
50 (((unsigned long)v3)<<16) |
51 (((unsigned long)v2)<< 8) |
52 (((unsigned long)v1) );
53 return 0;
54 }
55
56
57 extern int verstr_to_vernum(char const * verstr, unsigned long * vernum)
58 {
59 unsigned long v1,v2,v3,v4;
60
61 if (!vernum)
62 return -1;
63
64 if (strchr(verstr,'.'))
65 {
66 int count;
67
68 count = sscanf(verstr,"%lu.%lu.%lu.%lu",&v4,&v3,&v2,&v1);
69 if (count<4)
70 {
71 v1 = 0;
72 if (count<3)
73 {
74 v2 = 0;
75 if (count<2)
76 return -1; /* no data */
77 }
78 }
79 }
80 else
81 {
82 unsigned long temp;
83
84 temp = strtoul(verstr,NULL,10);
85 v4 = (temp/100);
86 v3 = (temp/ 10)%10;
87 v2 = (temp )%10;
88 v1 = 0;
89 }
90
91 if (v1>255 || v2>255 || v3>255 || v4>255)
92 return -1;
93 *vernum = (v4<<24) | (v3<<16) | (v2<< 8) | (v1 );
94 return 0;
95 }
96
97
98 extern char const * vernum_to_verstr(unsigned long vernum)
99 {
100 static char verstr[16];
101
102 sprintf(verstr,"%lu.%lu.%lu.%lu",
103 (vernum>>24) ,
104 (vernum>>16)&0xff,
105 (vernum>> 8)&0xff,
106 (vernum )&0xff);
107 return verstr;
108 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1