1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/n4c-dtn2-patch-2 Tue May 10 10:54:22 2011 +0000
1.3 @@ -0,0 +1,620 @@
1.4 +# HG changeset patch
1.5 +# User Aidan
1.6 +# Date 1305024472 0
1.7 +# Node ID a1248032cdd8537f51038ca0165e329e100245af
1.8 +# Parent 875893b4fede677fe2467a8ae2f9af0991b226b9
1.9 +XML thingy
1.10 +
1.11 +diff -r 875893b4fede -r a1248032cdd8 apps/dtnN4Cmiddle/dtnN4Crecv
1.12 +Binary file apps/dtnN4Cmiddle/dtnN4Crecv has changed
1.13 +diff -r 875893b4fede -r a1248032cdd8 apps/dtnN4Cmiddle/dtnN4Csettings.h
1.14 +--- a/apps/dtnN4Cmiddle/dtnN4Csettings.h Thu Apr 21 15:19:21 2011 +0000
1.15 ++++ b/apps/dtnN4Cmiddle/dtnN4Csettings.h Tue May 10 10:47:52 2011 +0000
1.16 +@@ -7,16 +7,16 @@
1.17 +
1.18 +
1.19 + // for dtnN4Crecv
1.20 +-#define RSDIR "/data/www/private/HTMLrequester/router_stage"
1.21 ++#define RSDIR "/home/dtnuser/data/www/private/HTMLrequester/router_stage"
1.22 + // wget cmd
1.23 + #define WGETSTR "wget -N -r -l 1 --no-remove-listing -p -t 1 -d --quota=104857600"
1.24 +
1.25 + // for pushedContent
1.26 +-#define PUBDIR "/data/www/public"
1.27 ++#define PUBDIR "/home/dtnuser/data/www/public"
1.28 + // next two need to be in same filesystem, hard links are used
1.29 +-#define RX_PATH "/data/www/public/rxpushedContent"
1.30 +-#define DOCROOT "/data/www/public/drpushedContent"
1.31 +-#define RXMETA_FILE "/data/www/public/rxpushedContent/metadata.xml"
1.32 ++#define RX_PATH "/home/dtnuser/data/www/public/rxpushedContent"
1.33 ++#define DOCROOT "/home/dtnuser/data/www/public/drpushedContent"
1.34 ++#define RXMETA_FILE "/home/dtnuser/data/www/public/rxpushedContent/metadata.xml"
1.35 +
1.36 + // for pushedContent
1.37 + #define SRCDIR "./public"
1.38 +@@ -30,7 +30,7 @@
1.39 + #define FILELIST "./filelist"
1.40 +
1.41 + #define GEN_PC_FILE "./generatePushedContent.sh"
1.42 +-#define APACFG "/data/apps/DTN2/apps/dtnN4Cmiddle/apache_cfg.sh"
1.43 ++#define APACFG "/home/dtnuser/data/apps/DTN2/apps/dtnN4Cmiddle/apache_cfg.sh"
1.44 + #define APACFGOUTPUT "/etc/apache2/sites-available/n4csites.conf"
1.45 +
1.46 +
1.47 +diff -r 875893b4fede -r a1248032cdd8 apps/dtnN4Cmiddle/pushedContent.c
1.48 +--- a/apps/dtnN4Cmiddle/pushedContent.c Thu Apr 21 15:19:21 2011 +0000
1.49 ++++ b/apps/dtnN4Cmiddle/pushedContent.c Tue May 10 10:47:52 2011 +0000
1.50 +@@ -30,7 +30,7 @@
1.51 + // generate content to push
1.52 + snprintf (generateContent, PATH_MAX, "%s %s/today/%s", GEN_PC_FILE, SRCDIR, LOCALDIR );
1.53 + syslog ( LOG_INFO, "Starting to generate pushed content: %s", generateContent );
1.54 +- if ( (rc = system ( generateContent )) != 0 )
1.55 ++ if ( (rc = system ( generateContent )) == SYS_ERR )
1.56 + {
1.57 + syslog ( LOG_ERR, "Error (%d) at generateContent: %s", rc, generateContent );
1.58 + return rc;
1.59 +@@ -199,7 +199,7 @@
1.60 + // add new content to repo using hg add
1.61 + snprintf ( hg, PATH_MAX, "cd %s;hg add today/%s", SRCDIR, LOCALDIR );
1.62 + syslog ( LOG_INFO, "Adding pushed content to hg: %s", hg );
1.63 +- if ( (rc = system ( hg )) != 0 )
1.64 ++ if ( (rc = system ( hg )) == SYS_ERR )
1.65 + {
1.66 + syslog ( LOG_ERR, "Error (%d) at hg: %s", rc, hg );
1.67 + release();
1.68 +@@ -226,7 +226,7 @@
1.69 + for(i=0; i<numReplaceFiles; i++)
1.70 + syslog ( LOG_INFO, "replaceFiles[%d]: %s", i, replaceFiles[i] );
1.71 +
1.72 +- if ( (rc = writeMetadata(addFiles, numAddFiles, removeFiles, numRemoveFiles, replaceFiles, numReplaceFiles, index)) != 0)
1.73 ++ if ( (rc = writeMetadata(addFiles, numAddFiles, removeFiles, numRemoveFiles, replaceFiles, numReplaceFiles, index)) == XML_ERR)
1.74 + {
1.75 + syslog ( LOG_ERR, "Error (%d) at writeMetadata", rc );
1.76 + release();
1.77 +@@ -250,7 +250,7 @@
1.78 + // tar content and metadata
1.79 + snprintf ( tar, PATH_MAX, "tar -cf %s %s", tarFile, META_FILE );
1.80 + syslog ( LOG_INFO, "Starting to tar pushed content: %s", tar );
1.81 +- if ( (rc = system ( tar )) != 0 )
1.82 ++ if ( (rc = system ( tar )) == SYS_ERR )
1.83 + {
1.84 + syslog ( LOG_ERR, "Error (%d) at tar: %s", rc, tar );
1.85 + release();
1.86 +@@ -269,7 +269,7 @@
1.87 + }
1.88 + fclose(tat);
1.89 + snprintf ( tar, PATH_MAX, "cd %s; tar --append --file=%s -T ../%s", SRCDIR, tarFile, FILELIST);
1.90 +- if ( (rc = system ( tar )) != 0 ) {
1.91 ++ if ( (rc = system ( tar )) == SYS_ERR ) {
1.92 + syslog ( LOG_ERR, "Error (%d) at tar: %s. Skipping", rc, tar );
1.93 + }
1.94 +
1.95 +@@ -287,7 +287,7 @@
1.96 + }
1.97 + fclose(tat);
1.98 + snprintf ( tar, PATH_MAX, "cd %s; tar --append --file=%s -T ../%s", SRCDIR, tarFile, FILELIST);
1.99 +- if ( (rc = system ( tar )) != 0 ) {
1.100 ++ if ( (rc = system ( tar )) == SYS_ERR ) {
1.101 + syslog ( LOG_ERR, "Error (%d) at tar: %s. Skipping", rc, tar );
1.102 + }
1.103 +
1.104 +@@ -296,7 +296,7 @@
1.105 + //todo need to compress this tar file before sending it
1.106 + char compress[PATH_MAX];
1.107 + snprintf(compress,PATH_MAX,"gzip %s",tarFile);
1.108 +- if ( (rc = system ( compress )) != 0 ) {
1.109 ++ if ( (rc = system ( compress )) == SYS_ERR ) {
1.110 + syslog ( LOG_ERR, "Error (%d) at compress: %s. Skipping", rc, compress );
1.111 + }
1.112 +
1.113 +@@ -313,7 +313,7 @@
1.114 + source_eid->uri, destinationUris[i], tarFile );
1.115 + syslog ( LOG_INFO, "dtnSendFile: %s", dtnSendFile );
1.116 +
1.117 +- if ( (rc = system ( dtnSendFile )) != 0 )
1.118 ++ if ( (rc = system ( dtnSendFile )) == SYS_ERR )
1.119 + {
1.120 + syslog ( LOG_ERR, "Error (%d) at dtnSendFile: %s", rc, dtnSendFile );
1.121 + release();
1.122 +@@ -324,9 +324,9 @@
1.123 + }
1.124 +
1.125 + // add new content to repo using hg add
1.126 +- snprintf ( hg, PATH_MAX, "cd %s;hg commit -m '%s'", SRCDIR, "msg to go here" );
1.127 ++ snprintf ( hg, PATH_MAX, "cd %s;hg commit -u dtnuser -m '%s'", SRCDIR, "msg to go here" );
1.128 + syslog ( LOG_INFO, "hg commit: %s", hg );
1.129 +- if ( (rc = system ( hg )) != 0 )
1.130 ++ if ( (rc = system ( hg )) == SYS_ERR )
1.131 + {
1.132 + syslog ( LOG_ERR, "Error (%d) at hg commit: %s", rc, hg );
1.133 + release();
1.134 +@@ -337,7 +337,7 @@
1.135 +
1.136 + snprintf ( cp, PATH_MAX, "cd %s;cp -rf today/%s yesterday/", SRCDIR, LOCALDIR );
1.137 + syslog ( LOG_INFO, "cp: %s", cp );
1.138 +- if ( (rc = system ( cp )) != 0 )
1.139 ++ if ( (rc = system ( cp )) == SYS_ERR )
1.140 + {
1.141 + syslog ( LOG_ERR, "Error (%d) at cp: %s", rc, cp );
1.142 + release();
1.143 +@@ -457,8 +457,8 @@
1.144 + syslog ( LOG_ERR, "Can't open tmp file %s",tnb);
1.145 + return rc;
1.146 + }
1.147 +- ssize_t fw=write(mst,payload.buf.buf_val,payload.buf.buf_len);
1.148 +- if (fw!=(ssize_t)payload.buf.buf_len) {
1.149 ++ size_t fw=write(mst,payload.buf.buf_val,payload.buf.buf_len);
1.150 ++ if (fw!=(size_t)payload.buf.buf_len) {
1.151 + syslog ( LOG_ERR, "Filed writing tmp file %s (ret: %d)",tnb,fw);
1.152 + return rc;
1.153 + }
1.154 +@@ -468,7 +468,7 @@
1.155 + snprintf ( tar, PATH_MAX, "tar -ozxf %s -c %s/", payload.filename.filename_val, RX_PATH );
1.156 + }
1.157 + syslog ( LOG_INFO, "untar: %s", tar );
1.158 +- if ( (rc = system ( tar )) != 0 ) {
1.159 ++ if ( (rc = system ( tar )) == SYS_ERR ) {
1.160 + // check if uncompressed works (backwards compat)
1.161 + if (payload.location==DTN_PAYLOAD_MEM) {
1.162 + snprintf ( tar, PATH_MAX, "tar -oxf %s -C %s/", tnb, RX_PATH );
1.163 +@@ -476,7 +476,7 @@
1.164 + snprintf ( tar, PATH_MAX, "tar -oxf %s -c %s/", payload.filename.filename_val, RX_PATH );
1.165 + }
1.166 + syslog ( LOG_INFO, "untar: %s", tar );
1.167 +- if ( (rc = system ( tar )) != 0 ) {
1.168 ++ if ( (rc = system ( tar )) == SYS_ERR ) {
1.169 + syslog ( LOG_ERR, "Error (%d) at untar: %s", rc, tar );
1.170 + return rc;
1.171 + } else {
1.172 +@@ -739,7 +739,7 @@
1.173 + // Get file names
1.174 + snprintf ( hg, PATH_MAX, "(cd %s;hg status today/) > %s", SRCDIR, STATUS_FILE );//todo the path returned may be rel
1.175 + syslog ( LOG_INFO, "Checking hg status: %s", hg );
1.176 +- if ( (rc = system ( hg )) != 0 )
1.177 ++ if ( (rc = system ( hg )) == SYS_ERR )
1.178 + {
1.179 + syslog ( LOG_ERR, "Error: system call %s returned %d", hg, rc );
1.180 + return rc;
1.181 +@@ -1011,41 +1011,41 @@
1.182 + if ( writer == NULL )
1.183 + {
1.184 + syslog ( LOG_ERR, "Error creating the xml writer" );
1.185 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.186 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.187 + return -1;
1.188 + }
1.189 +
1.190 + // Start the document with the xml default for the version,
1.191 + // encoding ISO 8859-1 and the default for the standalone declaration.
1.192 +- if ( (rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0 )
1.193 ++ if ( (rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) == XML_ERR )
1.194 + {
1.195 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartDocument", rc );
1.196 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.197 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.198 + return rc;
1.199 + }
1.200 +
1.201 + // need an outer wrapper element
1.202 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "PushMeta")) < 0 )
1.203 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "PushMeta")) == XML_ERR )
1.204 + {
1.205 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartElement", rc );
1.206 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.207 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.208 + return rc;
1.209 + }
1.210 +
1.211 + // Start an element named "INDEX" .
1.212 + snprintf(indexStr, 20, "%d", index );
1.213 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "INDEX", BAD_CAST indexStr )) < 0 )
1.214 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "INDEX", BAD_CAST indexStr )) == XML_ERR )
1.215 + {
1.216 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.217 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.218 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.219 + return rc;
1.220 + }
1.221 +
1.222 + // Start an element named "ENTRIES".
1.223 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES")) < 0 )
1.224 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES")) == XML_ERR )
1.225 + {
1.226 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartElement", rc );
1.227 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.228 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.229 + return rc;
1.230 + }
1.231 +
1.232 +@@ -1057,41 +1057,41 @@
1.233 + for ( i=0; i!=numAddFiles; i++ )
1.234 + {
1.235 + // Start an element named "ENTRY" as child of ENTRIES.
1.236 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) < 0 )
1.237 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) == XML_ERR )
1.238 + {
1.239 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartElement", rc );
1.240 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.241 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.242 + return rc;
1.243 + }
1.244 +
1.245 + // Add an attribute with name "type" and value "add" to ENTRY.
1.246 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_ADD)) < 0)
1.247 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_ADD)) == XML_ERR )
1.248 + {
1.249 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "type", TYPE_ADD );
1.250 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.251 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.252 + return rc;
1.253 + }
1.254 +
1.255 + // Start an element named "FILE" as child of ENTRY.
1.256 +
1.257 +- xmlChar *tmp=ConvertInput(addFiles[i],MY_ENCODING);
1.258 +- if (tmp!=NULL) {
1.259 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) < 0 )
1.260 ++ xmlChar *tmp=ConvertInput(addFiles[i],MY_ENCODING);
1.261 ++ if (tmp!=NULL) {
1.262 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) == XML_ERR )
1.263 + {
1.264 +- syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.265 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.266 +- return rc;
1.267 ++ syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.268 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.269 ++ return rc;
1.270 + }
1.271 + } else {
1.272 +- syslog ( LOG_ERR, "Eror converting: skipping file %d which is %s",i,addFiles[i]);
1.273 ++ syslog ( LOG_ERR, "Eror converting: skipping file %d which is %s",i,addFiles[i]);
1.274 + syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.275 + }
1.276 +
1.277 + // Close the element named ENTRY.
1.278 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.279 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.280 + {
1.281 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.282 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.283 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.284 + return rc;
1.285 + }
1.286 + }// end "add" for loop
1.287 +@@ -1107,103 +1107,103 @@
1.288 + // </ENTRY>
1.289 + for ( i=0; i!=numRemoveFiles; i++ )
1.290 + {
1.291 +- // replace today in filename with yesterday and see if we have it
1.292 +- char *tp=strstr(removeFiles[i],"today/");
1.293 +- if (tp==NULL || (strlen(tp)<=6)) {
1.294 ++ // replace today in filename with yesterday and see if we have it
1.295 ++ char *tp=strstr(removeFiles[i],"today/");
1.296 ++ if (tp==NULL || (strlen(tp)<=6)) {
1.297 + syslog ( LOG_ERR, "Can't parse %s to replace today with yesterday. Skipping it.",removeFiles[i]);
1.298 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.299 +- continue;
1.300 +- }
1.301 +- snprintf(hashFile,PATH_MAX,"%s/yesterday/%s",SRCDIR,tp+6);
1.302 +- if ( (rc = dohash(hashFile, HASH_SIZE, md )) < 0 )
1.303 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.304 ++ continue;
1.305 ++ }
1.306 ++ snprintf(hashFile,PATH_MAX,"%s/yesterday/%s",SRCDIR,tp+6);
1.307 ++ if ( (rc = dohash(hashFile, HASH_SIZE, md )) != 0 )
1.308 + {
1.309 + syslog ( LOG_ERR, "Can't find %s to hash it. Skipping it.",hashFile);
1.310 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.311 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.312 + continue;
1.313 + }
1.314 +
1.315 + // Start an element named "ENTRY" as child of ENTRIES.
1.316 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) < 0 )
1.317 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) == XML_ERR )
1.318 + {
1.319 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartElement", rc );
1.320 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.321 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.322 + return rc;
1.323 + }
1.324 +
1.325 + // Add an attribute with name "type" and value "remove" to ENTRY.
1.326 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_REMOVE)) < 0)
1.327 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_REMOVE)) == XML_ERR )
1.328 + {
1.329 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "type", TYPE_REMOVE );
1.330 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.331 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.332 + return rc;
1.333 + }
1.334 +
1.335 + // Add an element named "FILE" as child of ENTRY.
1.336 +- xmlChar *tmp=ConvertInput(removeFiles[i],MY_ENCODING);
1.337 +- if (tmp!=NULL) {
1.338 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) < 0 )
1.339 ++ xmlChar *tmp=ConvertInput(removeFiles[i],MY_ENCODING);
1.340 ++ if (tmp!=NULL) {
1.341 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) == XML_ERR )
1.342 + {
1.343 +- syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.344 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.345 +- return rc;
1.346 ++ syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.347 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.348 ++ return rc;
1.349 + }
1.350 +- } else {
1.351 +- syslog ( LOG_ERR, "Eror converting: skipping file %d which is %s",i,addFiles[i]);
1.352 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.353 +- }
1.354 ++ } else {
1.355 ++ syslog ( LOG_ERR, "Eror converting: skipping file %d which is %s",i,addFiles[i]);
1.356 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.357 ++ }
1.358 +
1.359 + // Start an element named "HASH" as child of ENTRY.
1.360 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "HASH")) < 0 )
1.361 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "HASH")) == XML_ERR )
1.362 + {
1.363 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.364 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.365 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.366 + return rc;
1.367 + }
1.368 +
1.369 + // Add an attribute with name "size" and value "1024" to HASH.
1.370 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "size", BAD_CAST HASH_SIZE_STR )) < 0)
1.371 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "size", BAD_CAST HASH_SIZE_STR )) == XML_ERR )
1.372 + {
1.373 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "size", HASH_SIZE_STR );
1.374 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.375 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.376 + return rc;
1.377 + }
1.378 + // Add an attribute with name "type" and value "SHA1" to HASH.
1.379 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_HASH )) < 0)
1.380 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_HASH )) == XML_ERR )
1.381 + {
1.382 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "type", TYPE_HASH );
1.383 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.384 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.385 + return rc;
1.386 + }
1.387 +
1.388 + // Add an element named "MD" as child of HASH.
1.389 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "MD", BAD_CAST md)) < 0 )
1.390 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "MD", BAD_CAST md)) == XML_ERR )
1.391 + {
1.392 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.393 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.394 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.395 + return rc;
1.396 + }
1.397 +
1.398 + //flush writer so md is not over written
1.399 +- if ( (rc = xmlTextWriterFlush(writer)) < 0 )
1.400 ++ if ( (rc = xmlTextWriterFlush(writer)) == XML_ERR )
1.401 + {
1.402 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterFlush", rc );
1.403 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.404 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.405 + return rc;
1.406 + }
1.407 +
1.408 + // Close the element named HASH.
1.409 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.410 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.411 + {
1.412 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.413 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.414 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.415 + return rc;
1.416 + }
1.417 +
1.418 + // Close the element named ENTRY.
1.419 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.420 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.421 + {
1.422 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.423 +- syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.424 ++ syslog ( LOG_ERR, "Rem count: %d, Line: %d",i,__LINE__);
1.425 + return rc;
1.426 + }
1.427 +
1.428 +@@ -1220,121 +1220,121 @@
1.429 + // </ENTRY>
1.430 + for ( i=0; i!=numReplaceFiles; i++ )
1.431 + {
1.432 +- // replace today in filename with yesterday and see if we have it
1.433 +- char *tp=strstr(replaceFiles[i],"today/");
1.434 +- if (tp==NULL || (strlen(tp)<=6)) {
1.435 ++ // replace today in filename with yesterday and see if we have it
1.436 ++ char *tp=strstr(replaceFiles[i],"today/");
1.437 ++ if (tp==NULL || (strlen(tp)<=6)) {
1.438 + syslog ( LOG_ERR, "Can no longer find %s. Skipping it.",replaceFiles[i]);
1.439 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.440 +- continue;
1.441 +- }
1.442 +- snprintf(hashFile,PATH_MAX,"%s/yesterday/%s",SRCDIR,tp+6);
1.443 +- if ( (rc = dohash(hashFile, HASH_SIZE, md )) < 0 )
1.444 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.445 ++ continue;
1.446 ++ }
1.447 ++ snprintf(hashFile,PATH_MAX,"%s/yesterday/%s",SRCDIR,tp+6);
1.448 ++ if ( (rc = dohash(hashFile, HASH_SIZE, md )) != 0 )
1.449 + {
1.450 + syslog ( LOG_ERR, "Can no longer find %s to hash it. Skipping it.",replaceFiles[i]);
1.451 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.452 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.453 + continue;
1.454 + }
1.455 +
1.456 + // Start an element named "ENTRY" as child of ENTRIES.
1.457 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) < 0 )
1.458 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY")) == XML_ERR )
1.459 + {
1.460 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterStartElement", rc );
1.461 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.462 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.463 + return rc;
1.464 + }
1.465 +
1.466 + // Add an attribute with name "type" and value "remove" to ENTRY.
1.467 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_REPLACE)) < 0)
1.468 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_REPLACE)) == XML_ERR )
1.469 + {
1.470 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "type", TYPE_REPLACE );
1.471 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.472 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.473 + return rc;
1.474 + }
1.475 +
1.476 + // Add an element named "FILE" as child of ENTRY.
1.477 +- xmlChar *tmp=ConvertInput(replaceFiles[i],MY_ENCODING);
1.478 +- if (tmp!=NULL) {
1.479 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) < 0 )
1.480 +- {
1.481 ++ xmlChar *tmp=ConvertInput(replaceFiles[i],MY_ENCODING);
1.482 ++ if (tmp!=NULL) {
1.483 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "FILE", tmp )) == XML_ERR )
1.484 ++ {
1.485 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.486 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.487 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.488 + return rc;
1.489 +- }
1.490 +- } else {
1.491 ++ }
1.492 ++ } else {
1.493 + syslog ( LOG_ERR, "Eror converting: skipping file %d which is %s",i,addFiles[i]);
1.494 +- syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.495 +- }
1.496 ++ syslog ( LOG_ERR, "Add count: %d, Line: %d",i,__LINE__);
1.497 ++ }
1.498 +
1.499 + // Start an element named "HASH" as child of ENTRY.
1.500 +- if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "HASH")) < 0 )
1.501 ++ if ( (rc = xmlTextWriterStartElement(writer, BAD_CAST "HASH")) == XML_ERR )
1.502 + {
1.503 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.504 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.505 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.506 + return rc;
1.507 + }
1.508 +
1.509 + // Add an attribute with name "size" and value "1024" to HASH.
1.510 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "size", BAD_CAST HASH_SIZE_STR )) < 0)
1.511 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "size", BAD_CAST HASH_SIZE_STR )) == XML_ERR )
1.512 + {
1.513 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "size", HASH_SIZE_STR );
1.514 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.515 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.516 + return rc;
1.517 + }
1.518 + // Add an attribute with name "type" and value "SHA1" to HASH.
1.519 +- if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_HASH )) < 0)
1.520 ++ if ( (rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST TYPE_HASH )) == XML_ERR )
1.521 + {
1.522 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteAttribute %s=%s", rc, "type", TYPE_HASH );
1.523 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.524 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.525 + return rc;
1.526 + }
1.527 +
1.528 + // Add an element named "MD" as child of HASH.
1.529 +- if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "MD", BAD_CAST md )) < 0 )
1.530 ++ if ( (rc = xmlTextWriterWriteElement(writer, BAD_CAST "MD", BAD_CAST md )) == XML_ERR )
1.531 + {
1.532 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterWriteElement", rc );
1.533 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.534 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.535 + return rc;
1.536 + }
1.537 +
1.538 + //flush writer so md is not over written
1.539 +- if ( (rc = xmlTextWriterFlush(writer)) < 0 )
1.540 ++ if ( (rc = xmlTextWriterFlush(writer)) == XML_ERR )
1.541 + {
1.542 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterFlush", rc );
1.543 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.544 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.545 + return rc;
1.546 + }
1.547 +
1.548 + // Close the element named HASH.
1.549 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.550 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.551 + {
1.552 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.553 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.554 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.555 + return rc;
1.556 + }
1.557 +
1.558 + // Close the element named ENTRY.
1.559 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.560 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.561 + {
1.562 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.563 +- syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.564 ++ syslog ( LOG_ERR, "Rep count: %d, Line: %d",i,__LINE__);
1.565 + return rc;
1.566 + }
1.567 +
1.568 + }//end "replace" for loop
1.569 +
1.570 + // Close the element named ENTRIES.
1.571 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0)
1.572 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.573 + {
1.574 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.575 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.576 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.577 + return rc;
1.578 + }
1.579 +
1.580 + // need an outer wrapper element
1.581 +- if ( (rc = xmlTextWriterEndElement(writer)) < 0 )
1.582 ++ if ( (rc = xmlTextWriterEndElement(writer)) == XML_ERR )
1.583 + {
1.584 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndElement", rc );
1.585 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.586 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.587 + return rc;
1.588 + }
1.589 +
1.590 +@@ -1342,15 +1342,15 @@
1.591 + // function xmlTextWriterEndElement, but since we do not want to
1.592 + // write any other elements, we simply call xmlTextWriterEndDocument,
1.593 + // which will do all the work.
1.594 +- if ( (rc = xmlTextWriterEndDocument(writer)) < 0)
1.595 ++ if ( (rc = xmlTextWriterEndDocument(writer)) == XML_ERR )
1.596 + {
1.597 + syslog ( LOG_ERR, "Error (%d) at xmlTextWriterEndDocument", rc );
1.598 +- syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.599 ++ syslog ( LOG_ERR, "XML error Line: %d",__LINE__);
1.600 + return rc;
1.601 + }
1.602 +
1.603 + xmlFreeTextWriter(writer);
1.604 +- syslog ( LOG_INFO, "Finished writing metadata" );
1.605 ++ syslog ( LOG_INFO, "Finished writing metadata" );
1.606 + return rc;
1.607 + }
1.608 +
1.609 +diff -r 875893b4fede -r a1248032cdd8 apps/dtnN4Cmiddle/pushedContent.h
1.610 +--- a/apps/dtnN4Cmiddle/pushedContent.h Thu Apr 21 15:19:21 2011 +0000
1.611 ++++ b/apps/dtnN4Cmiddle/pushedContent.h Tue May 10 10:47:52 2011 +0000
1.612 +@@ -31,7 +31,10 @@
1.613 + #define MAX_FILES PATH_MAX
1.614 + #define MAX_DEST_URI PATH_MAX
1.615 +
1.616 +-#define LOCALDIR "N4Csites"
1.617 ++#define XML_ERR -1
1.618 ++#define SYS_ERR -1
1.619 ++
1.620 ++#define LOCALDIR "N4Csites"
1.621 +
1.622 + // used by pushedcontent
1.623 + #define ADDPRECURSOR "today/N4Csites/"