home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 6
/
AACD06.ISO
/
AACD
/
Online
/
Dial
/
source
/
listhooks.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-22
|
2KB
|
91 lines
#include <libraries/locale.h>
#include <utility/hooks.h>
#include <strings.h>
#include <clib/utility_protos.h>
#include "cat.h"
extern struct Locale *locale;
struct ListEntry
{
char Name[64];
char Number[64];
};
struct CallByCallEntry
{
char Pattern[64];
char Number[64];
};
APTR list_dsplfunc(struct Hook *a0, APTR *a2, APTR a1)
{
if (a1)
{
*a2++=((struct ListEntry*)a1)->Name;
*a2=((struct ListEntry*)a1)->Number;
}
else
{
*a2++=GetString(MSG_Name);
*a2=GetString(MSG_Number);
}
return NULL;
}
APTR list_cmpfunc(struct Hook *a0, APTR a2, APTR a1)
{
if (locale)
return (APTR)StrnCmp(locale, a1, a2, -1, SC_COLLATE2); /* use locale comparison, if available */
else
return (APTR)Stricmp(a1,a2); /* directly compare structure, because Name-String is first entry */
}
APTR list_consfunc(struct Hook *a0, APTR a2, APTR a1)
{
struct ListEntry *NewEntry = (struct ListEntry*)malloc(sizeof(struct ListEntry));
memcpy(NewEntry, a1, sizeof(struct ListEntry));
return NewEntry;
}
APTR list_desfunc(struct Hook *a0, APTR a2, APTR a1)
{
free(a1);
}
/* CallByCall Listview */
APTR cbc_dsplfunc(struct Hook *a0, APTR *a2, APTR a1)
{
if (a1)
{
*a2++=((struct CallByCallEntry*)a1)->Pattern;
*a2=((struct CallByCallEntry*)a1)->Number;
}
else
{
*a2++=GetString(MSG_PATTERN);
*a2=GetString(MSG_Number);
}
return NULL;
}
APTR cbc_cmpfunc(struct Hook *a0, APTR a2, APTR a1)
{
return (APTR)(strlen(a2)-strlen(a1));
}
APTR cbc_consfunc(struct Hook *a0, APTR a2, APTR a1)
{
struct CallByCallEntry *NewEntry = (struct ListEntry*)malloc(sizeof(struct CallByCallEntry));
memcpy(NewEntry, a1, sizeof(struct CallByCallEntry));
return NewEntry;
}