2006-09-08 07:53:32 +00:00
|
|
|
/*
|
|
|
|
* condor/tc.c
|
|
|
|
*
|
|
|
|
* DC-API test application, utility for both sides
|
|
|
|
*
|
|
|
|
* (c) Daniel Drotos, 2006
|
|
|
|
*/
|
|
|
|
|
2006-08-24 12:58:57 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "tc.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
create_file(char *fn, char *what)
|
|
|
|
{
|
2006-09-08 07:53:32 +00:00
|
|
|
FILE *f= fopen(fn, "w");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (what)
|
|
|
|
fprintf(f, "%s", what);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2006-08-24 12:58:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
get_file(char *fn)
|
|
|
|
{
|
2006-09-08 07:53:32 +00:00
|
|
|
FILE *f;
|
|
|
|
char *buf= NULL;
|
2006-08-24 12:58:57 +00:00
|
|
|
|
2006-09-08 07:53:32 +00:00
|
|
|
if ((f= fopen(fn, "r")) != NULL)
|
2006-08-24 12:58:57 +00:00
|
|
|
{
|
2006-09-08 07:53:32 +00:00
|
|
|
int bs= 100, i;
|
|
|
|
char c;
|
|
|
|
|
|
|
|
buf= malloc(bs);
|
|
|
|
i= 0;
|
|
|
|
buf[i]= '\0';
|
|
|
|
while ((c= fgetc(f)) != EOF)
|
|
|
|
{
|
|
|
|
if (i > bs-2)
|
|
|
|
{
|
|
|
|
bs+= 100;
|
|
|
|
buf= realloc(buf, bs);
|
|
|
|
}
|
|
|
|
buf[i]= c;
|
|
|
|
i++;
|
|
|
|
buf[i]= '\0';
|
|
|
|
}
|
|
|
|
fclose(f);
|
2006-08-24 12:58:57 +00:00
|
|
|
}
|
2006-09-08 07:53:32 +00:00
|
|
|
return(buf);
|
2006-08-24 12:58:57 +00:00
|
|
|
}
|
2006-09-08 07:53:32 +00:00
|
|
|
|
|
|
|
/* Local variables: */
|
|
|
|
/* c-file-style: "linux" */
|
|
|
|
/* End: */
|