Browse Source

change case_*b from char* to void* so it is function pointer compatible

to byte_*
master
Felix von Leitner 18 years ago
parent
commit
fae591cfae
  1. 4
      case.h
  2. 2
      case/case_diffb.3
  3. 4
      case/case_diffb.c
  4. 2
      case/case_lowerb.3
  5. 3
      case/case_lowerb.c
  6. 9
      test/dllink.c

4
case.h

@ -4,12 +4,12 @@
/* turn upper case letters to lower case letters, ASCIIZ */
extern void case_lowers(char *s);
/* turn upper case letters to lower case letters, binary */
extern void case_lowerb(char *buf,unsigned long len);
extern void case_lowerb(void *buf,unsigned long len);
/* like str_diff, ignoring case */
extern int case_diffs(const char *,const char *);
/* like byte_diff, ignoring case */
extern int case_diffb(const char *,unsigned long,const char *);
extern int case_diffb(const void *,unsigned long,const void *);
/* like str_start, ignoring case */
extern int case_starts(const char *,const char *);

2
case/case_diffb.3

@ -4,7 +4,7 @@ case_diffb \- compare strings case-insensitively
.SH SYNTAX
.B #include <case.h>
int \fBcase_diffb\fP(const char* \fIa\fR,unsigned long \fIlen\fR,const char* \fIb\fR);
int \fBcase_diffb\fP(const void* \fIa\fR,unsigned long \fIlen\fR,const void* \fIb\fR);
.SH DESCRIPTION
case_diffb is similar to byte_diff. The difference is that for the
comparison 'A' == 'a', 'B' == 'b', ..., 'Z' == 'z'.

4
case/case_diffb.c

@ -1,9 +1,11 @@
#include "case.h"
int case_diffb(register const char *s,register unsigned long len,register const char *t)
int case_diffb(register const void* S,register unsigned long len,register const void* T)
{
register unsigned char x;
register unsigned char y;
register const char* s=(const char*)S;
register const char* t=(const char*)T;
while (len > 0) {
--len;

2
case/case_lowerb.3

@ -4,7 +4,7 @@ case_lowerb \- compare strings case-insensitively
.SH SYNTAX
.B #include <case.h>
void \fBcase_lowerb\fP(char* \fIs\fR,unsigned long \fIlen\fR);
void \fBcase_lowerb\fP(void* \fIs\fR,unsigned long \fIlen\fR);
.SH DESCRIPTION
case_lowerb converts each 'A' to 'a', 'B' to 'b', ..., 'Z' to 'z' in
\fIs\fR[0], \fIs\fR[1], ..., \fIs\fR[\fIlen\fR].

3
case/case_lowerb.c

@ -1,6 +1,7 @@
#include "case.h"
void case_lowerb(char *s,unsigned long len) {
void case_lowerb(void *S,unsigned long len) {
char* s=(char*)S;
unsigned char x;
while (len > 0) {
--len;

9
test/dllink.c

@ -4,6 +4,7 @@
#include "buffer.h"
#include <unistd.h>
#include <stdio.h>
#include "case.h"
main(int argc,char* argv[]) {
int s=socket_tcp4();
@ -22,7 +23,13 @@ main(int argc,char* argv[]) {
perror("connect");
return 1;
}
strcpy(buf,"dllink "); strcat(buf,argv[1]); strcat(buf,"\nq\n");
strcpy(buf,"dllink ");
if (case_equalb(argv[1],6,"ed2k:|")) {
strcat(buf,"ed2k://");
strcat(buf,argv[1]+5);
} else
strcat(buf,argv[1]);
strcat(buf,"\nq\n");
write(s,buf,strlen(buf));
for (;;) {
line[0]=0;

Loading…
Cancel
Save