Difference for socket/image.c from version 1.3 to 1.4


version 1.3 version 1.4
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: image.c,v 1.3 2002/03/26 07:18:57 mwedel Exp $";   *    "$Id: image.c,v 1.4 2003/12/02 18:51:44 ryo_saeba Exp $";
  */   */
   
 /*  /*
Line 26
 
Line 26
     The author can be reached via e-mail to crossfire-devel@real-time.com      The author can be reached via e-mail to crossfire-devel@real-time.com
 */  */
   
 /* This file deals with the image related communication to the  /** \file
    * Image related communication
    *
    *  \date 2003-12-02
    *
    * This file deals with the image related communication to the
  * client.  I've located all the functions in this file - this   * client.  I've located all the functions in this file - this
  * localizes it more, and means that we don't need to declare   * localizes it more, and means that we don't need to declare
  * things like all the structures as globals.   * things like all the structures as globals.
Line 39
 
Line 44
 #include <newserver.h>  #include <newserver.h>
 #include <loader.h>  #include <loader.h>
   
 #define MAX_FACE_SETS 20  #define MAX_FACE_SETS 20  /**< Maximum number of image sets the program will handle */
   
   /** Information about one image */
 typedef struct FaceInfo {  typedef struct FaceInfo {
   uint8 *data;     /* image data */    uint8 *data;     /**< image data */
   uint16 datalen;     /* length of the xpm data */    uint16 datalen;     /**< length of the xpm data */
   uint32 checksum;     /* Checksum of face data */    uint32 checksum;     /**< Checksum of face data */
 } FaceInfo;  } FaceInfo;
   
   /** Information about one face set */
 typedef struct {  typedef struct {
     char    *prefix;      char    *prefix;    /**< */
     char    *fullname;      char    *fullname;
     uint8   fallback;      uint8   fallback;   /**< faceset to use when an image is not found in this faceset */
     char    *size;      char    *size;
     char    *extension;      char    *extension;
     char    *comment;      char    *comment;
     FaceInfo *faces;      FaceInfo *faces; /**< images in this faceset */
 } FaceSets;  } FaceSets;
   
 static FaceSets facesets[MAX_FACE_SETS];  static FaceSets facesets[MAX_FACE_SETS];    /**< All facesets */
   
   /**
    * Checks specified faceset is valid
    * \param fsn faceset number
    */
 int is_valid_faceset(int fsn)  int is_valid_faceset(int fsn)
 {  {
     if (fsn >=0 && fsn < MAX_FACE_SETS && facesets[fsn].prefix) return TRUE;      if (fsn >=0 && fsn < MAX_FACE_SETS && facesets[fsn].prefix) return TRUE;
     return FALSE;      return FALSE;
 }  }
   
   /**
    * Frees all faceset information
    */
 void free_socket_images()  void free_socket_images()
 {  {
     int num,q;      int num,q;
Line 84
 
Line 97
     }      }
 }  }
   
 /* This returns the set we will actually use when sending  /**
    * This returns the set we will actually use when sending
  * a face.  This is used because the image files may be sparse.   * a face.  This is used because the image files may be sparse.
  * This function is recursive.  imageno is the face number we are   * This function is recursive.  imageno is the face number we are
  * trying to send   * trying to send
    *
    * If face is not found in specified faceset, tries with 'fallback' faceset.
    *
    * \param faceset faceset to check
    * \param imageno image number
    *
  */   */
 static int get_face_fallback(int faceset, int imageno)  static int get_face_fallback(int faceset, int imageno)
 {  {
Line 107
 
Line 127
     return get_face_fallback(facesets[faceset].fallback, imageno);      return get_face_fallback(facesets[faceset].fallback, imageno);
 }  }
   
 /* This is a simple recursive function that makes sure the fallbacks  /**
    * Checks fallback are correctly defined.
    * This is a simple recursive function that makes sure the fallbacks
  * are all proper (eg, the fall back to defined sets, and also   * are all proper (eg, the fall back to defined sets, and also
  * eventually fall back to 0).  At the top level, togo is set to MAX_FACE_SETS,   * eventually fall back to 0).  At the top level, togo is set to MAX_FACE_SETS,
  * if togo gets to zero, it means we have a loop.   * if togo gets to zero, it means we have a loop.
Line 132
 
Line 154
     check_faceset_fallback(fallback, togo);      check_faceset_fallback(fallback, togo);
 }  }
   
 /* read_client_images loads all the iamge types into memory.  #define MAX_IMAGE_SIZE 10000
   
   /**
    * Loads all the image types into memory.
    *
  *  This  way, we can easily send them to the client.  We should really do something   *  This  way, we can easily send them to the client.  We should really do something
  * better than abort on any errors - on the other hand, these are all fatal   * better than abort on any errors - on the other hand, these are all fatal
  * to the server (can't work around them), but the abort just seems a bit   * to the server (can't work around them), but the abort just seems a bit
  * messy (exit would probably be better.)   * messy (exit would probably be better.)
  */   *
    * Couple of notes:  We assume that the faces are in a continous block.
 /* Couple of notes:  We assume that the faces are in a continous block.  
  * This works fine for now, but this could perhaps change in the future   * This works fine for now, but this could perhaps change in the future
  */   *
    * Function largely rewritten May 2000 to be more general purpose.
 /* Function largely rewritten May 2000 to be more general purpose.  
  * The server itself does not care what the image data is - to the server,   * The server itself does not care what the image data is - to the server,
  * it is just data it needs to allocate.  As such, the code is written   * it is just data it needs to allocate.  As such, the code is written
  * to do such.   * to do such.
  */   */
   
   
 #define MAX_IMAGE_SIZE 10000  
 void read_client_images()  void read_client_images()
 {  {
     char filename[400];      char filename[400];
Line 250
 
Line 272
     } /* For fileno < MAX_FACE_SETS */      } /* For fileno < MAX_FACE_SETS */
 }  }
   
 /*  /**
  * Client tells us what type of faces it wants.  Also sets   * Client tells us what type of faces it wants.  Also sets
  * the caching attribute.   * the caching attribute.
  *   *
Line 276
 
Line 298
     }      }
 }  }
   
 /* client has requested pixmap that it somehow missed getting  /**
    * Client has requested pixmap that it somehow missed getting.
  * This will be called often if the client is   * This will be called often if the client is
  * caching images.   * caching images.
  */   */
