/*************************************************************
   This function reads the link information from a file
   and populates the linkInfoTable.
   It takes the path-name for the link info file and the 
   router name as argument
   When done, static variable linkcount contains the number of routerinfo 
   stored in the table
   Returns a pointer to the linkInfoTable
**************************************************************/
linkInfo* readlinks(char* path, char* router)
{
	FILE* fp;
	char* filename;
	char* delim = " ";
	char* line;
	char* word;
	
	if(linkcount != 0) 
	{
		return linkInfoTable;
	}

	if(path == NULL)
	{
		filename = (char*)malloc(strlen(router)+7);
		strncpy(filename,".",2);
	}
	else
	{
		filename = (char*)malloc(strlen(path)+strlen(router)+6);
		strncpy(filename,path,strlen(path)+strlen(router)+6);
	}
	
	strncat(filename,"/",2);
	strncat(filename,router,strlen(router)+1);
	strncat(filename,".cfg",5);

	fp = fopen(filename,"r");

	if(fp==NULL)
	{	
		perror("Unable to open Link Information File");
		exit(0);
	}

	line = (char*)malloc(101);
	while(fgets(line,100,fp))
	{
		if(line[0] == '#' || line[0] == '\n') continue;
		
		word = strsep(&line,delim);
		linkInfoTable[linkcount].router = malloc(strlen(word)+1);
		strncpy(linkInfoTable[linkcount].router,word,strlen(word)+1);
		
		word = strsep(&line,delim);
		linkInfoTable[linkcount].cost = atoi(word);

		word = strsep(&line,delim);
		linkInfoTable[linkcount].locallink = atoi(word);

		linkInfoTable[linkcount].remotelink = atoi(line);

		linkcount++;
	}
	
	fclose(fp);

	return linkInfoTable;
}
Example #2
0
/*
 * unbuffered output: writes values of matrix to file
 */
void writeMatrix(float **m, int dim1, int dim2, int fd) {
   int length, size, ndx1, ndx2, max_dbl_chars = 4 + DBL_MANT_DIG - DBL_MIN_EXP;
   char str_bf[DFLT_STR_SIZE + 1],
    *num_bf = (char*)alloca(sizeof(char) * max_dbl_chars);

   str_bf[0] = num_bf[0] = '\0';
   size = 0;

   for (ndx1 = 0; ndx1 < dim1; ++ndx1) {
      for (ndx2 = 0; ndx2 < dim2; ++ndx2) {
         length = snprintf(num_bf, max_dbl_chars, "%.2lf%c", m[ndx1][ndx2],
          (ndx2 < dim2 - 1 ? ' ' : '\n'));

         strncpy((char*)(str_bf + size), num_bf, DFLT_STR_SIZE - size + 1);
         if (size + length > DFLT_STR_SIZE) {
            write(fd, str_bf, size);
            strncpy(str_bf, (num_bf + (DFLT_STR_SIZE - size)),
             (size = (length - (DFLT_STR_SIZE - size))) + 1);
         }
         else size += length;
      }
   }

   write(fd, str_bf, size);
}
Example #3
0
int
__pmSecureServerCertificateSetup(const char *db, const char *passwd, const char *cert_nickname)
{
    PM_INIT_LOCKS();
    PM_LOCK(secureserver_lock);

    /* Configure optional (cmdline) password file in case DB locked */
    secure_server.password_file = passwd;

    /*
     * Configure location of the NSS database with a sane default.
     * For servers, we default to the shared (sql) system-wide database.
     * If command line db specified, pass it directly through - allowing
     * any old database format, at the users discretion.
     */
    if (db) {
	/* shortened-buffer-size (-2) guarantees null-termination */
	strncpy(secure_server.database_path, db, MAXPATHLEN-2);
    }

    if (cert_nickname) {
	strncpy(secure_server.cert_nickname, cert_nickname, MAX_CERT_NAME_LENGTH-2);
    }
    else {
	strncpy(secure_server.cert_nickname, SECURE_SERVER_CERTIFICATE, MAX_CERT_NAME_LENGTH-2);
    }

    PM_UNLOCK(secureserver_lock);
    return 0;
}
Example #4
0
bool
XFace::CreateFromXFace(const char *xfacedata)
{
#ifndef HAVE_COMPFACE_H
   return false;
#else
   if(data) delete [] data;
   if(xface) delete [] xface;
   initialised = false;

   xface = new char [2500];
   strncpy(xface, xfacedata, 2500);
   data = new char [5000];
   strncpy(data, xface, 5000);
   if(uncompface(data) < 0)
   {
      delete [] data;
      delete [] xface;
      data = xface = NULL;
      return false;
   }
   String out = strutil_enforceCRLF(wxString::FromAscii(xface));
   delete [] xface;
   xface = strutil_strdup(out.ToAscii());
   initialised = true;
   return true;
#endif
}
Example #5
0
static void print_gpu_detection_stats(FILE                 *fplog,
                                      const gmx_gpu_info_t *gpu_info,
                                      const t_commrec      *cr)
{
    char onhost[266], stmp[STRLEN];
    int  ngpu;

    if (!gpu_info->bDetectGPUs)
    {
        /* We skipped the detection, so don't print detection stats */
        return;
    }

    ngpu = gpu_info->ncuda_dev;

#if defined GMX_MPI && !defined GMX_THREAD_MPI
    /* We only print the detection on one, of possibly multiple, nodes */
    strncpy(onhost, " on host ", 10);
    gmx_gethostname(onhost+9, 256);
#else
    /* We detect all relevant GPUs */
    strncpy(onhost, "", 1);
#endif

    if (ngpu > 0)
    {
        sprint_gpus(stmp, gpu_info);
        md_print_warn(cr, fplog, "%d GPU%s detected%s:\n%s\n",
                      ngpu, (ngpu > 1) ? "s" : "", onhost, stmp);
    }
    else
    {
        md_print_warn(cr, fplog, "No GPUs detected%s\n", onhost);
    }
}
int segment_display_4x7_get_identity(SegmentDisplay4x7 *segment_display_4x7, char ret_uid[8], char ret_connected_uid[8], char *ret_position, uint8_t ret_hardware_version[3], uint8_t ret_firmware_version[3], uint16_t *ret_device_identifier) {
	DevicePrivate *device_p = segment_display_4x7->p;
	GetIdentity_ request;
	GetIdentityResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), SEGMENT_DISPLAY_4X7_FUNCTION_GET_IDENTITY, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	strncpy(ret_uid, response.uid, 8);
	strncpy(ret_connected_uid, response.connected_uid, 8);
	*ret_position = response.position;
	memcpy(ret_hardware_version, response.hardware_version, 3 * sizeof(uint8_t));
	memcpy(ret_firmware_version, response.firmware_version, 3 * sizeof(uint8_t));
	*ret_device_identifier = leconvert_uint16_from(response.device_identifier);



	return ret;
}
Example #7
0
psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
{    
    char *node = NULL;
    char  model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0};   

    /* Check model name */
    node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model);
    memset(model_name, 0x0, I2C_PSU_MODEL_NAME_LEN + 1);
    memset(modelname, 0x0, modelname_len); 
    if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) {
        
        return PSU_TYPE_UNKNOWN;
    }
	
	if (!strncmp(model_name, "FSH082", strlen("FSH082")))
	{
	    if (modelname)
            strncpy(modelname, model_name, strlen("FSH082")<(modelname_len-1)?strlen("FSH082"):(modelname_len-1));
        
        return PSU_TYPE_ACBEL;
    }
    if (!strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")))
    {
        if (modelname)
            strncpy(modelname, model_name, modelname_len-1);   
        return PSU_TYPE_YM2651Y;
    }

    return PSU_TYPE_UNKNOWN;
}
Example #8
0
/* Module initialisation */
_kernel_oserror *mod_init(const char *tail, int podule_base, void *pw)
{
    char *ucpath;
    const char *aliases;

    UNUSED(tail);
    UNUSED(podule_base);
    UNUSED(pw);

    /* ensure the !Unicode resource exists */
#ifdef __riscos__
    ucpath = getenv("Unicode$Path");
#else
    ucpath = getenv("UNICODE_DIR");
#endif

    if (ucpath == NULL) {
        strncpy(ErrorGeneric.errmess, "!Unicode resource not found.",
                252);
        return &ErrorGeneric;
    }

    aliases = get_aliases_path();

    if (iconv_initialise(aliases) == false) {
        strncpy(ErrorGeneric.errmess, "Unicode:Files.Aliases not "
                "found. Please read the Iconv installation "
                "instructions.", 252);
        return &ErrorGeneric;
    }

    return NULL;
}
void LSFW_SimpleMediaDecoder::GetInfoString(char *buf, int buflen, char *title, int titlelen)
{
    // lstrcpyn(title,"libsndfile supported File Properties",titlelen);
    strncpy(title,"libsndfile supported File Properties",titlelen);
    if (IsOpen())
    {
        char temp[4096],lengthbuf[128];
        format_timestr((double) m_length / (double)m_srate,lengthbuf,sizeof(lengthbuf));
        
        SF_FORMAT_INFO fi_major;
        fi_major.format=m_sfinfo.format & SF_FORMAT_TYPEMASK;
        ptr_sf_command(0,SFC_GET_FORMAT_INFO,&fi_major,sizeof(fi_major));
        
        
        SF_FORMAT_INFO fi_subformat;
        fi_subformat.format=m_sfinfo.format & SF_FORMAT_SUBMASK;
        ptr_sf_command(0,SFC_GET_FORMAT_INFO,&fi_subformat,sizeof(fi_subformat));
        
        
        sprintf(temp,"Length: %s:\r\n"
                "Samplerate: %.0f\r\n"
                "Channels: %d\r\n"
                "Bits/sample: %d\r\n"
                "Format: %s\r\n"
                "Encoding: %s\r\n"
                "libsndfile version: %s\r\n",
                lengthbuf,m_srate,m_nch,m_bps,fi_major.name,fi_subformat.name,ptr_sf_version_string());

        // lstrcpyn(buf,temp,buflen);
        strncpy(buf,temp,buflen);
        //delete[] fi.name;
    } else
        sprintf(buf,"Error: File not has been opened succesfully");

}
void coinFromToken(CoinType *coin, const TokenType *token) {
	memset(coin, 0, sizeof(*coin));

	coin->has_coin_name = true;
	strncpy(&coin->coin_name[0], token->ticker + 1, sizeof(coin->coin_name));

	coin->has_coin_shortcut = true;
	strncpy(&coin->coin_shortcut[0], token->ticker + 1, sizeof(coin->coin_shortcut));

	coin->has_forkid = true;
	coin->forkid = token->chain_id;

	coin->has_maxfee_kb = true;
	coin->maxfee_kb = 100000;

	coin->has_bip44_account_path = true;
	coin->bip44_account_path = 0x8000003C;

	coin->has_decimals = true;
	coin->decimals = token->decimals;

	coin->has_contract_address = true;
	coin->contract_address.size = 20;
	memcpy((char*)&coin->contract_address.bytes[0], token->address, 20);
	_Static_assert(20 <= sizeof(coin->contract_address.bytes),
	               "contract_address is not large enough to hold an ETH address");

	coin->has_curve_name = true;
	strncpy(&coin->curve_name[0], "secp256k1", sizeof(coin->curve_name));
}
Example #11
0
// fill a clean game board char array with current row values
// board must be a char buff[(17 * 8) + 1] = char buf[137]
// 136 chars and 1 '\0'
void make_board(tt_data * data, char * board) {

	// row buffers are 18 chars: 16 + \n + \0
	char *TOP_NUMBERS = "     0   1   2  \n";  // top numbers
	char *ROW_DIVIDER = "   +---+---+---+\n";  // row divider
	char *top_row =     " 0 | ~o | ~o | ~o |\n";  // top row
					 // "   +---+---+---+\n"
	char *middle_row =  " 1 | ~o | ~o | ~o |\n";  // middle row
					 // "   +---+---+---+\n"
	char *bottom_row =  " 2 | ~o | ~o | ~o |\n";  // bottom row
					 // "   +---+---+---+\n"

	strncpy( board + 17 * 0, TOP_NUMBERS, 17);
	strncpy( board + 17 * 1, ROW_DIVIDER, 17);
	snprintf(board + 17 * 2, 18, top_row, 
			 data->top[0], 
			 data->top[1], 
			 data->top[2]);
	strncpy( board + 17 * 3, ROW_DIVIDER, 17);
	snprintf(board + 17 * 4, 18, middle_row, 
			 data->middle[0], 
			 data->middle[1], 
			 data->middle[2]);
	strncpy( board + 17 * 5, ROW_DIVIDER, 17);
	snprintf(board + 17 * 6, 18, bottom_row, 
			 data->bottom[0], 
			 data->bottom[1], 
			 data->bottom[2]);
	strncpy( board + 17 * 7, ROW_DIVIDER, 17);
	board[17 * 8] = '\0';
}
Example #12
0
void http_field_callback(void *data, const char *field_name, size_t field_name_len, const char *field_value, size_t field_value_size) {
    char field[field_name_len + 5];
    strncpy(field, "HTTP_", 5);
    strncpy(field + 5, field_name, field_name_len);

    PyDict_SetItem((PyObject *)data, PyString_FromStringAndSize(field, field_name_len + 5), PyString_FromStringAndSize(field_value, field_value_size));
}
Example #13
0
char *chromFileName(char *track, char *chrom, char fileName[512])
/* Return chromosome specific version of file if it exists. */
{
if (fileExists(track))
    {
    strncpy(fileName, track, 512);
    }
else
    {
    char dir[256], root[128], ext[65];
    int len;
    splitPath(track, dir, root, ext);
    /* Chop trailing / off of dir. */
    len = strlen(dir);
    if (len > 0 && dir[len-1] == '/')
        dir[len-1] = 0;
    safef(fileName, 512, "%s/%s%s%s", dir, chrom, root, ext);
    if (!fileExists(fileName))
	{
        warn("Couldn't find %s or %s", track, fileName);
	strncpy(fileName, track, 512);
	}
    }
return fileName;
}
Example #14
0
void tablo_yaz(int satir, int kolon, long tablo_adi, char *data, char *ana_data, TABLO_FORM *tablo, TABLO_BILGI *baslik)
{
	int i, data_yeri = 0, kolon_yeri = 0;
	char gecici_data[80];

	memset(gecici_data, 0, 80);
	for (i = 0; i < baslik->eleman_sayisi; i++) {
		if (tablo[i].tablo_adi == tablo_adi) {
			switch(tablo[i].hucre) {
				case YAZI: strncpy(&ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon)], &data[data_yeri], strlen(&data[data_yeri]));
						   break;
				case SAYI: kolon_yeri = tablo[i].uzunluk - strlen(basamakla(&data[data_yeri]));
						   strncpy(&ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon+kolon_yeri)], basamakla(&data[data_yeri]), strlen(basamakla(&data[data_yeri])));
						   break;
				case YUVARLAK_KUTU:
						   ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon)] = '\x07';
						   break;
				case KARE_KUTU:
					if (data[data_yeri] == 1)
						ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon)] = 'X';
					else
						ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon)] = ' ';
					break;
				case TARIH:
						if (strlen(&data[data_yeri]) == 0)
							tarih_al(&data[data_yeri]);
						formatla(&data[data_yeri], gecici_data, "##/##/####");
						strncpy(&ana_data[((tablo[i].satir+satir)*82)+(tablo[i].kolon+kolon)], gecici_data, strlen(gecici_data));
					break;
			}
		}
		data_yeri += tablo[i].uzunluk + 1;
	}
}
Example #15
0
void PieceInfo::SetModel(lcModel* Model, bool UpdateMesh)
{
	if (mModel != Model)
	{
		mFlags = LC_PIECE_MODEL;
		mModel = Model;
	}

	strncpy(m_strName, Model->GetProperties().mName.toUpper().toLatin1().data(), sizeof(m_strName));
	m_strName[sizeof(m_strName)-1] = 0;
	strncpy(m_strDescription, Model->GetProperties().mName.toLatin1().data(), sizeof(m_strDescription));
	m_strDescription[sizeof(m_strDescription)-1] = 0;

	const QStringList& MeshLines = Model->GetFileLines();

	if (UpdateMesh && !MeshLines.isEmpty())
	{
		lcMemFile PieceFile;

		foreach (const QString& Line, MeshLines)
		{
			QByteArray Buffer = Line.toLatin1();
			PieceFile.WriteBuffer(Buffer.constData(), Buffer.size());
			PieceFile.WriteBuffer("\r\n", 2);
		}
void init_file_info(char* fileName, Trans_cfg *tcfg, char file_no[], char str_file_time[], time_t &file_time) {
    memset(file_no, '\0', 5);
    memset(str_file_time, '\0', 20);
    strncpy(file_no, fileName + tcfg->timestamp_begin + tcfg->timestamp_length, tcfg->filenum_length);
    strncpy(str_file_time, fileName + tcfg->timestamp_begin, tcfg->timestamp_length);
    strcat(str_file_time, "00");
    str_file_time[19] = '\0';
    str_file_time[18] = '0';
    str_file_time[17] = '0';
    str_file_time[16] = ':';
    str_file_time[15] = str_file_time[11];
    str_file_time[14] = str_file_time[10];
    str_file_time[13] = ':';
    str_file_time[12] = str_file_time[9];
    str_file_time[11] = str_file_time[8];
    str_file_time[10] = ' ';
    str_file_time[9]  = str_file_time[7];
    str_file_time[8]  = str_file_time[6];
    str_file_time[7]  = '-';
    str_file_time[6]  = str_file_time[5];
    str_file_time[5]  = str_file_time[4];
    str_file_time[4]  = '-';
    file_time         = ToTime_t(str_file_time);
    //printf("--------------------------file_time:%d\n",file_time);
}
Example #17
0
void Database_set(struct Connection *conn, int id, const char *name, const char *email, const int age)
{
	struct Address *addr = conn->db->rows[id];
	if(addr->set) die("Already set, delete it first", conn);

	addr->id = id;
	addr->set = 1;
	addr->age = age;

	char *res = strncpy(addr->name, name, conn->db->MAX_DATA);
	int change = strlen(addr->name);
	if(change == conn->db->MAX_DATA) {
		change--;
	}
	addr->name[change] = '\0';
	if(!res) die("Name copy failed", conn);

	res = strncpy(addr->email, email, conn->db->MAX_DATA);
	change = strlen(addr->email);
	if(change == conn->db->MAX_DATA) {
		change--;
	}
	addr->email[change] = '\0';
	if(!res) die("Email copy failed", conn);
}
Example #18
0
bool Edge::set(Node * parent, const char * start, const char * end, double lng)
{
  char * p2;
  bool result;
    // start name - remove connector part
  strncpy(name1, start, MNL);
  p2 = strrchr(name1, '.');
  result = (p2 != NULL);
  if (result)
  { // must have a connector name
    *p2++ = '\0';
    strncpy(conn1, p2, MCL);
  }
    // end name - remove connector part
  strncpy(name2, end, MNL);
  p2 = strrchr(name2, '.');
  result &= (p2 != NULL);
  if (result)
  {
    *p2++ = '\0';
    strncpy(conn2, p2, MCL);
  }
  length = lng;
  return result;
}
void get_sensor_id(char *msg, char *sid)
{
    char *ptr;

    ptr = strstr(msg, "SENSOR");

    /*
       Each message from a sensor contains an ID field with the following format:
       <id>SENSORXXXX</id>
       Were XXXX is a user specified 4 digit number. Each sensor id should be
       unique to assist in forensic backtracking and prevent confusion of the
       message sources and log files.
    */

    if (ptr != NULL)
    {
        strncpy(sid, ptr, 10);
    }
    else
    {
        strncpy(sid, "SENSORXXXX", 10); /* Unknown sensor ID. */
    }

    return;
}
Example #20
0
bool Edge::setNodes(Node * parent)
{ // set relations only
  const char * p1;
  char * p2;
  Node * n;
  char b[MNL];
    // start name - remove connector part
  strncpy(b, name1, MNL);
  p2 = b;
  p1 = p2;
  n = parent;
  while (p2 != NULL)
  {
    p1 = strsep(&p2, ".");
    n = n->getChild(p1);
  }
  node1 = n;
    // end name - remove connector part
  strncpy(b, name2, MNL);
  p2 = b;
  p1 = p2;
  n = parent;
  while (p2 != NULL)
  {
    p1 = strsep(&p2, ".");
    n = n->getChild(p1);
  }
  node2 = n;
  return node1 != NULL and node2 != NULL;
}
Example #21
0
static void InitFromClass( at_waypoint_t *self, hobj_t *cls )
{
	hpair_t		*pair;
	hobj_t		*pref;

	__named_message( "\n" );

	strncpy( self->ati.type, cls->type, ATI_STRINGSIZE );
	strncpy( self->ati.name, cls->name, ATI_STRINGSIZE );
	self->ati.type[ATI_STRINGSIZE-1] = '\0';
	self->ati.name[ATI_STRINGSIZE-1] = '\0';


	pref = FindClass( at_prefs, cls->type );

	pair = FindHPair( cls, "origin" );
	if( pair )
	{
		HPairCastToVec3d( self->origin, pair );
	} else
		NotFound( "origin" );
	

	L_InsertWaypoint( self );
}
Example #22
0
// Fetch attribute text. Use a revolving queue of LBUFFS
//
char *my_atr_get(dbref obj, const char *atrname)
{
    int atr, aflags;
    dbref aowner;
    char *value;
    char name[SBUF_SIZE];
    static char buff[LBUF_SIZE][NUM_BUFFS];
    static int x = 0;

    x = (x + 1) % NUM_BUFFS;

    // Crashes and burns without this. Dunno why.
    strncpy(name, atrname, SBUF_SIZE - 1);
#ifdef TM3
    int alen;
    atr = mkattr(name);
    value = atr_pget(obj, atr, &aowner, &aflags, &alen);
#endif

#ifdef MUX
    atr = mkattr(GOD, name);
    value = atr_pget(obj, atr, &aowner, &aflags);
#endif

    strncpy(buff[x], value, LBUF_SIZE - 1);
    free_lbuf(value);

    return buff[x];
}
Example #23
0
/*------------------------------------------------------------------------*/
int scsi_inquiry (struct inquiry_data *inq) {
  scsi_6byte_cmd INQUIRY = {0x12, 0x00, 0x00, 0x00, 0x60, 0x00};
  char inquiry[96];
  if (scsi_handle_cmd(INQUIRY, 6, NULL, 0, inquiry, 96) < 0) {
    fprintf(stderr, "scsi_inquiry: INQUIRY command failed\n");
    return(RET_FAIL);
  }
  inq->peripheral_qualifier   = (char)inquiry[0] >> 5;
  inq->peripheral_device_type = (char)inquiry[0] & 0x1f;
  inq->RMB = (inquiry[1] & 0x80) > 0;
  inq->device_type_modifier   = (char)inquiry[1] & 0x7f;
  inq->ISO_version            = (char)inquiry[2] >> 6;
  inq->ECMA_version           = ((char)inquiry[2] & 0x38) >> 3;
  inq->ANSI_version           = (char)inquiry[2] & 0x07;
  inq->AENC                   = (inquiry[3] & 0x80) > 0;
  inq->TrmIOP                 = (inquiry[3] & 0x40) > 0;
  inq->response_data_format   = (char)inquiry[3] & 0x0f;
  inq->RelAdr                 = (inquiry[7] & 0x80) > 0;
  inq->WBus32                 = (inquiry[7] & 0x40) > 0;
  inq->WBus16                 = (inquiry[7] & 0x20) > 0;
  inq->Sync                   = (inquiry[7] & 0x10) > 0;
  inq->Linked                 = (inquiry[7] & 0x08) > 0;
  inq->CmdQue                 = (inquiry[7] & 0x02) > 0;
  inq->SftRe                  = (inquiry[7] & 0x01) > 0;
  inq->additional_inquiry     = inquiry[4];
  strncpy(inq->vendor,   &inquiry[8],  8);
  strncpy(inq->model,    &inquiry[16], 16);
  strncpy(inq->revision, &inquiry[32], 4);
  inq->vendor[8]   = 0;
  inq->model[16]   = 0;
  inq->revision[4] = 0;
  return(RET_SUCCESS);
}
Example #24
0
void AddNewItem (LPMRUMENU lpMruMenu, LPCSTR lpItem, BOOL fRO)
{
WORD i, j;

	for (i = 0; i < lpMruMenu->wNbItemFill; i++) {
		if (strcmpi(lpItem, (lpMruMenu->lpMRU) + 
		    ((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0)
		{         
        // Shift the other items
			for (j = i; j > 0; j--) {
				strcpy ((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j),
						(lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1)));
				lpMruMenu->lpfRO[j] = lpMruMenu->lpfRO[j-1];
			}
			strncpy(lpMruMenu->lpMRU, lpItem, lpMruMenu->wMaxSizeLruItem-1);
			lpMruMenu->lpfRO[0] = fRO;
			return;
		}
	}

	lpMruMenu->wNbItemFill = tmin(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu);

	for (i = lpMruMenu->wNbItemFill-1; i > 0; i--) {
		strcpy (lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
			lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1)));
		lpMruMenu->lpfRO[i] = lpMruMenu->lpfRO[i-1];
	}
	strncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);  
	lpMruMenu->lpfRO[0] = fRO;
}
static void topicNameFromThingAndAction(char *pTopic, const char *pThingName, ShadowActions_t action,
										ShadowAckTopicTypes_t ackType) {

	char actionBuf[10];
	char ackTypeBuf[10];

	if(SHADOW_GET == action) {
		strncpy(actionBuf, "get", 10);
	} else if(SHADOW_UPDATE == action) {
		strncpy(actionBuf, "update", 10);
	} else if(SHADOW_DELETE == action) {
		strncpy(actionBuf, "delete", 10);
	}

	if(SHADOW_ACCEPTED == ackType) {
		strncpy(ackTypeBuf, "accepted", 10);
	} else if(SHADOW_REJECTED == ackType) {
		strncpy(ackTypeBuf, "rejected", 10);
	}

	if(SHADOW_ACTION == ackType) {
		snprintf(pTopic, MAX_SHADOW_TOPIC_LENGTH_BYTES, "$aws/things/%s/shadow/%s", pThingName, actionBuf);
	} else {
		snprintf(pTopic, MAX_SHADOW_TOPIC_LENGTH_BYTES, "$aws/things/%s/shadow/%s/%s", pThingName, actionBuf,
				 ackTypeBuf);
	}
}
void CScriptEngine::GetErrorMessage(int& iLineNum, LPSTR pstrMessage, int cchMessage, LPSTR pstrCode, int cchCode, LPSTR pstrLine, int cchLine)
{
   iLineNum = m_iErrorLineNum;
   if( pstrMessage != NULL ) strncpy(pstrMessage, m_szErrorMsg, cchMessage);
   if( pstrCode != NULL ) strncpy(pstrCode, m_szErrorCode, cchCode);
   if( pstrLine != NULL ) strncpy(pstrLine, m_szErrorLine, cchLine);
}
ProcessParamsTable *next_process_param( 
        const char *name, 
        const char *type,
            const char *fmt, ... )
{
  ProcessParamsTable *pp;
  va_list ap;
  pp = calloc( 1, sizeof( *pp ) );

  if ( ! pp )
  {
    perror( "next_process_param" );
    exit( 1 );
  }
  strncpy( pp->program, PROGRAM_NAME, LIGOMETA_PROGRAM_MAX );
  if ( ! strcmp( name, "userTag" ) || ! strcmp( name, "user-tag" ) )
    snprintf( pp->param, LIGOMETA_PARAM_MAX, "-userTag" );
  else
    snprintf( pp->param, LIGOMETA_PARAM_MAX, "--%s", name );
  strncpy( pp->type, type, LIGOMETA_TYPE_MAX );
  va_start( ap, fmt );
  vsnprintf( pp->value, LIGOMETA_VALUE_MAX, fmt, ap );
  va_end( ap );

  return pp;
}
Example #28
0
/*
 * Ink information is set from warning and an operator call.
 */
int pixus860i_setink(ST_STORESET *p_s, ST_BSCC2STS *p_ct, bscc2sts_tbl *p_tbl, ST_BSCCBUF *p_bsccbuf)
{
  int ret;
  int i=0;
//  int color_num=0;
  char pixus860icolor[]="lLCMY";
//  char *p_tok;

  if( (p_tbl->cartridge[0].type == UNEQUIP)|| (p_tbl->cartridge[0].type == '?')
      || (p_tbl->warning[0]==NOITEM) || (p_tbl->operator_call[0]==NOITEM)
      || (p_bsccbuf+DWS)->p_bsccsts==NULL || (p_bsccbuf+DOC)->p_bsccsts==NULL ){
	return(OK);
  }

  for(i=0; i<MAX860iCOLORNUM; i++){
	p_tbl->ink[i].color=pixus860icolor[i];
	ret=com_warnoperatechk(p_tbl->warning, p_tbl->ink[i].color, sizeof(p_tbl->warning));
	if(ret == OCCUR){
	  strncpy(p_tbl->ink[i].fill, TENPER, sizeof(p_tbl->ink[i].fill));
	  p_tbl->ink[i].alert=INKLOW;
	} else {
	  strncpy(p_tbl->ink[i].fill, FULL, sizeof(p_tbl->ink[i].fill));
	  p_tbl->ink[i].alert=NOALERT;
	}

	p_tbl->ink[i].color=pixus860icolor[i];
	ret=com_warnoperatechk(p_tbl->operator_call, p_tbl->ink[i].color, sizeof(p_tbl->operator_call));
	if(ret == OCCUR){
	  strncpy(p_tbl->ink[i].fill, ZEROPER, sizeof(p_tbl->ink[i].fill));
	  p_tbl->ink[i].alert=INKOUT;
	}
  }
  return(OK);
}
Example #29
0
int
key_enter()
{
	info_t cmd = CMD_PLAY;
	struct dir_contents *contents;
	char *name, *buf, *p;
	unsigned int buf_size;
	int ret = 0;
	bool is_dir;

	contents = file_list.contents;

	// file or directory name
	name = (char *)&contents->list[file_list.cur_idx]->name;

	is_dir = is_directory(name);

	if (is_dir)
		buf_size = strlen(name) + 1;
	else
		buf_size = strlen(file_list.dir_name) + 1 + strlen(name) + 1;

	buf = malloc(buf_size);
	if (!buf) {
		mvwprintw(status_win, 3, 5, "MALLOC ERROR");
		return (-1);
	}

	if (is_dir) {
		mvwprintw(status_win, 1, 5, "CHDIR  ");
		strncpy(buf, name, strlen(name));
		buf[buf_size - 1] = '\0';
		if (change_directory(buf) == -1) {
			mvwprintw(status_win, 3, 5, "ERROR: %s", buf);
			ret = -1;
		}
		free(buf);
		return (ret);
	} else {
		// creating a full path for selected file
		p = buf;
		strncpy(p, file_list.dir_name, strlen(file_list.dir_name));
		p += strlen(file_list.dir_name);
		*p++ = '/';
		strncpy(p, name, strlen(name));
		p += strlen(name);
		*p = '\0';
	}

	mvwprintw(status_win, 1, 5, "CMD: PLAY ");
	pthread_mutex_lock(&ui_status_cache_mutex);
	ui_status_cache = CMD_PLAY;
	pthread_mutex_unlock(&ui_status_cache_mutex);

	// send full path
	ret = send_packet(sock_fd, cmd, buf);
	free(buf);

	return (ret);
}
Example #30
0
// TODO: integrate in '/' command with search.inblock ?
static void visual_search (RCore *core) {
    const ut8 *p;
    int len, d = cursor;
    char str[128], buf[258];

    r_line_set_prompt ("search byte/string in block: ");
    r_cons_fgets (str, sizeof (str), 0, NULL);
    len = r_hex_str2bin (str, (ut8*)buf);
    if (*str=='"') {
        char *e = strncpy (buf, str+1, sizeof (buf)-1);
        if (e) {
            --e;
            if (*e=='"') *e=0;
        }
        len = strlen (buf);
    } else if (len<1) {
        strncpy (buf, str, sizeof (buf)-1);
        len = strlen (str);
    }
    p = r_mem_mem (core->block+d, core->blocksize-d,
                   (const ut8*)buf, len);
    if (p) {
        cursor = (int)(size_t)(p-core->block);
        if (len>1) {
            ocursor = cursor+len-1;
        } else ocursor = -1;
        showcursor (core, R_TRUE);
        eprintf ("FOUND IN %d\n", cursor);
        r_cons_any_key ();
    } else {
        eprintf ("Cannot find bytes\n");
        r_cons_any_key ();
        r_cons_clear00 ();
    }
}