123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #ifndef SLAC_AVERAGE_SOURCE
- #define SLAC_AVERAGE_SOURCE
- #include "../tools/error.h"
- #include "../tools/flags.h"
- #include "../tools/memory.h"
- #include "../slac/slac.h"
- signed slac_connect (struct session * session)
- {
- unsigned group = 0;
- unsigned total = 0;
- if (session->NumGroups > SIZEOF (session->AAG))
- {
- return (slac_debug (session, session->exit, __func__, "Too much data to analyse!"));
- }
- if (session->NumGroups > 0)
- {
- char string [512];
- while (group < session->NumGroups)
- {
- total += session->AAG [group];
- group++;
- }
- total /= group;
- if (total > session->limit)
- {
- char string [512];
- slac_debug (session, 0, __func__, "Average attenuation (%u) more than limit (%u) frow %d groups", total, session->limit, group);
- slac_debug (session, 0, __func__, "%s", HEXSTRING (string, session->AAG));
- return (- 1);
- }
- if (total > 0)
- {
- slac_debug (session, 0, __func__, "Average attenuation (%u) less than limit (%u) from %d groups", total, session->limit, group);
- slac_debug (session, 0, __func__, "%s", HEXSTRING (string, session->AAG));
- return (0);
- }
- }
- return (slac_debug (session, session->exit, __func__, "Nothing to analyse"));
- }
- #endif
|