Line 290
 
Line 313
  esrv_send_face(ns, facenum,1);   esrv_send_face(ns, facenum,1);
 }  }
   
 /*  /**
  * esrv_send_face sends a face to a client if they are in pixmap mode   * Sends a face to a client if they are in pixmap mode
  * nothing gets sent in bitmap mode.    * nothing gets sent in bitmap mode.
  * If nocache is true (nonzero), ignore the cache setting from the client -   * If nocache is true (nonzero), ignore the cache setting from the client -
  * this is needed for the askface, in which we really do want to send the   * this is needed for the askface, in which we really do want to send the
Line 354
 
Line 377
     free(sl.buf);      free(sl.buf);
 }  }
   
 /* send_image_info: Sends the number of images, checksum of the face file,  /**
    * Sends the number of images, checksum of the face file,
  * and the image_info file information.  See the doc/Developers/protocol   * and the image_info file information.  See the doc/Developers/protocol
  * if you want further detail.   * if you want further detail.
  */   */
Line 379
 
Line 403
     free(sl.buf);      free(sl.buf);
 }  }
   
   /**
    * Sends requested face information.
    * \param ns socket to send to
    * \param params contains first and last index of face
    *
    * For each image in [start..stop] sends
    *  - checksum
    *  - name
    */
 void send_image_sums(NewSocket *ns, char *params)  void send_image_sums(NewSocket *ns, char *params)
 {  {
     int start, stop, qq,i;      int start, stop, qq,i;


Legend:
line(s) removed in v.1.3 
line(s) changed
 line(s) added in v.1.4

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:33