Files
@ d11848bd0bc1
Branch filter:
Location: DistRen/src/client/distren.c
d11848bd0bc1
2.5 KiB
text/plain
Killed random junk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | /*
Copyright 2008 Nathan Phillip Brink, Ethan Zonca, Matt Orlando
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h> /* sprintf, printf */
#include <stdlib.h> /* malloc, free */
#include "options.h"
#include "execio.h"
#include <libxml/tree.h> /* Happy fun XML time */
#include <libxml/xmlwriter.h>
int main(int argc, char *argv[])
{
/* XML Testing, segfaults, so reverted to default. */
/*
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile(docname);
if (doc == NULL ) {
fprintf(stderr,"The document was not parsed correctly \n");
return;
}
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"I cannot parse an empty document \n");
xmlFreeDoc(doc);
return;
}
if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"The document you want me to parse is of the wrong type");
xmlFreeDoc(doc);
return;
}
*/
char buf[10];
struct execio *testrem;
char *execargv[] =
{
"ssh",
"protofusion.org",
"sh",
"-c",
"\"echo hello from ${HOSTNAME}\"",
(char *)NULL
};
size_t readlen;
fprintf(stderr, "testing execio (It shouldn't work) :-)\n");
fprintf(stderr, "execio_open returns %d\n", execio_open(&testrem, "ssh", execargv));
buf[9] = '\0';
while(!execio_read(testrem, buf, 9, &readlen))
{
if(readlen > 9)
{
fprintf(stderr, "execio_read doesn't set readlen correctly or read() is messed up\n");
return 1;
}
buf[readlen] = '\0';
fprintf(stderr, "read \"%s\"\n", buf);
}
return 0;
};
/* 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;
}
|