Changeset 70 for trunk/oscam.c


Ignore:
Timestamp:
05/12/09 05:25:27 (12 years ago)
Author:
rorothetroll
Message:

csctapi/io_serial.c : fix the serial port read/write wait routine to use select instead of poll

This make them compatible with Mac OS X and now oscamd works on OS X. The same code off course
still works on linux and other unix platforms. I let that code ran for 24h before commiting this code.
If you have any issue let me know and I'llr evert to poll for non compatible machines.

all the others : fix all the warning due to sign difference (mostly uchar versus char). This make the code compile

with -Werror on the more strict version of gcc (which is the case on OS X). I also noticed that in a lot of places
the code use a buffer defined as an uchar * ... and use strings functions (strnXXXX) where some memcpy/memcmp .. function
would have been preferable as we're suposedly manipulation a binary buffer. Anyway I fixed all of them and it now compile
without any warning or error on linux and OS X (and also probably on all the other unices but we will have to try before
adding -Werror on the other platform).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oscam.c

    r56 r70  
    153153
    154154#ifdef NEED_DAEMON
     155#ifdef OS_MACOSX
     156// this is done because daemon is being deprecated starting with 10.5 and -Werror will always trigger an error
     157static int daemon_compat(int nochdir, int noclose)
     158#else
    155159static int daemon(int nochdir, int noclose)
     160#endif
    156161{
    157162  int fd;
     
    337342
    338343      if (account &&
    339           client[i].pcrc==crc32(0L, MD5(account->pwd, strlen(account->pwd), NULL), 16))
     344          client[i].pcrc==crc32(0L, MD5((uchar *)account->pwd, strlen(account->pwd), NULL), 16))
    340345      {
    341346        client[i].grp     = account->grp;
     
    840845      if (account->dyndns[0])
    841846      {
    842         if (rht=gethostbyname(account->dyndns))
     847        if (rht=gethostbyname((const char *)account->dyndns))
    843848        {
    844849          memcpy(&udp_sa.sin_addr, rht->h_addr, sizeof(udp_sa.sin_addr));
     
    9951000static void init_service(int srv)
    9961001{
     1002#ifdef USE_PTHREAD
     1003   uchar dummy[1]={0x00};
     1004#endif
     1005
    9971006  switch(cs_fork(0, srv))
    9981007  {
     
    10081017        case 96: start_anticascader();
    10091018#endif
     1019#ifdef USE_PTHREAD
     1020        case 97: cs_logger(dummy);
     1021#else
    10101022        case 97: cs_logger();
     1023#endif
    10111024        case 98: start_resolver();
    10121025      }
     
    10861099          client[cs_idx].sidtabok= account->sidtabok;   // services
    10871100          client[cs_idx].sidtabno= account->sidtabno;   // services
    1088           client[cs_idx].pcrc  = crc32(0L, MD5(account->pwd, strlen(account->pwd), NULL), 16);
     1101          client[cs_idx].pcrc  = crc32(0L, MD5((uchar *)account->pwd, strlen(account->pwd), NULL), 16);
    10891102          memcpy(&client[cs_idx].ttab, &account->ttab, sizeof(client[cs_idx].ttab));
    10901103#ifdef CS_ANTICASC
     
    18861899
    18871900  if (cfg->nice!=99)
    1888     sprintf(buf, ", nice=%d", cfg->nice);
     1901    sprintf((char *)buf, ", nice=%d", cfg->nice);
    18891902  else
    18901903    buf[0]='\0';
    1891   cs_log("version=%s, system=%s%s", CS_VERSION_X, cs_platform(buf+64), buf);
     1904  cs_log("version=%s, system=%s%s", CS_VERSION_X, cs_platform((char *)buf+64), buf);
    18921905  cs_log("max. clients=%d, client max. idle=%d sec",
    18931906#ifdef CS_ANTICASC
     
    18971910#endif
    18981911  if( cfg->max_log_size )
    1899     sprintf(buf, "%d Kb", cfg->max_log_size);
     1912    sprintf((char *)buf, "%d Kb", cfg->max_log_size);
    19001913  else
    1901     strcpy(buf, "unlimited");
     1914    strcpy((char *)buf, "unlimited");
    19021915  cs_log("max. logsize=%s", buf);
    19031916  cs_log("client timeout=%d sec, cache delay=%d msec",
     
    19851998  gfd=mfdr+1;
    19861999
     2000#ifdef OS_MACOSX
     2001  if (bg && daemon_compat(1,0))
     2002#else
    19872003  if (bg && daemon(1,0))
     2004#endif
    19882005  {
    19892006    cs_log("Error starting in background (errno=%d)", errno);
     
    20712088            {
    20722089              cs_set_mloc(-1, "event: udp-socket");
    2073               if ((n=recvfrom(ph[i].ptab->ports[j].fd, buf+3, sizeof(buf)-3, 0, (struct sockaddr *)&cad, &scad))>0)
     2090              if ((n=recvfrom(ph[i].ptab->ports[j].fd, buf+3, sizeof(buf)-3, 0, (struct sockaddr *)&cad, (socklen_t *)&scad))>0)
    20742091              {
    20752092                int idx;
     
    21182135            {
    21192136              cs_set_mloc(-1, "event: tcp-socket");
    2120               if ((pfd=accept(ph[i].ptab->ports[j].fd, (struct sockaddr *)&cad, &scad))>0)
     2137              if ((pfd=accept(ph[i].ptab->ports[j].fd, (struct sockaddr *)&cad, (socklen_t *)&scad))>0)
    21212138              {
    21222139                switch(cs_fork(cs_inet_order(cad.sin_addr.s_addr), ntohs(cad.sin_port)))
Note: See TracChangeset for help on using the changeset viewer.