Changeset - d643c8d1d8a8
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 17 years ago 2009-02-19 23:05:33
ohnobinki@ohnopublishing.net
some code rewriting
1 file changed with 36 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -17,11 +17,36 @@
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <stdio.h>
 
#include <stdio.h> /* sprintf, printf */
 
#include <stdlib.h> /* malloc, free */
 
#include <string.h> /* strlen */
 

	
 
/* this function should probably not exist. asprintf should be used instead of sprintf */
 
size_t intstrlen(size_t theint)
 
{
 
  size_t len = 0; /* if the number is single digit, this will be incremented */
 
  do
 
    {
 
      theint /= 10;
 
      len ++;
 
    }
 
  while(theint > 0);
 
  
 
  return len;
 
}
 

	
 

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

	
 
  char *blendercmd;
 
  char *filename = "file.blend";  /* declares a variable to hold the file name */
 
  char *format = "blender.exe -b \"%s\" -o //tmp/frame -f %d -F JPEG -x 1"; /* the format string to pass to sprintf */
 
  unsigned int frame_to_render;
 
  size_t blenderstrlen;
 

	
 
  int toreturn;
 

	
 
  //just prove that linking to the shared lib werkz
 
  genericfunc();
 
  execlisten();
 
@@ -34,16 +59,19 @@ int main(int argc, char *argv[])
 
   * url to dl .blend file
 
   */
 

	
 
  int frame_to_render;
 

	
 
  frame_to_render = 10; // temporary, the number 10 will be replaced with a function call
 

	
 
  char file_name[25]; // declares a variable to hold the file name
 
  // file_name = job.file_name // retrieves file name from the blender structure
 
  // file_name = job.file_name // retrieves file name from the blender structure ?
 

	
 
  char string[100];
 
  sprintf(string, "blender.exe -b (filename).blend -o //tmp/frame -f %d -F JPEG -x 1", frame_to_render);
 
  blenderstrlen = strlen(format) - 2 * 2 /* format string minus placeholders */ + strlen(filename) + intstrlen(frame_to_render) + 1 /* NULL terminator */;
 
  blendercmd = malloc(blenderstrlen);
 
  snprintf(blendercmd, blenderstrlen, format, filename, frame_to_render);
 
  
 
  fprintf(stderr, "will run ``%s''\n", blendercmd);
 

	
 
  system(string);
 
  toreturn = system(blendercmd);
 
  free(blendercmd);
 

	
 
  return 0;
 
  return toreturn;
 
}
0 comments (0 inline, 0 general)