Search squid archive

Re: running squid on VERY low-end devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>     i have written a small external helper in perl and it seems to do the trick.
> 
> --------------------------------
> #!/usr/bin/microperl
> 
> while () {
> 
>         ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, 
> $dayOfYear, $daylightSavings) = localtime();
>         $year =3D 1900 + $yearOffset;
> 
>         if ($year < 2008) {
>                 print "ERR\n";
>         } else {
>                 print "OK\n";
>         }
> }
> --------------------------------
> 
>     i know perl isnt the most optimized language .... but as the= external acl 
> is started on squid startup and keeps running until squid exits, i dont think 
> that will be a problem.
> 
>     anyway, i would love to see something similar in C that could be compiled 
> and run with less memory than perl requires .... unfortunelly i cant code even a 
> 'hello world' in C !!! But i'll try that ..... shouldnt be too difficult.

Here's a basic C example:

#include <stdio.h>
#include <time.h>

#define INPUTSIZE 256

int main(int argc, char *argv[]) {

  char input[INPUTSIZE];
  char *cp;
  struct tm *local;
  time_t t;
  int year;

  while (fgets(input, sizeof(input), stdin)) {
    t = time(NULL);
    local = localtime(&t);
    year = local->tm_year + 1900;
    if (year < 2008) { printf("ERR\n"); } else { printf("OK\n"); }
    fflush(stdout);
  }

}

JD

PS: I put a "small" INPUTSIZE and do not check for overflow...


      


[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux