示例#1
0
/**
 * Build checksums for a binary/library found at path
 */
static void build_binary_checksum(char *path)
{
	char *binary, *pos, name[128], sname[128];

	binary = strrchr(path, '/');
	if (binary)
	{
		binary++;
		pos = strrchr(binary, '.');
		if (pos && streq(pos, ".so"))
		{
			snprintf(name, sizeof(name), "%.*s\",", (int)(pos - binary),
					 binary);
			if (streq(name, "libstrongswan\","))
			{
				snprintf(sname, sizeof(sname), "%s", "library_init");
			}
			else
			{
				snprintf(sname, sizeof(sname), "%.*s_init", (int)(pos - binary),
						 binary);
			}
			build_checksum(path, name, sname);
		}
		else
		{
			snprintf(name, sizeof(name), "%s\",", binary);
			build_checksum(path, name, NULL);
		}
	}
}
示例#2
0
void CommitEditor::alterFile(jstring jrelpath, jlong jrevision,
                             jobject jchecksum, jobject jcontents,
                             jobject jproperties)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  InputStream contents(jcontents);
  PropertyTable properties(jproperties, true, false);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN::Pool subPool(pool);
  Relpath relpath(jrelpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(relpath.error_occurred(),);

  svn_checksum_t checksum = build_checksum(jchecksum, subPool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(svn_editor_alter_file(
                  m_editor, relpath.c_str(), svn_revnum_t(jrevision),
                  (jcontents ? &checksum : NULL),
                  (jcontents ? contents.getStream(subPool) : NULL),
                  properties.hash(subPool)),);
}
示例#3
0
/**
 * Build checksums for a set of plugins
 */
static void build_plugin_checksums(char *plugins)
{
	enumerator_t *enumerator;
	char *plugin, path[256], under[128], sname[128], name[128];

	enumerator = enumerator_create_token(plugins, " ", " ");
	while (enumerator->enumerate(enumerator, &plugin))
	{
		snprintf(under, sizeof(under), "%s", plugin);
		translate(under, "-", "_");
		snprintf(path, sizeof(path), "%s/libstrongswan-%s.so",
				 PLUGINDIR, plugin);
		snprintf(sname, sizeof(sname), "%s_plugin_create", under);
		snprintf(name, sizeof(name), "%s\",", plugin);
		build_checksum(path, name, sname);
	}
	enumerator->destroy(enumerator);
}
示例#4
0
////////////////////////////////////////////////////////////////////////////////////////////
//
// CAMERA IO FUNCTION
//
//
////////////////////////////////////////////////////////////////////////////////////////////
DWORD CPco_cl_com::Control_Command(void *buf_in,DWORD size_in,
                                   void *buf_out,DWORD size_out)
{
  DWORD err=PCO_NOERROR;
  unsigned char buffer[PCO_SC2_DEF_BLOCK_SIZE];
  unsigned int size;
  WORD com_in,com_out;

/*
  if(hComMutex==NULL)
   writelog(COMMAND_M,hdriver,"Control_Command: No Mutex no wait");
  else
  {
   err = WaitForSingleObject(hComMutex,tab_timeout.command*3);
   writelog(COMMAND_M,hdriver,"Control_Command: Wait Mutex 0x%x done err=%d",hComMutex,err);
   switch (err)
   {
    case WAIT_OBJECT_0:
     break;
// Cannot get mutex ownership due to time-out.
    case WAIT_TIMEOUT:
    {
     writelog(ERROR_M,hdriver,"Control_Command: Timeout waiting for Mutex 0x%x",hComMutex);
     return PCO_ERROR_TIMEOUT | PCO_ERROR_DRIVER | PCO_ERROR_DRIVER_USB;
    }

// Got ownership of the abandoned mutex object.
    case WAIT_ABANDONED:
    {
     writelog(ERROR_M,hdriver,"Control_Command: Mutex abandoned");
     return PCO_ERROR_INVALIDHANDLE | PCO_ERROR_DRIVER | PCO_ERROR_DRIVER_USB;
    }
   }
  }
*/


//  if(clFlushPort)
  {
   err=clFlushPort(serialRef);
   if((int)err<0)
   {
    writelog(ERROR_M,hdriver,"Control_Command: pclSerialFlush error = %d",err);
   }
  }


  writelog(COMMAND_M,hdriver,"Control_Command: start= 0x%04x timeout %d",*(unsigned short*)buf_in,tab_timeout.command);

  com_out=0;
  com_in=*((WORD*)buf_in);
  memset(buffer,0,PCO_SC2_DEF_BLOCK_SIZE);

  size=size_in;
  err=build_checksum((unsigned char*)buf_in,(int*)&size);

  err=clSerialWrite(serialRef,(char*)buf_in,&size,tab_timeout.command);
  if((int)err<0)
  {
   writelog(ERROR_M,hdriver,"Control_Command: pclSerialWrite error = %d",err);
   err=PCO_ERROR_DRIVER_IOFAILURE | PCO_ERROR_DRIVER_CAMERALINK;
   goto sercom_out;
  }

  size=sizeof(WORD)*2;

  err=clSerialRead(serialRef,(char*)&buffer[0],&size,tab_timeout.command*2);
  if((int)err<0)
  {
   writelog(ERROR_M,hdriver,"Control_Command: pclSerialRead size:4 back %d error = %d",size,err);
   err=PCO_ERROR_DRIVER_IOFAILURE | PCO_ERROR_DRIVER_CAMERALINK;
   goto sercom_out;
  }

  com_out=*((WORD*)buffer);

  WORD *b;
  b=(WORD *)buffer; //size of packet is second WORD
  b++;
  size=(int)*b;
  if(size>PCO_SC2_DEF_BLOCK_SIZE)
   size=PCO_SC2_DEF_BLOCK_SIZE;
  size-=sizeof(WORD)*2;

  writelog(INTERNAL_1_M,hdriver,"Control_Command: before read com_out=0x%04x size %d",com_out,size);
  if((int)size<0)
  {
   writelog(ERROR_M,hdriver,"Control_Command: SerialRead remaining size<0 %d err %d com:0x%04x",size,err,*(WORD *)buffer);
   err=PCO_ERROR_DRIVER_IOFAILURE | PCO_ERROR_DRIVER_CAMERALINK;
   goto sercom_out;
  }

  if(com_in!=(com_out&0xFF3F))
  {
   writelog(ERROR_M,hdriver,"Control_Command: SerialRead comin  0x%04x != comout&0xFF3F 0x%04x",com_in,com_out&0xFF3F);
   err=PCO_ERROR_DRIVER_IOFAILURE | PCO_ERROR_DRIVER_CAMERALINK;
   goto sercom_out;
  }

  err=clSerialRead(serialRef,(char*)&buffer[sizeof(WORD)*2],&size,tab_timeout.command*2);
  if((int)err<0)
  {
   writelog(ERROR_M,hdriver,"Control_Command: pclSerialRead size:%d back %d error = %d",*b,size,err);
   err=PCO_ERROR_DRIVER_IOFAILURE | PCO_ERROR_DRIVER_CAMERALINK;
   goto sercom_out;
  }

  err=PCO_NOERROR;

  com_out=*((WORD*)buffer);
  if((com_out&RESPONSE_ERROR_CODE)==RESPONSE_ERROR_CODE)
  {
   SC2_Failure_Response resp;
   memcpy(&resp,buffer,sizeof(SC2_Failure_Response));
   err=resp.dwerrmess;
   if((err&0xC000FFFF)==PCO_ERROR_FIRMWARE_NOT_SUPPORTED)
    writelog(INTERNAL_1_M,hdriver,"Control_Command: com 0x%x FIRMWARE_NOT_SUPPORTED",com_in);
   else
    writelog(ERROR_M,hdriver,"Control_Command: com 0x%x RESPONSE_ERROR_CODE error 0x%x",com_in,err);
   size= sizeof(SC2_Failure_Response);
  }
  else
   size=size_out;

  if(err==PCO_NOERROR)
  {
   if(com_out!=(com_in|RESPONSE_OK_CODE))
   {
    err=PCO_ERROR_DRIVER_DATAERROR | PCO_ERROR_DRIVER_CAMERALINK;
    writelog(ERROR_M,hdriver,"Control_Command: Data error com_out 0x%04x should be 0x%04x",com_out,com_in|RESPONSE_OK_CODE);
   }
  }

  writelog(INTERNAL_1_M,hdriver,"Control_Command: before test_checksum read=0x%04x size %d",com_out,size);
  if(test_checksum(buffer,(int*)&size)==PCO_NOERROR)
  {
   size-=1;
   if(size<size_out)
    size_out=size;
   memcpy(buf_out,buffer,size_out);
  }
  else
   err=test_checksum(buffer,(int*)&size);

sercom_out:
/*  if(hComMutex)
  {
   if(!ReleaseMutex(hComMutex))
    writelog(ERROR_M,hdriver,"Control_Command: release Mutex failed");
   writelog(COMMAND_M,hdriver,"Control_Command: Release Mutex 0x%x done",hComMutex);
  }
*/

  writelog(COMMAND_M,hdriver,"Control_Command: Control_command end 0x%04x err 0x%x",com_out,err);
  return err ;
}