blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
268
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
58
| license_type
stringclasses 2
values | repo_name
stringlengths 5
118
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 816
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 2.31k
677M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 151
values | src_encoding
stringclasses 33
values | language
stringclasses 1
value | is_vendor
bool 2
classes | is_generated
bool 2
classes | length_bytes
int64 3
10.3M
| extension
stringclasses 119
values | content
stringlengths 3
10.3M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
228
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7474d91708e166196a92071abed55e4358790a6c | 33a6448e047d43eeeebe36f11cec5863c4d237c9 | /FileReadWriteCharacter/main.c | f73b56c824db77ca9043f16bbc2c6f2800163b97 | [] | no_license | Qianfinland/C | fca683f4e503a63435f43d1c82d1b5704b954bcf | 00f6530d1282149b5d218e4ab4069562c145fd8e | refs/heads/master | 2021-01-10T16:08:32.115000 | 2015-08-16T19:52:21 | 2015-08-16T19:52:21 | 36,993,923 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,026 | c |
#include <stdio.h>
int main() {
FILE *file = fopen("/home/qxzhou/NetBeansProjects/daydaylearning/FileReadWriteCharacter/read.txt", "r");
if(file == NULL)
{
printf("Error on open the file !");
return 1;
}
while(1)
{
int ch = fgetc(file);
if(ch == EOF)
break;
printf("%c", ch);
}
FILE *file2 = fopen("/home/qxzhou/NetBeansProjects/daydaylearning/FileReadWriteCharacter/write.txt", "w");
if(file2 == NULL)
{
printf("Error on open the file !");
return 1;
}
/*char c[1000];
printf("Enter a sentence to the file!\n");
fgets(c, sizeof(c), stdin);
//gets(c);//dangerous to use
fprintf(file2, "%s", c);*/
printf("Enter multiple lines of strings and end by ctrl+D\n");
while(1)
{
char ch;
ch = getchar();
//putchar(ch);//
if(ch == EOF)
break;
putc(ch, file2);
}
fclose(file);
fclose(file2);
return 0;
}
| [
"[email protected]"
] | |
a6268cf05d542102a4e024b55ddb4478cd60d8ce | e250176d7fc2d1d1ac604aa843543afe91e8843e | /chapter1/fold.c | 0e37e96d78aa3e77a5172cc49be766743550f4ba | [] | no_license | alicewriteswrongs/programminginc | 3ea2ebd1a4622856eecb1b49e8011d5fb2cc4ed8 | 69f17bfede6ccfea70677eb06c6dd76305429ca8 | refs/heads/master | 2021-08-27T15:31:10.765000 | 2015-07-14T19:53:23 | 2015-07-14T19:53:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,419 | c | #include <stdio.h>
/* this is program to 'fold' long lines onto two lines, and I think we're going to do 80
* characters/line
* */
#define MAXLINE 1000 // not going to bother with lines longer than 1000
#define OUTPUTMAXLINE 1020 // longer incase input is actually 1000 characters
#define SPLIT 79 // number of characters per output line (indexed from 0, so 79 == 80 characters per line
int mygetline(char line[], int maxline);
void foldit(char old[], char new[], int length);
main()
{
int lim = MAXLINE;
int len;
char before[MAXLINE];
char after[OUTPUTMAXLINE];
while ((len = mygetline(before, lim)) > 0) {
foldit(before,after,len);
printf("%s", after);
}
}
int mygetline(char before[], int maxline)
{
int c, i;
for (i = 0; i < maxline && (c = getchar()) != EOF && c != '\n'; i++)
before[i] = c;
if (c == '\n') {
before[i] = c;
i++;
}
before[i] = '\0';
return i;
}
void foldit(char old[], char new[], int length)
{
int i, offset, count;
offset = count = 0;
for (i = 0; i <= length; i++) {
if (count != SPLIT) {
new[i+offset] = old[i];
count += 1;
}
else if (count == SPLIT) {
new[i+offset] = old[i];
offset += 1;
new[i+offset] = '\n';
count = 0;
}
}
}
// I think it works! hahahaha!
| [
"[email protected]"
] | |
681714c9a7576083efca3998c82af18ed07b3562 | 99166976f3e170ad5d9fb2840b1c0ade2182a2c3 | /libs/rh4n_ldaparser/src/rh4n_lda_array.c | 18cc3aecdc99a46678399d32d905ecce91675310 | [] | no_license | audacity363/natAWSWrapper | 18acda09518788ae22c78b797e65ec3e3cd0531a | e99ed02d465ba9e6a3234ac30563b00d612d4d46 | refs/heads/master | 2020-06-15T08:49:09.333000 | 2019-08-25T17:35:27 | 2019-08-25T17:35:27 | 195,252,545 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,119 | c | #include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "rh4n.h"
#include "rh4n_ldaparser.h"
int rh4nldaGetArrayType(char *line, int *dimensions, int length[3], RH4nProperties *props, char *errorstr)
{
*dimensions= 0;
char *end_var_params = NULL, *comma = NULL,
*double_collon = NULL;
if((end_var_params = strchr(line, ')')) == NULL)
{
sprintf(errorstr, "Can not find array parms end");
rh4n_log_error(props->logging, "%s", errorstr);
return(RH4N_RET_LDA_PARSE_ERR);
}
*end_var_params = 0x00;
comma = rh4nldastrtok(line, ',');
while(comma)
{
(*dimensions)++;
//Check if a lower bound is specified
if((double_collon = strchr(comma, ':')) != NULL)
{
*double_collon = 0x00;
double_collon++;
length[(*dimensions)-1] = atoi(double_collon);
}
else
{
length[(*dimensions)-1] = atoi(comma);
}
comma = rh4nldastrtok(NULL, ',');
}
return(RH4N_RET_OK);
}
| [
"[email protected]"
] | |
872d8f0e8f79d8d3cc847d279d797bd59b047c8a | bfb77baec8635ec547dcab598fa537785a03d3fb | /MDK-ARM/Lora.c | f4632170ad1e6ae45ecaa5aa22ab3d9fc338799b | [] | no_license | huynd98/SENSOR1_DATN | 6fd4dc6eaae9665b738c86c31dd83b432823d140 | 6faedbe233ec30f4f1c79f0368cafcbe2a9ff678 | refs/heads/main | 2023-02-13T04:16:59.856000 | 2021-01-11T15:20:07 | 2021-01-11T15:20:07 | 318,145,813 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 8,661 | c | #include "Lora.h"
uint8_t readRegLora_8Bit(uint8_t address){
uint8_t result=0;
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
while ( HAL_SPI_Transmit(&hspi2,&address,1,100) != HAL_OK );
while ( HAL_SPI_Receive(&hspi2,&result,1,100) != HAL_OK );
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET);
return result;
}
/*****************************************************************/
void readRegLora(uint8_t address, uint8_t *receiveData, uint8_t length){
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
while ( HAL_SPI_Transmit(&hspi2,&address,1,100) != HAL_OK );
while ( HAL_SPI_Receive(&hspi2,receiveData,length,100) != HAL_OK );
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET);
}
/*****************************************************************/
void writeRegLora(uint8_t address, uint8_t data){
uint8_t add;
add = address | 0x80;
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
while ( HAL_SPI_Transmit(&hspi2,&add,1,100) != HAL_OK );
while ( HAL_SPI_Transmit(&hspi2,&data,1,100) != HAL_OK );
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET);
}
/*****************************************************************/
void writeToFIFO(uint8_t *data, uint8_t length){
uint8_t add= REG_FIFO | 0x80;
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
while ( HAL_SPI_Transmit(&hspi2,&add,1,100) != HAL_OK );
while ( HAL_SPI_Transmit(&hspi2,data,length,100) != HAL_OK );
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET);
}
/*****************************************************************/
void LoraSetFreq(uint32_t frequency){
uint64_t frf = ((uint64_t)frequency << 19) / 32000000;
writeRegLora(REG_FRF_MSB, (uint8_t)(frf >> 16));
writeRegLora(REG_FRF_MID, (uint8_t)(frf >> 8));
writeRegLora(REG_FRF_LSB, (uint8_t)(frf >> 0));
}
/*****************************************************************/
void LoraSleep(void){
writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP);
}
/*****************************************************************/
void LoraIdle(void){
writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_STDBY);
}
//**********************************************************
uint16_t LoraBegin(void){
//Blink Reset Pin
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_SET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_RESET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_SET);
HAL_Delay(10);
//Blink Slave Selection
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET);
HAL_Delay(10);
//Check Version
uint8_t version = readRegLora_8Bit(REG_VERSION);
if (version != 0x12) return 0;
//put in sleep mode
LoraSleep();
//Set Frequency
LoraSetFreq(FREQUENCY);
//Set base address FIFO
writeRegLora(REG_FIFO_TX_BASE_ADDR, 0);
writeRegLora(REG_FIFO_RX_BASE_ADDR, 0);
//set explicitheader mode
//writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xfe);
LoraExplicitHeaderMode();
// set LNA boost
writeRegLora(REG_LNA, readRegLora_8Bit(REG_LNA) | 0x03);
// set auto AGC
writeRegLora(REG_MODEM_CONFIG_3, 0x04);
//ocpTrim
writeRegLora(REG_OCP, 0x20 | (0x1F & 0x0B));
//TX power
writeRegLora(REG_PA_CONFIG, PA_BOOST | (17 - 2));
//put in standby Mode
LoraIdle();
return 1;
}
//*****************************************************
void LoraEnd(void){
LoraSleep();
}
//****************************************************
void LoraSetLdoFlag(void){
// Section 4.1.1.5
long symbolDuration = 1000 / ( LoraGetSignalBW() / (1L << LoraGetSpreadingFactor()) ) ;
uint8_t config3 = readRegLora_8Bit(REG_MODEM_CONFIG_3);
// Section 4.1.1.6
if(symbolDuration > 16) config3 = config3 | 0x08;
else config3 = config3 & 0xF7;
// bitWrite(config3, 3, ldoOn);
writeRegLora(REG_MODEM_CONFIG_3, config3);
}
//****************************************************
//set Spreading Factor
void LoraSetSpreadingFactor(uint8_t sf){
if (sf < 6) {
sf = 6;
} else if (sf > 12) {
sf = 12;
}
if (sf == 6) {
writeRegLora(REG_DETECTION_OPTIMIZE, 0xc5);
writeRegLora(REG_DETECTION_THRESHOLD, 0x0c);
} else {
writeRegLora(REG_DETECTION_OPTIMIZE, 0xc3);
writeRegLora(REG_DETECTION_THRESHOLD, 0x0a);
}
writeRegLora(REG_MODEM_CONFIG_2, (readRegLora_8Bit(REG_MODEM_CONFIG_2) & 0x0f) | ((sf << 4) & 0xf0));
LoraSetLdoFlag();
}
//******************************************************
uint16_t LoraGetSpreadingFactor(void){
return readRegLora_8Bit(REG_MODEM_CONFIG_2) >> 4;
}
//***************************************************
//get Signal Band Width
uint32_t LoraGetSignalBW(void){
uint8_t bw = (readRegLora_8Bit(REG_MODEM_CONFIG_1) >> 4);
switch (bw) {
case 0: return 7800;
case 1: return 10400;
case 2: return 15600;
case 3: return 20800;
case 4: return 31250;
case 5: return 41700;
case 6: return 62500;
case 7: return 125000;
case 8: return 250000;
case 9: return 500000;
}
return 0;
}
//*****************************************************
//set Signal BandWidth
void LoraSetSignalBW(uint32_t bandwidth){
int bw;
if (bandwidth <= 7.8E3) {
bw = 0;
} else if (bandwidth <= 10400) {
bw = 1;
} else if (bandwidth <= 15600) {
bw = 2;
} else if (bandwidth <= 20800) {
bw = 3;
} else if (bandwidth <= 31250) {
bw = 4;
} else if (bandwidth <= 41700) {
bw = 5;
} else if (bandwidth <= 62500) {
bw = 6;
} else if (bandwidth <= 125000) {
bw = 7;
} else if (bandwidth <= 250000) {
bw = 8;
} else /*if (bandwidth <= 250E3)*/ {
bw = 9;
}
writeRegLora(REG_MODEM_CONFIG_1, (readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0x0f) | (bw << 4));
LoraSetLdoFlag();
}
//********************************************************
//set Coding Rate
void LoraSetCodingRate(int denominator){
if (denominator < 5) {
denominator = 5;
} else if (denominator > 8) {
denominator = 8;
}
int cr = denominator - 4;
writeRegLora(REG_MODEM_CONFIG_1, (readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xf1) | (cr << 1));
}
//***********************************************************
//Lora is Transmitting
uint8_t LoraIsTransmitting(void){
if ((readRegLora_8Bit(REG_OP_MODE) & MODE_TX) == MODE_TX) {
return 1;
}
if (readRegLora_8Bit(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) {
// clear IRQ's
writeRegLora(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
}
return 0;
}
//***********************************************************
//Set imlicit Header Mode
void LoraImplicitHeaderMode(void){
writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) | 0x01);
}
//***********************************************************
//Set explicit Header Mode
void LoraExplicitHeaderMode(void){
writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xFE);
}
/********************************************************/
// set Lora into Rx mode : Continous or Single
void LoraRxMode(uint8_t RxMode){
writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | RxMode);
}
/********************************************************/
// set Lora into Rx mode : Continous or Single
void LoraTxMode(){
writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
}
/**************************************************************/
void LoraRead(uint8_t *arrayReadData){
uint8_t packetLength = 0;
uint8_t i;
uint8_t irqFlag = readRegLora_8Bit(REG_IRQ_FLAGS);
writeRegLora(REG_IRQ_FLAGS, irqFlag);
if((irqFlag & 0x40) != 0){
packetLength = readRegLora_8Bit(REG_RX_NB_BYTES);
writeRegLora(REG_FIFO_ADDR_PTR, readRegLora_8Bit(REG_FIFO_RX_CURRENT_ADDR));
for(i = 0; i <packetLength; i++){
arrayReadData[i]=readRegLora_8Bit(REG_FIFO);
}
//powerReadInt = ( arrayReadData[0]-48)*10 + (arrayReadData[1] -48);
//neu doc dc
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_RESET);
HAL_Delay(200);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_SET);
HAL_Delay(200);
}
}
/**************************************************************/
//Transfer Data have first address = buffer, and length = uint8_t Size
//return Size transfered
uint8_t LoraTransfer(uint8_t *buffer, uint8_t size){
// reset FIFO address and paload length
writeRegLora(REG_FIFO_ADDR_PTR, 0);
writeRegLora(REG_PAYLOAD_LENGTH, 0);
writeToFIFO(buffer,size);
writeRegLora(REG_PAYLOAD_LENGTH, size);
// put in TX mode
LoraTxMode();
// wait for TX done
while ((readRegLora_8Bit(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0) {}
// clear IRQ's
writeRegLora(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
return 1;
}
//convert read data to int
| [
"[email protected]"
] | |
0a8e0289152e8c5ddde56fb7659d8c479c4582cf | e4a1f59a825748852406246ad4a0a7e58c0c756b | /code/functs.h | be49b077ece743129c59d76e88d82e6b23007194 | [] | no_license | MVour/diseaseAggregator | 19d46631f1982a407cc243431392c9f1bdc13094 | acb9b05c4d6fe73ccbc063f0d4e9132352c9e97d | refs/heads/master | 2023-02-11T03:08:55.542000 | 2021-01-15T20:48:48 | 2021-01-15T20:48:48 | 330,018,961 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 975 | h | // #include "myList.h"
#include "myHash.h"
#include "heap.h"
#include "filesStats.h"
////// FUNCTS
void printMenu();
char* act(int, hashTable*, hashTable*, infoNode*, StatsList*, char* buf);
// void act_1(hashTable*, char*, char*);
char* act_2(hashTable*, char*, char*, char*, char*);
char* act_3(StatsList* myStats, int, char*, char*, char*, char*);
char* act_4(infoNode*, char*);
char* act_5(StatsList*, char*, char*, char*, char*);
char* act_6(hashTable* , char*, char*, char*, char*);
// void act_3_4(hashTable*, char*, char*, char*, int, int);
// void act_5(hashTable*, hashTable*, infoNode*, myPatient*);
// void act_6(infoNode*, char*, char*);
// void act_7(hashTable*, char*);
// void act_8(hashTable* cHash, hashTable* dHash, infoNode* pList);
int isDate(char*);
void treeToHeap(RBT*, maxHeap*, RBnode*, char*, char*, char*);
int statsToHeap(StatsList*, maxHeap*, char* country, char* disease, char*, char*);
// int count_keys(RBnode* n, char* date1, char* date2); | [
"[email protected]"
] | |
9b15002d5bd412d9ae808f94e24062e867912908 | 79b2d3126476fe7c997ebc5b8f0a1298b34630fd | /PROG/Sem1/Lab4/logo.h | f18a8f5846e8655b25d16b0468fe9ed466ff3075 | [] | no_license | DenisVasenin/Labs | 13ba28d4c29cbe8899cd20ac9cc1f1dbdd825659 | 4b96ea12987d2a0046f58fe8b6d36e775769233b | refs/heads/master | 2020-03-18T20:20:16.447000 | 2018-05-28T15:57:45 | 2018-05-28T15:57:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 646 | h | int logo()
{
puts("");
puts(" ============================");
puts(" ");
puts(" XX XX YY YY NN NN ");
puts(" XXXX YYYY NNNN NN ");
puts(" XX YY NN NN NN ");
puts(" XXXX YY NN NNNN ");
puts(" XX XX YY NN NN ");
puts(" ");
puts(" ");
puts(" Пенкин Станислав гр ИВТ-11 ");
puts(" ");
puts(" ============================");
puts("");
return(0);
}
| [
"[email protected]"
] | |
ff3959dcfefc32276c08841c6534ca13f08bec63 | d24750e5c892c961ebc316484e27de11774db135 | /Src/VL53l1X.c | 9130b1f3476a4024ec8ee467dd98e7873227adac | [] | no_license | MarcusCorbin1/Number12 | 3bc4f46a59bfd1f29a3ac61c214409eb43e2cdae | 0069173892eb944d12c0b6c9ee8a8dd2b52c481b | refs/heads/master | 2022-03-03T14:58:26.731000 | 2019-06-17T16:33:27 | 2019-06-17T16:33:27 | 192,381,912 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 950 | c | #include "stm32l4xx_hal.h"
#include "VL53l1X.h"
//Start the Data Initializer
void VL53L1_DataInit(I2C_HandleTypeDef i2cHandle) {
uint8_t buffer[12];
buffer[0] = 0x88;
buffer[1] = 0x00;
HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100);
HAL_Delay(20);
}
//Start the Static Initializer
void VL53L1_StaticInit(I2C_HandleTypeDef i2cHandle) {
uint8_t buffer[12];
buffer[0] = 0xFF;
buffer[1] = 0x01;
HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100);
uint16_t tempword = 0;
buffer[0] = 0xFF;
buffer[1] = tempword;
HAL_I2C_Master_Receive(&i2cHandle, 0x53, buffer, 2, 100);
buffer[0] = 0xFF;
buffer[1] = 0x00;
HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100);
}
// This function will get the measurement ready
void VL53L1_StartMeasurement(I2C_HandleTypeDef i2cHandle) {
uint8_t buffer[64];
buffer[0] = 0x000;
buffer[1] = 0x01;
HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100);
}
| [
"[email protected]"
] | |
726a722b8c6dcb1d128fb29aeec5b4130d327071 | 999d0cc68f04af3168b1eb5f766756b5661170f4 | /robot/第四组/舵机-STM32/USER/main.c | 555d4c36330cc649455c80a1336c946a2637e724 | [] | no_license | aestheticisma/2019 | e89e24b6fdf5e56d76af3211b97194ea01bab0e1 | 4286782e714cdcda86f8c477be2fc5a9297f49aa | refs/heads/master | 2020-06-19T19:05:32.242000 | 2019-07-14T13:34:13 | 2019-07-14T13:34:13 | 196,836,522 | 1 | 0 | null | 2019-07-14T12:55:50 | 2019-07-14T12:55:49 | null | GB18030 | C | false | false | 1,104 | c | #include "stm32f10x.h"
#include "car.h"
#include "delay.h"
#include "control.h"
#include "echo.h"
#include "infrared.h"
int main(void)
{
float a=0.0;
char len;
control_init();
SysTick_Init();//延时初始化
echo_init();
infrared_init();
//Usart1_Init();
while(1)
{ len='0';
a=(((float)Get_Adc(ADC_Channel_1))/4096)*3.3;
if(a>=0.95){
len = '1';
}
USART_SendData(USART1,len);
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
static_pole();
Delay_ms(2000);
}
}
//每次timer之后
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
}
}
void USART1_IRQHandler(void)
{
int order= 0 ;
if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET)
{
order = USART_ReceiveData(USART1);
USART_ClearITPendingBit(USART1,USART_IT_RXNE);
USART_ClearFlag(USART1,USART_IT_RXNE);
switch(order)
{
case 0x00000031://前进
up();
break;
case 0x00000032://倒车
down();
break;
}
}
}
| [
"[email protected]"
] | |
e4ca123d176646b4ad4c5e6601e1ec61881ef2b6 | eb127d545b1aa5d4f6dfe7b900613678a061ed8e | /clip/libclipmain/_util/clip_CLIP_HOSTCS.c | 68fd4dedfca7aaaf9947cfc9d259df1827c1ab7f | [] | no_license | amery/clip-angelo | a41fccb525b2fb311b2e179508b8ec50457ee7ae | 556fb1d40645d4c8fc33cda4014ab31a5b6500ea | refs/heads/master | 2020-05-05T04:12:01.911000 | 2010-12-25T10:42:00 | 2011-01-01T13:08:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 119 | c | int
clip_CLIP_HOSTCS(ClipMachine * ClipMachineMemory)
{
_clip_retc(ClipMachineMemory, _clip_hostcs);
return 0;
}
| [
"[email protected]"
] | |
0ddad1251dcd4016b4c526efeafe716af3f5026e | ef9a2839953f3586e66c1cf824c9de199f52d088 | /mcc_generated_files/X2CCode/Library/Math/Controller/inc/Sqrt_FiP16.h | b83fa9c934f92a6452ef0773f0ae3be8fd299024 | [] | no_license | MCHP-X2Cdemos/mc_foc_sl_fip_dsPIC33ck_mclv2.x | 72f1e06eb18738796d59938474c6d533bd07bb1e | d77e18983439d895b83b6d63fdaad4c8fdb028e7 | refs/heads/master | 2023-03-20T10:54:54.157000 | 2021-03-11T22:01:12 | 2021-03-11T22:01:12 | 288,478,027 | 2 | 0 | null | null | null | null | UTF-8 | C | false | false | 3,510 | h | /*
* Copyright (c) 2013, Linz Center of Mechatronics GmbH (LCM) http://www.lcm.at/
* All rights reserved.
*/
/*
* This file is licensed according to the BSD 3-clause license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the "Linz Center of Mechatronics GmbH" and "LCM" nor
* the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL "Linz Center of Mechatronics GmbH" BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This file is part of X2C. http://x2c.lcm.at/
* $LastChangedRevision: 1603 $
*/
/* USERCODE-BEGIN:Description */
/** Description: Square Root Computation **/
/** Calculation: **/
/** y = sqrt((abs(u)) **/
/** **/
/* USERCODE-END:Description */
#ifndef SQRT_FIP16_H
#define SQRT_FIP16_H
#ifdef __cplusplus
extern "C" {
#endif
#include "CommonFcts.h"
#if !defined(SQRT_FIP16_ISLINKED)
#define SQRT_FIP16_ID ((uint16)4817)
typedef struct {
uint16 ID;
int16 *In;
int16 Out;
} SQRT_FIP16;
#define SQRT_FIP16_FUNCTIONS { \
SQRT_FIP16_ID, \
(void (*)(void*))Sqrt_FiP16_Update, \
(void (*)(void*))Sqrt_FiP16_Init, \
(tLoadImplementationParameter)Common_Load, \
(tSaveImplementationParameter)Common_Save, \
(void* (*)(const void*, uint16))Sqrt_FiP16_GetAddress }
/**********************************************************************************************************************/
/** Public prototypes **/
/**********************************************************************************************************************/
void Sqrt_FiP16_Update(SQRT_FIP16 *pTSqrt_FiP16);
void Sqrt_FiP16_Init(SQRT_FIP16 *pTSqrt_FiP16);
void* Sqrt_FiP16_GetAddress(const SQRT_FIP16 *block, uint16 elementId);
#endif
#ifdef __cplusplus
}
#endif
#endif
| [
"christoph.baumgartner@microchipcom"
] | christoph.baumgartner@microchipcom |
51fbad2bfeb09528ca3cb36ba6098eb1c9816eff | 25ba673dae94a65d02989d8b72aa4ebda00b0652 | /예제9-6.c | c28ba2aeede8768fa8a3d745203496296575bb28 | [] | no_license | mykid7/C | 3c72d2414ba4a9ae889d57702468ccbfea19796a | 23d1de46d313521a53cb957014f492e3165cff17 | refs/heads/master | 2020-07-21T16:58:10.378000 | 2019-11-10T15:20:47 | 2019-11-10T15:20:47 | 206,925,648 | 0 | 0 | null | null | null | null | UHC | C | false | false | 380 | c | #include <stdio.h>
int main(void)
{
int a = 10; // 변수 선언과 초기화
int *p = &a; // 포인터 선언과 동시에 a를 가리키도록 초기화
double *pd; // double형 변수를 가리키는 포인터
pd = p; // 포인터 p 값을 포인터 pd에 대입
printf("%lf\n", *pd); // pd가 가리키는 변수의 값 출력
return 0;
} | [
"[email protected]"
] | |
cf438c03fe427b18d5ef0c3ee6b083cbcaf7fb89 | 2837f8a4e1c618f00ad7ba5cf4c248232ea1743b | /1012.c | 13ca81f31503b51ffd86f58d4a77bd3cf3a1fc50 | [] | no_license | jorgeduartejr/URI-online-judge---C | c56a2e887db097725694bef25ac390e9edb38b26 | d913288c68870f1058bd7fb0ce754ebc3a015ef8 | refs/heads/main | 2023-07-17T19:04:10.937000 | 2021-08-24T22:33:49 | 2021-08-24T22:33:49 | 399,618,839 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 610 | c | #include <stdio.h>
int main() {
double A,B,C;
double areaTriangulo, areaCirculo, areaTrapezio, areaQuadrado, areaRetangulo;
double pi = 3.14159;
scanf("%lf""%lf""%lf", &A,&B,&C);
areaTriangulo = (A * C)/2;
areaCirculo = C * C * pi;
areaTrapezio = ((A + B) * C)/2;
areaQuadrado = B * B;
areaRetangulo = A * B;
printf("TRIANGULO: %.3lf\n", areaTriangulo);
printf("CIRCULO: %.3lf\n",areaCirculo);
printf("TRAPEZIO: %.3lf\n",areaTrapezio);
printf("QUADRADO: %.3lf\n", areaQuadrado);
printf("RETANGULO: %.3lf\n", areaRetangulo);
return 0;
} | [
"[email protected]"
] | |
e68b09ef487cfbc95b0472becf08661d8f918a67 | 93f2b5dc75142b5d6f5cb31e1e02f1c5aac130a0 | /srcs_lem/get_next_line1.c | 9a771719bb18a1137c4edc964beaab2d64290170 | [] | no_license | Enshertid/lem-in_school21 | d869541fb45c6c6f9d8f96bb047d489aed895b26 | 3b326ec0c41cefe4af28eb46d76817ad89612a33 | refs/heads/master | 2022-05-07T23:49:00.736000 | 2020-03-15T16:34:49 | 2020-03-15T16:34:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 3,150 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ymanilow <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/02 14:42:04 by dbendu #+# #+# */
/* Updated: 2020/02/13 21:25:11 by ymanilow ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
#define GNL_BUFF 1024
void ft_lstappend(t_list **list, t_list *new)
{
if (!list || !new)
return ;
if (!*list)
{
*list = new;
new->end = new;
}
else
{
(*list)->end->next = new;
(*list)->end = new;
}
}
static void add_in_bufs(t_list **bufs, const char *src, size_t strlen,
int fd)
{
char *str;
str = ft_strnew(strlen);
ft_memcpy(str, src, strlen);
ft_lstappend(bufs, ft_lstnew(str, strlen + 1));
(*bufs)->end->content_size = fd;
free(str);
}
static int check_bufs(t_list **bufs, t_list **buf, int fd)
{
t_list *iter;
char *npos;
char *temp;
iter = *bufs;
while (iter && (int)iter->content_size != fd)
iter = iter->next;
if (!iter)
return (0);
npos = (char*)ft_memchr(iter->content, '\n', ft_strlen(iter->content));
ft_lstappend(buf, ft_lstnew(iter->content, npos ?
(size_t)(npos - (char*)iter->content) :
(size_t)ft_strlen(iter->content)));
if (!npos || (npos && !npos[1]))
ft_lstdelete(bufs, &iter);
else if (npos[1])
{
temp = ft_strdup(npos + 1);
free(iter->content);
iter->content = temp;
}
return (npos ? 1 : 0);
}
static char *lst_to_str(const t_list *list)
{
char *str;
char *striter;
const t_list *lstiter;
size_t len;
len = 0;
lstiter = list;
while (lstiter)
{
len += lstiter->content_size;
lstiter = lstiter->next;
}
str = ft_strnew(len);
if (!str)
return (NULL);
striter = str;
while (list)
{
ft_memcpy(striter, list->content, list->content_size);
striter += list->content_size;
list = list->next;
}
return (str);
}
int get_next_line(const int fd, char **line)
{
static t_list *bufs = NULL;
t_list *buf;
ssize_t ret;
char *npos;
char str[GNL_BUFF];
if (fd < 0 || !GNL_BUFF || read(fd, str, 0) < 0 || (buf = NULL))
return (-1);
if (!check_bufs(&bufs, &buf, fd))
{
while ((ret = read(fd, str, GNL_BUFF)))
{
npos = (char*)ft_memchr(str, '\n', ret);
ft_lstappend(&buf, ft_lstnew(str, npos ? npos - str : ret));
if (npos)
break ;
}
if (!ret && !buf)
return (0);
if (ret && npos && npos - str != ret - 1)
add_in_bufs(&bufs, npos + 1, ret - 1 - (npos - str), fd);
}
*line = lst_to_str(buf);
ft_lstpurge(&buf);
return (*line ? 1 : -1);
}
| [
"[email protected]"
] | |
25021c56cbd311feb2474cce81be4758cf5ee5d8 | 394c1965d2300d06df1a72868670397d4ac262c5 | /Libft/srcs/ft_putchar_fd.c | df6248e83b11873e2ab6dcb3898dc37e6be95fa4 | [] | no_license | lterrail/minishell | f0584386ca9f9184ab21f32ad900610ddb75f090 | a2221f74445c526eec356b672efee4640fd7aefb | refs/heads/master | 2021-07-25T16:39:30.554000 | 2020-04-30T15:55:05 | 2020-04-30T15:55:05 | 158,931,545 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 970 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lterrail <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 16:24:20 by lterrail #+# #+# */
/* Updated: 2018/04/11 17:00:53 by lterrail ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}
| [
"[email protected]"
] | |
435d938de995c245d164b32e935ec8b55a8bc340 | bb762a49e4f5324de253d6287438899a4c645632 | /Lista9/Questao1/tadArvoreBB3.c | 9f8071a9ac77eb7d89a79a9acd91267be9385138 | [] | no_license | RaquelBelmiro/estruturas-de-dados-c | 7de2defe4ffaf1849eb5408c533658c0637a1366 | f38f6e6758a897a24e8091e773b6651f02e09a45 | refs/heads/master | 2023-08-01T07:46:45.736000 | 2021-09-21T21:42:25 | 2021-09-21T21:42:25 | 408,981,056 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 3,945 | c | #include<stdio.h>
#include<stdlib.h>
struct reg_no_arvore
{
struct reg_no_arvore *ptrEsquerda;
int chave;
struct reg_no_arvore *ptrDireita;
};
typedef struct reg_no_arvore **tipo_no_arvore;
tipo_no_arvore inicializar_arvore(tipo_no_arvore sub_raiz)
{
sub_raiz = (struct reg_no_arvore**)malloc(sizeof(struct reg_no_arvore*));
*sub_raiz = NULL;
}
void incluir_no_arvore(tipo_no_arvore sub_raiz, int chave)
{
if (*sub_raiz == NULL)
{
*sub_raiz = malloc(sizeof(struct reg_no_arvore));
(*sub_raiz)->chave = chave;
(*sub_raiz)->ptrEsquerda = NULL;
(*sub_raiz)->ptrDireita = NULL;
}
else
{
if (chave < (*sub_raiz)->chave)
{
incluir_no_arvore(&((*sub_raiz)->ptrEsquerda), chave);
}
else
{
if (chave > (*sub_raiz)->chave)
{
incluir_no_arvore(&((*sub_raiz)->ptrDireita), chave);
}
}
}
}
void percurso_em_ordem(tipo_no_arvore sub_raiz)
{
if (*sub_raiz != NULL)
{
percurso_em_ordem(&((*sub_raiz)->ptrEsquerda));
printf("%d ", (*sub_raiz)->chave);
percurso_em_ordem(&((*sub_raiz)->ptrDireita));
}
}
void percurso_em_pre_ordem(tipo_no_arvore sub_raiz)
{
if (*sub_raiz != NULL)
{
printf("%d ", (*sub_raiz)->chave);
percurso_em_pre_ordem(&((*sub_raiz)->ptrEsquerda));
percurso_em_pre_ordem(&((*sub_raiz)->ptrDireita));
}
}
void percurso_em_pos_ordem(tipo_no_arvore sub_raiz)
{
if (*sub_raiz != NULL)
{
percurso_em_pos_ordem(&((*sub_raiz)->ptrEsquerda));
percurso_em_pos_ordem(&((*sub_raiz)->ptrDireita));
printf("%d ", (*sub_raiz)->chave);
}
}
int encontrar_elemento(tipo_no_arvore sub_raiz, int chave)
{
if ((*sub_raiz) == NULL)
{
return 0;
}
else
{
if (chave == (*sub_raiz)->chave)
{
return 1;
}
else
{
if (chave < (*sub_raiz)->chave)
{
return encontrar_elemento(&((*sub_raiz)->ptrEsquerda), chave);
}
else
{
if (chave > (*sub_raiz)->chave)
{
return encontrar_elemento(&((*sub_raiz)->ptrDireita), chave);
}
}
}
}
}
int numero_nos(tipo_no_arvore sub_raiz){
if (*sub_raiz != NULL)
{
return 1+numero_nos(&((*sub_raiz)->ptrEsquerda))+numero_nos(&((*sub_raiz)->ptrDireita));
}
return 0;
}
int qtdFolha(tipo_no_arvore sub_raiz){
if (*sub_raiz !=NULL)
{
if(((*sub_raiz)->ptrEsquerda==NULL) && ((*sub_raiz)->ptrDireita==NULL))
return 1+qtdFolha(&(*sub_raiz)->ptrEsquerda) + qtdFolha(&(*sub_raiz)->ptrDireita);
else
return qtdFolha(&(*sub_raiz)->ptrDireita) + qtdFolha(&(*sub_raiz)->ptrEsquerda);
}
else
return 0;
}
int qtdNull(tipo_no_arvore sub_raiz){
if (*sub_raiz !=NULL)
{
return qtdNull(&(*sub_raiz)->ptrEsquerda)+qtdNull(&(*sub_raiz)->ptrDireita);
}
else
return 1;
}
int altura(tipo_no_arvore sub_raiz){
if (*sub_raiz !=NULL)
{
if( altura(&((*sub_raiz)->ptrEsquerda)) > altura(&((*sub_raiz)->ptrDireita)))
return 1+altura(&(*sub_raiz)->ptrEsquerda);
else
return 1+altura(&(*sub_raiz)->ptrDireita);
}
return 0;
}
void copiarArvore(tipo_no_arvore sub_raiz_original, tipo_no_arvore sub_raiz_copia){
if(*sub_raiz_original!=NULL){
incluir_no_arvore(sub_raiz_copia,(*sub_raiz_original)->chave);
copiarArvore(&((*sub_raiz_original)->ptrDireita),sub_raiz_copia);
copiarArvore(&((*sub_raiz_original)->ptrEsquerda),sub_raiz_copia);
}
}
| [
"[email protected]"
] | |
00b89f8c82ebde7fba9cca6124b9592cc534c8af | a0d6b2c2dd8bcbe03e5c6fb35f766bd2af9a1d5c | /dynix.3.2.0/src/ucb/tftp/main.c | a7f804e9f48afbb7a6089aad2297032b45976d5f | [] | no_license | legacy-codedigger/Dynix.3.2.Source | 593485f234eee4de75c0e23fe689f247471c83f8 | 2789373c94bc57e4c4a915bcba354f2243e12ca4 | refs/heads/master | 2022-04-25T22:49:00.493000 | 2020-04-25T00:49:59 | 2020-04-25T00:49:59 | 258,656,640 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 13,184 | c |
/* $Copyright: $
* Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990
* Sequent Computer Systems, Inc. All rights reserved.
*
* This software is furnished under a license and may be used
* only in accordance with the terms of that license and with the
* inclusion of the above copyright notice. This software may not
* be provided or otherwise made available to, or used by, any
* other person. No title to or ownership of the software is
* hereby transferred.
*/
#ifndef lint
static char rcsid[] = "$Header: main.c 2.3 90/04/05 $";
#endif
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)main.c 5.7 (Berkeley) 6/29/88";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
/*
* TFTP User Program -- Command Interface.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <setjmp.h>
#include <ctype.h>
#include <netdb.h>
#define TIMEOUT 5 /* secs between rexmt's */
struct sockaddr_in sin;
int f;
short port;
int trace;
int verbose;
int connected;
char mode[32];
char line[200];
int margc;
char *margv[20];
char *prompt = "tftp";
jmp_buf toplevel;
int intr();
struct servent *sp;
int quit(), help(), setverbose(), settrace(), status();
int get(), put(), setpeer(), modecmd(), setrexmt(), settimeout();
int setbinary(), setascii();
#define HELPINDENT (sizeof("connect"))
struct cmd {
char *name;
char *help;
int (*handler)();
};
char vhelp[] = "toggle verbose mode";
char thelp[] = "toggle packet tracing";
char chelp[] = "connect to remote tftp";
char qhelp[] = "exit tftp";
char hhelp[] = "print help information";
char shelp[] = "send file";
char rhelp[] = "receive file";
char mhelp[] = "set file transfer mode";
char sthelp[] = "show current status";
char xhelp[] = "set per-packet retransmission timeout";
char ihelp[] = "set total retransmission timeout";
char ashelp[] = "set mode to netascii";
char bnhelp[] = "set mode to octet";
struct cmd cmdtab[] = {
{ "connect", chelp, setpeer },
{ "mode", mhelp, modecmd },
{ "put", shelp, put },
{ "get", rhelp, get },
{ "quit", qhelp, quit },
{ "verbose", vhelp, setverbose },
{ "trace", thelp, settrace },
{ "status", sthelp, status },
{ "binary", bnhelp, setbinary },
{ "ascii", ashelp, setascii },
{ "rexmt", xhelp, setrexmt },
{ "timeout", ihelp, settimeout },
{ "?", hhelp, help },
0
};
struct cmd *getcmd();
char *tail();
char *index();
char *rindex();
main(argc, argv)
char *argv[];
{
struct sockaddr_in sin;
int top;
sp = getservbyname("tftp", "udp");
if (sp == 0) {
fprintf(stderr, "tftp: udp/tftp: unknown service\n");
exit(1);
}
f = socket(AF_INET, SOCK_DGRAM, 0);
if (f < 0) {
perror("tftp: socket");
exit(3);
}
bzero((char *)&sin, sizeof (sin));
sin.sin_family = AF_INET;
if (bind(f, &sin, sizeof (sin)) < 0) {
perror("tftp: bind");
exit(1);
}
strcpy(mode, "netascii");
signal(SIGINT, intr);
if (argc > 1) {
if (setjmp(toplevel) != 0)
exit(0);
setpeer(argc, argv);
}
top = setjmp(toplevel) == 0;
for (;;)
command(top);
}
char hostname[100];
setpeer(argc, argv)
int argc;
char *argv[];
{
struct hostent *host;
if (argc < 2) {
strcpy(line, "Connect ");
printf("(to) ");
gets(&line[strlen(line)]);
makeargv();
argc = margc;
argv = margv;
}
if (argc > 3) {
printf("usage: %s host-name [port]\n", argv[0]);
return;
}
host = gethostbyname(argv[1]);
if (host) {
sin.sin_family = host->h_addrtype;
bcopy(host->h_addr, &sin.sin_addr, host->h_length);
strcpy(hostname, host->h_name);
} else {
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(argv[1]);
if (sin.sin_addr.s_addr == -1) {
connected = 0;
printf("%s: unknown host\n", argv[1]);
return;
}
strcpy(hostname, argv[1]);
}
port = sp->s_port;
if (argc == 3) {
port = atoi(argv[2]);
if (port < 0) {
printf("%s: bad port number\n", argv[2]);
connected = 0;
return;
}
port = htons(port);
}
connected = 1;
}
struct modes {
char *m_name;
char *m_mode;
} modes[] = {
{ "ascii", "netascii" },
{ "netascii", "netascii" },
{ "binary", "octet" },
{ "image", "octet" },
{ "octet", "octet" },
/* { "mail", "mail" }, */
{ 0, 0 }
};
modecmd(argc, argv)
char *argv[];
{
register struct modes *p;
char *sep;
if (argc < 2) {
printf("Using %s mode to transfer files.\n", mode);
return;
}
if (argc == 2) {
for (p = modes; p->m_name; p++)
if (strcmp(argv[1], p->m_name) == 0)
break;
if (p->m_name) {
setmode(p->m_mode);
return;
}
printf("%s: unknown mode\n", argv[1]);
/* drop through and print usage message */
}
printf("usage: %s [", argv[0]);
sep = " ";
for (p = modes; p->m_name; p++) {
printf("%s%s", sep, p->m_name);
if (*sep == ' ')
sep = " | ";
}
printf(" ]\n");
return;
}
setbinary(argc, argv)
char *argv[];
{ setmode("octet");
}
setascii(argc, argv)
char *argv[];
{ setmode("netascii");
}
setmode(newmode)
char *newmode;
{
strcpy(mode, newmode);
if (verbose)
printf("mode set to %s\n", mode);
}
/*
* Send file(s).
*/
put(argc, argv)
char *argv[];
{
int fd;
register int n;
register char *cp, *targ;
if (argc < 2) {
strcpy(line, "send ");
printf("(file) ");
gets(&line[strlen(line)]);
makeargv();
argc = margc;
argv = margv;
}
if (argc < 2) {
putusage(argv[0]);
return;
}
targ = argv[argc - 1];
if (index(argv[argc - 1], ':')) {
char *cp;
struct hostent *hp;
for (n = 1; n < argc - 1; n++)
if (index(argv[n], ':')) {
putusage(argv[0]);
return;
}
cp = argv[argc - 1];
targ = index(cp, ':');
*targ++ = 0;
hp = gethostbyname(cp);
if (hp == 0) {
printf("%s: Unknown host.\n", cp);
return;
}
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
sin.sin_family = hp->h_addrtype;
connected = 1;
strcpy(hostname, hp->h_name);
port = sp->s_port;
}
if (!connected) {
printf("No target machine specified.\n");
return;
}
if (argc < 4) {
cp = argc == 2 ? tail(targ) : argv[1];
fd = open(cp, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "tftp: "); perror(cp);
return;
}
if (verbose)
printf("putting %s to %s:%s [%s]\n",
cp, hostname, targ, mode);
sin.sin_port = port;
sendfile(fd, targ, mode);
return;
}
/* this assumes the target is a directory */
/* on a remote unix system. hmmmm. */
cp = index(targ, '\0');
*cp++ = '/';
for (n = 1; n < argc - 1; n++) {
strcpy(cp, tail(argv[n]));
fd = open(argv[n], O_RDONLY);
if (fd < 0) {
fprintf(stderr, "tftp: "); perror(argv[n]);
continue;
}
if (verbose)
printf("putting %s to %s:%s [%s]\n",
argv[n], hostname, targ, mode);
sin.sin_port = port;
sendfile(fd, targ, mode);
}
}
putusage(s)
char *s;
{
printf("usage: %s file ... host:target, or\n", s);
printf(" %s file ... target (when already connected)\n", s);
}
/*
* Receive file(s).
*/
get(argc, argv)
char *argv[];
{
int fd;
register int n;
register char *cp;
char *src;
if (argc < 2) {
strcpy(line, "get ");
printf("(files) ");
gets(&line[strlen(line)]);
makeargv();
argc = margc;
argv = margv;
}
if (argc < 2) {
getusage(argv[0]);
return;
}
if (!connected) {
for (n = 1; n < (argc - 1); n++)
if (index(argv[n], ':') == 0) {
getusage(argv[0]);
return;
}
}
for (n = 1; n < argc ; n++) {
src = index(argv[n], ':');
if (src == NULL)
src = argv[n];
else {
struct hostent *hp;
*src++ = 0;
hp = gethostbyname(argv[n]);
if (hp == 0) {
printf("%s: Unknown host.\n", argv[n]);
continue;
}
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
sin.sin_family = hp->h_addrtype;
connected = 1;
strcpy(hostname, hp->h_name);
port = sp->s_port;
}
if (argc < 4) {
cp = argc == 3 ? argv[2] : tail(src);
fd = creat(cp, 0644);
if (fd < 0) {
fprintf(stderr, "tftp: "); perror(cp);
return;
}
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
hostname, src, cp, mode);
sin.sin_port = port;
recvfile(fd, src, mode);
break;
}
cp = tail(src); /* new .. jdg */
fd = creat(cp, 0644);
if (fd < 0) {
fprintf(stderr, "tftp: "); perror(cp);
continue;
}
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
hostname, src, cp, mode);
sin.sin_port = port;
recvfile(fd, src, mode);
}
}
getusage(s)
char * s;
{
printf("usage: %s host:file host:file ... file, or\n", s);
printf(" %s file file ... file if connected\n", s);
}
int rexmtval = TIMEOUT;
setrexmt(argc, argv)
char *argv[];
{
int t;
if (argc < 2) {
strcpy(line, "Rexmt-timeout ");
printf("(value) ");
gets(&line[strlen(line)]);
makeargv();
argc = margc;
argv = margv;
}
if (argc != 2) {
printf("usage: %s value\n", argv[0]);
return;
}
t = atoi(argv[1]);
if (t < 0)
printf("%s: bad value\n", t);
else
rexmtval = t;
}
int maxtimeout = 5 * TIMEOUT;
settimeout(argc, argv)
char *argv[];
{
int t;
if (argc < 2) {
strcpy(line, "Maximum-timeout ");
printf("(value) ");
gets(&line[strlen(line)]);
makeargv();
argc = margc;
argv = margv;
}
if (argc != 2) {
printf("usage: %s value\n", argv[0]);
return;
}
t = atoi(argv[1]);
if (t < 0)
printf("%s: bad value\n", t);
else
maxtimeout = t;
}
status(argc, argv)
char *argv[];
{
if (connected)
printf("Connected to %s.\n", hostname);
else
printf("Not connected.\n");
printf("Mode: %s Verbose: %s Tracing: %s\n", mode,
verbose ? "on" : "off", trace ? "on" : "off");
printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n",
rexmtval, maxtimeout);
}
intr()
{
signal(SIGALRM, SIG_IGN);
alarm(0);
longjmp(toplevel, -1);
}
char *
tail(filename)
char *filename;
{
register char *s;
while (*filename) {
s = rindex(filename, '/');
if (s == NULL)
break;
if (s[1])
return (s + 1);
*s = '\0';
}
return (filename);
}
/*
* Command parser.
*/
command(top)
int top;
{
register struct cmd *c;
if (!top)
putchar('\n');
for (;;) {
printf("%s> ", prompt);
if (gets(line) == 0) {
if (feof(stdin)) {
quit();
} else {
continue;
}
}
if (line[0] == 0)
continue;
makeargv();
c = getcmd(margv[0]);
if (c == (struct cmd *)-1) {
printf("?Ambiguous command\n");
continue;
}
if (c == 0) {
printf("?Invalid command\n");
continue;
}
(*c->handler)(margc, margv);
}
}
struct cmd *
getcmd(name)
register char *name;
{
register char *p, *q;
register struct cmd *c, *found;
register int nmatches, longest;
longest = 0;
nmatches = 0;
found = 0;
for (c = cmdtab; p = c->name; c++) {
for (q = name; *q == *p++; q++)
if (*q == 0) /* exact match? */
return (c);
if (!*q) { /* the name was a prefix */
if (q - name > longest) {
longest = q - name;
nmatches = 1;
found = c;
} else if (q - name == longest)
nmatches++;
}
}
if (nmatches > 1)
return ((struct cmd *)-1);
return (found);
}
/*
* Slice a string up into argc/argv.
*/
makeargv()
{
register char *cp;
register char **argp = margv;
margc = 0;
for (cp = line; *cp;) {
while (isspace(*cp))
cp++;
if (*cp == '\0')
break;
*argp++ = cp;
margc += 1;
while (*cp != '\0' && !isspace(*cp))
cp++;
if (*cp == '\0')
break;
*cp++ = '\0';
}
*argp++ = 0;
}
/*VARARGS*/
quit()
{
exit(0);
}
/*
* Help command.
*/
help(argc, argv)
int argc;
char *argv[];
{
register struct cmd *c;
if (argc == 1) {
printf("Commands may be abbreviated. Commands are:\n\n");
for (c = cmdtab; c->name; c++)
printf("%-*s\t%s\n", HELPINDENT, c->name, c->help);
return;
}
while (--argc > 0) {
register char *arg;
arg = *++argv;
c = getcmd(arg);
if (c == (struct cmd *)-1)
printf("?Ambiguous help command %s\n", arg);
else if (c == (struct cmd *)0)
printf("?Invalid help command %s\n", arg);
else
printf("%s\n", c->help);
}
}
/*VARARGS*/
settrace()
{
trace = !trace;
printf("Packet tracing %s.\n", trace ? "on" : "off");
}
/*VARARGS*/
setverbose()
{
verbose = !verbose;
printf("Verbose mode %s.\n", verbose ? "on" : "off");
}
| [
"[email protected]"
] | |
ae6588ae9020907de235f7dc4c83350dbf925003 | 60cddbbb30ef7614070f6e1691ab9a3f0ce407e4 | /robo2-xsdk/libs/phymod/chip/falcon16/falcon16_diagnostics_dispatch.c | 12ba0238027635ff729ee0e14f43ab82c3db76e5 | [] | no_license | David-Croose/Broadcom-Compute-Connectivity-Software-robo2-xsdk | f2a1fe9a704e1a1873eac2fba02125ba7cb1570f | 25b15c851d6e8a5a70715603e4f8d8a9af8f66fe | refs/heads/master | 2022-11-27T00:00:23.553000 | 2020-08-03T07:36:34 | 2020-08-03T07:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,555 | c | /*
*
* $Id: phymod.xml,v 1.1.2.5 Broadcom SDK $
*
*
* This license is set out in https://github.com/Broadcom/Broadcom-Compute-Connectivity-Software-robo2-xsdk/master/Legal/LICENSE file.
*
* $Copyright: (c) 2020 Broadcom Inc.
* Broadcom Proprietary and Confidential. All rights reserved.$
*
*
* DO NOT EDIT THIS FILE!
*
*/
#include <phymod/phymod.h>
#include <phymod/phymod_diagnostics.h>
#include <phymod/phymod_diagnostics_dispatch.h>
#ifdef PHYMOD_FALCON16_SUPPORT
#include <phymod/chip/falcon16_diagnostics.h>
__phymod_diagnostics__dispatch__t__ phymod_diagnostics_falcon16_diagnostics_driver = {
falcon16_phy_rx_slicer_position_set,
falcon16_phy_rx_slicer_position_get,
falcon16_phy_rx_slicer_position_max_get,
falcon16_phy_prbs_config_set,
falcon16_phy_prbs_config_get,
falcon16_phy_prbs_enable_set,
falcon16_phy_prbs_enable_get,
falcon16_phy_prbs_status_get,
falcon16_phy_pattern_config_set,
falcon16_phy_pattern_config_get,
falcon16_phy_pattern_enable_set,
falcon16_phy_pattern_enable_get,
falcon16_core_diagnostics_get,
falcon16_phy_diagnostics_get,
falcon16_phy_pmd_info_dump,
NULL, /* phymod_phy_pcs_info_dump */
falcon16_phy_eyescan_run,
NULL, /* phymod_phy_link_mon_enable_set */
NULL, /* phymod_phy_link_mon_enable_get */
NULL, /* phymod_phy_link_mon_status_get */
NULL, /* phymod_phy_fec_correctable_counter_get */
NULL, /* phymod_phy_fec_uncorrectable_counter_get */
};
#endif /* PHYMOD_FALCON16_SUPPORT */
| [
"[email protected]"
] | |
dfa01ea86a2bce6ee9052f2c25dae843b063fff3 | f99fe5e7d6b160cef405cba7775899a81ed2a5e5 | /src/cmptr3.c | f8f7532066b3e512f34a811e1517283e6b79cdc7 | [] | no_license | rajdipnayek/cslatec | 83122616f72769b36fa7b6d00b3ec988bbb35fe3 | c2a4301febfe44e2d1e0c0fa3a73ca49e44780db | refs/heads/master | 2021-01-06T16:47:40.152000 | 2015-05-01T20:03:32 | 2015-05-01T20:17:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 8,360 | c | /* cmptr3.f -- translated by f2c (version 12.02.01).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include <stdlib.h> /* For exit() */
#include <f2c.h>
/* Table of constant values */
static complex c_b10 = {1.f,0.f};
/* DECK CMPTR3 */
/* Subroutine */ int cmptr3_(integer *m, complex *a, complex *b, complex *c__,
integer *k, complex *y1, complex *y2, complex *y3, complex *tcos,
complex *d__, complex *w1, complex *w2, complex *w3)
{
/* System generated locals */
integer i__1, i__2, i__3, i__4, i__5, i__6;
complex q__1, q__2, q__3, q__4;
/* Local variables */
static integer i__, n;
static complex x, z__;
static integer k1, k2, k3, k4, l1, l2, l3, ip;
static complex xx;
static integer mm1, k1p1, k2p1, k3p1, k4p1, k2k3k4, kint1, lint1, lint2,
lint3, kint2, kint3;
/* ***BEGIN PROLOGUE CMPTR3 */
/* ***SUBSIDIARY */
/* ***PURPOSE Subsidiary to CMGNBN */
/* ***LIBRARY SLATEC */
/* ***TYPE COMPLEX (TRI3-S, CMPTR3-C) */
/* ***AUTHOR (UNKNOWN) */
/* ***DESCRIPTION */
/* Subroutine to solve tridiagonal systems. */
/* ***SEE ALSO CMGNBN */
/* ***ROUTINES CALLED (NONE) */
/* ***REVISION HISTORY (YYMMDD) */
/* 801001 DATE WRITTEN */
/* 890206 REVISION DATE from Version 3.2 */
/* 891214 Prologue converted to Version 4.0 format. (BAB) */
/* 900402 Added TYPE section. (WRB) */
/* ***END PROLOGUE CMPTR3 */
/* ***FIRST EXECUTABLE STATEMENT CMPTR3 */
/* Parameter adjustments */
--w3;
--w2;
--w1;
--d__;
--tcos;
--y3;
--y2;
--y1;
--k;
--c__;
--b;
--a;
/* Function Body */
mm1 = *m - 1;
k1 = k[1];
k2 = k[2];
k3 = k[3];
k4 = k[4];
k1p1 = k1 + 1;
k2p1 = k2 + 1;
k3p1 = k3 + 1;
k4p1 = k4 + 1;
k2k3k4 = k2 + k3 + k4;
if (k2k3k4 == 0) {
goto L101;
}
l1 = k1p1 / k2p1;
l2 = k1p1 / k3p1;
l3 = k1p1 / k4p1;
lint1 = 1;
lint2 = 1;
lint3 = 1;
kint1 = k1;
kint2 = kint1 + k2;
kint3 = kint2 + k3;
L101:
i__1 = k1;
for (n = 1; n <= i__1; ++n) {
i__2 = n;
x.r = tcos[i__2].r, x.i = tcos[i__2].i;
if (k2k3k4 == 0) {
goto L107;
}
if (n != l1) {
goto L103;
}
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
w1[i__3].r = y1[i__4].r, w1[i__3].i = y1[i__4].i;
/* L102: */
}
L103:
if (n != l2) {
goto L105;
}
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
w2[i__3].r = y2[i__4].r, w2[i__3].i = y2[i__4].i;
/* L104: */
}
L105:
if (n != l3) {
goto L107;
}
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
w3[i__3].r = y3[i__4].r, w3[i__3].i = y3[i__4].i;
/* L106: */
}
L107:
q__2.r = b[1].r - x.r, q__2.i = b[1].i - x.i;
c_div(&q__1, &c_b10, &q__2);
z__.r = q__1.r, z__.i = q__1.i;
q__1.r = c__[1].r * z__.r - c__[1].i * z__.i, q__1.i = c__[1].r *
z__.i + c__[1].i * z__.r;
d__[1].r = q__1.r, d__[1].i = q__1.i;
q__1.r = y1[1].r * z__.r - y1[1].i * z__.i, q__1.i = y1[1].r * z__.i
+ y1[1].i * z__.r;
y1[1].r = q__1.r, y1[1].i = q__1.i;
q__1.r = y2[1].r * z__.r - y2[1].i * z__.i, q__1.i = y2[1].r * z__.i
+ y2[1].i * z__.r;
y2[1].r = q__1.r, y2[1].i = q__1.i;
q__1.r = y3[1].r * z__.r - y3[1].i * z__.i, q__1.i = y3[1].r * z__.i
+ y3[1].i * z__.r;
y3[1].r = q__1.r, y3[1].i = q__1.i;
i__2 = *m;
for (i__ = 2; i__ <= i__2; ++i__) {
i__3 = i__;
q__3.r = b[i__3].r - x.r, q__3.i = b[i__3].i - x.i;
i__4 = i__;
i__5 = i__ - 1;
q__4.r = a[i__4].r * d__[i__5].r - a[i__4].i * d__[i__5].i,
q__4.i = a[i__4].r * d__[i__5].i + a[i__4].i * d__[i__5]
.r;
q__2.r = q__3.r - q__4.r, q__2.i = q__3.i - q__4.i;
c_div(&q__1, &c_b10, &q__2);
z__.r = q__1.r, z__.i = q__1.i;
i__3 = i__;
i__4 = i__;
q__1.r = c__[i__4].r * z__.r - c__[i__4].i * z__.i, q__1.i = c__[
i__4].r * z__.i + c__[i__4].i * z__.r;
d__[i__3].r = q__1.r, d__[i__3].i = q__1.i;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ - 1;
q__3.r = a[i__5].r * y1[i__6].r - a[i__5].i * y1[i__6].i, q__3.i =
a[i__5].r * y1[i__6].i + a[i__5].i * y1[i__6].r;
q__2.r = y1[i__4].r - q__3.r, q__2.i = y1[i__4].i - q__3.i;
q__1.r = q__2.r * z__.r - q__2.i * z__.i, q__1.i = q__2.r * z__.i
+ q__2.i * z__.r;
y1[i__3].r = q__1.r, y1[i__3].i = q__1.i;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ - 1;
q__3.r = a[i__5].r * y2[i__6].r - a[i__5].i * y2[i__6].i, q__3.i =
a[i__5].r * y2[i__6].i + a[i__5].i * y2[i__6].r;
q__2.r = y2[i__4].r - q__3.r, q__2.i = y2[i__4].i - q__3.i;
q__1.r = q__2.r * z__.r - q__2.i * z__.i, q__1.i = q__2.r * z__.i
+ q__2.i * z__.r;
y2[i__3].r = q__1.r, y2[i__3].i = q__1.i;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ - 1;
q__3.r = a[i__5].r * y3[i__6].r - a[i__5].i * y3[i__6].i, q__3.i =
a[i__5].r * y3[i__6].i + a[i__5].i * y3[i__6].r;
q__2.r = y3[i__4].r - q__3.r, q__2.i = y3[i__4].i - q__3.i;
q__1.r = q__2.r * z__.r - q__2.i * z__.i, q__1.i = q__2.r * z__.i
+ q__2.i * z__.r;
y3[i__3].r = q__1.r, y3[i__3].i = q__1.i;
/* L108: */
}
i__2 = mm1;
for (ip = 1; ip <= i__2; ++ip) {
i__ = *m - ip;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ + 1;
q__2.r = d__[i__5].r * y1[i__6].r - d__[i__5].i * y1[i__6].i,
q__2.i = d__[i__5].r * y1[i__6].i + d__[i__5].i * y1[i__6]
.r;
q__1.r = y1[i__4].r - q__2.r, q__1.i = y1[i__4].i - q__2.i;
y1[i__3].r = q__1.r, y1[i__3].i = q__1.i;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ + 1;
q__2.r = d__[i__5].r * y2[i__6].r - d__[i__5].i * y2[i__6].i,
q__2.i = d__[i__5].r * y2[i__6].i + d__[i__5].i * y2[i__6]
.r;
q__1.r = y2[i__4].r - q__2.r, q__1.i = y2[i__4].i - q__2.i;
y2[i__3].r = q__1.r, y2[i__3].i = q__1.i;
i__3 = i__;
i__4 = i__;
i__5 = i__;
i__6 = i__ + 1;
q__2.r = d__[i__5].r * y3[i__6].r - d__[i__5].i * y3[i__6].i,
q__2.i = d__[i__5].r * y3[i__6].i + d__[i__5].i * y3[i__6]
.r;
q__1.r = y3[i__4].r - q__2.r, q__1.i = y3[i__4].i - q__2.i;
y3[i__3].r = q__1.r, y3[i__3].i = q__1.i;
/* L109: */
}
if (k2k3k4 == 0) {
goto L115;
}
if (n != l1) {
goto L111;
}
i__ = lint1 + kint1;
i__2 = i__;
q__1.r = x.r - tcos[i__2].r, q__1.i = x.i - tcos[i__2].i;
xx.r = q__1.r, xx.i = q__1.i;
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
q__2.r = xx.r * y1[i__4].r - xx.i * y1[i__4].i, q__2.i = xx.r *
y1[i__4].i + xx.i * y1[i__4].r;
i__5 = i__;
q__1.r = q__2.r + w1[i__5].r, q__1.i = q__2.i + w1[i__5].i;
y1[i__3].r = q__1.r, y1[i__3].i = q__1.i;
/* L110: */
}
++lint1;
l1 = lint1 * k1p1 / k2p1;
L111:
if (n != l2) {
goto L113;
}
i__ = lint2 + kint2;
i__2 = i__;
q__1.r = x.r - tcos[i__2].r, q__1.i = x.i - tcos[i__2].i;
xx.r = q__1.r, xx.i = q__1.i;
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
q__2.r = xx.r * y2[i__4].r - xx.i * y2[i__4].i, q__2.i = xx.r *
y2[i__4].i + xx.i * y2[i__4].r;
i__5 = i__;
q__1.r = q__2.r + w2[i__5].r, q__1.i = q__2.i + w2[i__5].i;
y2[i__3].r = q__1.r, y2[i__3].i = q__1.i;
/* L112: */
}
++lint2;
l2 = lint2 * k1p1 / k3p1;
L113:
if (n != l3) {
goto L115;
}
i__ = lint3 + kint3;
i__2 = i__;
q__1.r = x.r - tcos[i__2].r, q__1.i = x.i - tcos[i__2].i;
xx.r = q__1.r, xx.i = q__1.i;
i__2 = *m;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__;
i__4 = i__;
q__2.r = xx.r * y3[i__4].r - xx.i * y3[i__4].i, q__2.i = xx.r *
y3[i__4].i + xx.i * y3[i__4].r;
i__5 = i__;
q__1.r = q__2.r + w3[i__5].r, q__1.i = q__2.i + w3[i__5].i;
y3[i__3].r = q__1.r, y3[i__3].i = q__1.i;
/* L114: */
}
++lint3;
l3 = lint3 * k1p1 / k4p1;
L115:
;
}
return 0;
} /* cmptr3_ */
| [
"[email protected]"
] | |
87b393e0e37d196a9779122a7240425d0269f0da | 3c406f63a82affe48a40c6e4312ad071aebcf62e | /static/test.c | d6839978199fc1bb3d5e211d972bd5e850265b0f | [] | no_license | vivek703/OWN_EXP | d1a2c78ea69a7114088783e373660d2d39ed317e | fe0f7359693d8822b52121e07d808495f1c93e5e | refs/heads/master | 2022-05-29T13:37:09.261000 | 2020-05-04T18:23:16 | 2020-05-04T18:23:16 | 257,104,389 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 125 | c | #include "test.h"
#include <stdio.h>
static int static_1(void)
{
printf("HI\n");
}
void test(void)
{
static_1();
}
| [
"[email protected]"
] | |
9f6d231ad84008b479ecfd7312376ec07fe56433 | be3167504c0e32d7708e7d13725c2dbc9232f2cb | /mame/src/mame/video/hyprduel.c | b76ea0787ef0284ca2f66abcf3b42fcc7c27a322 | [] | no_license | sysfce2/MAME-Plus-Plus-Kaillera | 83b52085dda65045d9f5e8a0b6f3977d75179e78 | 9692743849af5a808e217470abc46e813c9068a5 | refs/heads/master | 2023-08-10T06:12:47.451000 | 2016-08-01T09:44:21 | 2016-08-01T09:44:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 24,329 | c |
/* based on driver from video/metro.c by Luca Elia */
/* modified by Hau */
/***************************************************************************
-= Metro Games =-
driver by Luca Elia ([email protected])
Note: if MAME_DEBUG is defined, pressing Z with:
Q Shows Layer 0
W Shows Layer 1
E Shows Layer 2
A Shows Sprites
Keys can be used together!
[ 3 Scrolling Layers ]
There is memory for a huge layer, but the actual tilemap
is a smaller window (of fixed size) carved from anywhere
inside that layer.
Tile Size: 8 x 8 x 4
(later games can switch to 8 x 8 x 8, 16 x 16 x 4/8 at run time)
Big Layer Size: 2048 x 2048 (8x8 tiles) or 4096 x 4096 (16x16 tiles)
Tilemap Window Size: 512 x 256 (8x8 tiles) or 1024 x 512 (16x16 tiles)
The tile codes in memory do not map directly to tiles. They
are indexes into a table (with 0x200 entries) that defines
a virtual set of tiles for the 3 layers. Each entry in that
table adds 16 tiles to the set of available tiles, and decides
their color code.
Tile code with their msbit set are different as they mean:
draw a tile filled with a single color (0-1ff)
[ 512 Zooming Sprites ]
The sprites are NOT tile based: the "tile" size can vary from
8 to 64 (independently for width and height) with an 8 pixel
granularity. The "tile" address is a multiple of 8x8 pixels.
Each sprite can be shrinked to ~1/4 or enlarged to ~32x following
an exponential curve of sizes (with one zoom value for both width
and height)
***************************************************************************/
#include "emu.h"
#include "includes/hyprduel.h"
/***************************************************************************
Palette GGGGGRRRRRBBBBBx
***************************************************************************/
WRITE16_MEMBER(hyprduel_state::hyprduel_paletteram_w)
{
data = COMBINE_DATA(&m_paletteram[offset]);
palette_set_color_rgb(machine(), offset, pal5bit(data >> 6), pal5bit(data >> 11), pal5bit(data >> 1));
}
/***************************************************************************
Tilemaps: Tiles Set & Window
Each entry in the Tiles Set RAM uses 2 words to specify a starting
tile code and a color code. This adds 16 consecutive tiles with
that color code to the set of available tiles.
Offset: Bits: Value:
0.w fedc ---- ---- ----
---- ba98 7654 ---- Color Code
---- ---- ---- 3210 Code High Bits
2.w Code Low Bits
***************************************************************************/
/***************************************************************************
Tilemaps: Rendering
***************************************************************************/
/* A 2048 x 2048 virtual tilemap */
#define BIG_NX (0x100)
#define BIG_NY (0x100)
/* A smaller 512 x 256 window defines the actual tilemap */
#define WIN_NX (0x40)
#define WIN_NY (0x20)
//#define WIN_NX (0x40+1)
//#define WIN_NY (0x20+1)
/* 8x8x4 tiles only */
INLINE void get_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int layer, UINT16 *vram)
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
UINT16 code;
int table_index;
UINT32 tile;
/* The actual tile index depends on the window */
tile_index = ((tile_index / WIN_NX + state->m_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
((tile_index % WIN_NX + state->m_window[layer * 2 + 1] / 8) % BIG_NX);
/* Fetch the code */
code = vram[tile_index];
/* Use it as an index into the tiles set table */
table_index = ((code & 0x1ff0) >> 4 ) * 2;
tile = (state->m_tiletable[table_index + 0] << 16) + state->m_tiletable[table_index + 1];
if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */
{
int _code = code & 0x000f;
tileinfo.pen_data = state->m_empty_tiles + _code * 16 * 16;
tileinfo.palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo.flags = 0;
tileinfo.group = 0;
}
else
{
tileinfo.group = 0;
SET_TILE_INFO(
0,
(tile & 0xfffff) + (code & 0xf),
(((tile & 0x0ff00000) >> 20)) + 0x100,
TILE_FLIPXY((code & 0x6000) >> 13));
}
}
/* 8x8x4 or 8x8x8 tiles. It's the tile's color that decides: if its low 4
bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */
INLINE void get_tile_info_8bit( running_machine &machine, tile_data &tileinfo, int tile_index, int layer, UINT16 *vram )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
UINT16 code;
int table_index;
UINT32 tile;
/* The actual tile index depends on the window */
tile_index = ((tile_index / WIN_NX + state->m_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
((tile_index % WIN_NX + state->m_window[layer * 2 + 1] / 8) % BIG_NX);
/* Fetch the code */
code = vram[tile_index];
/* Use it as an index into the tiles set table */
table_index = ((code & 0x1ff0) >> 4) * 2;
tile = (state->m_tiletable[table_index + 0] << 16) + state->m_tiletable[table_index + 1];
if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */
{
int _code = code & 0x000f;
tileinfo.pen_data = state->m_empty_tiles + _code * 16 * 16;
tileinfo.palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo.flags = 0;
tileinfo.group = 0;
}
else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */
{
tileinfo.group = 1;
SET_TILE_INFO(
1,
(tile & 0xfffff) + 2*(code & 0xf),
((tile & 0x0f000000) >> 24) + 0x10,
TILE_FLIPXY((code & 0x6000) >> 13));
}
else
{
tileinfo.group = 0;
SET_TILE_INFO(
0,
(tile & 0xfffff) + (code & 0xf),
(((tile & 0x0ff00000) >> 20)) + 0x100,
TILE_FLIPXY((code & 0x6000) >> 13));
}
}
/* 16x16x4 or 16x16x8 tiles. It's the tile's color that decides: if its low 4
bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */
INLINE void get_tile_info_16x16_8bit( running_machine &machine, tile_data &tileinfo, int tile_index, int layer, UINT16 *vram )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
UINT16 code;
int table_index;
UINT32 tile;
/* The actual tile index depends on the window */
tile_index = ((tile_index / WIN_NX + state->m_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
((tile_index % WIN_NX + state->m_window[layer * 2 + 1] / 8) % BIG_NX);
/* Fetch the code */
code = vram[tile_index];
/* Use it as an index into the tiles set table */
table_index = ((code & 0x1ff0) >> 4) * 2;
tile = (state->m_tiletable[table_index + 0] << 16) + state->m_tiletable[table_index + 1];
if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */
{
int _code = code & 0x000f;
tileinfo.pen_data = state->m_empty_tiles + _code * 16 * 16;
tileinfo.palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo.flags = 0;
tileinfo.group = 0;
}
else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */
{
tileinfo.group = 1;
SET_TILE_INFO(
3,
(tile & 0xfffff) + 8*(code & 0xf),
((tile & 0x0f000000) >> 24) + 0x10,
TILE_FLIPXY((code & 0x6000) >> 13));
}
else
{
tileinfo.group = 0;
SET_TILE_INFO(
2,
(tile & 0xfffff) + 4*(code & 0xf),
(((tile & 0x0ff00000) >> 20)) + 0x100,
TILE_FLIPXY((code & 0x6000) >> 13));
}
}
INLINE void hyprduel_vram_w( running_machine &machine, offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
COMBINE_DATA(&vram[offset]);
{
/* Account for the window */
int col = (offset % BIG_NX) - ((state->m_window[layer * 2 + 1] / 8) % BIG_NX);
int row = (offset / BIG_NX) - ((state->m_window[layer * 2 + 0] / 8) % BIG_NY);
if (col < -(BIG_NX-WIN_NX))
col += (BIG_NX-WIN_NX) + WIN_NX;
if (row < -(BIG_NY-WIN_NY))
row += (BIG_NY-WIN_NY) + WIN_NY;
if ((col >= 0) && (col < WIN_NX) && (row >= 0) && (row < WIN_NY))
state->m_bg_tilemap[layer]->mark_tile_dirty(row * WIN_NX + col);
}
}
TILE_GET_INFO_MEMBER(hyprduel_state::get_tile_info_0_8bit)
{
get_tile_info_8bit(machine(), tileinfo, tile_index, 0, m_vram_0);
}
TILE_GET_INFO_MEMBER(hyprduel_state::get_tile_info_1_8bit)
{
get_tile_info_8bit(machine(), tileinfo, tile_index, 1, m_vram_1);
}
TILE_GET_INFO_MEMBER(hyprduel_state::get_tile_info_2_8bit)
{
get_tile_info_8bit(machine(), tileinfo, tile_index, 2, m_vram_2);
}
WRITE16_MEMBER(hyprduel_state::hyprduel_vram_0_w)
{
hyprduel_vram_w(machine(), offset, data, mem_mask, 0, m_vram_0);
}
WRITE16_MEMBER(hyprduel_state::hyprduel_vram_1_w)
{
hyprduel_vram_w(machine(), offset, data, mem_mask, 1, m_vram_1);
}
WRITE16_MEMBER(hyprduel_state::hyprduel_vram_2_w)
{
hyprduel_vram_w(machine(), offset, data, mem_mask, 2, m_vram_2);
}
/* Dirty the relevant tilemap when its window changes */
WRITE16_MEMBER(hyprduel_state::hyprduel_window_w)
{
UINT16 olddata = m_window[offset];
UINT16 newdata = COMBINE_DATA(&m_window[offset]);
if (newdata != olddata)
{
offset /= 2;
m_bg_tilemap[offset]->mark_all_dirty();
}
}
/***************************************************************************
Video Init Routines
***************************************************************************/
/*
Sprites are not tile based, so we decode their graphics at runtime.
We can't do it at startup because drawgfx requires the tiles to be
pre-rotated to support vertical games, and that, in turn, requires
the tile's sizes to be known at startup - which we don't!
*/
static void alloc_empty_tiles( running_machine &machine )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
int code,i;
state->m_empty_tiles = auto_alloc_array(machine, UINT8, 16*16*16);
state->save_pointer(NAME(state->m_empty_tiles), 16*16*16);
for (code = 0; code < 0x10; code++)
for (i = 0; i < 16 * 16; i++)
state->m_empty_tiles[16 * 16 * code + i] = code;
}
static void hyprduel_postload(running_machine &machine)
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
int i;
for (i = 0; i < 3; i++)
{
UINT16 wx = state->m_window[i * 2 + 1];
UINT16 wy = state->m_window[i * 2 + 0];
state->m_bg_tilemap[i]->set_scrollx(0, state->m_scroll[i * 2 + 1] - wx - (wx & 7));
state->m_bg_tilemap[i]->set_scrolly(0, state->m_scroll[i * 2 + 0] - wy - (wy & 7));
state->m_bg_tilemap[i]->mark_all_dirty();
}
}
static void expand_gfx1(hyprduel_state &state)
{
UINT8 *base_gfx = state.machine().root_device().memregion("gfx1")->base();
UINT32 length = 2 * state.machine().root_device().memregion("gfx1")->bytes();
state.m_expanded_gfx1 = auto_alloc_array(state.machine(), UINT8, length);
for (int i = 0; i < length; i += 2)
{
UINT8 src = base_gfx[i / 2];
state.m_expanded_gfx1[i+0] = src & 15;
state.m_expanded_gfx1[i+1] = src >> 4;
}
}
VIDEO_START_MEMBER(hyprduel_state,common_14220)
{
expand_gfx1(*this);
alloc_empty_tiles(machine());
m_tiletable_old = auto_alloc_array(machine(), UINT16, m_tiletable.bytes() / 2);
m_dirtyindex = auto_alloc_array(machine(), UINT8, m_tiletable.bytes() / 4);
save_pointer(NAME(m_tiletable_old), m_tiletable.bytes() / 2);
save_pointer(NAME(m_dirtyindex), m_tiletable.bytes() / 4);
m_bg_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(hyprduel_state::get_tile_info_0_8bit),this), TILEMAP_SCAN_ROWS, 8, 8, WIN_NX, WIN_NY);
m_bg_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(hyprduel_state::get_tile_info_1_8bit),this), TILEMAP_SCAN_ROWS, 8, 8, WIN_NX, WIN_NY);
m_bg_tilemap[2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(hyprduel_state::get_tile_info_2_8bit),this), TILEMAP_SCAN_ROWS, 8, 8, WIN_NX, WIN_NY);
m_bg_tilemap[0]->map_pen_to_layer(0, 15, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[0]->map_pen_to_layer(1, 255, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[1]->map_pen_to_layer(0, 15, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[1]->map_pen_to_layer(1, 255, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[2]->map_pen_to_layer(0, 15, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[2]->map_pen_to_layer(1, 255, TILEMAP_PIXEL_TRANSPARENT);
m_bg_tilemap[0]->set_scrolldx(0, 0);
m_bg_tilemap[1]->set_scrolldx(0, 0);
m_bg_tilemap[2]->set_scrolldx(0, 0);
/* Set up save state */
save_item(NAME(m_sprite_xoffs));
save_item(NAME(m_sprite_yoffs));
machine().save().register_postload(save_prepost_delegate(FUNC(hyprduel_postload), &machine()));
}
VIDEO_START_MEMBER(hyprduel_state,hyprduel_14220)
{
m_sprite_yoffs_sub = 2;
VIDEO_START_CALL_MEMBER(common_14220);
}
VIDEO_START_MEMBER(hyprduel_state,magerror_14220)
{
m_sprite_yoffs_sub = 0;
VIDEO_START_CALL_MEMBER(common_14220);
}
/***************************************************************************
Video Registers
Offset: Bits: Value:
0.w Number Of Sprites To Draw
2.w f--- ---- ---- ---- Disabled Sprites Layer Priority
-edc ---- ---- ----
---- ba-- ---- ---- Sprites Masked Layer
---- --98 ---- ---- Sprites Priority
---- ---- 765- ----
---- ---- ---4 3210 Sprites Masked Number
4.w Sprites Y Offset
6.w Sprites X Offset
8.w Sprites Color Codes Start
-
10.w fedc ba98 76-- ----
---- ---- --54 ---- Layer 2 Priority (3 backmost, 0 frontmost)
---- ---- ---- 32-- Layer 1 Priority
---- ---- ---- --10 Layer 0 Priority
12.w Backround Color
***************************************************************************/
/***************************************************************************
Sprites Drawing
Offset: Bits: Value:
0.w fedc b--- ---- ---- Priority (0 = Max)
---- -a98 7654 3210 X
2.w fedc ba-- ---- ---- Zoom (Both X & Y)
---- --98 7654 3210 Y
4.w f--- ---- ---- ---- Flip X
-e-- ---- ---- ---- Flip Y
--dc b--- ---- ---- Size X *
---- -a98 ---- ---- Size Y *
---- ---- 7654 ---- Color
---- ---- ---- 3210 Code High Bits **
6.w Code Low Bits **
* 8 pixel increments
** 8x8 pixel increments
***************************************************************************/
/* Draw sprites */
static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
UINT8 *base_gfx4 = state->m_expanded_gfx1;
UINT8 *base_gfx8 = state->memregion("gfx1")->base();
UINT32 gfx_size = state->memregion("gfx1")->bytes();
int max_x = machine.primary_screen->width();
int max_y = machine.primary_screen->height();
int max_sprites = state->m_spriteram.bytes() / 8;
int sprites = state->m_videoregs[0x00 / 2] % max_sprites;
int color_start = ((state->m_videoregs[0x08 / 2] & 0xf) << 4) + 0x100;
int i, j, pri;
static const int primask[4] = { 0x0000, 0xff00, 0xff00|0xf0f0, 0xff00|0xf0f0|0xcccc };
UINT16 *src;
int inc;
if (sprites == 0)
return;
for (i = 0; i < 0x20; i++)
{
if (!(state->m_videoregs[0x02 / 2] & 0x8000))
{
src = state->m_spriteram + (sprites - 1) * (8 / 2);
inc = -(8 / 2);
} else {
src = state->m_spriteram;
inc = (8 / 2);
}
for (j = 0; j < sprites; j++)
{
int x, y, attr, code, color, flipx, flipy, zoom, curr_pri, width, height;
/* Exponential zoom table extracted from daitoride */
static const int zoomtable[0x40] =
{
0xAAC,0x800,0x668,0x554,0x494,0x400,0x390,0x334,
0x2E8,0x2AC,0x278,0x248,0x224,0x200,0x1E0,0x1C8,
0x1B0,0x198,0x188,0x174,0x164,0x154,0x148,0x13C,
0x130,0x124,0x11C,0x110,0x108,0x100,0x0F8,0x0F0,
0x0EC,0x0E4,0x0DC,0x0D8,0x0D4,0x0CC,0x0C8,0x0C4,
0x0C0,0x0BC,0x0B8,0x0B4,0x0B0,0x0AC,0x0A8,0x0A4,
0x0A0,0x09C,0x098,0x094,0x090,0x08C,0x088,0x080,
0x078,0x070,0x068,0x060,0x058,0x050,0x048,0x040
};
x = src[0];
curr_pri = (x & 0xf800) >> 11;
if ((curr_pri == 0x1f) || (curr_pri != i))
{
src += inc;
continue;
}
pri = (state->m_videoregs[0x02 / 2] & 0x0300) >> 8;
if (!(state->m_videoregs[0x02 / 2] & 0x8000))
{
if (curr_pri > (state->m_videoregs[0x02 / 2] & 0x1f))
pri = (state->m_videoregs[0x02 / 2] & 0x0c00) >> 10;
}
y = src[1];
attr = src[2];
code = src[3];
flipx = attr & 0x8000;
flipy = attr & 0x4000;
color = (attr & 0xf0) >> 4;
zoom = zoomtable[(y & 0xfc00) >> 10] << (16 - 8);
x = (x & 0x07ff) - state->m_sprite_xoffs;
y = (y & 0x03ff) - state->m_sprite_yoffs;
width = (((attr >> 11) & 0x7) + 1) * 8;
height = (((attr >> 8) & 0x7) + 1) * 8;
UINT32 gfxstart = (8 * 8 * 4 / 8) * (((attr & 0x000f) << 16) + code);
if (state->flip_screen())
{
flipx = !flipx; x = max_x - x - width;
flipy = !flipy; y = max_y - y - height;
}
if (color == 0xf) /* 8bpp */
{
/* Bounds checking */
if ((gfxstart + width * height - 1) >= gfx_size)
continue;
gfx_element gfx(machine, base_gfx8 + gfxstart, width, height, width, 0, 256);
pdrawgfxzoom_transpen(bitmap,cliprect, &gfx,
0,
color_start >> 4,
flipx, flipy,
x, y,
zoom, zoom,
machine.priority_bitmap,primask[pri], 255);
}
else
{
/* Bounds checking */
if ((gfxstart + width / 2 * height - 1) >= gfx_size)
continue;
gfx_element gfx(machine, base_gfx4 + 2 * gfxstart, width, height, width, 0, 16);
pdrawgfxzoom_transpen(bitmap,cliprect, &gfx,
0,
color + color_start,
flipx, flipy,
x, y,
zoom, zoom,
machine.priority_bitmap,primask[pri], 15);
}
#if 0
{ /* Display priority + zoom on each sprite */
char buf[80];
sprintf(buf, "%02X %02X",((src[ 0 ] & 0xf800) >> 11)^0x1f,((src[ 1 ] & 0xfc00) >> 10) );
ui_draw_text(buf, x, y);
}
#endif
src += inc;
}
}
}
/***************************************************************************
Screen Drawing
***************************************************************************/
WRITE16_MEMBER(hyprduel_state::hyprduel_scrollreg_w)
{
UINT16 window = m_window[offset];
COMBINE_DATA(&m_scroll[offset]);
if (offset & 0x01)
m_bg_tilemap[offset / 2]->set_scrollx(0, m_scroll[offset] - window - (window & 7));
else
m_bg_tilemap[offset / 2]->set_scrolly(0, m_scroll[offset] - window - (window & 7));
}
WRITE16_MEMBER(hyprduel_state::hyprduel_scrollreg_init_w)
{
int i;
for (i = 0; i < 3; i++)
{
UINT16 wx = m_window[i * 2 + 1];
UINT16 wy = m_window[i * 2 + 0];
m_scroll[i * 2 + 1] = data;
m_scroll[i * 2 + 0] = data;
m_bg_tilemap[i]->set_scrollx(0, data - wx - (wx & 7));
m_bg_tilemap[i]->set_scrolly(0, data - wy - (wy & 7));
}
}
static void draw_layers( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
UINT16 layers_pri = state->m_videoregs[0x10/2];
int layer;
/* Draw all the layers with priority == pri */
for (layer = 2; layer >= 0; layer--) // tilemap[2] below?
{
if ( pri == ((layers_pri >> (layer*2)) & 3) )
{
if (layers_ctrl & (1 << layer)) // for debug
state->m_bg_tilemap[layer]->draw(bitmap, cliprect, 0, 1 << (3 - pri));
}
}
}
/* Dirty tilemaps when the tiles set changes */
static void dirty_tiles( running_machine &machine, int layer, UINT16 *vram )
{
hyprduel_state *state = machine.driver_data<hyprduel_state>();
int col, row;
for (row = 0; row < WIN_NY; row++)
{
for (col = 0; col < WIN_NX; col++)
{
int offset = (col + state->m_window[layer * 2 + 1] / 8) % BIG_NX + ((row + state->m_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX;
UINT16 code = vram[offset];
if (!(code & 0x8000) && state->m_dirtyindex[(code & 0x1ff0) >> 4])
state->m_bg_tilemap[layer]->mark_tile_dirty(row * WIN_NX + col);
}
}
}
SCREEN_UPDATE_IND16( hyprduel )
{
hyprduel_state *state = screen.machine().driver_data<hyprduel_state>();
int i, pri, layers_ctrl = -1;
UINT16 screenctrl = *state->m_screenctrl;
{
int dirty = 0;
memset(state->m_dirtyindex, 0, state->m_tiletable.bytes() / 4);
for (i = 0; i < state->m_tiletable.bytes() / 4; i++)
{
UINT32 tile_new = (state->m_tiletable[2 * i + 0] << 16 ) + state->m_tiletable[2 * i + 1];
UINT32 tile_old = (state->m_tiletable_old[2 * i + 0] << 16 ) + state->m_tiletable_old[2 * i + 1];
if ((tile_new ^ tile_old) & 0x0fffffff)
{
state->m_dirtyindex[i] = 1;
dirty = 1;
}
}
memcpy(state->m_tiletable_old, state->m_tiletable, state->m_tiletable.bytes());
if (dirty)
{
dirty_tiles(screen.machine(), 0, state->m_vram_0);
dirty_tiles(screen.machine(), 1, state->m_vram_1);
dirty_tiles(screen.machine(), 2, state->m_vram_2);
}
}
state->m_sprite_xoffs = state->m_videoregs[0x06 / 2] - screen.width() / 2;
state->m_sprite_yoffs = state->m_videoregs[0x04 / 2] - screen.height() / 2 - state->m_sprite_yoffs_sub;
/* The background color is selected by a register */
screen.machine().priority_bitmap.fill(0, cliprect);
bitmap.fill((state->m_videoregs[0x12 / 2] & 0x0fff) + 0x1000, cliprect);
/* Screen Control Register:
f--- ---- ---- ---- ?
-edc b--- ---- ----
---- -a98 ---- ---- ? Leds
---- ---- 7--- ---- 16x16 Tiles (Layer 2)
---- ---- -6-- ---- 16x16 Tiles (Layer 1)
---- ---- --5- ---- 16x16 Tiles (Layer 0)
---- ---- ---4 32--
---- ---- ---- --1- ? Blank Screen
---- ---- ---- ---0 Flip Screen */
if (screenctrl & 2)
return 0;
state->flip_screen_set(screenctrl & 1);
#if 0
if (screen.machine().input().code_pressed(KEYCODE_Z))
{ int msk = 0;
if (screen.machine().input().code_pressed(KEYCODE_Q)) msk |= 0x01;
if (screen.machine().input().code_pressed(KEYCODE_W)) msk |= 0x02;
if (screen.machine().input().code_pressed(KEYCODE_E)) msk |= 0x04;
if (screen.machine().input().code_pressed(KEYCODE_A)) msk |= 0x08;
if (msk != 0)
{
bitmap.fill(0, cliprect);
layers_ctrl &= msk;
}
popmessage("%x-%x-%x:%04x %04x %04x",
state->m_videoregs[0x10/2]&3,(state->m_videoregs[0x10/2] & 0xc) >> 2, (state->m_videoregs[0x10/2] & 0x30) >> 4,
state->m_videoregs[0x02/2], state->m_videoregs[0x08/2],
*state->m_screenctrl);
}
#endif
for (pri = 3; pri >= 0; pri--)
draw_layers(screen.machine(), bitmap, cliprect, pri, layers_ctrl);
if (layers_ctrl & 0x08)
draw_sprites(screen.machine(), bitmap, cliprect);
return 0;
}
| [
"mameppk@199a702f-54f1-4ac0-8451-560dfe28270b"
] | mameppk@199a702f-54f1-4ac0-8451-560dfe28270b |
ba1e8d10b4304a881878387964db1a02e670c5d3 | 166fba38e48ca1968348f5a6fd8c435392d619db | /jzz.c | d1576d8fbf128a1060ae1ca5dd4b9ce9d27aea4e | [] | no_license | Yuvpriya/jazz | 0925c109f2f2652ed886f4cce0c0c362ff96ba5b | 0e81454801892f6fc762f74cb15b363d8640c301 | refs/heads/master | 2021-01-01T16:53:35.835000 | 2017-07-21T12:33:36 | 2017-07-21T12:33:36 | 97,944,469 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 295 | c | #include<stdio.h>
#include<string.h>
int main()
{
char p[20],q[20],r[20],i;
scanf("%s",p);
scanf("%s",r);
scanf("%s",q);
for(i=0;i<19;i++)
{
if((p[i]==q[i])&&(q[i]==r[i]))
{
printf("%c",p[i]);
}
else
break;
}
return 0;
}
| [
"[email protected]"
] | |
32004cd6aee41c08905cd5b705ab6f8ff0bb6507 | cdf75036c20eed12b54f9110c95588652899fa4c | /Others/atoi_2.c | 1845ab7cbe713cde67484b57a0fe4dd8bbf74bd5 | [] | no_license | M1c17/C_Programming_Language | 6ca585297ab6014a8a5a86ec1e4be8fb58f01e39 | 15c3074a7876dea9615a3d4a5dd0bb8120abf180 | refs/heads/main | 2023-03-06T05:41:51.665000 | 2021-02-07T04:41:49 | 2021-02-07T04:41:49 | 323,505,241 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 862 | c | #include <stdio.h>
#include <ctype.h>
#include <string.h>
/* atoi: convert s to integer; version 2 */
int atoi(char line[]);
int main(){
int val;
char str[10];
strcpy(str, "-93284927");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
strcpy(str, "hello");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
return 0;
}
int atoi(char line[]){
//Initialize variables
int i, n, sign;
//skip white space, if any
for (i = 0; isspace(line[i]); ++i){
;
}
//get sign, if any
sign = (line[i] == '-') ? -1 : 1;
//skip sign, if any
if (line[i] == '+' || line[i] == '-'){
++i;
}
//get integer part and convert it
for (n = 0; isdigit(line[i]); ++i){
n = 10 * n + (line[i] - '0');
}
return sign * n;
}
| [
"[email protected]"
] | |
ad6c47c43213451cd6735ee31d3b8c2cb5b854d4 | fd0137df01992ad3153ba9658e71e6c763760b7f | /Emu48/DDESERV.C | 6478426a222253dd6a1def7b7c0fb139a99e39fc | [] | no_license | tolkien/Emu48 | b22a61dc952d70f9fd93e32a9a8a95c103f96e4b | 777d5a9c399f4b2d800e8376bf2e62431bda71a0 | refs/heads/master | 2021-06-20T01:36:10.050000 | 2017-05-12T18:11:34 | 2017-05-12T18:11:34 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C | false | false | 4,855 | c | /*
* DdeServ.c
*
* This file is part of Emu48
*
* Copyright (C) 1998 Christoph Gießelink
*
*/
#include "pch.h"
#include "Emu48.h"
#include "io.h"
HDDEDATA CALLBACK DdeCallback(UINT iType,UINT iFmt,HCONV hConv,
HSZ hsz1,HSZ hsz2,HDDEDATA hData,
DWORD dwData1,DWORD dwData2)
{
TCHAR *psz,szBuffer[32];
HDDEDATA hReturn;
LPBYTE lpData,lpHeader;
DWORD dwAddress,dwSize,dwLoop,dwIndex;
UINT nStkLvl;
BOOL bSuccess;
// disable stack loading items on HP38G, HP39/40G
BOOL bStackEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E';
switch (iType)
{
case XTYP_CONNECT:
// get service name
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
if (0 != lstrcmp(szBuffer,szAppName))
return (HDDEDATA) FALSE;
// get topic name
DdeQueryString(idDdeInst,hsz1,szBuffer,ARRAYSIZEOF(szBuffer),0);
return (HDDEDATA) (INT_PTR) (0 == lstrcmp(szBuffer,szTopic));
case XTYP_POKE:
// quit on models without stack or illegal data format or not in running state
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
return (HDDEDATA) DDE_FNOTPROCESSED;
// get item name
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
nStkLvl = _tcstoul(szBuffer,&psz,10);
if (*psz != 0 || nStkLvl < 1) // invalid number format
return (HDDEDATA) DDE_FNOTPROCESSED;
SuspendDebugger(); // suspend debugger
bDbgAutoStateCtrl = FALSE; // disable automatic debugger state control
if (!(Chipset.IORam[BITOFFSET]&DON)) // HP off
{
// turn on HP
KeyboardEvent(TRUE,0,0x8000);
Sleep(dwWakeupDelay);
KeyboardEvent(FALSE,0,0x8000);
}
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
{
hReturn = DDE_FNOTPROCESSED;
goto cancel;
}
while (nState!=nNextState) Sleep(0);
_ASSERT(nState==SM_SLEEP);
bSuccess = FALSE;
// get data and size
lpData = DdeAccessData(hData,&dwSize);
// has object length header
if (lpData && dwSize >= sizeof(DWORD))
{
dwIndex = *(LPDWORD) lpData; // object length
if (dwIndex <= dwSize - sizeof(DWORD))
{
// reserve unpacked object length memory
LPBYTE pbyMem = (LPBYTE) malloc(dwIndex * 2);
if (pbyMem != NULL)
{
// copy data and write to stack
CopyMemory(pbyMem+dwIndex,lpData+sizeof(DWORD),dwIndex);
bSuccess = (WriteStack(nStkLvl,pbyMem,dwIndex) == S_ERR_NO);
free(pbyMem); // free memory
}
}
}
DdeUnaccessData(hData);
SwitchToState(SM_RUN); // run state
while (nState!=nNextState) Sleep(0);
_ASSERT(nState==SM_RUN);
if (bSuccess == FALSE)
{
hReturn = DDE_FNOTPROCESSED;
goto cancel;
}
KeyboardEvent(TRUE,0,0x8000);
Sleep(dwWakeupDelay);
KeyboardEvent(FALSE,0,0x8000);
// wait for sleep mode
while (Chipset.Shutdn == FALSE) Sleep(0);
hReturn = (HDDEDATA) DDE_FACK;
cancel:
bDbgAutoStateCtrl = TRUE; // enable automatic debugger state control
ResumeDebugger();
return hReturn;
case XTYP_REQUEST:
// quit on models without stack or illegal data format or not in running state
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
return NULL;
// get item name
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
nStkLvl = _tcstoul(szBuffer,&psz,10);
if (*psz != 0 || nStkLvl < 1) // invalid number format
return NULL;
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
return NULL;
while (nState!=nNextState) Sleep(0);
_ASSERT(nState==SM_SLEEP);
dwAddress = RPL_Pick(nStkLvl); // pick address of stack level "item" object
if (dwAddress == 0)
{
SwitchToState(SM_RUN); // run state
return NULL;
}
dwLoop = dwSize = (RPL_SkipOb(dwAddress) - dwAddress + 1) / 2;
lpHeader = (Chipset.type != 'X') ? (LPBYTE) BINARYHEADER48 : (LPBYTE) BINARYHEADER49;
// length of binary header
dwIndex = (DWORD) strlen((LPCSTR) lpHeader);
// size of objectsize + header + object
dwSize += dwIndex + sizeof(DWORD);
// reserve memory
if ((lpData = (LPBYTE) malloc(dwSize)) == NULL)
{
SwitchToState(SM_RUN); // run state
return NULL;
}
// save data length
*(DWORD *)lpData = dwLoop + dwIndex;
// copy header
memcpy(lpData + sizeof(DWORD),lpHeader,dwIndex);
// copy data
for (dwIndex += sizeof(DWORD);dwLoop--;++dwIndex,dwAddress += 2)
lpData[dwIndex] = Read2(dwAddress);
// write data
hReturn = DdeCreateDataHandle(idDdeInst,lpData,dwSize,0,hsz2,iFmt,0);
free(lpData);
SwitchToState(SM_RUN); // run state
while (nState!=nNextState) Sleep(0);
_ASSERT(nState==SM_RUN);
return hReturn;
}
return NULL;
UNREFERENCED_PARAMETER(hConv);
UNREFERENCED_PARAMETER(dwData1);
UNREFERENCED_PARAMETER(dwData2);
}
| [
"[email protected]"
] | |
04fea91c01ee1587f19ad32ee856fa3859d09f22 | ade70089afe2f9bd496985fe67d46c5372042ab0 | /nvm/versions/node/v16.14.0/include/node/openssl/opensslv.h | afe0161c9ca2dc78a4eac5c0a5319f30e43aba74 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"CC0-1.0",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-unicode",
"Artistic-2.0",
"BSD-3-Clause",
"Zlib",
"NAIST-2003",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"NTP",
"LicenseRef-scancode-public-domain-disclaimer",
"ICU"
] | permissive | gn0rt0n/dotfiles | 96e37a87cec555cbfd222795466c140eb502c892 | 35f01242e7ac73a8b21b5e62398f1185102b7ee9 | refs/heads/master | 2023-02-23T03:02:35.212000 | 2023-02-19T02:53:00 | 2023-02-19T02:53:00 | 299,629,236 | 0 | 1 | null | 2022-10-16T02:07:11 | 2020-09-29T13:40:38 | C | UTF-8 | C | false | false | 4,110 | h | /*
* Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef HEADER_OPENSSLV_H
# define HEADER_OPENSSLV_H
#ifdef __cplusplus
extern "C" {
#endif
/*-
* Numeric release version identifier:
* MNNFFPPS: major minor fix patch status
* The status nibble has one of the values 0 for development, 1 to e for betas
* 1 to 14, and f for release. The patch level is exactly that.
* For example:
* 0.9.3-dev 0x00903000
* 0.9.3-beta1 0x00903001
* 0.9.3-beta2-dev 0x00903002
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
* 0.9.3 0x0090300f
* 0.9.3a 0x0090301f
* 0.9.4 0x0090400f
* 1.2.3z 0x102031af
*
* For continuity reasons (because 0.9.5 is already out, and is coded
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
* part is slightly different, by setting the highest bit. This means
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
* with 0x0090600S...
*
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x101010dfL
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m+quic 14 Dec 2021"
/*-
* The macros below are to be used for shared library (.so, .dll, ...)
* versioning. That kind of versioning works a bit differently between
* operating systems. The most usual scheme is to set a major and a minor
* number, and have the runtime loader check that the major number is equal
* to what it was at application link time, while the minor number has to
* be greater or equal to what it was at application link time. With this
* scheme, the version number is usually part of the file name, like this:
*
* libcrypto.so.0.9
*
* Some unixen also make a softlink with the major version number only:
*
* libcrypto.so.0
*
* On Tru64 and IRIX 6.x it works a little bit differently. There, the
* shared library version is stored in the file, and is actually a series
* of versions, separated by colons. The rightmost version present in the
* library when linking an application is stored in the application to be
* matched at run time. When the application is run, a check is done to
* see if the library version stored in the application matches any of the
* versions in the version string of the library itself.
* This version string can be constructed in any way, depending on what
* kind of matching is desired. However, to implement the same scheme as
* the one used in the other unixen, all compatible versions, from lowest
* to highest, should be part of the string. Consecutive builds would
* give the following versions strings:
*
* 3.0
* 3.0:3.1
* 3.0:3.1:3.2
* 4.0
* 4.0:4.1
*
* Notice how version 4 is completely incompatible with version, and
* therefore give the breach you can see.
*
* There may be other schemes as well that I haven't yet discovered.
*
* So, here's the way it works here: first of all, the library version
* number doesn't need at all to match the overall OpenSSL version.
* However, it's nice and more understandable if it actually does.
* The current library version is stored in the macro SHLIB_VERSION_NUMBER,
* which is just a piece of text in the format "M.m.e" (Major, minor, edit).
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
* we need to keep a history of version numbers, which is done in the
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
* should only keep the versions that are binary compatible with the current.
*/
# define SHLIB_VERSION_HISTORY ""
# define SHLIB_VERSION_NUMBER "81.1.1"
#ifdef __cplusplus
}
#endif
#endif /* HEADER_OPENSSLV_H */
| [
"[email protected]"
] | |
26393171c0093670884c0ea4829ff4beaea2848e | fda015cc078e877754e4cd5a48e970f0a1159ada | /src/sources/shared/system_support/os_specifics.h | aee560f47e775860f7a101ac20eaaa04456aeddf | [] | no_license | cran/liquidSVM | 886e0487104a434d3854120a774ebe120e1ddeae | 35b8af219f5d52df5513789793c1e5cf07d310b8 | refs/heads/master | 2020-04-06T04:12:26.063000 | 2019-09-14T17:20:02 | 2019-09-14T17:20:02 | 83,014,436 | 2 | 0 | null | null | null | null | UTF-8 | C | false | false | 4,395 | h | // Copyright 2015, 2016, 2017 Ingo Steinwart
//
// This file is part of liquidSVM.
//
// liquidSVM is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// liquidSVM is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with liquidSVM. If not, see <http://www.gnu.org/licenses/>.
#if !defined (OS_SPECIFICS_H)
#define OS_SPECIFICS_H
#include "sources/shared/system_support/compiler_specifics.h"
//**********************************************************************************************************************************
// Linux and Mac
//**********************************************************************************************************************************
#if defined __linux__ || defined __MACH__
#define POSIX_OS__
#define THREADING_IMPLEMENTED
#ifdef __SSE2__
#define SSE2__
#endif
#ifdef __AVX__
#define AVX__
#endif
#ifdef __AVX2__
#define AVX2__
#endif
#define sync_add_and_fetch __sync_add_and_fetch
#define Tmutex pthread_mutex_t
#define Tthread_handle pthread_t
#define atomic_unsigned unsigned
#define thread__ __thread
#define restrict__ __restrict__
#endif
//**********************************************************************************************************************************
// Windows
//**********************************************************************************************************************************
#if defined _WIN32
#if !defined (NOMINMAX)
#define NOMINMAX
#endif
#include <malloc.h> // Has to come before windows.h
#include <windows.h> // Has to come before emmintrin.h/immintrin.h in simd_basics.h !
#include <iso646.h>
#define THREADING_IMPLEMENTED
#undef COMPILE_WITH_CUDA__
// The next line repeats the default of MS Visual Studio 2012++
// Basically, it assumes that Windows is not running on a CPU built before 2004 or so.
#define SSE2__
#ifdef __AVX__
#define AVX__
#endif
#ifdef __AVX2__
#define AVX2__
#endif
#define Tmutex HANDLE
#define Tthread_handle HANDLE
#ifdef __MINGW32__
#define sync_add_and_fetch __sync_add_and_fetch
#define atomic_unsigned unsigned
#define thread__ __thread
#else
#define sync_add_and_fetch atomic_fetch_add
#if defined(MSVISUAL_LEGACY)
#define atomic_unsigned unsigned
#else
#define atomic_unsigned atomic_uint
#endif
#define thread__ __declspec(thread)
#endif
#define restrict__ __restrict
#endif
//**********************************************************************************************************************************
// Other Operating Systems
//**********************************************************************************************************************************
#if !defined(POSIX_OS__) && !defined(_WIN32)
#define UNKNOWN_OS__
#undef THREADING_IMPLEMENTED
// The following definitions are meant as safeguards. Depending on the
// situtation they may or may not be necessary.
#undef SSE2__
#undef AVX__
#undef AVX2__
#undef COMPILE_WITH_CUDA__
#define Tmutex unsigned
#define Tthread_handle void*
#define atomic_unsigned unsigned
#define thread__
#define restrict__
#endif
//**********************************************************************************************************************************
// More safeguards
//**********************************************************************************************************************************
// Make sure that simd instructions are only used on systems on which we can
// safely alloc aligned memory. Currently, this is true for MS Windows and
// systems supporting POSIX with optional posix_memalign commands.
#if defined _WIN32
#define SIMD_ACTIVATED
#else
#include <unistd.h>
#if defined(_POSIX_ADVISORY_INFO) && _POSIX_ADVISORY_INFO > 0
#define SIMD_ACTIVATED
#else
#undef SIMD_ACTIVATED
#undef AVX2__
#undef AVX__
#undef SSE2__
#endif
#endif
#endif
| [
"[email protected]"
] | |
4e6ed1901fc0f9319647713b68b5b6b327930a06 | 3f309b1dd9774ca1eef2c7bb7626447e6c3dbe70 | /apps/evsys/evsys_trigger/firmware/src/config/sam_l10_xpro/peripheral/clock/plib_clock.c | e3a6e5298e13415f391dd1c25b0e3d7d7fe6eb46 | [
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"LicenseRef-scancode-public-domain"
] | permissive | Unitek-KL/csp | 30892ddf1375f5191173cafdfba5f098245a0ff7 | 2ac7ba59465f23959e51d2f16a5712b57b79ef5f | refs/heads/master | 2020-12-10T13:42:26.878000 | 2019-10-14T17:55:22 | 2019-10-14T17:56:20 | 233,609,402 | 0 | 0 | NOASSERTION | 2020-01-13T14:04:51 | 2020-01-13T14:04:51 | null | UTF-8 | C | false | false | 4,781 | c | /*******************************************************************************
CLOCK PLIB
Company:
Microchip Technology Inc.
File Name:
plib_clock.c
Summary:
CLOCK PLIB Implementation File.
Description:
None
*******************************************************************************/
/*******************************************************************************
* Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to comply with third party license terms applicable to your
* use of third party software (including open source software) that may
* accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*******************************************************************************/
#include "plib_clock.h"
#include "device.h"
static void OSCCTRL_Initialize(void)
{
/**************** OSC16M IniTialization *************/
OSCCTRL_REGS->OSCCTRL_OSC16MCTRL = OSCCTRL_OSC16MCTRL_FSEL(0x0) | OSCCTRL_OSC16MCTRL_ENABLE_Msk;
}
static void OSC32KCTRL_Initialize(void)
{
OSC32KCTRL_REGS->OSC32KCTRL_RTCCTRL = OSC32KCTRL_RTCCTRL_RTCSEL(0);
}
static void FDPLL_Initialize(void)
{
GCLK_REGS->GCLK_PCHCTRL[0] = GCLK_PCHCTRL_GEN(0x1) | GCLK_PCHCTRL_CHEN_Msk;
while ((GCLK_REGS->GCLK_PCHCTRL[0] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk)
{
/* Wait for synchronization */
}
/****************** DPLL Initialization *********************************/
/* Configure DPLL */
OSCCTRL_REGS->OSCCTRL_DPLLCTRLB = OSCCTRL_DPLLCTRLB_FILTER(0) | OSCCTRL_DPLLCTRLB_LTIME(0)| OSCCTRL_DPLLCTRLB_REFCLK(2) ;
OSCCTRL_REGS->OSCCTRL_DPLLRATIO = OSCCTRL_DPLLRATIO_LDRFRAC(0) | OSCCTRL_DPLLRATIO_LDR(63);
while((OSCCTRL_REGS->OSCCTRL_DPLLSYNCBUSY & OSCCTRL_DPLLSYNCBUSY_DPLLRATIO_Msk) == OSCCTRL_DPLLSYNCBUSY_DPLLRATIO_Msk)
{
/* Waiting for the synchronization */
}
/* Selection of the DPLL Enable */
OSCCTRL_REGS->OSCCTRL_DPLLCTRLA = OSCCTRL_DPLLCTRLA_ENABLE_Msk ;
while((OSCCTRL_REGS->OSCCTRL_DPLLSYNCBUSY & OSCCTRL_DPLLSYNCBUSY_ENABLE_Msk) == OSCCTRL_DPLLSYNCBUSY_ENABLE_Msk )
{
/* Waiting for the DPLL enable synchronization */
}
while((OSCCTRL_REGS->OSCCTRL_DPLLSTATUS & (OSCCTRL_DPLLSTATUS_LOCK_Msk | OSCCTRL_DPLLSTATUS_CLKRDY_Msk)) !=
(OSCCTRL_DPLLSTATUS_LOCK_Msk | OSCCTRL_DPLLSTATUS_CLKRDY_Msk))
{
/* Waiting for the Ready state */
}
}
static void GCLK0_Initialize(void)
{
GCLK_REGS->GCLK_GENCTRL[0] = GCLK_GENCTRL_DIV(2) | GCLK_GENCTRL_SRC(7) | GCLK_GENCTRL_GENEN_Msk;
while((GCLK_REGS->GCLK_SYNCBUSY & GCLK_SYNCBUSY_GENCTRL0_Msk) == GCLK_SYNCBUSY_GENCTRL0_Msk)
{
/* wait for the Generator 0 synchronization */
}
}
static void GCLK1_Initialize(void)
{
GCLK_REGS->GCLK_GENCTRL[1] = GCLK_GENCTRL_DIV(4) | GCLK_GENCTRL_SRC(5) | GCLK_GENCTRL_GENEN_Msk;
while((GCLK_REGS->GCLK_SYNCBUSY & GCLK_SYNCBUSY_GENCTRL1_Msk) == GCLK_SYNCBUSY_GENCTRL1_Msk)
{
/* wait for the Generator 1 synchronization */
}
}
void CLOCK_Initialize (void)
{
/* Function to Initialize the Oscillators */
OSCCTRL_Initialize();
/* Function to Initialize the 32KHz Oscillators */
OSC32KCTRL_Initialize();
GCLK1_Initialize();
FDPLL_Initialize();
GCLK0_Initialize();
/* Selection of the Generator and write Lock for EIC */
GCLK_REGS->GCLK_PCHCTRL[3] = GCLK_PCHCTRL_GEN(0x0) | GCLK_PCHCTRL_CHEN_Msk;
while ((GCLK_REGS->GCLK_PCHCTRL[3] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk)
{
/* Wait for synchronization */
}
/* Selection of the Generator and write Lock for EVSYS_0 */
GCLK_REGS->GCLK_PCHCTRL[6] = GCLK_PCHCTRL_GEN(0x0) | GCLK_PCHCTRL_CHEN_Msk;
while ((GCLK_REGS->GCLK_PCHCTRL[6] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk)
{
/* Wait for synchronization */
}
} | [
"http://support.microchip.com"
] | http://support.microchip.com |
74155732b9c958f7e75602f9329f9c20146aa7a9 | 54acb0bc5cfe18341533cf9b451757374e98f9d0 | /ProiectRetele/functions.h | 95e415efb92f5c944b170864006c8e9debcc06be | [] | no_license | balandan/Proiect-Retele | 2a13b6bb3ca917188fa2f41bab159ea47be9ccf2 | 430503bfc24a963c5577a50a18a3254c3142f217 | refs/heads/master | 2020-03-12T15:45:09.726000 | 2018-04-23T13:17:14 | 2018-04-23T13:17:14 | 130,698,324 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 8,566 | h | #include <stdio.h>
#include "listOfItems.h"
int typeOfUser;
int searchInServer(int descriptor,char fileName[30])
{
DIR *dir;
struct dirent *file;
dir = opendir (".");
if(dir==NULL)
{
printf("Fail to open this directory");
exit(1);
}
while( (file=readdir(dir))!=NULL )
{
if( strcmp(file->d_name,fileName)==0)
{
closedir(dir);
return 1;
}
}
closedir(dir);
return 0;
}
int download(char nameOfFile[30],int descriptor)
{
int ptr_myfile;
int counter=0;
char buffer[1024];
char mesaj[100];
bzero(mesaj,100);
char messageFromClient[50];
ptr_myfile=open(nameOfFile,O_RDONLY);
if (ptr_myfile < 0)
{
strcat(mesaj,"Unable to open file!");
//printf("%s",mesaj);
//write(descriptor,"Unable to open file!",30);
}
else strcat(mesaj,"The file was found!");
//printf("%d\n",bytes);
//printf("%d",counter);
printf("[server]%s\n",mesaj);
write(descriptor,mesaj,35);
bzero(messageFromClient,50);
read(descriptor,messageFromClient,50);
if(strcmp(messageFromClient,"done")==0 && strcmp(mesaj,"The file was found!")==0)
{
int bytes;
while ((bytes=read(ptr_myfile,buffer,1024))>0)
{
counter+=bytes;
//printf("%d\n",bytes);
}
int n = counter;
write(descriptor, &n, sizeof(n));
close(ptr_myfile);
write(descriptor,nameOfFile,100);
ptr_myfile=open(nameOfFile,O_RDONLY);
while (n>0)
{
bytes=read(ptr_myfile,buffer,1024);
n=n-bytes;
printf("[server]We sent %d%s%d%s\n",bytes," there are still ", n ," bytes to send");
sleep(0.1);
write(descriptor,buffer,bytes);
//printf("[server]We sent %d%s"," bytes");
}
}
bzero(messageFromClient,50);
close(ptr_myfile);
}
void primireComenzi(int descriptor)
{
char message[100];
char *firstWord;
char *secondWord;
char path[100];
read(descriptor,message,100);
printf("[server]The message recived:%s",message); //primim comanda
//printf("%s",firstWord);
if(strcmp(message,"ls\n")==0 && (typeOfUser==0 || typeOfUser==1)) //comanda pentru ls
{
write(descriptor,"start",6);
listOfItems(descriptor);
primireComenzi(descriptor);
}
else if (strcmp(message,"exit\n")==0 && (typeOfUser==0 || typeOfUser==1))
{
char answer[5];
write(descriptor,"Are you sure?",15);
printf ("[server]Message sent:%s\n","Are you sure?\n");
read(descriptor,answer,5);
if(strcmp(answer,"yes")==0) {
printf("[server]A client has disconnected\n");
close(descriptor);
exit(0);
}
else primireComenzi(descriptor);
}
firstWord=strtok(message," ");
secondWord=strtok(NULL,"\n");
if(strcmp(firstWord,"download")==0 && (typeOfUser==0 || typeOfUser==1))
{
printf("[server]The file that the client ask for:%s\n",secondWord);
//read(descriptor,path,100);
//printf("%s",path);
download(secondWord,descriptor);
primireComenzi(descriptor);
}
else if (strcmp(firstWord,"delete")==0 && typeOfUser==1)
{
//printf("[server]Message recived:delete %s",secondWord);
if(remove(secondWord)==0) write(descriptor,"The file was deleted!",30);
else write(descriptor,"The file can't be deleted or do not exist",50);
primireComenzi(descriptor);
}
else if (strcmp(firstWord,"delete")==0 && typeOfUser==0)
{
primireComenzi(descriptor);
}
else if (strcmp(firstWord,"copy")==0 && typeOfUser==1)
{
int x=searchInServer(descriptor,secondWord);
if (x==1)
{
char nameForTheNewFile[30];
char buffer[1024];
char file[30];//numele final al fisierului pe care il deschidem
char theFileWeOpen[30];
char *extension;//folosim pentru a afla extensia noului fisier
char *nume;//folosim pentru a afla denumirea noului fisier
int openFile;
write(descriptor,"File found!",15);
printf("%s\n","[server]File found!");
read(descriptor,nameForTheNewFile,30);
bzero(theFileWeOpen,30);
strcat(theFileWeOpen,secondWord);
extension=strtok(secondWord,".");
extension=strtok(NULL,"\n");
nume=strtok(nameForTheNewFile,"\n");
bzero(file,30);
strcat(file,nume);
strcat(file,".");
strcat(file,extension);
openFile=open(theFileWeOpen,O_RDONLY);
if (openFile < 0)
{
printf("%s\n","[server]Unable to open file!");
}
int x;
x=open(file,O_WRONLY|O_CREAT);
int bytes=0;
while ((bytes=read(openFile,buffer,1024))>0)
{
write(x,buffer,bytes);
}
close(x);
close(openFile);
printf("[server]The file was copied!\n");
write(descriptor,"Done",5);
primireComenzi(descriptor);
}
else
{
write(descriptor,"File not found!",15);
printf("%s\n","[server]File not found!");
primireComenzi(descriptor);
}
}
else if (strcmp(firstWord,"copy")==0 && typeOfUser==0)
{
primireComenzi(descriptor);
}
else primireComenzi(descriptor);
//primireComenzi(descriptor);
}
int searchInFile(char user[20],char pass[20])
{
int nr_linie=0;
int nr_linie2=0;
char buffer[20];
FILE *a;
a=fopen("user.txt","r");
if (a!=NULL)
{
while(!feof(a))
{
fgets(buffer,20,a);
nr_linie+=1;
if (strcmp(buffer,user)==0)
{
break;
}
bzero(buffer,20);
}
fclose(a);
if(nr_linie %2==1)
{
a=fopen("user.txt","r");
while(!feof(a))
{
fgets(buffer,20,a);
nr_linie2+=1;
if(nr_linie2==nr_linie+1 && strcmp(buffer,pass)==0) return 1;
bzero(buffer,20);
}
}
}
return 0;
}
int typeUser (char username[30])
{
char buffer[30];
FILE *b;
b=fopen("whitelist.txt","r");
if(b!=NULL)
{
while(!feof(b))
{
fgets(buffer,30,b);
if(strcmp(buffer,username)==0) return 1;
}
}
fclose(b);
b=fopen("blacklist.txt","r");
if(b!=NULL)
{
while(!feof(b))
{
fgets(buffer,30,b);
if(strcmp(buffer,username)==0) return 0;
}
}
fclose(b);
}
void login (int descriptor)
{
char *username;
char *password;
char buffer[100];
char msg[100]; //mesajul primit de la client
int i=0;
int y;
char c;
char newPassword[50];
int bytes;
bytes = read (descriptor, msg, sizeof (buffer)); //Citim datele de autentificare
if (bytes < 0)
{
perror ("Eroare la read() de la client.\n");
close(descriptor);
exit(0);
}
printf ("[server]Message recived:%s\n", msg);
username = strtok(msg,"\n"); //Le prelucram
password = strtok(NULL,"\n");
while(password[i]!='\0')
{
y=(int)password[i];
y--;
c=y;
newPassword[i]=c;
i++;
}
newPassword[i]='\0'; //Am decriptat parola
char spatiu[3]="\n";
char nume[20];
bzero(nume,20);
strcat(nume,username);
strcat(nume,spatiu);
int x=searchInFile(nume,newPassword); //cautam in fisierul de logare daca datele primite sunt valide
if(x){
bzero(msg,100);
strcat(msg,"Connected");
printf ("[server]Message sent:%s\n",msg);
typeOfUser=typeUser(nume); //daca sunt valide determinam din ce fisier face parte userul conectat
//printf("%d",typeOfUser);
}
else
{
bzero(msg,100);
strcat(msg,"Try again");
printf ("[server]Message sent:%s\n",msg);
}
if (bytes && write (descriptor, msg, bytes) < 0) //trimitem mesaj de raspuns
{
perror ("[server] Eroare la write() catre client.\n");
//return 0;
}
if (strcmp(msg,"Connected")==0) //daca mesajul trimis este connected apelam functia unde putem primi comenzi
{
write(descriptor, &typeOfUser, sizeof(typeOfUser));//scriem clientului tipul de user ce tocmai s-a logat
//printf("%d",typeOfUser);
primireComenzi(descriptor);
}
else if(strcmp(msg,"Try again")==0) //daca datele sunt gresite se ofera posibilitatea de a incerca de nou
{
login(descriptor);
}
close(descriptor);
exit(0);
}
| [
"[email protected]"
] | |
f8a07ef6a3923daba641e7ac3c0fd7ad2ecbfc87 | 1fabbdfd1ca9ea1b6808893e12bd907eb74de414 | /xcode/Classes/Native/AssemblyU2DCSharp_SPacket_SocketInstance_GC_SYNC_REACHEDSCENMethodDeclarations.h | cc71e70250fd75fada95620a65e6af4003c60645 | [] | no_license | Klanly/TutorialPackageClient | 6f889e96c40ab13c97d107708ae8f3c71a484301 | b9d61ba2f287c491c9565b432f852980ec3fee28 | refs/heads/master | 2020-12-03T01:42:35.256000 | 2016-11-01T02:40:21 | 2016-11-01T02:40:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 743 | h | #pragma once
#include <stdint.h>
#include <assert.h>
#include <exception>
#include "codegen/il2cpp-codegen.h"
// SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler
struct GC_SYNC_REACHEDSCENEHandler_t2847;
// PacketDistributed
struct PacketDistributed_t2209;
// System.Void SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler::.ctor()
void GC_SYNC_REACHEDSCENEHandler__ctor_m16033 (GC_SYNC_REACHEDSCENEHandler_t2847 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.UInt32 SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler::Execute(PacketDistributed)
uint32_t GC_SYNC_REACHEDSCENEHandler_Execute_m16034 (GC_SYNC_REACHEDSCENEHandler_t2847 * __this, PacketDistributed_t2209 * ___ipacket, MethodInfo* method) IL2CPP_METHOD_ATTR;
| [
"[email protected]"
] | |
c8bd691314e2dda543aebd10b67df1d55639c9da | 598883867c454c3706ef844d5c0505c00142ba61 | /LCD/LCD.h | 8a928231dcc96aff1080d4fd704910a849aef356 | [] | no_license | ahmedelgazwy/Password-Based-Lock | 996b245047e1602b175aad5a7b1c04eb3d0e2ff7 | 337ebc6e545d25e134d972cb5ef637ad986fa650 | refs/heads/master | 2021-03-02T20:24:19.206000 | 2020-03-08T19:40:14 | 2020-03-08T19:40:14 | 245,902,521 | 0 | 0 | null | 2020-03-08T23:06:35 | 2020-03-08T23:06:35 | null | UTF-8 | C | false | false | 568 | h | #ifndef __LCD__H__
#define __LCD__H__
#include "std_types.h"
#include "IO_ports.h"
#define LCD_DATA GPIO_PORTC_DATA_R
#define LCD_DATA_DIR GPIO_PORTC_DIR_R
#define LCD_DATA_DEN GPIO_PORTC_DEN_R
#define LCD_DATA_AFSEL GPIO_PORTC_AFSEL_R
#define LCD_DATA_AMSEL GPIO_PORTC_AMSEL_R
#define LCD_DATA_PCTL GPIO_PORTC_PCTL_R
#define LCD_CTRL GPIO_PORTD_DATA_R
#define LCD_CTRL_DIR GPIO_PORTD_DIR_R
#define LCD_CTRL_DEN GPIO_PORTD_DEN_R
#define LCD_CTRL_AFSEL GPIO_PORTD_AFSEL_R
#define LCD_CTRL_AMSEL GPIO_PORTD_AMSEL_R
#define LCD_CTRL_PCTL GPIO_PORTD_PCTL_R
#endif
| [
"[email protected]"
] | |
8b39fe097d9a0ad75f4e8e176acbcd3e9e6ce47c | 5c255f911786e984286b1f7a4e6091a68419d049 | /code/24fbc88b-b066-449c-ae5b-a5acd378d8ab.c | 6c6cfa7dc48bd7868bbeecf6b19c39cd6bf27ae4 | [] | no_license | nmharmon8/Deep-Buffer-Overflow-Detection | 70fe02c8dc75d12e91f5bc4468cf260e490af1a4 | e0c86210c86afb07c8d4abcc957c7f1b252b4eb2 | refs/heads/master | 2021-09-11T19:09:59.944000 | 2018-04-06T16:26:34 | 2018-04-06T16:26:34 | 125,521,331 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 217 | c | #include <stdio.h>
int main() {
int i=0;
int j=14;
int k;
int l;
k = 53;
l = 64;
k = i/j;
l = i/j;
l = l/j;
l = k-j*i;
printf("vulnerability");
printf("%d%d\n",l,l);
return 0;
}
| [
"[email protected]"
] | |
85535a4d92f8f2666b9a5170975b7e8728e2f10d | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/246/087/CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13.c | 820a233fd4b7e26bdeed91be32983bf04da283ab | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446000 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C | false | false | 6,999 | c | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13.c
Label Definition File: CWE78_OS_Command_Injection.strings.label.xml
Template File: sources-sink-13.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Fixed string
* Sink: w32_execv
* BadSink : execute command with execv
* Flow Variant: 13 Control flow: if(GLOBAL_CONST_FIVE==5) and if(GLOBAL_CONST_FIVE!=5)
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define COMMAND_INT_PATH "%WINDIR%\\system32\\cmd.exe"
#define COMMAND_INT "cmd.exe"
#define COMMAND_ARG1 "/c"
#define COMMAND_ARG2 "dir "
#define COMMAND_ARG3 data
#else /* NOT _WIN32 */
#include <unistd.h>
#define COMMAND_INT_PATH "/bin/sh"
#define COMMAND_INT "sh"
#define COMMAND_ARG1 "-c"
#define COMMAND_ARG2 "ls "
#define COMMAND_ARG3 data
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#include <process.h>
#define EXECV _execv
#ifndef OMITBAD
void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_bad()
{
char * data;
char dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
if(GLOBAL_CONST_FIVE==5)
{
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
char *replace;
SOCKET listenSocket = INVALID_SOCKET;
SOCKET acceptSocket = INVALID_SOCKET;
size_t dataLen = strlen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a listen socket */
listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listenSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(TCP_PORT);
if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
{
break;
}
acceptSocket = accept(listenSocket, NULL, NULL);
if (acceptSocket == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed */
recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(char) * (100 - dataLen - 1), 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* Append null terminator */
data[dataLen + recvResult / sizeof(char)] = '\0';
/* Eliminate CRLF */
replace = strchr(data, '\r');
if (replace)
{
*replace = '\0';
}
replace = strchr(data, '\n');
if (replace)
{
*replace = '\0';
}
}
while (0);
if (listenSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(listenSocket);
}
if (acceptSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(acceptSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
}
{
char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL};
/* execv - specify the path where the command is located */
/* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */
EXECV(COMMAND_INT_PATH, args);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the GLOBAL_CONST_FIVE==5 to GLOBAL_CONST_FIVE!=5 */
static void goodG2B1()
{
char * data;
char dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
if(GLOBAL_CONST_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Append a fixed string to data (not user / external input) */
strcat(data, "*.*");
}
{
char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL};
/* execv - specify the path where the command is located */
/* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */
EXECV(COMMAND_INT_PATH, args);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
char * data;
char dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
if(GLOBAL_CONST_FIVE==5)
{
/* FIX: Append a fixed string to data (not user / external input) */
strcat(data, "*.*");
}
{
char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL};
/* execv - specify the path where the command is located */
/* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */
EXECV(COMMAND_INT_PATH, args);
}
}
void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"[email protected]"
] | |
140d8434c9645707bed4716235e4ff9dc4315eca | c9eccf85f19371a3843911c1480e761de4773722 | /src/lvgl/src/lv_misc/lv_bidi.h | f3f758b43ab14b9f6180db943b44a41d1f39df7d | [
"MIT"
] | permissive | mibus/TTGO_TWatch_Library | 7d3c04ca2358b181264ea744a1bcd8338f508d91 | bd77e6edba3baf9c5c68de4683a01b81f6b3a8b3 | refs/heads/master | 2022-11-25T03:04:40.292000 | 2020-07-25T03:15:55 | 2020-07-25T03:15:55 | 275,497,118 | 0 | 0 | MIT | 2020-06-28T03:13:55 | 2020-06-28T03:13:54 | null | UTF-8 | C | false | false | 4,064 | h | /**
* @file lv_bifi.h
*
*/
#ifndef LV_BIDI_H
#define LV_BIDI_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include <stdbool.h>
#include <stdint.h>
/*********************
* DEFINES
*********************/
/* Special non printable strong characters.
* They can be inserted to texts to affect the run's direction*/
#define LV_BIDI_LRO "\xE2\x80\xAD" /*U+202D*/
#define LV_BIDI_RLO "\xE2\x80\xAE" /*U+202E*/
/**********************
* TYPEDEFS
**********************/
enum {
/*The first 4 values are stored in `lv_obj_t` on 2 bits*/
LV_BIDI_DIR_LTR = 0x00,
LV_BIDI_DIR_RTL = 0x01,
LV_BIDI_DIR_AUTO = 0x02,
LV_BIDI_DIR_INHERIT = 0x03,
LV_BIDI_DIR_NEUTRAL = 0x20,
LV_BIDI_DIR_WEAK = 0x21,
};
typedef uint8_t lv_bidi_dir_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
#if LV_USE_BIDI
/**
* Convert a text to get the characters in the correct visual order according to
* Unicode Bidirectional Algorithm
* @param str_in the text to process
* @param str_out store the result here. Has the be `strlen(str_in)` length
* @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL`
*/
void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir);
/**
* Auto-detect the direction of a text based on the first strong character
* @param txt the text to process
* @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL`
*/
lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt);
/**
* Get the logical position of a character in a line
* @param str_in the input string. Can be only one line.
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
* If not required anymore has to freed with `lv_mem_free()`
* Can be `NULL` is unused
* @param len length of the line in character count
* @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL`
* @param vicual_pos the visual character position which logical position should be get
* @param is_rtl tell the the char at `viasual_pos` is RTL or LTR context
* @return the logical character position
*/
uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir,
uint32_t visual_pos, bool * is_rtl);
/**
* Get the visual position of a character in a line
* @param str_in the input string. Can be only one line.
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
* If not required anymore has to freed with `lv_mem_free()`
* Can be `NULL` is unused
* @param len length of the line in character count
* @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL`
* @param logical_pos the logical character position which visual position should be get
* @param is_rtl tell the the char at `logical_pos` is RTL or LTR context
* @return the visual character position
*/
uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir,
uint32_t logical_pos, bool * is_rtl);
/**
* Bidi process a paragraph of text
* @param str_in the string to process
* @param str_out store the result here
* @param len length of teh text
* @param base_dir base dir of the text
* @param pos_conv_out an `uint16_t` array to store the related logical position of the character.
* Can be `NULL` is unused
* @param pos_conv_len length of `pos_conv_out` in element count
*/
void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir,
uint16_t * pos_conv_out, uint16_t pos_conv_len);
/**********************
* MACROS
**********************/
#endif /*LV_USE_BIDI*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_BIDI_H*/
| [
"[email protected]"
] | |
a2ee19d7d87b6949e20292b2a52ca26dc7dd75dd | 0b98befdd49f707ed1923703bcdac9740bb4d699 | /priv/codegolf/Draw the Sawtooth Alphabet.c | de85b8d2d1997998ac9bef46d8908dbbd40b99cb | [] | no_license | jbebe/all-my-projects | a957f2ae70d3ca09d49e1efc52c3cd9f6f786094 | 32a8b12b17d48c0138005eb54cb1ed9745baa737 | refs/heads/master | 2021-01-10T08:55:55.291000 | 2015-05-29T20:16:05 | 2015-05-29T20:16:05 | 35,968,468 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 884 | c | /*
A simple one today. Write the shortest program that draws
a "sawtooth alphabet" given a positive integer for the height.
You must write the name of your programming language when you come
to the letter it starts with.
For example, if your language is Python and the input is 1
the output should be:
ABCDEFGHIJKLMNOPythonQRSTUVWXYZ
If the input is 2 the output should be:
B D F H J L N Python R T V X Z
A C E G I K M O Q S U W Y
If the input is 4 the output should be:
D J Python V
C E I K O Q U W
B F H L N R T X Z
A G M S Y
*/
/*
if n holds the height:
*/
// C + escape codes: 81
x;main(y){for(y=n--;x<26;x++)printf("\033[%d;%dH%c",n?x/n&1?y++:y--:y,x+1,x+65);}
// C 110
x;char a[702]={[0 ...701]=32};main(y){for(y=--n;x<26;a[x*27-1]=10)a[27*(n?x/n&1?y++:y--:y)+x]=x+++65;puts(a);} | [
"[email protected]"
] | |
6e4b62fc82e9d7f43ce043d45c270328142a1c71 | dec6419e67295954f5c526d9631685d9d8499342 | /src/xoip_messages.c | 7d8d11f458027296451ce911469b4db64fdc59bf | [] | no_license | vassilux/xoip2 | 23029e19221f98fbb24368259ba0770541cdb8e2 | 4893d31a9dbad1fc585b515c3a371ce59f752180 | refs/heads/master | 2021-01-01T05:49:33.621000 | 2014-08-21T14:12:06 | 2014-08-21T14:12:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 10,909 | c | /*
* XoIP -- telephony toolkit.
*
* Copyright (C) <2014>, <vassilux>
*
* <Vassili Gontcharov> <[email protected]>
*
*/
/*! \file
*
* \brief Xoipeton application
*
* \author\verbatim <Vassili Gontcharov> <[email protected]> \endverbatim
*
* This is a Xoip for development of an Asterisk application
* \ingroup applications
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>core</support_level>
***/
#include <stdio.h>
#include <stdlib.h>
#include "asterisk.h"
#include "asterisk/logger.h"
//#include "asterisk/astmm.h"
#include "xoip_messages.h"
int do_process_message (const char *buf, int size,
struct f1_messages_handlers *handlers);
static void do_process_message_fa(int track, int callref, char *code, struct f1_messages_handlers *handlers)
{
if(code == NULL){
return;
}
if(code[0] == 'M'){
handlers->mute_micro_operator(track, callref, true);
}else if(code[0] == 'N'){
handlers->mute_micro_operator(track, callref, false);
}
}
/*!
* \brief Intiaialize the emmessions configuration for the given communication.
*
* \param track The track number.
* \param callref The call reference.
* \param messages The string array of parameters.
* \param handlers The pointer to the wrapper of the app_xoip functions.
*/
static void do_process_message_fc(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers)
{
char *emmission_type = messages[3];
int dtmf_duration = 0;
int silence_duration = 0;
int loudness = 0;
if(emmission_type != NULL &&(strcmp(emmission_type, "DTMF") == 0)){
if(messages[4] != NULL){
/*
* pay an attention cause the F1 send packege without , between DTMF
* and duration
*/
dtmf_duration = atoi(messages[4] + 4); // move 4 to skip DTMF string
}
if(messages[5] != NULL){
silence_duration = atoi(messages[5]);
}
if(messages[6] != NULL){
loudness = atoi(messages[6]);
}
}
}
/*!
* \brief Send the frequencies to th] channel identified by the given track and callref
*/
static void do_process_message_ff(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers)
{
int freq;
int duration;
int level;
char *mode = NULL;
char *break_record;
if(messages[3] != NULL){
freq = atoi(messages[3]);
}
if(messages[4] != NULL){
duration = atoi(messages[4]);
}
if(messages[5] != NULL){
level = atoi(messages[5]);
}
mode = messages[6];
break_record = messages[6];
handlers->send_freq(track, callref, freq, duration, level, mode, break_record);
}
/*!
* \brief Process FL message. Send data to the channel identificated by the given track and callref
*/
static void do_process_message_fl(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers)
{
int mode_transfer;
char *data;
char *mode_operator = NULL;
char *break_record;
if(messages[3] != NULL){
mode_transfer = atoi(messages[3]);
}
data = messages[4];
mode_operator = messages[5];
break_record = messages[6];
handlers->send_data(track, callref, mode_transfer, data, mode_operator, break_record);
}
/*!
*
*/
int do_process_message (const char *buf, int size,
struct f1_messages_handlers *handlers)
{
int res = 0;
char *buffer = strdup (buf);
const char *sep = ",";
char messages[10][255] = { '\0' };
int count = 0;
ast_verb(5, "Get packet from f1 endpoint : [%s\n]", buffer);
char *token = NULL;
for (token = strtok (buffer, sep); token; token = strtok (NULL, sep))
{
if (token != NULL)
{
strcpy (messages[count], token);
count++;
}
}
char type = messages[0][2];
/* this is special case for ithe polling and mode request messages */
if(messages[0][0] == 'R' && type == 'S'){
handlers->request_reboot();
goto goout;
}else if(type == 'N'){
/* skip this one */
handlers->request_mode_normal();
goto goout;
}else if(messages[0][0]== 'V' && type == 'R'){
goto goout;
}else if(type == 'P'){
ast_verb(5, "Get polling [%s].\n", messages[3]);
handlers->polling(messages[3]);
goto goout;
}
int track = atoi (messages[1]);
long callref = 0;
sscanf(messages[2], "%04X", &callref);
/* so far sor good */
switch (type)
{
case 'A':
do_process_message_fa(track, callref, messages[3], handlers);
break;
case 'C':
do_process_message_fc(track, callref, messages, handlers);
break;
case 'F':
do_process_message_ff(track, callref, messages, handlers);
break;
case 'G':
{
char proto = messages[3][0];
int level = 0;
if (messages[4] != NULL)
{
level = atoi (messages[4]);
}
handlers->answer (track, callref, proto, level);
}
break;
case 'H':
{
char *callee = messages[3];
char *caller = messages[4];
char *volum = messages[5];
handlers->commut (track, callref, callee, caller, volum);
}
break;
case 'I':
{
char proto = messages[3][0];
int loudness = 0;
if(messages[4] != NULL){
loudness = atoi(messages[4]);
}
handlers->switch_protocol(track, callref, proto, loudness);
}
break;
case 'K':
handlers->ack_alarm(track, callref);
break;
case 'L':
do_process_message_fl(track, callref, messages, handlers);
break;
case 'M':
{
int record_track = 0;
if(messages[3] != NULL){
record_track = atoi(messages[4]);
}
handlers->record_request(track, callref, record_track);
}
break;
case 'r':
case 'R':
//ast_log(AST_LOG_VERBOSE, " Processing R.\n");
handlers->hangup (track, callref);
break;
case 'V':
{
int volume;
if(messages[3] != NULL){
volume = atoi(messages[3]);
}
handlers->volume_adjust(track, callref, volume);
}
break;
case 'W':
handlers->queuing_call(track, callref, messages[3]);
break;
case 'U':
break;
default:
ast_log (AST_LOG_VERBOSE, " Processing but type not found : [%c]..\n",
buf);
break;
}
goto goout;
goout:
res = size;
free (buffer);
return res;
}
/*!
*
*/
int xoip_build_XC_msg (int voie, int callref, const char *did,
const char *caller, const char *transfered, char *dest,
int size)
{
snprintf (dest, size - 1, "X C,%02d,%04X,%s,%s,T%s\r",
voie, callref, did, caller, transfered);
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_Xg_msg (int voie, int callref, int state, int res, char *dest, int size)
{
if(res != 0){
snprintf (dest, size - 1, "X g,%02d,%04X,1,%01d\r",
voie, callref, res);
}else{
snprintf (dest, size - 1, "X g,%02d,%04X,%d\r",
voie, callref,state);
}
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_XL_msg (int voie, int callref, int res, char *dest, int size)
{
if(res != 0){
snprintf (dest, size - 1, "X L,%02d,%04X,1,%01d\r",
voie, callref, res);
}else{
snprintf (dest, size - 1, "X L,%02d,%04d\r",
voie, callref);
}
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_Xm_msg(int voie, int callref, int state, int res, char *dest, int size)
{
if(res != 0){
snprintf (dest, size - 1, "X m,%02d,%04X,1,%01d\r",
voie, callref, res);
}else{
snprintf (dest, size - 1, "X m,%02d,%04d\r",
voie, callref);
}
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_XE_msg(int status, char *dest, int size)
{
snprintf (dest, size - 1, "X E,%01d,%s\r",
status, "XoIP Alarms-V0.2.0.80,Dem V0000,Mod V0000");
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_Xr_msg (int voie, int callref, char *dest, int size)
{
snprintf (dest, size, "X r,%02d,%04d\r", voie, callref);
return 0;
}
/*!
*
*/
int xoip_build_Xh_msg (int voie, int callref, int state, const char *callee,
char *dest, int size)
{
snprintf (dest, size, "X h,%02d,%04X,%01d,%s\r",
voie, callref, state, callee);
return 0;
}
/*!
*
*/
int xoip_build_Xi_msg(int voie, int callref, int state, int res, char *dest, int size)
{
snprintf (dest, size - 1, "X i,%02d,%04X,%01d,%01d\r",
voie, callref, state, res);
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_Xk_msg(int voie, int callref, int state, int res, char *dest, int size)
{
snprintf (dest, size - 1, "X k,%02d,%04X,%01d,%01d\r",
voie, callref, state, res);
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_Xf_msg (int voie, int callref, int state, int res, char *dest, int size)
{
snprintf (dest, size - 1, "X f,%02d,%04X,%01d,%01d\r",
voie, callref, state, res);
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
*
*/
int xoip_build_XA_msg (int voie, int callref, const char *data, char *dest, int size)
{
snprintf (dest, size, "X A,%02d,%04X,%s\r",
voie, callref, data);
return 0;
}
/*!
* \brief Build X w message.
* The response for f1 F W request : qeueuing a call
*/
int xoip_build_Xw_msg(int voie, int callref, int res, char *dest, int size)
{
snprintf (dest, size - 1, "X w,%02d,%04X,%01d\r",
voie, callref, res);
if(strlen(dest) == 0){
return -1;
}
return 0;
}
/*!
* \brief Parsing message from the given buffer.
* Buffer can content few messges
*
* \param buf messages buffer
* \param size the length of the buffer
* \params handlers the structur of callback for each type of message
*
* \retval -1 on error
* \retval > 0 the lenth of processing messages
*/
int process_message (const char *buf, int size,
struct f1_messages_handlers *handlers)
{
int res = 0;
int i = 0;
int count = 0;
char *buffer = strdup (buf);
const char *sep = "\r";
char *token = NULL;
/* must be changed */
char messages[10][255] = { '\0' };
for (token = strtok (buffer, sep); token; token = strtok (NULL, sep))
{
strcpy (messages[count], token);
count++;
}
res = 0;
for (i = 0; i < count; i++)
{
/* increment by the token length */
res += do_process_message (messages[i], strlen (messages[i]), handlers);
}
/* add to the result the number of tokens. May be addt length(sep) can be good idea */
res += count;
free (buffer);
return res;
}
| [
"[email protected]"
] |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
- Downloads last month
- 22