#include #include #include #include #include "xcmc.h" /**************/ /* PROTOTYPES */ /**************/ void cmclogon(void); void cmcsend(void); void cmclogoff(void); void cmcsenddocs(void); void cmcprintconfig(void); /****************************/ /* FIELDS USED BY CMC CALLS */ /****************************/ CMC_return_code rc; CMC_session_id sessid; CMC_message msg[2]; CMC_flags flgs, flags; CMC_ui_id ui_id; char user[17], pass[9]; CMC_uint16 vers; CMC_extension *extensions; CMC_object_identifier charset; CMC_string service; /*********************************/ /* FIELDS FOR CMC_SEND_DOCUMENTS */ /*********************************/ char addresses[256], text[256], subject[80], titles[256], files[256], delimiter[2]; int main(int nump, char **parmz) { cmcprintconfig(); if(nump < 2 || strcmp(parmz[1], "SEND") == 0) { cmclogon(); cmcsend(); cmclogoff(); } else cmcsenddocs(); } void cmclogon(void) { /***********************************************************/ /* This won't be needed with cmc_send_documents, but it is */ /* needed with cmc_send. */ /***********************************************************/ /* UI-ID is not used anyway, set to 0 */ ui_id = 0; /* USER must be 16 or less characters, terminated with a \0 */ strcpy(user, "MY_USER"); /* NOTE: If you wish to pass a NULL user, any NULL character */ /* pointer will work just fine... */ /* PASS must be 8 characters, terminated with a \0 */ strcpy(pass, "PaSsWoRd"); /* NOTE: If you wish to pass a NULL user, any NULL character */ /* pointer will work just fine here, too... */ /* SERVICE, CHARACTER SET, AND EXTENSIONS ARE NOT USED, PASS NULLS. */ service = NULL; extensions = NULL; charset = NULL; /* Programmed to specification 1.00 */ vers = 100; /* Pass a 0 in FLGS because we don't support LOGON_UI, ERROR_UI, */ /* or COUNTED_STRING_TYPE. */ flgs = 0; /* sessid is the session ID that must be used in all the other calls. */ rc = cmc_logon(service, user, pass, charset, ui_id, vers, flgs, &sessid, extensions); /* I am just printing the return, you will probably want to stop */ /* if you don't get a 0 return... */ printf("LOGON = %d\n", rc); } void cmcsend(void) { /******************************************************************/ /* There are two ways of sending a text file. First, there is the */ /* sending as a file method. Here is how to do this method: */ /******************************************************************/ /* FLGS is 0 because we don't support COUNTED_STRING_TYPE or any */ /* of the UIs... */ flgs = 0; /* To indicate that the message text is a file, we set the */ /* CMC_MSG_TEXT_NOTE_AS_FILE flag in the CMC_message */ /* structure. */ /* Set the CMC_MSG_TEXT_NOTE_AS_FILE flag */ msg[0].message_flags = 0 | CMC_MSG_TEXT_NOTE_AS_FILE; /* MESSAGE-REFERENCE, MESSAGE-TYPE are ignored. */ /* You may specify them if you wish... */ msg[0].message_reference = NULL; msg[0].message_extensions = NULL; msg[0].message_type = (CMC_string)malloc(9); strcpy(msg[0].message_type, "CMC: IPM"); /* NOTE: For the purpose of sending a new message, MESSAGE-REFERENCE */ /* has no use whatsoever. Also, we currently don't bother to */ /* check the MESSAGE-TYPE field, although it may be useful in */ /* the future... */ /* TEXT-NOTE is NULL in this case because the text is in a file. */ msg[0].text_note = NULL; /* TIME-SENT isn't used, but set it to 0 anyway... */ msg[0].time_sent.second = 0; msg[0].time_sent.minute = 0; msg[0].time_sent.hour = 0; msg[0].time_sent.day = 0; msg[0].time_sent.month = 0; msg[0].time_sent.year = 0; msg[0].time_sent.isdst = 0; msg[0].time_sent.tmzone = 0; /* SUBJECT is a string terminated by \0. */ msg[0].subject = (CMC_string)malloc(80); strcpy(msg[0].subject, "Re: Geoff's behaviour..."); /* Set up attachment structure... */ msg[0].attachments = (CMC_attachment *)malloc(sizeof(CMC_attachment)*2); /* attach_title isn't used yet... */ /* Actually, you can go ahead and put one in, but currently, the */ /* NETMAIL engine won't use it... */ msg[0].attachments[0].attach_title = (CMC_string)malloc(17); strcpy(msg[0].attachments[0].attach_title, "Some Text..."); msg[0].attachments[1].attach_title = (CMC_string)malloc(17); strcpy(msg[0].attachments[1].attach_title, "Binary Data..."); /* attach_type isn't used yet... */ /* You can put one in, either CMC-ATT-OID-BINARY or -TEXT, but */ /* it will have no affect... */ msg[0].attachments[0].attach_type = (CMC_object_identifier)malloc(17); strcpy(msg[0].attachments[0].attach_type, CMC_ATT_OID_TEXT); msg[0].attachments[1].attach_type = (CMC_object_identifier)malloc(17); strcpy(msg[0].attachments[1].attach_type, CMC_ATT_OID_BINARY); /* Set the ATT_LAST_ELEMENT flag in the second entry... */ msg[0].attachments[0].attach_flags = 0; msg[0].attachments[1].attach_flags = 0 | CMC_ATT_LAST_ELEMENT; /* attach_filename is a string terminated by a \0... */ msg[0].attachments[0].attach_filename = (CMC_string)malloc(37); strcpy(msg[0].attachments[0].attach_filename, "FILE.GRP.ACCT01"); msg[0].attachments[1].attach_filename = (CMC_string)malloc(37); strcpy(msg[0].attachments[1].attach_filename, "FILE.GRP.ACCT02"); /* We don't use attachment extensions... */ msg[0].attachments[0].attach_extensions = NULL; msg[0].attachments[1].attach_extensions = NULL; /* Load recipients with the address of our recipient array... */ msg[0].recipients = (CMC_recipient *)malloc(sizeof(CMC_recipient)*3); /* name and address must be strings terminated with a \0... */ msg[0].recipients[0].name = (CMC_string)malloc(20); strcpy(msg[0].recipients[0].name, "JOHN Q. PUBLIC"); msg[0].recipients[0].address = (CMC_string)malloc(20); strcpy(msg[0].recipients[0].address, "YOU@THERE.COM"); msg[0].recipients[0].name_type = CMC_TYPE_INDIVIDUAL; /* This one (entry 0) goes on the "TO:" list... */ msg[0].recipients[0].role = CMC_ROLE_TO; /* The recip_flags available are CMC_RECIP_IGNORE, */ /* CMC_RECIP_LIST_TRUNCATED, and CMC_RECIP_LAST_ELEMENT. */ /* We don't need any of these for this recipient... */ msg[0].recipients[0].recip_flags = 0; msg[0].recipients[0].recip_extensions = NULL; /* Same stuff for entry 1... */ msg[0].recipients[1].name = (CMC_string)malloc(20); strcpy(msg[0].recipients[1].name, "JOHN DOE"); msg[0].recipients[1].address = (CMC_string)malloc(20); strcpy(msg[0].recipients[1].address, "ME@HERE.COM"); msg[0].recipients[1].name_type = CMC_TYPE_INDIVIDUAL; /* This one (entry 1) goes on the "CC:" list... */ msg[0].recipients[1].role = CMC_ROLE_CC; msg[0].recipients[1].recip_flags = 0; msg[0].recipients[1].recip_extensions = NULL; /* Entry 2, same story (almost)... */ msg[0].recipients[2].name = (CMC_string)malloc(20); strcpy(msg[0].recipients[2].name, "CAPTAIN KLUTZ"); msg[0].recipients[2].address = (CMC_string)malloc(20); strcpy(msg[0].recipients[2].address, "BOSS@HERE.COM"); msg[0].recipients[2].name_type = CMC_TYPE_INDIVIDUAL; /* Entry 2 is goes on the "BCC:" list... */ msg[0].recipients[2].role = CMC_ROLE_BCC; msg[0].recipients[2].recip_extensions = NULL; /* Last recipient, set the flag... */ msg[0].recipients[2].recip_flags = 0 | CMC_RECIP_LAST_ELEMENT; /* 2nd message... */ /* NO ATTACHMENTS used in this message... */ msg[1].message_reference = NULL; msg[1].attachments = NULL; msg[1].message_extensions = NULL; msg[1].message_type = (CMC_string)malloc(9); strcpy(msg[1].message_type, "CMC: IPM"); /* SUBJECT is a string terminated by \0. */ msg[1].subject = (CMC_string)malloc(80); strcpy(msg[1].subject, "Re: Geoff's attitude..."); /* Notice that this time around, CMC_MSG_TEXT_NOTE_AS_FILE is */ /* *NOT* set, but I am setting CMC-MSG-LAST-ELEMENT... */ msg[1].message_flags = 0 | CMC_MSG_LAST_ELEMENT; /* TIME-SENT isn't used, but set it to 0 anyway... */ msg[1].time_sent.second = 0; msg[1].time_sent.minute = 0; msg[1].time_sent.hour = 0; msg[1].time_sent.day = 0; msg[1].time_sent.month = 0; msg[1].time_sent.year = 0; msg[1].time_sent.isdst = 0; msg[1].time_sent.tmzone = 0; /* Load the message into text_note, terminated by a \0... */ msg[1].text_note = (CMC_string)malloc(256); strcpy(msg[1].text_note, "NOTHING IN PARTICULAR\015\n"); /* Load recipients with the address of our recipient array... */ msg[1].recipients = (CMC_recipient *)malloc(sizeof(CMC_recipient)); msg[1].recipients[0].name = (CMC_string)malloc(20); strcpy(msg[1].recipients[0].name, "JOHN Q. PUBLIC"); msg[1].recipients[0].address = (CMC_string)malloc(20); strcpy(msg[1].recipients[0].address, "YOU@THERE.COM"); msg[1].recipients[0].name_type = CMC_TYPE_INDIVIDUAL; /* This one (entry 0) goes on the "TO:" list... */ msg[1].recipients[0].role = CMC_ROLE_TO; /* Last recipient, set the flag... */ msg[1].recipients[0].recip_flags = 0 | CMC_RECIP_LAST_ELEMENT; rc = cmc_send(sessid, msg, flgs, ui_id, extensions); /* I am just printing the return, you will probably want to stop */ /* if you don't get a 0 return... */ printf("SEND = %d\n", rc); } void cmcsenddocs(void) { /* SET UP ADDRESSES */ strcpy(addresses, "YOU@THERE.COM,ME@HERE.COM,BCC:BOSS@HERE.COM"); /* SET UP TEXT */ strcpy(text, "Thou art luck. I have sent the a document."); /* NOTE: If you have no text, any NULL character pointer will do... */ /* SET UP SUBJECT */ strcpy(subject, "ALMOST FREE UNLIMITED TIME OFFER!"); /* NOTE: If you have no subject, any NULL character pointer will do... */ /* SET UP TITLES */ strcpy(titles, "Some Text,A Program"); /* NOTE: If you have no titles, any NULL character pointer will do... */ /* SET UP FILES */ strcpy(files, "FILE.GRP.ACCT01,FILE.GRP.ACCT02"); /* NOTE: If you have no titles, any NULL character pointer will do... */ /* DELIMITER is a comma! */ strcpy(delimiter, ","); /* LEAVE FLAGS AT 0 THIS TIME. */ flags = 0; rc = cmc_send_documents(addresses, subject, text, flags, files, titles, delimiter, ui_id); printf("SEND_DOC = %d\n", rc); } void cmclogoff(void) { /* Set FLGS to 0 because we don't support any UIs... */ flgs = 0; rc = cmc_logoff(sessid, ui_id, flgs, extensions); /* I am just printing the return, you will probably want to stop */ /* if you don't get a 0 return... */ printf("LOGOFF = %d\n", rc); } void cmcprintconfig(void) { int ii; CMC_session_id temp_id; CMC_enum what, et; CMC_extension *none; CMC_string str; CMC_object_identifier *oi; CMC_boolean boo; CMC_uint16 uint; temp_id = 0; /* Not logged on... */ none = (CMC_extension *)NULL; /* What character set? */ what = CMC_CONFIG_CHARACTER_SET; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&oi, none); if(rc == 0) { for(ii = 0; ii < 100 && oi[ii] != NULL; ii++) { printf("Char set: %s\n", oi[ii]); cmc_free(oi[ii]); } cmc_free(oi); } else printf("Char set: ???\n"); /* What line terminator? */ what = CMC_CONFIG_LINE_TERM; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&et, none); printf("Line terminator: "); if(rc == 0) { switch(et) { case CMC_LINE_TERM_CRLF: printf("CR/LF\n"); break; case CMC_LINE_TERM_LF: printf("LF\n"); break; case CMC_LINE_TERM_CR: printf("CR\n"); break; default: printf("BOGUS RETURN!\n"); } } else printf("???\n"); /* What default service? */ what = CMC_CONFIG_DEFAULT_SERVICE; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&str, none); if(rc == 0) { printf("Default service: %s\n", str); cmc_free(&str); } else printf("Default service: ???\n"); /* What default user? */ what = CMC_CONFIG_DEFAULT_USER; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&str, none); if(rc == 0) { printf("Default user: %s\n", str); cmc_free(&str); } else printf("Default user: ???\n"); /* Password required? */ what = CMC_CONFIG_REQ_PASSWORD; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&et, none); printf("Password: "); if(rc == 0) { switch(et) { case CMC_REQUIRED_NO: printf("Not required\n"); break; case CMC_REQUIRED_OPT: printf("Optional\n"); break; case CMC_REQUIRED_YES: printf("Required\n"); break; default: printf("BOGUS RETURN!\n"); } } else printf("???\n"); /* Service name required? */ what = CMC_CONFIG_REQ_SERVICE; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&et, none); printf("Service name: "); if(rc == 0) { switch(et) { case CMC_REQUIRED_NO: printf("Not required\n"); break; case CMC_REQUIRED_OPT: printf("Optional\n"); break; case CMC_REQUIRED_YES: printf("Required\n"); break; default: printf("BOGUS RETURN!\n"); } } else printf("???\n"); /* User required? */ what = CMC_CONFIG_REQ_USER; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&et, none); printf("User: "); if(rc == 0) { switch(et) { case CMC_REQUIRED_NO: printf("Not required\n"); break; case CMC_REQUIRED_OPT: printf("Optional\n"); break; case CMC_REQUIRED_YES: printf("Required\n"); break; default: printf("BOGUS RETURN!\n"); } } else printf("???\n"); /* UI available? */ what = CMC_CONFIG_UI_AVAIL; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&boo, none); if(rc == 0) if(boo == CMC_TRUE) printf("UI: Available\n"); else printf("UI: Not available\n"); else printf("UI: ???\n"); /* DO_NOT_MARK_AS_READ supported? */ what = CMC_CONFIG_SUP_NOMKMSGREAD; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&boo, none); if(rc == 0) if(boo == CMC_TRUE) printf("DO_NOT_MARK_AS_READ supported: Yes\n"); else printf("DO_NOT_MARK_AS_READ supported: No\n"); else printf("DO_NOT_MARK_AS_READ supported: ???\n"); /* COUNTED_STRING supported? */ what = CMC_CONFIG_SUP_COUNTED_STR; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&boo, none); if(rc == 0) if(boo == CMC_TRUE) printf("Counted string: Supported\n"); else printf("Counted string: Not supported\n"); else printf("Counted string: ???\n"); /* Which version? */ what = CMC_CONFIG_VER_IMPLEM; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&uint, none); if(rc == 0) printf("Version (implementation): %d\n", uint); else printf("Version (implementation): ???\n"); /* Which spec? */ what = CMC_CONFIG_VER_SPEC; rc = cmc_query_configuration(temp_id, what, (CMC_buffer)&uint, none); if(rc == 0) printf("Version (specs): %d\n", uint); else printf("Version (specs): ???\n"); }