bin/dbupdate/dbupdate.cc
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- error_init
- process_object
- process_file
- generate_upd_file
- main
1 /***************************************
2 $Revision: 1.18 $
3
4 DBupdate
5
6 Status: NOT REVIEWED, NOT TESTED
7
8 Author(s): Engin Gunduz
9
10 ******************/ /******************
11 Modification History:
12 engin (01/03/2000) Created.
13 ******************/ /******************
14 Copyright (c) 2000 RIPE NCC
15
16 All Rights Reserved
17
18 Permission to use, copy, modify, and distribute this software and its
19 documentation for any purpose and without fee is hereby granted,
20 provided that the above copyright notice appear in all copies and that
21 both that copyright notice and this permission notice appear in
22 supporting documentation, and that the name of the author not be
23 used in advertising or publicity pertaining to distribution of the
24 software without specific, written prior permission.
25
26 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
28 AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
29 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
30 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
31 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 ***************************************/
33
34
35
36
37
38 #include "dbupdate.h"
39 #include "erroutines.h"
40 #include "ca_configFns.h"
41 #include "ca_dictSyms.h"
42 #include "ca_macros.h"
43 #include "ca_srcAttribs.h"
44 #include "notification.h"
45
46 int tracing = 0;
47 int test_mode = 0;
48 int reading_from_mail = 0;
49
50 /* required configuration variables */
51 char *tmpdir = NULL;
52 char *mailcmd = NULL;
53 char *notitxt = NULL;
54 char *notimailtxt = NULL;
55 char *fwtxt = NULL;
56 char *fwmailtxt = NULL;
57 char *mailtxt = NULL;
58 char *notiflog = NULL;
59 char *crosslog = NULL;
60 char *acklog = NULL;
61 char *forwlog = NULL;
62 char *humailbox = NULL;
63 char *overridecryptedpw = NULL;
64 int * testmode = NULL;
65 /* end of config variables */
66
67 void error_init(int argc, char ** argv) {
/* [<][>][^][v][top][bottom][index][help] */
68 er_path_t erlogstr;
69
70 ER_init(argc, argv);
71
72 erlogstr.fdes = stderr;
73 erlogstr.asp = 0;
74 erlogstr.sev = ER_SEV_W;
75 erlogstr.mode = ER_M_SEVCHAR | ER_M_TEXTLONG;
76
77 ER_setpath(& erlogstr);
78
79 } /* error_init() */
80
81
82
83 /* Checks the object's syntax, retrives the old version of it from the db,
84 and checks auth2. If everything is OK, then sends it to RIPdb, where referential
85 integrity is checked, and the object is really committed to the db.
86
87 Arguments:
88 char * arg: The object,
89 credentials_struct credentials: The struct containing the credentials, such as
90 'From:' field of the e-mail update,
91 GHashTable * NIC_hdl_hash: A hash containing
92 char * ack_file_name: The file name, to be used to store ACK message
93 */
94
95
96
97 int process_object(char * arg, credentials_struct credentials, GHashTable * NIC_hdl_hash, char * ack_file_name,
/* [<][>][^][v][top][bottom][index][help] */
98 GHashTable * ntfy_hash, GHashTable * forw_hash, GHashTable * cross_hash){
99 bool code = true;
100 Object *o;
101 char * old_version = NULL;
102 o = new Object;
103 int result = 0;
104 int result_from_RIPupd = 0;
105 char * auto_nic = NULL;
106 char * changed_obj = NULL;
107 char * obj_with_AUTO_NIC_hdl;
108 char * assigned_NIC;
109
110 char * value = NULL;/* these two are for */
111 Attr * attr; /* ack messages only */
112
113 if(has_ref_to_AUTO_nic_hdl(arg)){/* if this object has refs to AUTO NIC hdls*/
114 /* then first replace AUTO NIC hdls with assigned NIC hdls (in NIC_hdl_hash) */
115 if((arg = replace_refs_to_AUTO_NIC_hdl(changed_obj, arg, NIC_hdl_hash)) == NULL){
116 return UP_ANE; /* AUTO NIC hdl error */
117 };
118 }
119
120 code = o->scan(arg,strlen(arg));
121 if(code){
122 /* is the object to be deleted? */
123 if(o->isDeleted){
124 //printf("DEBUG: This object is to be deleted\n");
125 old_version = get_old_version(arg);
126 if(old_version == NULL){ /* the object doesn't exist in the db! */
127 AK_add_to_ack(ack_file_name, "\nDelete FAILED: [%s] %s\nEntry not found\n\n%s\n",
128 o->type->getName(), get_search_key(o, o->type->getName(), arg), arg);
129 return UP_NSO; /* no such object */
130 }else {/* the object is in the db */
131 if(identical(old_version, arg)){/* if the old & new versions are identical */
132 result = check_auth(NULL, old_version, o->type->getName(), credentials);
133 if(result == UP_AUTH_OK){
134 if(tracing) {
135 printf("TRACING: Will send the obj to be deleted\n");
136 }
137 result_from_RIPupd = send_object_db(arg, NULL, "DEL");
138 if(result_from_RIPupd == 0){
139 AK_add_to_ack(ack_file_name, "\nDelete OK: [%s] %s\n",
140 o->type->getName(), get_search_key(o, o->type->getName(), arg));
141 NT_write_all_ntfs(arg, NULL, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
142 }else{
143 AK_add_to_ack(ack_file_name, "\nDelete FAILED: [%s] %s\nReferential intergrity failure\n",
144 o->type->getName(), get_search_key(o, o->type->getName(), arg));
145 }
146 result_from_RIPupd = 0;
147 }else{ /* auth failed */
148 if(tracing) {
149 printf("TRACING: Auth failed\n");
150 }
151
152 AK_add_to_ack(ack_file_name, "\nDelete FAILED: [%s] %s\nAuth failed\n",
153 o->type->getName(), get_search_key(o, o->type->getName(), arg));
154 NT_write_all_frwds(arg, NULL, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
155 return UP_AUF; /* Auth failed */
156 }
157 }else{/* the new & old versions do not match */
158 AK_add_to_ack(ack_file_name, "\nDelete FAILED: new & old versions do not match\n");
159 return UP_NOM; /* new & old versions do not match */
160 }
161 }
162 }else {/* the object is _not_ to be deleted */
163 if(has_AUTO_NIC_hdl(arg)){/* it the object has an AUTO NIC hdl */
164 /* then its nic-hdl attribute must be modified so that RIPupdate
165 would understand that it must assign a NIC handle to it */
166 /* but first check the auth */
167 result = check_auth(arg, NULL, o->type->getName(), credentials);
168 if(result == UP_AUTH_OK){
169 if(tracing) {
170 printf("TRACING: Will send the obj to be created with AUTO NIC hdl\n");
171 }
172 auto_nic = (char *)malloc(1024); /* should be enough for a NIC hdl */
173 obj_with_AUTO_NIC_hdl = replace_AUTO_NIC_hdl(arg, auto_nic);
174 if(tracing) {
175 printf("TRACING: Called replace_AUTO_NIC_hdl, get [%s]\n", obj_with_AUTO_NIC_hdl);
176 printf("TRACING: Will send the obj to be added\n");
177 }
178 assigned_NIC = (char *)malloc(128); /* this should be enough for a NIC hdl */
179 result_from_RIPupd = send_object_db(obj_with_AUTO_NIC_hdl, assigned_NIC, "ADD");
180 if(result_from_RIPupd == 0){
181 AK_add_to_ack(ack_file_name, "\nNew OK: [%s] %s\n",
182 o->type->getName(), assigned_NIC);
183 NT_write_all_ntfs(NULL, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
184 }else{
185 AK_add_to_ack(ack_file_name, "\nNew FAILED: [%s] %s\nReferential integrity failure\n",
186 o->type->getName(), arg);
187 }
188 result_from_RIPupd = 0;
189 if(tracing && assigned_NIC != NULL) {
190 printf("TRACING: send_object_db returned [%s] as assigned NIC hdl\n", assigned_NIC);
191 }
192 if(assigned_NIC != NULL){
193 printf("DEBUG: auto_nic=[%s], assigned_NIC=[%s]\n", auto_nic, assigned_NIC);
194 g_hash_table_insert(NIC_hdl_hash, auto_nic, assigned_NIC);
195 printf("DEBUG: NIC_hdl_hash has %i pairs\n",g_hash_table_size(NIC_hdl_hash));
196 }
197
198 }else{
199 /* auth failed ! */
200 if(tracing) {
201 printf("TRACING: Auth failed\n");
202 }
203
204 ER_perror(0, result, "");
205 AK_add_to_ack(ack_file_name, "\nNew FAILED: [%s] %s\nAuth failed\n",
206 o->type->getName(), get_search_key(o, o->type->getName(), arg));
207 NT_write_all_frwds(NULL, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
208 return UP_AUF; /* Auth failed */
209 }
210 }
211 else{
212 old_version = get_old_version(arg);
213 if(old_version != NULL){/* so, this is an update operation */
214 result = check_auth(arg, old_version, o->type->getName(), credentials);
215 if(result == UP_AUTH_OK){
216 if(tracing) {
217 printf("TRACING: Will send the obj to be updated\n");
218 }
219 result_from_RIPupd = send_object_db(arg, NULL, "UPD");
220 if(result_from_RIPupd == 0){
221 AK_add_to_ack(ack_file_name, "\nUpdate OK: [%s] %s\n",
222 o->type->getName(), get_search_key(o, o->type->getName(), arg));
223 NT_write_all_ntfs(old_version, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
224 }else{
225 AK_add_to_ack(ack_file_name, "\nUpdate FAILED: [%s]\n%s\nReferential integrity failure\n",
226 o->type->getName(), get_search_key(o, o->type->getName(), arg));
227 }
228 result_from_RIPupd = 0;
229 }else{
230 /* auth failed ! */
231 if(tracing) {
232 printf("TRACING: Auth failed\n");
233 }
234
235 AK_add_to_ack(ack_file_name, "\nUpdate FAILED: [%s] %s\nAuth failed\n",
236 o->type->getName(), get_search_key(o, o->type->getName(), arg));
237 NT_write_all_frwds(old_version, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
238 return UP_AUF; /* Auth failed */
239 }
240 }else { /* old_version == NULL, so, creation */
241 result = check_auth(arg, NULL, o->type->getName(), credentials);
242 if(result == UP_AUTH_OK){
243 if(tracing) {
244 printf("TRACING: Will send the obj to be added\n");
245 }
246 result_from_RIPupd = send_object_db(arg, NULL, "ADD");
247 if(result_from_RIPupd == 0){
248 AK_add_to_ack(ack_file_name, "\nNew OK [%s] %s\n",
249 o->type->getName(), get_search_key(o, o->type->getName(), arg));
250 NT_write_all_ntfs(NULL, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
251
252 }else{
253 AK_add_to_ack(ack_file_name, "\nNew FAILED: [%s] %s\nReferential integrity failure\n",
254 o->type->getName(), get_search_key(o, o->type->getName(), arg));
255 }
256 result_from_RIPupd = 0;
257 }else{
258 /* auth failed ! */
259 if(tracing) {
260 printf("TRACING: Auth failed\n");
261 }
262
263 ER_perror(0, result, "");
264 AK_add_to_ack(ack_file_name, "\nNew FAILED: [%s] %s\nAuth failed\n",
265 o->type->getName(), get_search_key(o, o->type->getName(), arg));
266 NT_write_all_frwds(NULL, arg, tmpdir, ntfy_hash, forw_hash, cross_hash, credentials.from);
267 return UP_AUF; /* Auth failed */
268 }
269 }
270 }
271 }
272 }else{/* even if obj doesn't parse properly, it may be a legacy object
273 which the user wants to delete... */
274 if(tracing){
275 printf("TRACING: Object didn't parse\n");
276 }
277 AK_add_to_ack(ack_file_name, "\nUpdate FAILED: Syntax error in object\n");
278 //////////////////////////////////
279 if(o->attrs.head() != NULL){
280 for(attr = o->attrs.head(); attr; attr = o->attrs.next(attr)){
281 if(attr->len > 0){
282 value = (char*)malloc(attr->len);
283 strncpy(value, (char *)(arg+attr->offset) ,
284 attr->len - 1);
285 value[attr->len - 1] = '\0';
286 AK_add_to_ack(ack_file_name, "%s\n", value);
287 if(!attr->errors.empty()){
288 AK_add_to_ack_string(ack_file_name, attr->errors);
289 }
290 free(value);
291 }else{
292 if(!attr->errors.empty()){
293 AK_add_to_ack_string(ack_file_name, attr->errors);
294 }
295 }
296 }
297 }
298 if(o->has_error){
299 AK_add_to_ack_string(ack_file_name, o->errors);
300 }
301 //////////////////////////////////
302 return UP_NIY; /* Not implemented yet */
303 }
304 }
305
306
307
308
309
310
311
312
313 /* processes the objects in the given file */
314 void process_file(char * filename, credentials_struct credentials,
/* [<][>][^][v][top][bottom][index][help] */
315 GHashTable * AUTO_NIC_hdl_hash, char * ack_file_name,
316 GHashTable * ntfy_hash, GHashTable * forw_hash, GHashTable * cross_hash){
317
318 FILE * input_file;
319 GSList *list_of_objects = NULL, *list_of_objects2 = NULL;
320 GSList *next = NULL;
321 int object_count = 0;
322 char *object = NULL;
323 char *line;
324 int result = 0;
325
326
327
328 if((input_file = fopen(filename, "r")) == NULL){
329 printf("Couldn't open the file %s: %s\n", filename, strerror(errno));
330 exit(1);
331 }
332
333 line = (char *)malloc(1024);
334 while(fgets(line, 1024, input_file) != NULL){
335 /* first, if it is a pasword, save it, but do not regard it as an attrib */
336 if(strstr(line, "password:") == line){
337 cout << "This is a password" << endl;
338 credentials.password_list = g_slist_append(credentials.password_list,
339 g_strstrip(strdup(line + strlen("password:"))));
340 continue;
341 }
342 /* if the length of the line read is 2, then this is an empty line ("\n\r")*/
343 if(strlen(line) == 2){
344 if(object != NULL){
345 list_of_objects = g_slist_append(list_of_objects, object);
346 object = NULL;
347 }
348 }else{
349 /* if the line contains only the EOL sequence "\n\r" */
350 if(object == NULL && strlen(line) != 2){
351 object = (char *)malloc(strlen(line));
352 object = strdup(line);
353 }
354 else{
355 object = (char *)realloc(object, strlen(object) + strlen(line));
356 object = strcat(object, line);
357 }
358 }
359
360 }
361
362 /* now, if at the very and of the input file there wasn't an
363 empty line, we have to add the remaining object in the 'object'
364 variable */
365 if(object != NULL){
366 //cout << "The object was" << endl << object << endl;
367 list_of_objects = g_slist_append(list_of_objects, object);
368 object = NULL;
369 }
370
371
372
373 if(tracing) {
374 printf("TRACING: Will process the objects in the list\n");
375 }
376 next = list_of_objects;
377 object_count = 0;
378 for( next = list_of_objects; next != NULL ; next = g_slist_next(next) ){
379 object_count++;
380
381 if(tracing) {
382 cout << "TRACING: Got an object from the list" << endl;
383 cout << (char *)next->data << endl;
384 }
385
386 if(has_ref_to_AUTO_nic_hdl((char *)next->data)){/* defer the processing */
387 if(tracing) {
388 printf("TRACING: this object has a ref to an AUTO NIC hdl\n");
389 }
390 list_of_objects2 = g_slist_append(list_of_objects2, strdup((char *)next->data));
391 }else{
392 result = 0;
393 result = process_object((char *)next->data, credentials, AUTO_NIC_hdl_hash, ack_file_name,
394 ntfy_hash, forw_hash, cross_hash);
395 }
396 }
397
398 if(tracing) {
399 printf("TRACING: list_of_objects2 has %d entries\n", g_slist_length(list_of_objects2));
400 }
401
402 if(tracing) {
403 printf("TRACING: will start to process the second list\n");
404 }
405
406 for( next = list_of_objects2; next != NULL ; next = g_slist_next(next) ){
407 if(tracing) {
408 printf("TRACING: Will process object: %s\n", (char *)next->data);
409 }
410 result = process_object((char *)next->data, credentials, AUTO_NIC_hdl_hash, ack_file_name,
411 ntfy_hash, forw_hash, cross_hash);
412 }
413
414
415
416 }/* process_file */
417
418
419
420
421
422
423 /* Generates a unique file name and returns the full path of the filename
424 for storing notification message. */
425
426 char * generate_upd_file(){
/* [<][>][^][v][top][bottom][index][help] */
427
428 char * name;
429
430 /* allocate space for name. 32 should be enough for PID */
431 name = (char*)malloc(strlen("/tmp/dbupdate-tmp.") + strlen("notify") +32 );
432
433 sprintf(name, "/tmp/dbupdate-tmp.%i", getpid());
434
435
436 return name;
437
438 }
439
440
441
442
443
444 /* main */
445 void main(int argc, char **argv, char **envp){
/* [<][>][^][v][top][bottom][index][help] */
446 //init_and_set_options(argc, argv, envp);
447
448 int count = 0;
449
450 char * temp;
451 char * temp_upd_file = NULL;
452 char *input_file_name = NULL;
453 GHashTable *AUTO_NIC_hdl_hash;
454 credentials_struct credentials;
455
456
457 GHashTable *ntfy_hash, *forw_hash, *cross_hash;
458
459
460 char *mail_command_line, * ack_file_name;
461 char *config_file_name = NULL;
462
463
464 /* for using MM module */
465 int retcode;
466 MM_header *mail_header = NULL;
467 MM_xmp_list *part_list;
468 MM_xmp *partptr;
469 long debug = 0;
470
471 /* optarg & optind are necessary to use getopt(3C) */
472 extern char *optarg;
473 extern int optind;
474
475
476 /* create notification hashes */
477 ntfy_hash = g_hash_table_new(g_str_hash, g_str_equal);
478 forw_hash = g_hash_table_new(g_str_hash, g_str_equal);
479
480
481 credentials.password_list = NULL;
482 credentials.from = NULL;
483 int ch;
484 char * to_address = NULL;
485
486 AUTO_NIC_hdl_hash = g_hash_table_new(g_str_hash, g_str_equal);
487 error_init(argc, argv);
488
489
490 while ((ch = getopt(argc, argv, "MtTf:c:")) != -1){
491 switch(ch) {
492 case 'M':
493 reading_from_mail = 1;
494 break;
495 case 'f':
496 input_file_name = strdup(optarg);
497 break;
498 case 'c':
499 config_file_name = strdup(optarg);
500 break;
501 case 't':
502 tracing = 1;
503 break;
504 case 'T':
505 test_mode = 1;
506 break;
507 case '?':
508 default:
509 printf("Unknown option\n");exit(1);
510 }
511 }
512
513
514
515 /* config stuff */
516 ca_populateDictionary(dictionary, VARS);
517 /* if -c flag is given, use the named file as config file, otherwise use
518 default filename */
519 if( config_file_name != NULL){
520 ca_readConfig(config_file_name, confVars, VARS);
521 }else{
522 ca_readConfig("dbupdate.conf", confVars, VARS);
523 }
524 tmpdir = ca_get_tmpdir;
525 tmpdir = g_strstrip(tmpdir);
526 mailcmd = ca_get_mailcmd;
527 mailcmd = g_strstrip(mailcmd);
528 notitxt = ca_get_notitxt;
529 mailtxt = ca_get_mailtxt;
530 crosslog = ca_get_crosslog;
531 fwtxt = ca_get_fwtxt;
532 humailbox = ca_get_humailbox;
533 humailbox = g_strstrip(humailbox);
534 overridecryptedpw = ca_get_overridecryptedpw;
535 overridecryptedpw = g_strstrip(overridecryptedpw);
536 acklog = ca_get_acklog;
537 acklog = g_strstrip(acklog);
538 notiflog = ca_get_notiflog;
539 notiflog = g_strstrip(notiflog);
540 notimailtxt = ca_get_notimailtxt;
541 forwlog = ca_get_forwlog;
542 forwlog = g_strstrip(forwlog);
543 fwmailtxt = ca_get_fwmailtxt;
544 //test_mode = ca_get_testmode;
545
546 printf("TMPDIR is: [%s]\n", tmpdir);
547 printf("MAILCMD is: [%s]\n", mailcmd);
548 printf("NOTITXT is: [%s]\n", notitxt);
549 printf("CROSSLOG is: [%s]\n", crosslog);
550 printf("FWTXT is: [%s]\n", fwtxt);
551 printf("HUMAILBOX is: [%s]\n", humailbox);
552 printf("OVERRIDECRYPTEDPW is: [%s]\n", overridecryptedpw);
553 printf("ACKLOG is: [%s]\n", acklog);
554 printf("NOTIFLOG is: [%s]\n", notiflog);
555 printf("FORWLOG is: [%s]\n", forwlog);
556 printf("NOTIMAILTXT is: [%s]\n", notimailtxt);
557 printf("FWMAILTXT is: [%s]\n", fwmailtxt);
558 //printf("TESTMODE is: [%i]\n", test_mode);
559 /* end of config stuff */
560
561
562
563 /* initialize the parser */
564 schema.initialize();
565
566
567 /* Generate a name for temporary file for storing acks (AK_ack_file_name_generate
568 also creates it) */
569 ack_file_name = AK_ack_file_name_generate(tmpdir, ACK_FILE_PREFIX);
570
571
572 /* Allocate memory for the header */
573 mail_header = (MM_header *)malloc(sizeof(MM_header));
574
575 /* Initialize the list of extracted MIME parts */
576 part_list = (MM_xmp_list *)malloc(sizeof(MM_xmp_list));
577 MM_xmp_list_init (part_list);
578
579
580 if(reading_from_mail){
581 if(input_file_name != NULL){
582 if((retcode = MM_decode(input_file_name, mail_header, part_list, 1, 0)) != 0){
583 printf("DEBUG: MM_decode returned %i\n", retcode);
584 exit(retcode);
585 }
586
587 }else{/* input_file_name == NULL */
588 temp_upd_file = generate_upd_file();
589 MM_store(temp_upd_file, 0);
590 if((retcode = MM_decode(temp_upd_file, mail_header, part_list, 1, 0)) != 0){
591 printf("DEBUG: MM_decode returned %i\n", retcode);
592 exit(retcode);
593 }
594
595 }
596 unlink(temp_upd_file);
597 printf ("Mail headers:\n\n");
598 printf ("From - [%s]",mail_header->from);
599 /* some MAIL-FROM's in mntner auths contain "From: " string too,
600 so we have to have it in credential.from */
601 temp = (char *)malloc(strlen(mail_header->from) + strlen("From: ") + 1);
602 sprintf(temp, "From: %s", mail_header->from);
603 temp[strlen(temp) - 4] = '\0'; /* cut two '\r\n's at the end */
604 credentials.from = temp;
605 printf ("credentials.from = [%s]\n", credentials.from );
606 mail_header->subject[strlen(mail_header->subject) - 4] = '\0';
607 printf ("Subject - [%s]",mail_header->subject);
608 printf ("Date - [%s]",mail_header->date);
609 printf ("Message-ID - [%s]",mail_header->message_id);
610 printf ("Reply-To - [%s]",mail_header->reply_to);
611 printf ("Cc - [%s]",mail_header->cc);
612 to_address = find_to_address(credentials.from);
613 AK_add_to_ack(ack_file_name, "To: %s\nFrom: %s\nSubject: Re: %s \nReply-To: %s\n\nAcknowledgement message from database software, beta version\n", to_address, humailbox, mail_header->subject, humailbox);
614 if(credentials.from != NULL){
615 AK_add_to_ack(ack_file_name, "\n[%s]\n", credentials.from);
616 }
617
618 partptr = part_list->head;
619 while (partptr != NULL){
620
621 printf("-----------------------------------------\n");
622 printf ("Section: %s\n",partptr->number);
623 printf ("Content-type: %s\n",partptr->type);
624 if (partptr->supported){
625 printf ("Supported\n");
626 printf ("Filename is [%s]\n", partptr->file);
627 process_file(partptr->file, credentials,
628 AUTO_NIC_hdl_hash, ack_file_name,
629 ntfy_hash, forw_hash, cross_hash);
630 }
631 else
632 printf ("Unsupported\n");
633 printf ("\n\n");
634 partptr = partptr->next;
635 }
636
637
638 /* Clean up the temporary files */
639 MM_cleanup(part_list, 0);
640
641
642 }else{/* not reading from the mail message */
643 if(input_file_name != NULL){
644 process_file(input_file_name, credentials,
645 AUTO_NIC_hdl_hash, ack_file_name,
646 ntfy_hash, forw_hash, cross_hash);
647 }
648
649 }
650
651
652 if(reading_from_mail && to_address != NULL){
653 AK_send_ack(ack_file_name, to_address, mailcmd);
654 }
655 AK_log_ack(ack_file_name, acklog);
656 AK_delete_ack(ack_file_name);
657
658 NT_send_ntfy_list(ntfy_hash, mailcmd);
659 NT_log_ntfy_list(ntfy_hash, notiflog);
660 NT_delete_ntfy_list(ntfy_hash);
661
662 NT_send_ntfy_list(forw_hash, mailcmd);
663 NT_log_ntfy_list(forw_hash, forwlog);
664 //NT_delete_ntfy_list(forw_hash);
665
666
667
668 if(tracing) {
669 printf("TRACING: END\n");
670 }
671
672
673 }