Exemple #1
0
_declspec ( dllexport ) WORD GetServerNames(HANDLE serverList,
											char retServerNames[MAXPATH][MAXPATH])
{
	char szServerString[MAXPATH]="";
	BYTE far *pServerList;
	WORD wServerCount;
	WORD *pwServerLength;
	BYTE far *pServerName;

	pServerList  = (BYTE far *)OSLockObject(serverList);
	wServerCount = (WORD) *pServerList;
	pwServerLength = (WORD *)(pServerList + sizeof(WORD));
	pServerName = (BYTE far *) pServerList + sizeof(wServerCount) + ((wServerCount) * sizeof(WORD));
	memmove (szServerString, "Local", strlen("Local"));
	szServerString[5] = '\0'; 		
	strcpy_s(retServerNames[0], 6, szServerString);

	for (UINT i=0; i<wServerCount; pServerName+=pwServerLength[i], i++)
	{
		memmove (szServerString, pServerName, pwServerLength[i]);
		szServerString[pwServerLength[i]] = '\0'; 	
		strcpy_s(retServerNames[i+1], MAXPATH, szServerString);
	}
	OSUnlockObject (serverList);
	OSMemFree (serverList);
	
	return wServerCount;
}
Exemple #2
0
WORD _stdcall gCWF_ERROR_PROC(const void far *pCDField,WORD phase,STATUS error,HANDLE ErrorText,WORD wErrorTextSize,void far *ctx)
{
	_CD		*cd = (_CD*)OSLockObject(ErrorText);
	CDFIELD	*field = (CDFIELD*)pCDField;

//	Dump_Text((char*)dump_ptr,pcd->text.Header.Length - sizeof(pcd->text));


	char	*cptr = (char*)cd;
	glog._log(LOG_ERROR,"gCWF_ERROR_PROC phase = %u, error = %X, text = %s",phase,error,cptr);
	OSUnlockObject(ErrorText);
	return CWF_NEXT_FIELD;
}
Exemple #3
0
/** eus_MimeAtchFileCtnt( ***
Saves the body content of a MIME part as a file attachment to the specified 
Notes document, base64 decoding it if necessary, in the manner Notes itself 
does with MIME body-part attachments.

--- parameters & return ----
pt_CTNT: address of information structure describing the raw MIME part and the 
	type of attachment (and its name) that needs to be accomplished
pt_bufFl: Optional Input & Output. Address of a buffered-file object managed by 
	the LibFileSystem.h module. If input is provided, the raw MIME part is 
	contained within this file, and all content pointers in the pt_CTNT 
	information structure represent relative offsets into the file. Opaque file 
	object will undergo change as a result of this procedure's work. If null, 
	procedure infers that the MIME part resides in a memory buffer, and this 
	input-output parameter is ignored.
h_NOTE: handle to the Notes document to which the file attachment should be made
ppc: Optional Output. Address of pointer variable to receive address of 
	filename associated with the attachment. Caller is responsible for freeing 
	the memory allocated to the string. If null, output is supressed.
RETURN:
	eus_ERR_INVLD_ARG if any input is obviously invalid
	!eus_SUCCESS if a base64 decoding error occurred
	eus_SUCCESS if no error occured
	the Notes API error code otherwise

--- revision history -------
3/14/03 PR: created			*/
STATUS eus_MimeAtchFileCtnt( const MimePrtCtnt *const  pt_CTNT, 
								BufFile *const  pt_bufFl, 
								const NOTEHANDLE  h_NOTE, 
								char * *const  ppc)	{
	const DWORD  ul_LEN_BUF_DFLT = 0x200 * 0x400;
	const WORD  us_LEN_LINE_MAX = 0x50;

	size_t  ui_lenPrt, ui, ui_len = NULL;
	DWORD  ul_lenObj, ul_lenObjBuf;
	char  pc_atchNm[ MAXPATH];
	DBHANDLE  h_db;
	ObjInfo  t_obj;
	HANDLE  h = NULL;
	char * pc, * pc_end;
	long  l, l_, l_end;
	BYTE * puc, * puc_, * puc_end, * puc_bufIn = NULL;
	STATUS  us_err;
	BOOL  f_fail = FALSE;

	if (!( pt_CTNT && pt_CTNT->ui_len && pt_CTNT->puc_ctnt && 
								pt_CTNT->puc_atchNm && pt_CTNT->us_lenAtchNm && 
								pt_CTNT->puc_bdy && h_NOTE))
		return eus_ERR_INVLD_ARG;

	*ppc = NULL;

	//determine the length of the body part and ending coördinate
	if (!( ui_lenPrt = pt_CTNT->ui_len - (pt_CTNT->puc_bdy - 
															pt_CTNT->puc_ctnt)))
		return eus_ERR_INVLD_ARG;

	//Note the encoding involved, if any, and get ahold of the attachment name. 
	//	(Only base64 and no-encoding are currently supported.)
	if (!pt_bufFl)	{
		if (pt_CTNT->puc_encdg && strnicmp( epc_MIM_CTNTENC_B64, 
											pt_CTNT->puc_encdg, 
											eus_LEN_MIM_CTNTENC_B64) != ei_SAME)
			return eus_ERR_INVLD_ARG;
		memcpy( pc_atchNm, pt_CTNT->puc_atchNm, pt_CTNT->us_lenAtchNm);
	}else	{
		if (pt_CTNT->puc_encdg)	{
			if (el_bufFileCpyCtnt( (long) pt_CTNT->puc_encdg, 
											eus_LEN_MIM_CTNTENC_B64, pc_atchNm, 
											pt_bufFl) < eus_LEN_MIM_CTNTENC_B64)
				return !eus_SUCCESS;
			if (strnicmp( epc_MIM_CTNTENC_B64, pc_atchNm, 
											eus_LEN_MIM_CTNTENC_B64) != ei_SAME)
				return eus_ERR_INVLD_ARG;
		}
		if (el_bufFileCpyCtnt( (long) pt_CTNT->puc_atchNm, 
											pt_CTNT->us_lenAtchNm, pc_atchNm, 
											pt_bufFl) < pt_CTNT->us_lenAtchNm)
			return !eus_SUCCESS;
	} //if (!pt_bufFl)
	pc_atchNm[ pt_CTNT->us_lenAtchNm] = NULL;

	//begin a Notes database object of the size ultimately needed
	ul_lenObj = pt_CTNT->puc_encdg ? ui_lenPrt * 3 / 4 : ui_lenPrt;
	NSFNoteGetInfo( h_NOTE, _NOTE_DB, &h_db);
	if (!h_db)
		return eus_ERR_INVLD_ARG;
	if (us_err = eus_PrepObjectWrite( h_db, ul_lenObj, &t_obj))
		return us_err;

	//allocate a Notes memory block for use in populating the database object
	ul_lenObjBuf = ui_lenPrt < ul_LEN_BUF_DFLT ? ui_lenPrt : ul_LEN_BUF_DFLT;
	if (us_err = OSMemAlloc( NULL, ul_lenObjBuf, &h))
		goto errJump;

	//if base64 decoding needs to be done...
	if (pt_bufFl)	{
		l = (long) pt_CTNT->puc_bdy;
		l_end = l + ui_lenPrt;
	}else	{
		puc = pt_CTNT->puc_bdy;
		puc_end = puc + ui_lenPrt;
	}
	if (pt_CTNT->puc_encdg)
		//until all the attachment content has been processed...
		do	{
			BYTE * puc_bufOut;
			size_t  ui_lenOut;

			//set up the Notes-owned buffer
			pc = puc_bufIn = OSLockObject( h);
			pc_end = pc + ul_lenObjBuf;

			//fill a Notes-owned buffer with base64 encoded content, CRLFs 
			//	stripped out...
			do	{
				//locate the end of the current line, append it to the buffer, 
				//	and get in position for next
				if (pt_bufFl)	{
					if (( l_ = el_bufFileSeekStr( epc_CRLF, l, 
													l + us_LEN_LINE_MAX, 
													pt_bufFl)) == ei_FAIL)	{
						us_err = eus_ERR_INVLD_ARG;
						goto errJump;
					}
					ui = l_ - l;
					if (f_fail = el_bufFileCpyCtnt( l, ui, pc, pt_bufFl) < 
																	(int) ui)
						goto errJump;
					l = l_ + eui_LEN_CRLF;
				}else	{
					if (!( puc_ = epc_strInBuf( epc_CRLF, puc, us_LEN_LINE_MAX, 
															eui_LEN_CRLF)))	{
						us_err = eus_ERR_INVLD_ARG;
						goto errJump;
					}
					ui = puc_ - puc;
					memcpy( pc, puc, ui);
					puc = puc_ + eui_LEN_CRLF;
				} //if (pt_bufFl)

				//position on the next-write buffer position
				pc += ui;
			} while (pc < pc_end - us_LEN_LINE_MAX * 3 / 4 && (pt_bufFl ? l < 
														l_end : puc < puc_end));
			*pc = NULL;

			//base64 decode the buffer
			if (f_fail = !f_base64decode( &puc_bufOut, &ui_lenOut, puc_bufIn))
				goto errJump;

			//copy the decoded output back into the Notes buffer and unlock the 
			//	buffer, then write the decoded output to the attachment object
			memcpy( puc_bufIn, puc_bufOut, ui_lenOut);
			free( puc_bufOut);
			OSUnlockObject( h);
			puc_bufIn = NULL;
			if (us_err = eus_AppendToObject( h, ui_lenOut, &t_obj))
				goto errJump;

			//keep track of the total length written to database object
			ui_len += ui_lenOut;
		} while (pt_bufFl ? l < l_end : puc < puc_end);
	//else simply write the part's body content directly into the attachment 
	//	object...
	else
		//until all the attachment content has been processed...
		do	{
			//set up the Notes-owned buffer
			pc = puc_bufIn = OSLockObject( h);
			pc_end = pc + ul_lenObjBuf;

			//fill a Notes-owned buffer with content
			ui = ui_lenPrt - ui_len < ul_lenObjBuf ? ui_lenPrt - ui_len : 
																ul_lenObjBuf;
			if (pt_bufFl)	{
				if (f_fail = el_bufFileCpyCtnt( l, ui, pc, pt_bufFl) < (int) ui)
					goto errJump;
				l += ui;
			}else	{
				memcpy( pc, puc, ui);
				puc += ui;
			} //if (pt_bufFl)

			//write the content to the attachment object
			OSUnlockObject( h);
			puc_bufIn = NULL;
			if (us_err = eus_AppendToObject( h, ui, &t_obj))
				goto errJump;

			//keep track of the total length written to database object
			ui_len += ui;
		} while (pt_bufFl ? l < l_end : puc < puc_end);
		OSMemFree( h);

	//commit the now fully compiled object to the note
	if (us_err = eus_CommitObject( h_NOTE, NULL, pc_atchNm, HOST_MSDOS, NULL, 
																NULL, &t_obj))
		goto errJump;

	//if we're working via a bufferred file, reflow the body part content 
	//	since overwritten
	if (pt_bufFl)
		f_fail = !ef_bufFileSpliceToPrfx( (long) pt_CTNT->puc_ctnt, 
												pt_CTNT->puc_bdy - 
												pt_CTNT->puc_ctnt, pt_bufFl);

	if (ppc && !f_fail)
		if (*ppc = malloc( pt_CTNT->us_lenAtchNm + 1))	{
			memcpy( *ppc, pc_atchNm, pt_CTNT->us_lenAtchNm);
			(*ppc)[ pt_CTNT->us_lenAtchNm] = NULL;
		}else
			us_err = eus_ERR_MEM;

	return us_err + f_fail;

errJump:
	if (h)	{
		if (puc_bufIn)
			OSUnlockObject( h);
		OSMemFree( h);
	}
	eus_releaseObject( &t_obj);

	return us_err + f_fail;
} //eus_MimeAtchFileCtnt(
/** eus_GetDesignNote( ***
Obtain the NoteID of the specified database design note.

--- parameters & return ------
h_DB_TARGET: handle to the target database
us_NOTE_CLASS: The class(es) of design note to be located in the target 
	database. Multiple non-single-instance classes may be specified by ORing 
	them together.
pc_NOTENM: Optional. Pointer to the name of the design-element note to be 
	located in the target database. Required if the note class 
	(us_NOTE_CLASS) is not of the unique-note type. If the note class is of 
	the unique-note type, the parameter is ignored.
pnid: Output. Address of the variable in which to store the NoteID of the 
	located design note.
RETURN:
	eus_SUCCESS if no error occured
	!eus_SUCCESS if invalid parameters were passed
	ERR_NOT_FOUND if specified design note could not be located in the 
		database
	the Notes API error code otherwise

--- suggested enhancement ----
2/22/00 PR
+ should not search for aliases in view/folder, agent or page notes as those 
  do aliasing by pipe delimiter in a regular text field (not text-list), and 
  NIFFindDesignNote() finds aliases in such notes correctly
+ important to allow case-insensitivity when searching aliases, as 
  NIFFindDesignNote() works that way

--- revision history ---------
2/22/00 PR: created			*/
STATUS eus_GetDesignNote( DBHANDLE  H, 
							const WORD  us_NOTE_CLASS, 
							char *const  pc_NOTENM, 
							NOTEID *const  pnid)	{
	const BOOL  f_SPECIAL_DESIGN_NOTE = !!(us_NOTE_CLASS & 
												NOTE_CLASS_SINGLE_INSTANCE);

	HCOLLECTION  hcl;
	COLLECTIONPOSITION  t_pos;
	WORD  us_flags;
	NOTEID  nid, nid_tentative;
	STATUS  us_err, us_errTemp;

	if (!( H && us_NOTE_CLASS && (!pc_NOTENM ? f_SPECIAL_DESIGN_NOTE : 
															TRUE) && pnid))
		return !eus_SUCCESS;

	*pnid = nid = nid_tentative = NULL;

	//if we're looking for a "special" design note (i.e. one-of-a-kind and 
	//	therefore not necessary to "name"), try to get ahold of it and return 
	//	the result
	if (f_SPECIAL_DESIGN_NOTE)
		return NSFDbGetSpecialNoteID( H, (WORD) (SPECIAL_ID_NOTE | 
														us_NOTE_CLASS), pnid);

	//if the named design note can be located by normal means, do so and 
	//	return the result
	if ((us_err = NIFFindDesignNote( H, pc_NOTENM, us_NOTE_CLASS, pnid)) && 
												ERR( us_err) != ERR_NOT_FOUND)
		return us_err;
	if (!us_err)
		return eus_SUCCESS;

	//Since the name wasn't found by main title, we will try to to find a 
	//	matching alias. First, get ahold of the database's design-note 
	//	collection.
	if (us_err = NIFOpenCollection( H, H, NOTE_CLASS_DESIGN | 
									NOTE_ID_SPECIAL, OPEN_SHARED_VIEW_NOTE, 
									NULLHANDLE, &hcl, NULL, NULL, NULL, NULL))
		return us_err;

	//then for each design note...
	memset( &t_pos, NULL, sizeof( COLLECTIONPOSITION));
	do	{
		const DWORD  ul_ALL_ENTRIES = 0xFFFFFFFF;
		const WORD  us_OFFSET_STATIC = sizeof( NOTEID) + sizeof( WORD);

		HANDLE  h;
		DWORD  ul;
		void * pv_entry;
		WORD  us_entry;

		if ((us_err = NIFReadEntries( hcl, &t_pos, NAVIGATE_NEXT, 1, 
									NAVIGATE_NEXT, ul_ALL_ENTRIES, 
									READ_MASK_NOTEID | READ_MASK_NOTECLASS | 
									READ_MASK_SUMMARY, &h, NULL, NULL, &ul, 
									&us_flags)) || !ul)
			goto errJump;
		pv_entry = OSLockObject( h);
		for (us_entry = 0; us_entry < ul; us_entry++, (BYTE *) pv_entry += 
										us_OFFSET_STATIC + ((ITEM_TABLE *) 
										((BYTE *) pv_entry + 
										us_OFFSET_STATIC))->Length)	{
			void * pv;
			WORD  us_typ, us_count, us;

			//if the note is not of the desired design class, loop for the 
			//	next note
			if (!( *(WORD *) ((NOTEID *) pv_entry + 1) & us_NOTE_CLASS))
				continue;

			//if the note has no alias info, loop for the next note
			if (!NSFLocateSummaryValue( (ITEM_TABLE *) ((BYTE *) pv_entry + 
											us_OFFSET_STATIC), FIELD_TITLE, 
											&pv, &us, &us_typ) || 
											us_typ != TYPE_TEXT_LIST)
				continue;

			//if no alias match is found, loop for the next note
			if (!ef_TextListContainsEntry( pv, FALSE, pc_NOTENM, &us, 
																&us_count))
				continue;
			_ASSERTE( us && us_count > 1);

			//if our match is the last alias in the title item, or if the 
			//	last alias is also a match, set the output NoteID, then 
			//	break out of these loops
			if (us == us_count - 1 || ef_TextListEntryMatches( pv, FALSE, 
													(WORD) (us_count - 1), 
													pc_NOTENM))	{
				nid = *(NOTEID *) pv_entry;
				break;
			}

			//if we haven't found another already, note that we've found a 
			//	tentative match
			if (!nid_tentative)
				nid_tentative = *(NOTEID *) pv_entry;
		} //for (us_entry = 0; us_entry < ul

		//free resouces associated with this instance of reading the 
		//	design-note collection
		OSUnlockObject( h);
		OSMemFree( h);
	} while (us_flags & SIGNAL_MORE_TO_DO && !nid);

	//if no "output" NoteID was set...
	if (!nid)
		//if a tentative NoteID match was found...
		if (nid_tentative)
			//we can now bless it as the actual match, so commit it as the 
			//	output NoteID
			*pnid = nid_tentative;
		//else set an error that the note was not found
		else
			us_err = ERR_NOT_FOUND;
	//else commit the "output" NoteID as the actual output
	else
		*pnid = nid;

errJump:
	if (us_errTemp = NIFCloseCollection( hcl))
		if (!us_err)
			us_err = us_errTemp;

	return us_err;
} //eus_GetDesignNote(
Exemple #5
0
_declspec ( dllexport ) void * ATOM_OSLockObject(HANDLE handle)
{
	return OSLockObject(handle);
}
Exemple #6
0
_declspec ( dllexport ) WORD GetServerNamesEx(char retServerNames[MAX_SERVERS][MAXPATH])
{
	BOOL status = NOERROR;
	char szLocation[MAXENVVALUE];
	char szPAB[MAXENVVALUE];
	HANDLE db;
	char full_netpath[MAXPATH-1];
	NOTEID view_id;
	HCOLLECTION hCollection;
	COLLECTIONPOSITION pCollPosition;
	HANDLE hBuffer;
	DWORD NumberReturned = 0;
	NOTEID *IdList;
	NOTEHANDLE note;
	char szFieldName[80] = { 0 };
	char szFieldType[80] = { 0 };
	WORD retServerCount = 0;
	bool bUseLocal = false;

	// first, get the name of the current location
	status = OSGetEnvironmentString("Location", szLocation, MAXENVVALUE);
	if (status == TRUE) 
	{
		char *pb = strchr(szLocation, ',');
		if (pb != NULL)
			*pb = 0 ;
	}

	status = OSGetEnvironmentString("MAILSERVER", szPAB, MAXENVVALUE);
	if (status == TRUE) 
	{
		char *pb = strchr(szPAB, ',');
		if (pb != NULL)
			*pb = 0 ;
	}

	if (status = OSPathNetConstruct(NULL, szPAB, _T("names.nsf"), full_netpath))
	{
		printf("unable to open the public NAB %s!!names.nsf\n", szFieldName);
		return 0;
	}

	if (status = NSFDbOpen (full_netpath, &db))
        return 0;

	if (bUseLocal)
	{
		// choose local PAB view
		if (status = NIFFindView(db, _T("Connections"), &view_id))
		{
			NSFDbClose(db);
			return 0;
		}
	} else
	{
		// choose server list from server Directory
		if (status = NIFFindView(db, _T("Servers"), &view_id))
		{
			NSFDbClose(db);
			return 0;
		}
	}

	if (status = NIFOpenCollection( db,	 
									db,	  
		                			view_id,	 
									0,		   
		                			NULLHANDLE,	  
                					&hCollection,	 
		                			NULL,		   
		                			NULL,		
									NULL,	    	
		                			NULL ))	
	{
		NSFDbClose(db);
		return 0;
	}

	pCollPosition.Level = 0;
	pCollPosition.Tumbler[0] = 1;

	 if (status = NIFReadEntries(hCollection,	
							     &pCollPosition,		
							     NAVIGATE_CURRENT,	   
							     1L,		
							     NAVIGATE_NEXT,	   
							     0xFFFFFFFF,		  
							     READ_MASK_NOTEID,	
							     &hBuffer,	  
							     NULL,		 
							     NULL,		 
							     &NumberReturned,	  
							     NULL))		
	 {
		NIFCloseCollection(hCollection);
		NSFDbClose(db);
		return 0;
	 }

	 strcpy_s(retServerNames[retServerCount++], MAXPATH, _T("Local"));
	 if (NumberReturned != 0) 
	 {
		if (hBuffer != NULLHANDLE)
        {
    		IdList = (NOTEID far *)OSLockObject(hBuffer);
    		for (DWORD i=0; i<(DWORD)NumberReturned; i++)
			{
  				if (status = NSFNoteOpen( db, IdList[i], 0, &note))
				{
					// skip categories
				} else
				{
					// scan documents
					WORD lenFieldName = NSFItemGetText(note, 
													  (bUseLocal) ? _T("Destination") : _T("ServerName"), 
													  szFieldName, 
													  sizeof(szFieldName)); 
					strcpy_s(retServerNames[retServerCount++], MAXPATH, szFieldName);
					status = NSFNoteClose(note);
				}
			}
			OSUnlockObject(hBuffer);
            OSMemFree(hBuffer);
		}
	}

	if (status)
	{
		NIFCloseCollection(hCollection);
		NSFDbClose(db);
		return 0;
	}

	if (status = NIFCloseCollection(hCollection))
	{
		NSFDbClose(db);
		return 0;
	}

	if (status = NSFDbClose(db))
		return 0;

	return retServerCount;
}