Click here to Skip to main content
15,886,095 members
Articles / Desktop Programming / MFC

Scan2PDF

Rate me:
Please Sign up or sign in to vote.
4.90/5 (75 votes)
22 Apr 20053 min read 432.9K   20.9K   230  
A utility for bulk scanning, converting the scanned pages to PDF and burning them on CD/DVD for archiving.
/******************************************************************************
|* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|* PARTICULAR PURPOSE.
|* 
|* Copyright 1995-2004 Ahead Software AG. All Rights Reserved.
|*-----------------------------------------------------------------------------
|* NeroSDK / NeroCmd
|*
|* PROGRAM: AddLogLineCallback.cpp
|*
|* PURPOSE: AddLogLine callback implementation
******************************************************************************/


#include "stdafx.h"
#include "BurnContext.h"


// This is a Nero callback. The text may cointain several lines
// separated by newline characters: NL(LF) '\n' and is null character terminated.

void NERO_CALLBACK_ATTR CBurnContext::AddLogLine (void *pUserData, NERO_TEXT_TYPE type, const char *text)
{
	const char *header;
	const char *start;

	// Evaluate the type of log entry that should be added
	// and assign the line header accordingly.

	switch (type)
	{
		case NERO_TEXT_INFO:        // informative text
			header = "[i]";
			break;
		case NERO_TEXT_STOP:        // some operation stopped prematurely
			header = "[#]";
			break;
		case NERO_TEXT_EXCLAMATION: // important information 
			header = "[!]";
			break;
		case NERO_TEXT_QUESTION:    // a question which requires an answer
			header = "[?]";
			break;
		case NERO_TEXT_DRIVE:		// a message concerning a CD-ROM drive or recorder
			header = "[-]";
			break;
		default:
			header = "";
	}

	// Step through the message text, considering newline characters
	// and inserting a line break every 76 characters if the line is longer

	start = text;
	while (*start)
	{
		// search for newline NL(LF) and set a pointer to the 
		// next newline character. If no newline is found end becomes NULL.

		char *end = (char*)strchr (start, '\n');

		// Determine the length of the string part to be printed.
		// If a newline character was found the length is the difference between end and start
		// Otherwise there is no newline between the current position of start in the string
		// and the end of the string. So the length can be determined by a simple call to strlen.

		int len;
		if (NULL != end)
		{
			len = end - start;
			
			// replace newline character with 0 to not print parts of the following line
			*end = 0;
		}
		else
		{
			len = strlen (start);
		}

		// We also make sure that no more than 76 characters are printed
		// no matter how long the current string part really is.

		if (len > 76)
		{
			len = 76;
		}

		// The formatted output:

		printf ("%-4.4s%-76.76s", header, start);
		header = ""; // we print the header only in the first line


		// Shift the start pointer right by the amount of bytes just printed.

		start += len;

		// If newline characters were found start has to be set to the next character
		// If end contains NULL this means that either no newlines were found or
		// the end of the string has been reached.


		if (NULL != end)
		{
			++start;
		}
	}

	printf("\n");
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Solaris Electronics LLC
United Arab Emirates United Arab Emirates
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:


You can see list of my articles, by clicking here


Comments and Discussions