Skip to content

Commit

Permalink
added scan_short function
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhangui committed May 27, 2024
1 parent 7793c26 commit 53ad812
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ COMMONSOURCES = base/alloc.c base/alloc_re.c base/allwrite.c base/arc4random.c \
base/scan_double.c base/scan_fromhex.c base/scan_int.c base/scan_long.c \
base/scan_plusminus.c base/scan_uint.c base/scan_ulong.c \
base/scan_ulonglong.c base/scan_ushort.c base/scan_xlong.c \
base/sconfig.c base/seek_cur.c base/seek_end.c \
base/scan_short.c base/sconfig.c base/seek_cur.c base/seek_end.c \
base/seek_set.c base/seek_trunc.c base/setuserid.c base/sgetopt.c \
base/sha256_crypt.c base/sha512_crypt.c base/sig.c base/sig_alarm.c \
base/sig_block.c base/sig_bug.c base/sig_catch.c base/sig_child.c \
Expand Down
52 changes: 30 additions & 22 deletions base/scan.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
/*
* $Log: scan.h,v $
* Revision 1.10 2023-02-08 11:23:04+05:30 Cprogrammer
* include qmailconfig.h if HAVE_CONFIG_H is not defined
*
* Revision 1.9 2020-11-22 23:52:02+05:30 Cprogrammer
* use const keyword
*
* Revision 1.8 2020-07-23 11:27:48+05:30 Cprogrammer
* added scan_double(), scan_hexdump() prototyps
*
* Revision 1.7 2020-07-01 12:14:40+05:30 Cprogrammer
* added scan_fromhex()
*
* Revision 1.6 2019-06-24 21:26:25+05:30 Cprogrammer
* added scan_ulonglong, scan_plusminus prototypes
*
* Revision 1.5 2004-10-11 14:01:40+05:30 Cprogrammer
* added function prototypes
*
* Revision 1.4 2004-06-18 23:01:43+05:30 Cprogrammer
* added RCS log
*
* $Id: scan.h,v 1.11 2024-05-27 08:01:25+05:30 Cprogrammer Exp mbhangui $
*/
#ifndef SCAN_H
#define SCAN_H
Expand All @@ -42,9 +21,38 @@ unsigned int scan_xlong(const char *, unsigned long *);
unsigned int scan_long(const char *, long *);
unsigned int scan_8long(const char *, unsigned long *);
unsigned int scan_int(const char *, int *);
unsigned int scan_short(const char *, short *);
unsigned int scan_plusminus(const char *, int *);
int scan_fromhex(unsigned char c);
unsigned int scan_double(const char *, double *);
size_t scan_hexdump(const char *, char *, size_t *);

#endif

/*
* $Log: scan.h,v $
* Revision 1.11 2024-05-27 08:01:25+05:30 Cprogrammer
* added scan_short function
*
* Revision 1.10 2023-02-08 11:23:04+05:30 Cprogrammer
* include qmailconfig.h if HAVE_CONFIG_H is not defined
*
* Revision 1.9 2020-11-22 23:52:02+05:30 Cprogrammer
* use const keyword
*
* Revision 1.8 2020-07-23 11:27:48+05:30 Cprogrammer
* added scan_double(), scan_hexdump() prototyps
*
* Revision 1.7 2020-07-01 12:14:40+05:30 Cprogrammer
* added scan_fromhex()
*
* Revision 1.6 2019-06-24 21:26:25+05:30 Cprogrammer
* added scan_ulonglong, scan_plusminus prototypes
*
* Revision 1.5 2004-10-11 14:01:40+05:30 Cprogrammer
* added function prototypes
*
* Revision 1.4 2004-06-18 23:01:43+05:30 Cprogrammer
* added RCS log
*
*/
61 changes: 61 additions & 0 deletions base/scan_short.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* $Id: scan_short.c,v 1.1 2024-05-27 08:01:13+05:30 Cprogrammer Exp mbhangui $
*/
#include "scan.h"

unsigned int
scan_short(register const char *s, register short *i)
{
register unsigned int pos;
register short result;
register unsigned char c;
short sign;

/*-
* determine sign of the number
*/
for (pos = result = 0, sign = 1; s[pos] && (s[pos] == ' ' || s[pos] == '\t'); pos++);
switch (s[pos])
{
case '\0':
return 0;
case '-':
++pos;
sign = -1;
break;
case '+':
++pos;
sign = 1;
break;
default:
if ((s[pos] - '0') >= 10) {
*i = 0;
return pos;
}
break;
}
for (; s[pos]; pos++) {
if ((c = (unsigned char)(s[pos] - '0')) >= 10) {
*i = result * sign;
return pos;
}
result = result * 10 + c;
}
*i = result * sign;
return pos;
}

void
getversion_scan_short_c()
{
const char *x = "$Id: scan_short.c,v 1.1 2024-05-27 08:01:13+05:30 Cprogrammer Exp mbhangui $";

x++;
}

/*
* $Log: scan_short.c,v $
* Revision 1.1 2024-05-27 08:01:13+05:30 Cprogrammer
* Initial revision
*
*/
2 changes: 1 addition & 1 deletion conf-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3
1.4
27 changes: 16 additions & 11 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
* XXX XXX XX XXXX XX:XX:XX +0000 @email@ @version@-@release@%{?dist}
Release @version@-@release@ Start 29/04/2024 End XX/XX/XXXX
01. envdir.c: handle symbolic links to .envdir and .envfile correctly
- 29/04/2024
02. tryshsgr.c, tryulong32.c, tryulong64.c: fix compiler warnings
- 09/05/2024
03. fix discarded-qualifier compiler warnings
- 12/05/2024
04. fix function prototypes
- 17/05/2024
05. mkpasswd.c, qdirname.c: fix discarded-qualifier-warnings
- 23/05/2024
06. added wildmat function
- 27/05/2024
07. scan_short.c: added scan_short function

* Sun Mar 03 2024 15:44:18 +0000 Manvendra Bhangui <libqmail@indimail.org> 1.3-1.1%{?dist}
Release 1.3-1.1 Start 30/11/2023 End 03/02/2024
- 30/11/2023
Expand All @@ -15,17 +31,6 @@ Release 1.3-1.1 Start 30/11/2023 End 03/02/2024
06. timeoutread.c, timeoutwrite.c: added version using poll() instead of
select() - taken from Erwin Hofman's fehQlibs
- 31/01/2024
07. envdir.c: handle symbolic links to .envdir and .envfile correctly
- 29/04/2024
08. tryshsgr.c, tryulong32.c, tryulong64.c: fix compiler warnings
- 09/05/2024
09. fix discarded-qualifier compiler warnings
- 12/05/2024
10. fix function prototypes
- 17/05/2024
11. mkpasswd.c, qdirname.c: fix discarded-qualifier-warnings
- 23/05/2024
12. added wildmat function

* Fri Sep 08 2023 12:40:38 +0530 Manvendra Bhangui <libqmail@indimail.org> 1.2-1.1%{?dist}
Release 1.2-1.1 Start 24/04/2023 End 08/09/2023
Expand Down

0 comments on commit 53ad812

Please sign in to comment.