hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
58c08fd08bfb640346967759ce79bc9210fb42f8
735
h
C
TimeSchedule/timeeditdelegate.h
SteakingCoder/MyTimeSchedule
1cc017e8439f9830fa056dda11bd40536eba8986
[ "Apache-2.0" ]
null
null
null
TimeSchedule/timeeditdelegate.h
SteakingCoder/MyTimeSchedule
1cc017e8439f9830fa056dda11bd40536eba8986
[ "Apache-2.0" ]
1
2018-02-08T15:16:12.000Z
2018-03-03T16:18:55.000Z
TimeSchedule/timeeditdelegate.h
HuangDanGeeker/MyTimeSchedule
1cc017e8439f9830fa056dda11bd40536eba8986
[ "Apache-2.0" ]
null
null
null
#ifndef TIMEEDITDELEGATE_H #define TIMEEDITDELEGATE_H #include <QObject> #include <QItemDelegate> class TimeEditDelegate : public QItemDelegate { public: TimeEditDelegate(QObject * parent); //返回改变Model数据的widget,该widget是经过定制行为的Widget QWidget *createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const; //将可操作的数据提供给widget void setEditorData(QWidget * editor, const QModelIndex & index) const; //将widget的数据展示到Item中 void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; #endif // TIMEEDITDELEGATE_H
30.625
115
0.77551
[ "model" ]
58ca213beab12922e415570a13b49ef836de3a1a
557
h
C
src/components/Camera.h
solidajenjo/FluidSimulation
051bb986b48fa521dbb0ac0a7a7f802a1b79892d
[ "MIT" ]
null
null
null
src/components/Camera.h
solidajenjo/FluidSimulation
051bb986b48fa521dbb0ac0a7a7f802a1b79892d
[ "MIT" ]
null
null
null
src/components/Camera.h
solidajenjo/FluidSimulation
051bb986b48fa521dbb0ac0a7a7f802a1b79892d
[ "MIT" ]
null
null
null
#pragma once #include "Component.h" #include "Transform.h" #include "Geometry/Frustum.h" class Camera : public Component { public: Camera(Application* App) : Component(App) { m_Transform = new Transform(App); } virtual ~Camera() { delete m_Transform; } void Update() override; Transform* m_Transform { nullptr }; math::Frustum m_Frustum; float m_Speed = 0.1f; void LookAt(const math::float3& target); private: void UpdateInput(); void UpdateFrustum(); void Yaw(float amount); void Pitch(float amount); };
19.206897
83
0.67325
[ "geometry", "transform" ]
58d59d9b8121bf32ed05bb050c6c0e7070430fee
16,359
c
C
mycode/mini_tracer/src/mini_tracer.c
xuhongv/GPRS_A9G
e41aef96b5c0ed606ec554451c6ca135cb9fd585
[ "MIT" ]
10
2019-11-12T03:36:32.000Z
2021-12-19T08:20:09.000Z
mycode/mini_tracer/src/mini_tracer.c
xuhongv/GPRS_A9G
e41aef96b5c0ed606ec554451c6ca135cb9fd585
[ "MIT" ]
null
null
null
mycode/mini_tracer/src/mini_tracer.c
xuhongv/GPRS_A9G
e41aef96b5c0ed606ec554451c6ca135cb9fd585
[ "MIT" ]
7
2019-11-12T03:36:33.000Z
2021-07-10T13:39:48.000Z
/* * @Description: In User Settings Edit * @Author: your name * @Date: 2019-08-03 19:57:03 * @LastEditTime: 2019-08-28 10:03:18 * @LastEditors: Please set LastEditors */ #include "stdbool.h" #include "stdint.h" #include "stdio.h" #include "string.h" #include "api_os.h" #include "api_debug.h" #include "api_event.h" #include "api_mqtt.h" #include "api_network.h" #include "api_socket.h" #include "api_info.h" #include "mini_tracer.h" #include "buffer.h" #include "gps_parse.h" #include "math.h" #include "gps.h" #include "cJSON.h" #define PDP_CONTEXT_APN "cmnet" #define PDP_CONTEXT_USERNAME "" #define PDP_CONTEXT_PASSWD "" #define MAIN_TASK_STACK_SIZE (2048 * 2) #define MAIN_TASK_PRIORITY 0 #define MAIN_TASK_NAME "Main Task" #define SECOND_TASK_STACK_SIZE (2048 * 2) #define SECOND_TASK_PRIORITY 1 #define SECOND_TASK_NAME "MQTT Task" #define GPS_TASK_STACK_SIZE (2048 * 2) #define GPS_TASK_PRIORITY 0 #define GPS_TASK_NAME "GPS Task" bool flagIsGPSFinish = false; uint8_t imei[16], subTopic[50], pubTopic[50]; char getLatitude[15], getLongitude[15]; uint8_t postDate[150]; static HANDLE mainTaskHandle = NULL; static HANDLE mqttTaskHandle = NULL; static HANDLE grsTaskHandle = NULL; static HANDLE semMqttStart = NULL; MQTT_Connect_Info_t ci; static MQTT_Client_t *mqttClient; typedef enum { MQTT_EVENT_CONNECTED = 0, MQTT_EVENT_DISCONNECTED, MQTT_EVENT_MAX } MQTT_Event_ID_t; typedef struct { MQTT_Event_ID_t id; MQTT_Client_t *client; } MQTT_Event_t; typedef enum { MQTT_STATUS_DISCONNECTED = 0, MQTT_STATUS_CONNECTED, MQTT_STATUS_MAX } MQTT_Status_t; MQTT_Status_t mqttStatus = MQTT_STATUS_DISCONNECTED; static uint32_t reconnectInterval = 3000; void StartTimerPublish(uint32_t interval, MQTT_Client_t *client); void StartTimerConnect(uint32_t interval, MQTT_Client_t *client); void OnPublish(void *arg, MQTT_Error_t err); bool AttachActivate() { uint8_t status; bool ret = Network_GetAttachStatus(&status); if (!ret) { Trace(2, "get attach staus fail"); return false; } Trace(2, "attach status:%d", status); if (!status) { ret = Network_StartAttach(); if (!ret) { Trace(2, "network attach fail"); return false; } } else { ret = Network_GetActiveStatus(&status); if (!ret) { Trace(2, "get activate staus fail"); return false; } Trace(2, "activate status:%d", status); if (!status) { Network_PDP_Context_t context = { .apn = PDP_CONTEXT_APN, .userName = PDP_CONTEXT_USERNAME, .userPasswd = PDP_CONTEXT_PASSWD}; Network_StartActive(context); } } return true; } static void NetworkEventDispatch(API_Event_t *pEvent) { switch (pEvent->id) { case API_EVENT_ID_NETWORK_REGISTER_DENIED: Trace(2, "network register denied"); break; case API_EVENT_ID_NETWORK_REGISTER_NO: Trace(2, "network register no"); break; case API_EVENT_ID_NETWORK_REGISTERED_HOME: case API_EVENT_ID_NETWORK_REGISTERED_ROAMING: Trace(2, "network register success"); AttachActivate(); break; case API_EVENT_ID_NETWORK_DETACHED: Trace(2, "network detached"); AttachActivate(); break; case API_EVENT_ID_NETWORK_ATTACH_FAILED: Trace(2, "network attach failed"); AttachActivate(); break; case API_EVENT_ID_NETWORK_ATTACHED: Trace(2, "network attach success"); AttachActivate(); break; case API_EVENT_ID_NETWORK_DEACTIVED: Trace(2, "network deactived"); AttachActivate(); break; case API_EVENT_ID_NETWORK_ACTIVATE_FAILED: Trace(2, "network activate failed"); AttachActivate(); break; case API_EVENT_ID_NETWORK_ACTIVATED: Trace(2, "network activate success.."); if (semMqttStart) OS_ReleaseSemaphore(semMqttStart); break; case API_EVENT_ID_SIGNAL_QUALITY: Trace(2, "CSQ:%d", pEvent->param1); break; default: break; } } static void EventDispatch(API_Event_t *pEvent) { switch (pEvent->id) { case API_EVENT_ID_NETWORK_REGISTERED_HOME: case API_EVENT_ID_NETWORK_REGISTERED_ROAMING: Trace(1, "gprs register complete"); flagIsGPSFinish = true; NetworkEventDispatch(pEvent); break; case API_EVENT_ID_GPS_UART_RECEIVED: // Trace(1,"received GPS data,length:%d, data:%s,flag:%d",pEvent->param1,pEvent->pParam1,flag); GPS_Update(pEvent->pParam1, pEvent->param1); break; case API_EVENT_ID_NO_SIMCARD: Trace(2, "!!NO SIM CARD%d!!!!", pEvent->param1); break; case API_EVENT_ID_SIMCARD_DROP: Trace(2, "!!SIM CARD%d DROP!!!!", pEvent->param1); break; case API_EVENT_ID_SYSTEM_READY: Trace(2, "system initialize complete"); break; case API_EVENT_ID_NETWORK_REGISTER_DENIED: case API_EVENT_ID_NETWORK_REGISTER_NO: case API_EVENT_ID_NETWORK_DETACHED: case API_EVENT_ID_NETWORK_ATTACH_FAILED: case API_EVENT_ID_NETWORK_ATTACHED: case API_EVENT_ID_NETWORK_DEACTIVED: case API_EVENT_ID_NETWORK_ACTIVATE_FAILED: case API_EVENT_ID_NETWORK_ACTIVATED: case API_EVENT_ID_SIGNAL_QUALITY: NetworkEventDispatch(pEvent); break; default: break; } } void OnMqttReceived(void *arg, const char *topic, uint32_t payloadLen) { Trace(1, "MQTT received data , topic:[%s], payload length:%d", topic, payloadLen); } void OnMqttReceiedData(void *arg, const uint8_t *data, uint16_t len, MQTT_Flags_t flags) { char jsonData[255]; memset(jsonData, '\0', sizeof(jsonData)); strncpy(jsonData, data, len); Trace(1, "MQTT recieved data , length:%d,data:%s", len, jsonData); Trace(1, "cJSON_Version Version: %s ", cJSON_Version()); ////首先整体判断是否为一个json格式的数据 cJSON *pJsonRoot = cJSON_Parse(data); //如果是否json格式数据 if (NULL == pJsonRoot) { Trace(1, "MQTT data pJsonRoot == NULL"); goto __cJSON_Delete; } cJSON *pCMD = cJSON_GetObjectItemCaseSensitive(pJsonRoot, "cmd"); if (cJSON_IsString(pCMD) && (pCMD->valuestring != NULL)) { printf("Checking monitor \"%s\"\n", pCMD->valuestring); } if (NULL != pCMD) { Trace(1, "MQTT data pChange get cmd : %s", pCMD->valuestring); if (0 == strcmp(pCMD->valuestring, "refresh")) { Trace(1, "MQTT data cmd:refresh"); //不能在这里直接发布消息,使用定时器发布不会断开mqtt连接!! //也不能把下面的延迟改为0,会直接死机!!哈哈!这个是我测试出来的! StartTimerPublish(100, mqttClient); } } else { const char *error_ptr = cJSON_GetErrorPtr(); Trace(1, "MQTT data pChange get fail: %s", error_ptr); } __cJSON_Delete: cJSON_Delete(pJsonRoot); } void OnMqttSubscribed(void *arg, MQTT_Error_t err) { if (err != MQTT_ERROR_NONE) Trace(1, "MQTT subscribe fail,error code:%d", err); else Trace(1, "MQTT subscribe success , topic:%s", (const char *)arg); } void OnMqttConnection(MQTT_Client_t *client, void *arg, MQTT_Connection_Status_t status) { Trace(1, "MQTT connection status:%d", status); MQTT_Event_t *event = (MQTT_Event_t *)OS_Malloc(sizeof(MQTT_Event_t)); if (!event) { Trace(1, "MQTT no memory"); return; } if (status == MQTT_CONNECTION_ACCEPTED) { Trace(1, "MQTT succeed connect to broker"); //!!! DO NOT suscribe here(interrupt function), do MQTT suscribe in task, or it will not excute event->id = MQTT_EVENT_CONNECTED; event->client = client; //mqttClient = (MQTT_Client_t *)OS_Malloc(sizeof(MQTT_Client_t)); mqttClient = client; OS_SendEvent(mqttTaskHandle, event, OS_TIME_OUT_WAIT_FOREVER, OS_EVENT_PRI_NORMAL); } else { event->id = MQTT_EVENT_DISCONNECTED; event->client = client; mqttClient = client; OS_SendEvent(mqttTaskHandle, event, OS_TIME_OUT_WAIT_FOREVER, OS_EVENT_PRI_NORMAL); Trace(1, "MQTT connect to broker fail,error code:%d", status); } Trace(1, "MQTT OnMqttConnection() end"); } void OnPublish(void *arg, MQTT_Error_t err) { if (err == MQTT_ERROR_NONE) Trace(1, "MQTT publish success"); else Trace(1, "MQTT publish error, error code:%d", err); } void OnTimerPublish(void *param) { MQTT_Error_t err; MQTT_Client_t *client = (MQTT_Client_t *)param; uint8_t status = MQTT_IsConnected(client); Trace(1, "mqtt status:%d", status); if (mqttStatus != MQTT_STATUS_CONNECTED) { Trace(1, "MQTT not connected to broker! can not publish"); return; } Trace(1, "MQTT OnTimerPublish"); //向MQTT服务器(broker)发布消息 //client:MQTT客户端对象 // topic:主题 // port:服务器端口 // payload:消息体 // payloadLen:消息体长度 // dup:标示发送重复数 // qos:服务质量 // retain:需要服务器持久保存消息 // callback:发布请求回调函数 // arg:需要传递给回调函数的参数 err = MQTT_Publish(client, pubTopic, postDate, strlen(postDate), 1, 2, 0, OnPublish, NULL); if (err != MQTT_ERROR_NONE) Trace(1, "MQTT publish error, error code:%d", err); } void StartTimerPublish(uint32_t interval, MQTT_Client_t *client) { OS_StartCallbackTimer(mainTaskHandle, interval, OnTimerPublish, (void *)client); } void OnTimerStartConnect(void *param) { MQTT_Error_t err; MQTT_Client_t *client = (MQTT_Client_t *)param; uint8_t status = MQTT_IsConnected(client); Trace(1, "mqtt status:%d", status); if (mqttStatus == MQTT_STATUS_CONNECTED) { Trace(1, "already connected!"); return; } err = MQTT_Connect(client, BROKER_IP, BROKER_PORT, OnMqttConnection, NULL, &ci); if (err != MQTT_ERROR_NONE) { Trace(1, "MQTT connect fail,error code:%d", err); reconnectInterval += 1000; if (reconnectInterval >= 60000) reconnectInterval = 60000; StartTimerConnect(reconnectInterval, client); } } void StartTimerConnect(uint32_t interval, MQTT_Client_t *client) { OS_StartCallbackTimer(mainTaskHandle, interval, OnTimerStartConnect, (void *)client); } void SecondTaskEventDispatch(MQTT_Event_t *pEvent) { switch (pEvent->id) { case MQTT_EVENT_CONNECTED: reconnectInterval = 3000; mqttStatus = MQTT_STATUS_CONNECTED; Trace(1, "MQTT connected, now subscribe topic:%s", subTopic); MQTT_Error_t err; MQTT_SetInPubCallback(pEvent->client, OnMqttReceived, OnMqttReceiedData, (pEvent->client)); //向MQTT服务器(broker)发起订阅主题请求 err = MQTT_Subscribe(pEvent->client, subTopic, 2, OnMqttSubscribed, (void *)subTopic); if (err != MQTT_ERROR_NONE) Trace(1, "MQTT subscribe error, error code:%d", err); StartTimerPublish(PUBLISH_INTERVAL, pEvent->client); break; case MQTT_EVENT_DISCONNECTED: mqttStatus = MQTT_STATUS_DISCONNECTED; StartTimerConnect(reconnectInterval, pEvent->client); break; default: break; } } void TaskMqtt(void *pData) { MQTT_Event_t *event = NULL; semMqttStart = OS_CreateSemaphore(0); OS_WaitForSemaphore(semMqttStart, OS_WAIT_FOREVER); OS_DeleteSemaphore(semMqttStart); semMqttStart = NULL; Trace(1, "start mqtt task"); INFO_GetIMEI(imei); sprintf(subTopic, "/A9g/%s/get", imei); sprintf(pubTopic, "/A9g/%s/update", imei); Trace(1, "start mqtt test"); Trace(1, "subTopic: %s", subTopic); Trace(1, "pubTopic: %s", pubTopic); MQTT_Client_t *client = MQTT_ClientNew(); MQTT_Error_t err; memset(&ci, 0, sizeof(MQTT_Connect_Info_t)); ci.client_id = imei; ci.client_user = CLIENT_USER; ci.client_pass = CLIENT_PASS; ci.keep_alive = 30; ci.clean_session = 1; ci.use_ssl = false; err = MQTT_Connect(client, BROKER_IP, BROKER_PORT, OnMqttConnection, NULL, &ci); if (err != MQTT_ERROR_NONE) Trace(1, "MQTT connect fail,error code:%d", err); while (1) { if (OS_WaitEvent(mqttTaskHandle, (void **)&event, OS_TIME_OUT_WAIT_FOREVER)) { SecondTaskEventDispatch(event); OS_Free(event); } } } void TaskGPS(void *pData) { GPS_Info_t *gpsInfo = Gps_GetInfo(); uint8_t buffer[150]; //wait for gprs register complete //The process of GPRS registration network may cause the power supply voltage of GPS to drop, //which resulting in GPS restart. while (!flagIsGPSFinish) { Trace(1, "wait for gprs regiter complete please ."); OS_Sleep(2000); } //open GPS hardware(UART2 open either) GPS_Init(); GPS_Open(NULL); //wait for gps start up, or gps will not response command while (gpsInfo->rmc.latitude.value == 0) { Trace(1, "while (gpsInfo->rmc.latitude.value == 0)"); OS_Sleep(1000); } // set gps nmea output interval for (uint8_t i = 0; i < 5; ++i) { bool ret = GPS_SetOutputInterval(10000); Trace(1, "set gps ret:%d", ret); if (ret) break; OS_Sleep(1000); } if (!GPS_GetVersion(buffer, 150)) Trace(1, "get gps firmware version fail"); else Trace(1, "gps firmware version:%s", buffer); if (!GPS_SetOutputInterval(1000)) Trace(1, "set nmea output interval fail"); Trace(1, "init ok"); while (1) { //show fix info uint8_t isFixed = gpsInfo->gsa[0].fix_type > gpsInfo->gsa[1].fix_type ? gpsInfo->gsa[0].fix_type : gpsInfo->gsa[1].fix_type; char *isFixedStr = "no fix"; if (isFixed == 2) isFixedStr = "2D fix"; else if (isFixed == 3) { if (gpsInfo->gga.fix_quality == 1) isFixedStr = "3D fix"; else if (gpsInfo->gga.fix_quality == 2) isFixedStr = "3D/DGPS fix"; } //convert unit ddmm.mmmm to degree(°) int temp = (int)(gpsInfo->rmc.latitude.value / gpsInfo->rmc.latitude.scale / 100); double latitude = temp + (double)(gpsInfo->rmc.latitude.value - temp * gpsInfo->rmc.latitude.scale * 100) / gpsInfo->rmc.latitude.scale / 60.0; temp = (int)(gpsInfo->rmc.longitude.value / gpsInfo->rmc.longitude.scale / 100); double longitude = temp + (double)(gpsInfo->rmc.longitude.value - temp * gpsInfo->rmc.longitude.scale * 100) / gpsInfo->rmc.longitude.scale / 60.0; // gcvt(latitude, 6, getLatitude); // gcvt(longitude, 6, getLongitude); //you can copy ` getLatitude,buff2 `(latitude,longitude) to http://www.gpsspg.com/maps.htm check location on map //snprintf(buffer, sizeof(buffer), "{\"IsFix\":\"%s\",\"Lat\":%s,\"Lon\":%s}", isFixedStr, getLatitude, getLongitude); sprintf(postDate, "{\"IsFix\":\"%s\",\"Lat\":%lf,\"Lon\":%lf}", isFixedStr, latitude, longitude); // snprintf(buffer, sizeof(buffer), "{\"GPSfixMode\":%d, \"BDSFixMode\":%d,\"FixQuality\":%d,\"IsFixed\":\"%s\",\"coordinate\":\"WGS84\", \"Latitude\":%s,\"Longitude\":%s,\"unit\":\"degree\"}", gpsInfo->gsa[0].fix_type, gpsInfo->gsa[1].fix_type, // gpsInfo->gga.fix_quality, isFixedStr, getLatitude, getLongitude); //show in tracer //Trace(1, buffer); Trace(1, postDate); //sayHello(); OS_Sleep(5000); //10秒后获取GPS定位信息 } } void MainTask(void *pData) { API_Event_t *event = NULL; mqttTaskHandle = OS_CreateTask(TaskMqtt, NULL, NULL, SECOND_TASK_STACK_SIZE, SECOND_TASK_PRIORITY, 0, 0, SECOND_TASK_NAME); grsTaskHandle = OS_CreateTask(TaskGPS, NULL, NULL, GPS_TASK_STACK_SIZE, GPS_TASK_PRIORITY, 0, 0, GPS_TASK_NAME); while (1) { if (OS_WaitEvent(mainTaskHandle, (void **)&event, OS_TIME_OUT_WAIT_FOREVER)) { EventDispatch(event); OS_Free(event->pParam1); OS_Free(event->pParam2); OS_Free(event); } } } void mini_tracer_Main(void) { mainTaskHandle = OS_CreateTask(MainTask, NULL, NULL, MAIN_TASK_STACK_SIZE, MAIN_TASK_PRIORITY, 0, 0, MAIN_TASK_NAME); OS_SetUserMainHandle(&mainTaskHandle); }
28.851852
253
0.640015
[ "3d" ]
58de15072a1e595ba819c695af97023d051c531b
7,187
h
C
ComCTQMC/ctqmc/include/bath/algebra/Exchange.h
comscope/comsuite
d51c43cad0d15dc3b4d1f45e7df777cdddaa9d6c
[ "BSD-3-Clause" ]
18
2019-06-15T18:08:21.000Z
2022-01-30T05:01:29.000Z
ComCTQMC/ctqmc/include/bath/algebra/Exchange.h
comscope/Comsuite
b80ca9f34c519757d337487c489fb655f7598cc2
[ "BSD-3-Clause" ]
null
null
null
ComCTQMC/ctqmc/include/bath/algebra/Exchange.h
comscope/Comsuite
b80ca9f34c519757d337487c489fb655f7598cc2
[ "BSD-3-Clause" ]
11
2019-06-05T02:57:55.000Z
2021-12-29T02:54:25.000Z
#ifndef CTQMC_INCLUDE_BATH_ALGEBRA_EXCHANGE_BATH_H #define CTQMC_INCLUDE_BATH_ALGEBRA_EXCHANGE_BATH_H #include <cmath> #include <stdexcept> #include <vector> #include <map> #include <algorithm> #include "../Bath.h" #include "../Hyb.h" #include "../../../../include/BlasLapack.h" namespace bath { struct Exchange { ut::KeyType keyOld, keyNew; int flavorNew; }; template<typename Value> struct Update<Value, Exchange> : itf::Update<Value> { TypeId type() { return get_type_id<Exchange>(); }; void add(Exchange upd, Bath<Value> const& bath, Hyb<Value> const& hyb) { int const N = bath.opsL_.size(); std::vector<Value> vec(N); if(hyb.isR(upd.flavorNew)) { // u = Delta, v = e int const pos = bath.posR_.find(upd.keyOld)->second, flavorOld = bath.opsR_[pos].flavor(); auto const& ops = bath.opsL_; for(int n = 0; n < N; ++n) vec[n] = hyb(ops[n].flavor(), upd.flavorNew, ops[n].key() - upd.keyNew) - hyb(ops[n].flavor(), flavorOld, ops[n].key() - upd.keyOld); for(auto& list : list_) if(!list.isR) list.vec[pos] = vec[list.pos] = .5*(hyb(list.flavorNew, upd.flavorNew, list.keyNew - upd.keyNew) - hyb(ops[list.pos].flavor(), flavorOld, ops[list.pos].key() - upd.keyOld)); list_.push_back({true, pos, upd.keyOld, upd.keyNew, upd.flavorNew, std::move(vec)}); } else { // u = e, v = Delta int const pos = bath.posL_.find(upd.keyOld)->second, flavorOld = bath.opsL_[pos].flavor(); auto const& ops = bath.opsR_; for(int n = 0; n < N; ++n) vec[n] = hyb(upd.flavorNew, ops[n].flavor(), upd.keyNew - ops[n].key()) - hyb(flavorOld, ops[n].flavor(), upd.keyOld - ops[n].key()); for(auto& list : list_) if(list.isR) list.vec[pos] = vec[list.pos] = .5*(hyb(upd.flavorNew, list.flavorNew, upd.keyNew - list.keyNew) - hyb(flavorOld, ops[list.pos].flavor(), upd.keyOld - ops[list.pos].key())); list_.push_back({false, pos, upd.keyOld, upd.keyNew, upd.flavorNew, std::move(vec)}); } }; double ratio(Bath<Value> const& bath, Hyb<Value> const& hyb) { int const inc = 1, N = bath.opsL_.size(), size = list_.size(); auto const& B = bath.B_; if(size == 1) { auto const& list = list_[0]; return std::abs(detRatio_ = list.isR ? 1. + dotu(&N, B.data(list.pos, 0), &N, list.vec.data(), &inc) : 1. + dotu(&N, list.vec.data(), &inc, B.data(0, list.pos), &inc)); } std::vector<Value> toInvert(size*size); auto it = toInvert.data(); for(auto const& u_j : list_) if(u_j.isR) { for(auto const& v_i : list_) if(v_i.isR) { // v_i = e, u_j = Delta *it++ = dotu(&N, B.data(v_i.pos, 0), &N, u_j.vec.data(), &inc); } else { // v_i = Delta, u_j = Delta char const no = 'n'; Value const zero = .0, one = 1.; std::vector<Value> Bu(N); gemv(&no, &N, &N, &one, B.data(), &N, u_j.vec.data(), &inc, &zero, Bu.data(), &inc); *it++ = dotu(&N, v_i.vec.data(), &inc, Bu.data(), &inc); } } else for(auto const& v_i : list_) // v_i = e, u_j = e : v_i = Delta, u_j = e *it++ = v_i.isR ? B.at(v_i.pos, u_j.pos) : dotu(&N, v_i.vec.data(), &inc, B.data(0, u_j.pos), &inc); for(int i = 0; i < size; ++i) toInvert[i*size + i] += 1.; inv_.resize(size*size, .0); for(int i = 0; i < size; ++i) inv_[i*size + i] = 1.; int ipiv[size]; int info; gesv(&size, &size, toInvert.data(), &size, ipiv, inv_.data(), &size, &info); detRatio_ = 1.; for(int i = 0; i < size; ++i) detRatio_ *= (ipiv[i] != i + 1 ? -toInvert[i*size + i] : toInvert[i*size + i]); return std::abs(detRatio_); }; int accept(Bath<Value>& bath, Hyb<Value> const& hyb) { int const inc = 1, N = bath.opsL_.size(), size = list_.size(); auto& B = bath.B_; char const no = 'n', yes = 't'; Value const zero = .0, one = 1.; std::vector<Value> BU(N*size), BtV(N*size); for(int k = 0; k < size; ++k) { auto const& list = list_[k]; if(list.isR) { // u = Delta, v = e gemv(&no, &N, &N, &one, B.data(), &N, list.vec.data(), &inc, &zero, BU.data() + N*k, &inc); copy(&N, B.data(list.pos, 0), &N, BtV.data() + N*k, &inc); bath.posR_.erase(list.keyOld); bath.posR_[list.keyNew] = list.pos; bath.opsR_[list.pos] = Operator<Value>(list.keyNew, list.flavorNew); } else { // u = e, v = Delta copy(&N, B.data(0, list.pos), &inc, BU.data() + N*k, &inc); gemv(&yes, &N, &N, &one, B.data(), &N, list.vec.data(), &inc, &zero, BtV.data() + N*k, &inc); bath.posL_.erase(list.keyOld); bath.posL_[list.keyNew] = list.pos; bath.opsL_[list.pos] = Operator<Value>(list.keyNew, list.flavorNew); } } if(size == 1) { Value const fact = -1./detRatio_; geru(&N, &N, &fact, BU.data(), &inc, BtV.data(), &inc, B.data(), &N); } else { Value const fact = -1.; std::vector<Value> temp(N*size); gemm(&no, &no, &N, &size, &size, &one, BU.data(), &N, inv_.data(), &size, &zero, temp.data(), &N); gemm(&no, &yes, &N, &N, &size, &fact, temp.data(), &N, BtV.data(), &N, &one, B.data(), &N); } bath.det_ *= detRatio_; return 1; }; void reject(Bath<Value>& bath, Hyb<Value> const& hyb) { }; private: struct Entry { bool isR; int pos; ut::KeyType keyOld, keyNew, flavorNew; std::vector<Value> vec; }; Value detRatio_; std::vector<Value> inv_; std::vector<Entry> list_; }; } #endif
49.226027
207
0.429526
[ "vector" ]
58eb98276116edd8358279491c2acfc972887211
16,379
c
C
src/debug/debug_print.c
JiaoMaWHU/scarab
03f311520acdd91caafc8d59436ff4352cfb6b0c
[ "MIT" ]
33
2020-02-22T00:08:05.000Z
2022-03-19T18:10:48.000Z
src/debug/debug_print.c
JiaoMaWHU/scarab
03f311520acdd91caafc8d59436ff4352cfb6b0c
[ "MIT" ]
32
2020-04-27T18:06:08.000Z
2022-03-09T03:19:16.000Z
src/debug/debug_print.c
JiaoMaWHU/scarab
03f311520acdd91caafc8d59436ff4352cfb6b0c
[ "MIT" ]
26
2020-02-22T01:04:07.000Z
2022-03-03T00:30:10.000Z
/* Copyright 2020 HPS/SAFARI Research Groups * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /*************************************************************************************** * File : debug/debug_print.c * Author : HPS Research Group * Date : 4/14/1998 * Description : Functions to print out various debugging information. ***************************************************************************************/ #include <stdio.h> #include "debug/debug_macros.h" #include "globals/assert.h" #include "globals/enum.h" #include "globals/global_defs.h" #include "globals/global_types.h" #include "globals/global_vars.h" #include "globals/utils.h" #include "isa/isa.h" #include "debug/debug_print.h" #include "thread.h" #include "core.param.h" /**************************************************************************************/ /* Macros */ /* these masks control what debug op fields get printed. note that they are always printed in the order defined in Field_Enum. */ #define FULL_FIELD_MASK (0xffffffff) #define SHORT_FIELD_MASK \ ((0x1 << TOP_LINE_FIELD) | (0x1 << DISASM_FIELD) | (0x1 << ADDR_FIELD) | \ (0x1 << BOTTOM_LINE_FIELD)) #define DONT_SHOW_FIELDS ((0x1 << NODE_INFO_FIELD) | (0x1 << OP_TYPE_FIELD)) /**************************************************************************************/ /* Local prototypes */ static int compare_reg_ids(const void* p1, const void* p2); static int print_reg_array(char* buf, Reg_Info* regs, uns num); /**************************************************************************************/ /* External Variables */ extern const char* const int_reg_names[]; extern const char* const fp_reg_names[]; /**************************************************************************************/ /* An enum to enumerate all of the different rows to be printed. */ typedef enum { TOP_LINE_FIELD, DISASM_FIELD, ADDR_FIELD, OP_NUM_FIELD, OP_TYPE_FIELD, MEM_INFO_FIELD, NODE_INFO_FIELD, BOTTOM_LINE_FIELD, NUM_OP_FIELDS, } Field_Enum; /**************************************************************************************/ /* Type field enum definitions. */ DEFINE_ENUM(Op_Type, OP_TYPE_LIST); const char* const mem_type_names[] = {"NOT_MEM", "MEM_LD", "MEM_ST", "MEM_PF"}; const char* const cf_type_names[] = {"NOT_CF", "CF_BR", "CF_CBR", "CF_CALL", "CF_IBR", "CF_ICALL", "CF_ICO", "CF_RET", "CF_SYS"}; const char* const bar_type_names[] = {"NOT_BAR"}; DEFINE_ENUM(Op_State, OP_STATE_LIST); const char* const icache_state_names[] = { "IC_FETCH", "IC_REFETCH", "IC_FILL", "IC_WAIT_FOR_MISS", "IC_WAIT_FOR_REDIRECT", "IC_WAIT_FOR_EMPTY_ROB", "IC_WAIT_FOR_TIMER"}; const char* const tcache_state_names[] = {"TC_FETCH", "TC_WAIT_FOR_MISS", "TC_WAIT_FOR_REDIRECT", "TC_WAIT_FOR_CALLSYS", "TC_ICACHE_FETCH", "TC_ICACHE_REFETCH", "TC_ICACHE_FILL", "TC_ICACHE_WAIT_FOR_MISS", "TC_ICACHE_WAIT_FOR_REDIRECT", "TC_ICACHE_WAIT_FOR_CALLSYS" "TC_TCACHE_FETCH", "TC_TCACHE_REFETCH", "TC_TCACHE_FILL", "TC_TCACHE_WAIT_FOR_MISS", "TC_TCACHE_WAIT_FOR_REDIRECT", "TC_TCACHE_WAIT_FOR_CALLSYS"}; const char* const sm_state_names[] = {"RS_NULL", "RS_ICACHE", "RS_DECODE", "RS_MAP", "RS_NODE", "RS_EXEC", "RS_RETIRE", "NUM_SM_STATES"}; /**************************************************************************************/ /* print_field_head: */ void print_field_head(FILE* stream, uns field) { switch(field) { case TOP_LINE_FIELD: case BOTTOM_LINE_FIELD: fprintf(stream, "+"); break; case DISASM_FIELD: case ADDR_FIELD: case OP_NUM_FIELD: case MEM_INFO_FIELD: case NODE_INFO_FIELD: case OP_TYPE_FIELD: fprintf(stream, "|"); break; default: FATAL_ERROR(0, "Invalid field number (%d) in print_field_head.\n", field); } } /**************************************************************************************/ /* print_field_head: */ void print_field_tail(FILE* stream, uns field) { switch(field) { case TOP_LINE_FIELD: case BOTTOM_LINE_FIELD: case DISASM_FIELD: case ADDR_FIELD: case OP_NUM_FIELD: case MEM_INFO_FIELD: case NODE_INFO_FIELD: case OP_TYPE_FIELD: fprintf(stream, "\n"); break; default: FATAL_ERROR(0, "Invalid field number (%d) in print_field_tail.\n", field); } } /**************************************************************************************/ /* print_op_field: */ void print_op_field(FILE* stream, Op* op, uns field) { switch(field) { case TOP_LINE_FIELD: case BOTTOM_LINE_FIELD: fprintf(stream, "--------------------+"); break; case DISASM_FIELD: if(op) fprintf(stream, "%-20s|", disasm_op(op, FALSE)); else fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); break; case ADDR_FIELD: if(op) { fprintf(stream, "a:%-9s f:%-2d%c", hexstr64s(op->inst_info->addr), op->fu_num, (op->off_path ? 'O' : ' ')); if(OP_DONE(op)) fprintf(stream, "D "); else { if(op->state == OS_WAIT_FWD) if(cycle_count < op->rdy_cycle - 1) fprintf(stream, "%c%lld", op->replay ? 'w' : 'W', op->rdy_cycle - cycle_count - 1); else fprintf(stream, "%c%c", 'R', op->replay ? 'r' : ' '); else fprintf(stream, "%c%c", Op_State_str(op->state)[0], op->replay ? 'r' : ' '); } if(op->table_info->cf_type) { Flag bits = op->oracle_info.mispred << 2 | op->oracle_info.misfetch << 1 | op->oracle_info.btb_miss; switch(bits) { case 0x4: fprintf(stream, "P|"); break; /* mispredict */ case 0x3: case 0x2: fprintf(stream, "F|"); break; /* misfetch or (misfetch and btb miss) */ case 0x1: fprintf(stream, "M|"); break; /* btb miss */ case 0x5: case 0x6: fprintf(stream, "B|"); break; /* mispredict, (misfetch or btb miss) */ case 0x7: fprintf(stream, "A|"); break; /* mispredict, misfetch, btb miss */ case 0x0: fprintf(stream, " |"); break; default: ERROR(op->proc_id, "Invalid prediction result state (0x%x).\n", bits); } } else fprintf(stream, " |"); } else fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); break; case OP_NUM_FIELD: if(op) fprintf(stream, "o:%-3d %3d%c %3d%c %3d%c|", (int)(op->op_num % 1000), op->oracle_info.num_srcs > 0 ? (int)(op->oracle_info.src_info[0].op_num % 1000) : -1, ((op->srcs_not_rdy_vector & 1) == 0 ? 'r' : 'w'), op->oracle_info.num_srcs > 1 ? (int)(op->oracle_info.src_info[1].op_num % 1000) : -1, ((op->srcs_not_rdy_vector & 2) == 0 ? 'r' : 'w'), op->oracle_info.num_srcs > 2 ? (int)(op->oracle_info.src_info[2].op_num % 1000) : -1, ((op->srcs_not_rdy_vector & 4) == 0 ? 'r' : 'w')); else fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); break; case OP_TYPE_FIELD: if(op) fprintf(stream, "%19s |", Op_Type_str(op->inst_info->table_info->op_type)); else fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); break; case MEM_INFO_FIELD: if(!op || op->table_info->mem_type == NOT_MEM) fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); else { Counter addr_dep = 0; Counter data_dep = 0; uns ii; for(ii = 0; ii < op->oracle_info.num_srcs; ii++) { Src_Info* src = &op->oracle_info.src_info[ii]; if(src->type == MEM_ADDR_DEP) addr_dep = src->op_num; if(src->type == MEM_DATA_DEP) data_dep = src->op_num; } fprintf(stream, "va:%-9s %3d %3d|", hexstr64s(op->oracle_info.va), (uns)(addr_dep % 1000), (uns)(data_dep % 1000)); } break; case NODE_INFO_FIELD: if(!op) fprintf(stream, "xxxxxxxxxxxxxxxxxxxx|"); else fprintf(stream, " node_id:%-3d |", (uns)(op->node_id % 1000)); break; default: FATAL_ERROR(0, "Invalid field number (%d) in print_op_field.\n", field); } } /**************************************************************************************/ /* print_op_array: */ void print_op_array(FILE* stream, Op* ops[], uns array_length, uns op_count) { int field_mask = FULL_FIELD_MASK & ~DONT_SHOW_FIELDS; uns ii, jj; for(ii = 0; ii < NUM_OP_FIELDS; ii++) { if(TESTBIT(field_mask, ii)) { print_field_head(stream, ii); for(jj = 0; jj < array_length; jj++) { Op* op = jj < op_count ? ops[jj] : NULL; print_op_field(stream, op, ii); } print_field_tail(stream, ii); } } } /**************************************************************************************/ /* print_open_op_array: Leave off bottom line */ void print_open_op_array(FILE* stream, Op* ops[], uns array_length, uns op_count) { int field_mask = FULL_FIELD_MASK & ~(0x1 << BOTTOM_LINE_FIELD) & ~DONT_SHOW_FIELDS; uns ii, jj; for(ii = 0; ii < NUM_OP_FIELDS; ii++) { if(TESTBIT(field_mask, ii)) { print_field_head(stream, ii); for(jj = 0; jj < array_length; jj++) { Op* op = jj < op_count ? ops[jj] : NULL; print_op_field(stream, op, ii); } print_field_tail(stream, ii); } } } /**************************************************************************************/ /* print_open_op_array_end: Print bottom line for an open op array */ void print_open_op_array_end(FILE* stream, uns array_length) { int field_mask = FULL_FIELD_MASK & (0x1 << BOTTOM_LINE_FIELD); uns jj; if(TESTBIT(field_mask, BOTTOM_LINE_FIELD)) { print_field_head(stream, BOTTOM_LINE_FIELD); for(jj = 0; jj < array_length; jj++) print_op_field(stream, NULL, BOTTOM_LINE_FIELD); print_field_tail(stream, BOTTOM_LINE_FIELD); } } /**************************************************************************************/ /* print_op: */ void print_op(Op* op) { uns ii; for(ii = 0; ii < NUM_OP_FIELDS; ii++) { if(TESTBIT(FULL_FIELD_MASK, ii)) { print_field_head(GLOBAL_DEBUG_STREAM, ii); print_op_field(GLOBAL_DEBUG_STREAM, op, ii); print_field_tail(GLOBAL_DEBUG_STREAM, ii); } } } /**************************************************************************************/ /* print_func_op: */ void print_func_op(Op* op) { char opcode[MAX_STR_LENGTH + 1]; if(op->table_info->op_type == OP_CF) { sprintf(opcode, "%s", cf_type_names[op->table_info->cf_type]); } else if(op->table_info->op_type == OP_IMEM || op->table_info->op_type == OP_FMEM) { sprintf(opcode, "%s", mem_type_names[op->table_info->mem_type]); } else { sprintf(opcode, "%s", Op_Type_str(op->table_info->op_type)); } fprintf(GLOBAL_DEBUG_STREAM, "%2d %08x %10s", op->proc_id, (uns32)op->inst_info->addr, opcode); char buf[MAX_STR_LENGTH + 1]; print_reg_array(buf, op->inst_info->srcs, op->table_info->num_src_regs); fprintf(GLOBAL_DEBUG_STREAM, " in: %-30s", buf); print_reg_array(buf, op->inst_info->dests, op->table_info->num_dest_regs); fprintf(GLOBAL_DEBUG_STREAM, " out: %-30s", buf); if(op->oracle_info.mem_size) { fprintf(GLOBAL_DEBUG_STREAM, " %2d @ %08x", op->oracle_info.mem_size, (uns32)op->oracle_info.va); } fprintf(GLOBAL_DEBUG_STREAM, "\n"); } static int compare_reg_ids(const void* p1, const void* p2) { uns16 v1 = *((uns16*)p1); uns16 v2 = *((uns16*)p2); if(v1 < v2) return -1; if(v1 > v2) return 1; return 0; } static int print_reg_array(char* buf, Reg_Info* regs, uns num) { uns i; char* orig_buf = buf; buf[0] = '\0'; // empty string in case there are zero regs // printing sorted array for easy comparison between frontends uns16 reg_buf[MAX2(MAX_SRCS, MAX_DESTS)]; ASSERT(0, num <= MAX2(MAX_SRCS, MAX_DESTS)); for(i = 0; i < num; ++i) reg_buf[i] = regs[i].id; qsort(reg_buf, num, sizeof(uns16), compare_reg_ids); for(i = 0; i < num; ++i) buf += sprintf(buf, " %s", disasm_reg(reg_buf[i])); return buf - orig_buf; } /**************************************************************************************/ /* print_short_op_array: */ void print_short_op_array(FILE* stream, Op* ops[], uns array_length) { uns ii, jj; for(ii = 0; ii < NUM_OP_FIELDS; ii++) { if(TESTBIT(SHORT_FIELD_MASK, ii)) { print_field_head(stream, ii); for(jj = 0; jj < array_length; jj++) { Op* op = ops[jj]; print_op_field(stream, op, ii); } print_field_tail(stream, ii); } } } /**************************************************************************************/ /* disasm_op: */ char* disasm_op(Op* op, Flag wide) { static char buf[MAX_STR_LENGTH + 1]; const char* opcode; if(op->table_info->op_type == OP_CF) { opcode = cf_type_names[op->table_info->cf_type]; } else if(op->table_info->op_type == OP_IMEM || op->table_info->op_type == OP_FMEM) { opcode = mem_type_names[op->table_info->mem_type]; } else { opcode = Op_Type_str(op->table_info->op_type); } uns i = 0; i += sprintf(&buf[i], "%s", opcode); if(wide) { i += sprintf(&buf[i], "("); i += print_reg_array(&buf[i], op->inst_info->srcs, op->table_info->num_src_regs); if(op->table_info->mem_type == MEM_LD && op->oracle_info.mem_size > 0) { i += sprintf(&buf[i], " %d@%08x", op->oracle_info.mem_size, (int)op->oracle_info.va); } if(op->table_info->num_src_regs + op->table_info->num_dest_regs > 0) i += sprintf(&buf[i], " ->"); i += print_reg_array(&buf[i], op->inst_info->dests, op->table_info->num_dest_regs); if(op->table_info->mem_type == MEM_ST && op->oracle_info.mem_size > 0) { i += sprintf(&buf[i], " %d@%08x", op->oracle_info.mem_size, (int)op->oracle_info.va); } i += sprintf(&buf[i], " )"); } return buf; }
33.840909
89
0.518957
[ "3d" ]
95a8e1a8f68bf1e3c519606dd8fceac968b00d2e
6,864
h
C
Libraries/ChibiOS-2.6.7/os/hal/include/mmc_spi.h
craigsacco/invetech-sumobot
f1964ad8c5fd3ce46597bef4ff980fbaa99ed5b7
[ "MIT" ]
null
null
null
Libraries/ChibiOS-2.6.7/os/hal/include/mmc_spi.h
craigsacco/invetech-sumobot
f1964ad8c5fd3ce46597bef4ff980fbaa99ed5b7
[ "MIT" ]
7
2015-03-26T07:46:58.000Z
2015-03-26T07:56:11.000Z
Libraries/ChibiOS-2.6.7/os/hal/include/mmc_spi.h
craigsacco/invetech-sumobot
f1964ad8c5fd3ce46597bef4ff980fbaa99ed5b7
[ "MIT" ]
null
null
null
/* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. ChibiOS/RT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. ChibiOS/RT 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. --- A special exception to the GPL can be applied should you wish to distribute a combined work that includes ChibiOS/RT, without being obliged to provide the source code for any proprietary components. See the file exception.txt for full details of how and when the exception can be applied. */ /** * @file mmc_spi.h * @brief MMC over SPI driver header. * * @addtogroup MMC_SPI * @{ */ #ifndef _MMC_SPI_H_ #define _MMC_SPI_H_ #if HAL_USE_MMC_SPI || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ #define MMC_CMD0_RETRY 10 #define MMC_CMD1_RETRY 100 #define MMC_ACMD41_RETRY 100 #define MMC_WAIT_DATA 10000 /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ /** * @name MMC_SPI configuration options * @{ */ /** * @brief Delays insertions. * @details If enabled this options inserts delays into the MMC waiting * routines releasing some extra CPU time for the threads with * lower priority, this may slow down the driver a bit however. * This option is recommended also if the SPI driver does not * use a DMA channel and heavily loads the CPU. */ #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) #define MMC_NICE_WAITING TRUE #endif /** @} */ /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ #if !HAL_USE_SPI || !SPI_USE_WAIT #error "MMC_SPI driver requires HAL_USE_SPI and SPI_USE_WAIT" #endif /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ /** * @brief MMC/SD over SPI driver configuration structure. */ typedef struct { /** * @brief SPI driver associated to this MMC driver. */ SPIDriver *spip; /** * @brief SPI low speed configuration used during initialization. */ const SPIConfig *lscfg; /** * @brief SPI high speed configuration used during transfers. */ const SPIConfig *hscfg; } MMCConfig; /** * @brief @p MMCDriver specific methods. */ #define _mmc_driver_methods \ _mmcsd_block_device_methods /** * @extends MMCSDBlockDeviceVMT * * @brief @p MMCDriver virtual methods table. */ struct MMCDriverVMT { _mmc_driver_methods }; /** * @extends MMCSDBlockDevice * * @brief Structure representing a MMC/SD over SPI driver. */ typedef struct { /** * @brief Virtual Methods Table. */ const struct MMCDriverVMT *vmt; _mmcsd_block_device_data /** * @brief Current configuration data. */ const MMCConfig *config; /*** * @brief Addresses use blocks instead of bytes. */ bool_t block_addresses; } MMCDriver; /*===========================================================================*/ /* Driver macros. */ /*===========================================================================*/ /** * @name Macro Functions * @{ */ /** * @brief Returns the card insertion status. * @note This macro wraps a low level function named * @p sdc_lld_is_card_inserted(), this function must be * provided by the application because it is not part of the * SDC driver. * * @param[in] mmcp pointer to the @p MMCDriver object * @return The card state. * @retval FALSE card not inserted. * @retval TRUE card inserted. * * @api */ #define mmcIsCardInserted(mmcp) mmc_lld_is_card_inserted(mmcp) /** * @brief Returns the write protect status. * * @param[in] mmcp pointer to the @p MMCDriver object * @return The card state. * @retval FALSE card not inserted. * @retval TRUE card inserted. * * @api */ #define mmcIsWriteProtected(mmcp) mmc_lld_is_write_protected(mmcp) /** @} */ /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ #ifdef __cplusplus extern "C" { #endif void mmcInit(void); void mmcObjectInit(MMCDriver *mmcp); void mmcStart(MMCDriver *mmcp, const MMCConfig *config); void mmcStop(MMCDriver *mmcp); bool_t mmcConnect(MMCDriver *mmcp); bool_t mmcDisconnect(MMCDriver *mmcp); bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk); bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer); bool_t mmcStopSequentialRead(MMCDriver *mmcp); bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk); bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer); bool_t mmcStopSequentialWrite(MMCDriver *mmcp); bool_t mmcSync(MMCDriver *mmcp); bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip); bool_t mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk); bool_t mmc_lld_is_card_inserted(MMCDriver *mmcp); bool_t mmc_lld_is_write_protected(MMCDriver *mmcp); #ifdef __cplusplus } #endif #endif /* HAL_USE_MMC_SPI */ #endif /* _MMC_SPI_H_ */ /** @} */
33.15942
80
0.531614
[ "object" ]
95ad3dd224e7f0ed404fa3e183623043b3f590d9
4,527
h
C
include/am/filemapper/persist_stl.h
izenecloud/izenelib
9d5958100e2ce763fc75f27217adf982d7c9d902
[ "Apache-2.0" ]
31
2015-03-03T19:13:42.000Z
2020-09-03T08:11:56.000Z
include/am/filemapper/persist_stl.h
izenecloud/izenelib
9d5958100e2ce763fc75f27217adf982d7c9d902
[ "Apache-2.0" ]
1
2016-12-24T00:12:11.000Z
2016-12-24T00:12:11.000Z
include/am/filemapper/persist_stl.h
izenecloud/izenelib
9d5958100e2ce763fc75f27217adf982d7c9d902
[ "Apache-2.0" ]
8
2015-09-06T01:55:21.000Z
2021-12-20T02:16:13.000Z
#ifndef PERSIST_STL_H #define PERSIST_STL_H #include <vector> #include <string> #include <map> #include <set> #include <list> #include <deque> #include "persist.h" NS_IZENELIB_AM_BEGIN template<class T> class mapped_list : public std::list<T, izenelib::am::allocator<T> > { }; template<class C, class Traits = std::char_traits<C> > class basic_string : public std::basic_string<C, Traits, izenelib::am::allocator<C> > { void operator=(const std::basic_string<C> &s); public: basic_string() { } basic_string(const C*c) : std::basic_string<C, Traits, izenelib::am::allocator<C> >(c) { } basic_string(const std::basic_string<C> &s) { assign(s.begin(), s.end()); } basic_string(char* p, size_t sz) :std::basic_string<C, Traits, izenelib::am::allocator<C> >(p,sz) { } basic_string &operator=(const C *s) { assign(s); return *this; } // TODO: Other constructors }; //typedef basic_string<char> string; //typedef basic_string<wchar_t> wstring; typedef basic_string<char> mapped_string; typedef basic_string<wchar_t> mapped_wstring; template<class T> class mapped_vector : public std::vector<T, izenelib::am::allocator<T> > { // TODO: constructors }; template<class T, class L = std::less<T> > class mapped_set : public std::set<T, L, izenelib::am::allocator<T> > { }; template<class T, class L = std::less<T> > class mapped_multiset : public std::multiset<T, L, izenelib::am::allocator<T> > { }; template<class T, class V, class L = std::less<T> > class mapped_map : public std::map<T, V, L, izenelib::am::allocator<std::pair<T,V> > > { }; template<class T, class V, class L = std::less<T> > class mapped_multimap : public std::multimap<T, V, L, izenelib::am::allocator<std::pair<T,V> > > { }; // fixed_string is a fixed-length string template<int N, class C=char, class L=unsigned char> class fixed_string { L len; // The actual length of the string C str[N+1]; // The string, with 1 for a null-terminator public: typedef C *iterator; typedef const C *const_iterator; fixed_string() { clear(); } fixed_string(const_iterator d) { assign(d); } template<int M, class L2> fixed_string(const fixed_string<M,C,L2> &b) { assign(b.begin(), b.end()); } fixed_string<N,C,L> &operator=(const_iterator d) { assign(d); return *this; } template<int M,class L2> fixed_string<N,C,L> &operator=(const fixed_string<M,C,L2> &b) { assign(b.begin(), b.end()); return *this; } iterator begin() { return str; } const_iterator begin() const { return str; } iterator end() { return str+len; } const_iterator end() const { return str+len; } const_iterator c_str() const { return begin(); } size_t size() const { return len; } void clear() { len=0; str[len]=0; } void assign(const_iterator a) { for (len=0; len<N && *a; ++a, ++len) str[len] = *a; str[len]=0; // Zero-terminate } void assign(const_iterator a, const_iterator b) { for (len=0; len<N && a!=b; ++a, ++len) str[len] = *a; str[len]=0; // Zero-terminate } C &operator[](size_t n) { return str[n]; } const C&operator[](size_t n) const { return str[n]; } template<int M,class L2> bool operator==(const fixed_string<M,C,L2> &b) const { if (size() != b.size()) return false; for (unsigned p=0; p<size(); ++p) { if (str[p] != b[p]) return false; } return true; } bool operator==(const_iterator b) const { for (unsigned p=0; p<=size(); ++p) { if (str[p] != b[p]) return false; } return true; } template<int M,class L2> bool operator<(const fixed_string<M,C,L2> &b) const { for (const C* pa = begin(), *pb = b.begin(); *pb; ++pa, ++pb) { if (*pa < *pb) return true; else if (*pa > *pb) return false; } return false; } }; NS_IZENELIB_AM_END #endif
20.861751
97
0.537442
[ "vector" ]
95af06278f1e7089ea50e065e9725c00a1fee7d1
65,224
c
C
osprey/arith/edition.c
sharugupta/OpenUH
daddd76858a53035f5d713f648d13373c22506e8
[ "BSD-2-Clause" ]
null
null
null
osprey/arith/edition.c
sharugupta/OpenUH
daddd76858a53035f5d713f648d13373c22506e8
[ "BSD-2-Clause" ]
null
null
null
osprey/arith/edition.c
sharugupta/OpenUH
daddd76858a53035f5d713f648d13373c22506e8
[ "BSD-2-Clause" ]
null
null
null
/* Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ static char ar_eval_lib_edition[] = "@(#)arith.a version 2." EDITION; char AR_version [] = EDITION; /* arith.a edition number */ char AR_libmv2[32] = "x.x.x.x (00000)"; /* libm[v2].a version and edition #s */ char AR_arith_data[2] = "\0"; /* arith.a data file edition number */ const char *arith_vers_name(void) { return "arith";} const char *arith_vers_ID(void) { return "a";} const char *arith_vers_number(void) { return EDITION;} /* Change log for each edition: Edition 241: 1. MIPS NaNs are the opposite of SPARC/T90-IEEE/Alpha NaNs: the latter has the high bit of the mantissa clear for signalling NaNs, and set for quiet ones, while the former is the other way around. Edition 240: 1. Add status setting for AR_STAT_INEXACT in IEEE normalization. 2. Makefile cleanup -- don't execute "target" if not on a Cray machine, and in the "arith.a:" target, copy the arith.h file into a "common" subdirectory. I had moved the common files into a "common" subdir in the USS directory in edition 234, and modified the get.obj.arith script accordingly, but I needed to do the same thing in the build directory structure, so that doing a "get.obj.arith -v xn ..." would work. 3. Remove the use of /cray/uss/compiler/cost/bin/validate from the get.obj.arith script. Edition 239: 1. Add AR_ibits(). Edition 238: 1. Missed some modules that needed additions for 8-bit and 16-bit integers. 2. Add full support for determining the host architecture. 3. Fix some minor divots in float-->string conversions. 4. Add AR_ishft() and AR_ishftc(), for the corresponding f90 intrinsics, and add code to testint.c to test these. 5. Remove the use of <ctype.h> in strcvt.c. This allows us to compile arith with 9.x #include files, and link it with 8.x libraries, and have everything work right. It doesn't hurt wide-character compatibility, because there is quite a bit of code in strcvt.c that is incompatible with wide characters already. Edition 237: 1. Add support for 8-bit and 16-bit integers. Edition 236: 1. Bring in the MIPS quad changes from Rich Shapiro. 2. Fix 703309 -- non-base-10 int-to-str conversions yielded trash. 3. Add appropriate casts to cray1_sim.c and mpp_sim.c, to remove some warnings about mistyped assignments. Edition 235: 1. Remove the MIPS hack in native.c for the INDEX(), SCAN(), and VERIFY() intrinsics. 2. Make negating IEEE float/complex 0.0 work right (it was yielding -0.0). 3. Undo #2. The IEEE standard says that -x is x with its sign bit toggled. That is, it is not necessarily the same as (0-x). Edition 234: 1. Expand the simulated stack size for Cray-1 style simulation. As of the 3.0 arith data file, 2 kwords is not enough. It's now 10 kwords. 2. Clean up the code in various spots so that the Solaris and IRIX compilers don't emit any warnings any more. 3. Really support the IRIX platform. 4. Allow re-updating of the current USS edition. 5. Move the USS arith.{doc,h,msg}.* files into a "common" subdirectory (aesthetics -- makes the directory easier to look at). 6. Make sure all the files installed on USS have group-write access. 7. Clean up get.obj.arith -- the indentation had gotten a little odd over the years. 8. Use click and/or clack for IRIX builds, instead of maestro, since those two cross-mount USS and the other CCN PVPs. 9. Retag the PL every time we do a revision. 10. Add a -n option to remote-builds.csh, to tell it not to do a "make delete" before proceeding with the builds. Edition 233: 1. Make _numargs() work properly on T3E. The SSIB/DSIB simulation was broken. Edition 232: 1. Fix some problems with the preprocessing for MIPS. Edition 231: 1. Simulate byte-manipulation instructions properly for a T3E. 2. Remove pdbgint support for MPP. 3. Add environment variable control of ar_disasm debugging for MPP. Edition 230: 1. Allow for building on a TS (only building _on_ one, not _for_ one). Edition 229: 1. Modifications to the self-tests to allow for correct results on TS-IEEE (they've never been right before this). 2. Continuing Makefile cleanup. 3. MIPS real*16 support from Rich Shapiro. 4. Added support for printing integers from MPP library code during simulation. Edition 228: 1. More closely follow the IEEE rules regarding NaNs as operands and results. 2. Use the functional forms of isdigit() and isspace(), rather than the macro forms. This allows us to compile with UNICOS 9.x #include files, without forcing users of arith to link with UNICOS 9.x libs (specifically, optcg wants to be able to link with UNICOS 8.x libs). 3. Try again. In the Makefile, #include the UNICOS 8.3 <ctype.h> instead of the 9.0 one. We still link with 9.0 libs. This should allow both nondebug and debug builds of things that link in arith to work. (Fix #2, above, failed when linking debug compilers.) Edition 227: 1. For version comparison between the arith data file and the libm.a when simulating, do a better job of figuring out the libm.a version. Also did some prettification of the version checking code in mpp_sim.c, and a minor change to allow for creating the MPP simulation data file on a C-90. Edition 226: 1. Oops. Send store_mpp_word() the _address_ of the register you want to simulate storing, not the contents of it. Sheesh. Edition 225: 1. Large amounts of Makefile beautification, after Mark Cruciani had some targeting problems. 2. Add a -z switch to get.obj.arith, to return sources, and add a new target "install_source" to the Makefile, to install them where the -z logic is expecting to find them. This new target should be made after "update" is made. 3. Take out the -X1 for T3E builds temporarily. It's causing problems with the currently-available hardware. Edition 224: 1. IRIX/MIPS changes. Add fintrin_irix.f, fintrin_dc_irix.f, fintrin_irix_f77.f. Update Makefile to understand about IRIX, and build the three new modules. Update #ifdefs in confidence.c, miscmath.c, native.c, simulate.c, strcvt.c, and test_ar_intrin.c to do MIPS like we do Solaris. 2. Fix a problem in AR_make_complex (miscmath.c), where aliasing result and op2 led to wrong results. 3. Set up the simulated stack differently in mpp_sim.c. For the T3E, we had the simulated DSIB between the simulated frames of the caller and callee. The latter two need to abut, or arg addressing when simulating routines with more than 6 arguments won't work. 4. Replace a sequence of '|' expressions in ar_convert_str_to_float() with a sequence of '|=' assignments. The former is subject to expression reordering which, although it apparently hasn't yet occurred, would get the arguments to _defgu2sd() in the wrong order if it happened. Edition 223: 1. Fix for spr 100775. Insure that 64 bit addressing is used in Ar_put_real_address(). Previous cast to long it was getting only the low order 32 bits. 2. Changed get.obj.arith to provide release 2 arith versions for cft90 6.x or 6.X products. Edition 222: 1. Changed header processing for cld a.out again. Do move down over header after all segments are processed. Insure that segment ids can't be redefined by an undefined segment. 2. Perform right shifts using macro with unsigned longs so no sign extension takes place, even for Cray systems that sign extend right shifts. The SHRIGHT64X macro specifically does sign extension and will continue to sign extend. 3. Changed definitions of parcels to unsigned longs to insure that sign extension doesn't take place. Edition 221: 1. Changed definitions for cld a.out header. Defined dynamically rather that static assignements. 2. Spr 100747: Mod by Greg Titus. arith.internal.h: Add ar_crnd128() declaration. cvt.c: Call ar_crnd128() for 128-bit Cray floating point round_int_div. convert.c: Add ar_crnd128() body. 3. SPR 101290: Mod by Greg Titus. mpp_sim.c: Fix invalid type punning (IEEE complex to IEEE float) in ar_pass_arg_value(). We were passing a misaligned 32-bit IEEE float to ar_convert_to_float() when we were doing the real part of a 32-bit IEEE complex. Edition 220: 1. Changed Makefile to build Cray-t3d and Cray-t3e targets. 2. Changes for native versions of Cray-t3d and Cray-t3e that use Solaris simulation routines. Edition 219: 1. Changed mpp_sim.c to handle the segment identifier differences between the t3d and t3e. open_intrinsics_file now looks at the segment type field of the file header instead of the id, and load/store_mpp_word now looks at variables corresponding to the new segment identifiers. T3E data files built with mppldr should not be used. Those produced by cld will be handled (hopefully) by this mod. 2. Changed arith_mpp.s to add the 32-bit SCANI, VERIFYI, and INDEXI intrinsics to the list of those needing to have their fcd arguments converted to byte-lengths. Edition 218: 1. Triton-IEEE 0162 and 0163 divide instructions had the operands reversed for the divide calls. This fixes SPRs: 95451, 96747, 95582, 97309, 99176, 99366. Edition 217: 1. MPP 0x18 instructions were being called illegal and arith was aborting. These are now disassembled and ignored. For 0x18c (RPCC), the rtc is moved into ra. 2. The mpp intrinsic simulations for index, scan, verify, and selected_ real_kind for 32-bit integers were not supported. The appropriate entry points are now in place however. Edition 216: 1. Fix for SPR 98417. The 01xx40 instructions (loads and stores to and from S-regs with 3-parcel address expressions) were incorrectly simulated. Only two parcels were ever being used. Edition 215: 1. Changed get.obj.arith to use /bin/cp instead of whatever one's path pointed to, to prevent ownership problems, and now use chmod to force the correct permissions. 2. Added "bump" to the Makefile to allow moving the newest version to latest without creating a new newest. 3. Fixed SPR 96747. This was a problem with the 174[1,2,3] instructions on the c90 and triton causing the reshape intrinsic to fail for 128-bit data items. The loop variables and indices in the loops in ar_sim (cray1_sim.c) for these instructions were wrong. Edition 214: 1. Fixed bug in ar_itoc128 in which the resulting exponent was 1 too big. (jhw) Altered this function to return the correct status. This fixes SPR 90659. 2. Fixed bugs in ar_sim simulation of 026/027 instructions that were causing unsimulated instruction errors and not using new A-reg operand instructions. 3. Removed rounding in conversion of Cray 128-bit to 64-bit floating point since all compilers internally just truncate (keep the first 64-bits). 4. Added tbb and svc to the change list, made the default uss results repository to be in cray/uss/a6/jhw, and changed the c90 and triton cc and libs setup to the correct directories in Makefile. Edition 213: 1. Added check for compatible floating point format between the requested resulttype and that specified by the arith data file. Generate arith error message 2018 for a mismatch. 2. Added /opt/ctl/craylibs[_m]/craylibs[_m] as the first default location for the (native) arith data file. Added check for libm.a in the . directory as well as the .. directory relative to the arith data file. 3. Relaxed the requirement for libm.a existing--cross-compilations do not require it. However, if it does exist, it's version must match. 4. Added integer*8 versions of native power function evaluation. 5. Added test for IEEE attribute in get.obj.arith in determining the default target. 6. Added simulation for the remaining cray-ts[,ieee] instructions that may be encountered in future releases of libraries. 7. Modified arith_mpp.s to support T3D and T3E libraries and convert to the T3E argument/fcd interfaces if necessary. 8. Modified mpp_sim.c to interface to either T3D or T3E libraries. Edition 212: 1. Added simulation of Triton instructions Vi Vj*[LU]Vk. 2. Fixed bug in simulation of Vi Vj,Vj<Ak instruction. Fixed bug in store_pvp_word to mask the segment number. Edition 211: 1. Added full 128-bit IEEE arithmetic everywhere. 2. Removed rounding argument from ar_cfadd/sub64 routines--wasn't used. 3. Removed all internal arith declaration stuff from arith.h. In particular, removed the internal declarations for the AR_DATA union and moved them to an internal ar_data union in arith.internal.h. 4. Removed internal redundancy of rounding mode names. 5. Changed internal AR_FLOAT_NOT_COMPLEX to AR_FLOAT_SIMPLE. 6. Added ar_state_info struct and associated ar_state_register variable. Moved ar_CRAY_64_trunc_bits and ar_IEEE_denorm_behavior into this variable. 7. Added partial support for "multi-targetable" arith. Intrinsic folding is multi-targetable via the arith data file pointed to by CRAYLIBS. Basic arithmetic still depends upon input type arguments. 8. Added support for cray-ts and cray-ts,ieee in the Makefile and get.obj.arith. Edition 210: 1. Fixed problem with 64-bit pointers being cleared to 24-bits in ar_clear_unused_bits. 2. Now allow uppercase, lowercase, and full names for new and latest version ids. 3. Switched to Craylibs 2.0 for arith testing. 4. Fixed problem in cray1_sim.c and mpp_sim.c that generated libm warning message on non-package versions of Craylibs. Edition 209: 1. Modified Makefile support for updating arith data files to be able to create and update using the newest (possibly non-packaged) versions of Craylibs. Also, modified *.o targets to be arith.a(*.o) to minimize the amount of recompilation after a make clobber. The edition target copies an initial arith.a from the corresponding system directory. 2. Changed severity level of 2016 arith message to Logfile_Warning. 3. Added check for non-package version of arith data file (?.x.?.? in AR_libmv2) which skips libm[v2].a validation step when data file is opened. 4. Made modifications to accept 128-bit IEEE floating and 64-bit integer AR_TYPEs for Solaris. Internally 128-bit IEEE floating values are converted to/from 64-bit values for the time being. Also, the integer-to-integer power function uses the 32-bit intrinsic for the time being. 5. 64-bit pointers no longer have the upper 8 bits cleared by ar_clear_unused_bits. 6. Allow 46-bit integer type in MPP simulation (since this is also used for Triton currently). Eliminates AR_STAT_INVALID_TYPE for powri. 7. Added cray-ts as an allowable target in get.obj.arith. 8. Changed c++ product in get.obj.arith to return the same arith.a as scc for ccg and mppcg code generators but continue to return an arith.a with no intrinsic folding for rcg. Also force new version for mppcg. 9. Removed extern of ARSQRTA from confidence.c and ctgen.c since Cray-2 is no longer supported. Added trapmathlibabort() to confidence.c. 10. Fix MPP simulation of defgu2sd returning 32-bit IEEE floats by moving the upper 32-bits returned by defgu2sd into the lower 32-bits. Also, set the dynamic rounding mode variables to round-to-nearest defaults. Edition 208: 1. Fixed bug in PVP simulation of Ai [PQZ]Sj instruction to test for j==0. 2. Changed DCMPLX in test_native.f, sim_c1_gen.f, and sim_mpp_sim.f to CMPLX since DCMPLX is no longer recognized. Edition 207: 1. Allow more slop in stores also (see edition 205 notes). Fixes problem in which a simulated ORE load is stored back to the same location with the same value. 2. Added this "allowable ORE" logic to mpp_sim.c but only up to 8 words. Edition 206: 1. Added a bunch of new PVP instructions to be simulated. Now the only PVP (YMP) instructions not simulated are ERR, EXIT, half-precision floating multiply, monitor instructions, and any instruction referencing shared registers. Edition 205: 1. Add more slop for vector loads in simulated search functions such as in memchr. Return bad data (0xf0f0...f0) for up to 64 words beyond known data length rather than trying to read the data and possibly getting an ORE. Force internal error if any simulated store goes beyond known data length. Edition 204: 1. Define EDITION string on cc command line now. 2. Added declarations for arith_vers_name, arith_vers_ID, and arith_vers_number in arith.h. 3. Changed back argument in calls to _F90_{INDEX,SCAN,VERIFY} to be a pointer rather than a value due to a library change. 4. Changed makefile to permit the PVP arith data file to be built on a C90 (but still in Y-mode and using YMP libraries though). Also build the MPP arith data file on a C90. Edition 203: 1. Bugfixes in get.obj.arith. 2. Added AR_cabs to no_intrin.c (to resolve external reference in miscmath.c)--returns AR_STAT_UNDEFINED. Added ar_divide_complex to no_intrin.c (to resolve external reference in math.c)--computes "standard" algorithm. 3. Added 3 "" arguments to 2016 warning message call to PRINTMSG to support cft77's (Pascal) version of PRINTMSG. 4. Fixed bug to return AR_STAT_UNDERFLOW in ar_cvt_str_to_float. 5. Added what-line to arith_c1.s and arith_mpp.s so that a 'what -s arith' will display the libm version of the arith data file. Also, cray1_sim.c and mpp_sim.c search for the what-line string and use it, if found, to obtain the libm version number. The what-line does not contain the arith.a version number so tests using this (to generate internal error messages) were changed. Edition 202: 1. Removed 'cray-2' from the list of MACHINES in Makefile. Miscellaneous other improvements such as email to-list. 2. Fixed bug in get.obj.arith when -v la needed to back up to the previous release, the latest edition in that release wasn't being gotten. 3. Fixed bug in AR_power in native.c for 32-bit IEEE complex--ARPOWCR was being called even when the power was complex type. Edition 201: 1. Removed cvs log entries in all files except edition.c. 2. Added test in 'make update' to NOT update get.obj.arith or result test case files for release branch updates. Added associated note to README. 3. Fixed bugs in get.obj.arith associated with getting development editions. Version string now contains the release number but only if the release number is greater than 1. 4. Deleted support for cray-2 and cray-x4 everywhere. 5. Deleted calls to native PVP library/intrinsic functions. All such functions are now simulated. Note that this implicitly eliminates support for the cmcs code generator products. 6. Removed save/clear/restore of ar_CRAY_64_trunc_bits from intrin.c and mpp_sim.c. Save/clear/restore of ar_CRAY_64_trunc_bits is applied to all PVP library/intrinsic function simulation (in cray1_sim.c). 7. Removed AR_IEEE_denorm_behavior routine. Denorm behavior is now specified inside corresponding intrinsic evaluation modules (e.g., mpp_sim.c). Added AR_Denorm_Operands_Trap flag and set it for MPP arithmetic evaluation (in mpp_sim.c). Moved all denorm declarations from arith.h to arith.internal.h to make it invisible to the outside world. 8. Defined AR_STAT_SEMIVALID error status bit. Updated arith.doc to describe the situations under which this bit is set. 9. Restructured the intrinsic folding routines. Now either intrin.c or no_intrin.c must be used with the latter causing load-time missing external messages if intrinsic evaluation routines are called. Some intrinsic evaluation routines, such as those for string conversions, may exist in no_intrin.c. In any case, these source files contain the high-level interface routines to intrinsic folding (AR_name routines). The high-level interface routines in turn call lower-level routines, named ar_name, in either native.c or simulate.c. Those in native.c ultimately call native (non-Cray system) library routines. Those in simulate.c ultimately cause a simulation of Cray system (PVP or MPP) library routines. The lower level ar_name routines in simulate.c now do generic argument set up via calls to support routines located in specific platform modules (cray1_sim.c or mpp_sim.c). After arguments have been set up, routine ar_sim is called to simulate just the evaluation of the specific library function for the specific platform. Finally, routine ar_get_function_value is called to get the function value from the appropriate register. 10. Fixed AR_convert_str_to_int to call ar_set_invalid_result for overflows rather than clearing the unused bits. In some cases, AR_STAT_ZERO was being set in addition to AR_STAT_OVERFLOW. 11. Fixed bug in AR_convert which set AR_STAT_UNDERFLOW for the conversion of 0.0 from 64 to 32-bit IEEE float. 12. Fixed bug in AR_i32/64norm which was not setting AR_STAT_UNDERFLOW when the operand bits were not zero, but the normalization process caused all coefficient bits to become zero. Also removed unnecessary test for expo < 0 when preceding logic guaranteed it was always >= 0. 13. Changed Makefile naming of arith cpio file in tlc_rel to use the last two fields in the libm.a what -s version number. 14. Changed names of internal non-static routines to always begin with 'ar_' from 'AR_'. All user-callable routines should now consistently begin with 'AR_'. 15. Added a description to arith.doc for AR_one and AR_round_int_div. 16. Added version number proposal entry points into edition.c. 17. Fixed long standing bug in convert.c (ar_ifix64/32) in which zero was being incorrectly returned when the shift count was greater than the number of coefficient bits and the rounding mode was not AR_ROUND_ZERO. It is possible for the rounding to produce a value of 1 after all coefficient bits have been shifted off. 18. Fixed bug in mpp_sim.c in which the CMPULE/T instructions were not being evaluated correctly. 19. In simulate.c corrected the value stored into lcap1 for the call to defgu2sd to be a character address versus a word address. This requires ar_pass_ext_address to pass back a word-to-character shift count if the external address descriptor is requested. 20. Added AR_index, AR_scan, AR_verify, AR_reshape, and AR_transfer as well as new logical type AR_Logical and associated constants AR_const_true and AR_const_false in arith.h. 21. Modified F90 routine ARSELRK to use PRESENT(P/R) and call the library routine with the correct argument/s. Edition 54: 1. Changes in Makefile, get.obj.arith, and README to support the creation and use of release branches. This includes new Makefile targets edition, update, revision, and new_release. Also get.obj.arith now uses the -R option to translate a product version to an arith release number (default is still the development version except for cft77 which is forced to release 1). 2. Added 'cam' to the list of supported products in get.obj.arith. 3. Added logic to IEEE floating point arithmetic routines to return AR_STAT_UNDEFINED for denormalized operands and the denorm behavior flag is not AR_Denorms_Keep (i.e., an assumed MPP compiler). This logic needs to exist in release 1 of arith to support updates to the "frozen" cft77_m compilers (and in particular fix SPR 79459). This logic will be changed in release 2 of arith to more explicitly trap on denorm operands based on new values for the denorm behavior flag. Edition 53: 1. Support for the Fortran 90 modulo and selected_real_kind now exists for PVP, MPP, and Solaris compilers along with associated confidence tests. AR_Modulo is the name of the arith routine that supports the Fortran 90 modulo intrinsic. This distinguishes it from AR_modulo which was the Fortran 77 mod intrinsic which could return different results. 2. Added AR_mod to be the Fortran 77 mod intrinsic and deprecated AR_modulo to (hopefully) eliminate maintenance questions and user confusion. AR_mod is identical to the old AR_modulo for now. 3. Made changes to Makefile to build arith data files using modulo and selected_real_kind from libfi.a. Edition 52: 1. Added support for floating modulus and selected_real_kind for cf90_m only. This is a temporary edition to support MPP compilers only. Edition 51: 1. Fixed LDS and STS MPP instruction simulation to NOT return AR_STAT_UNDEFINED (AR_convert returns this when converting a 64-bit NaN to 32-bit but this exception cannot occur on MPP hardware when simply loading/storing a NaN value). 2. Added characters to the internal ar_eval_lib_edition variable so that it can be printed by the what command. Edition 50: 1. Changed AR_[ic]fcmp* routines to be statically declared inside compare.c and removed their interface description from arith.internal.h. 2. Changed the IEEE compare algorithms to not use subtract since they must be exact and not overflow or underflow. 3. Changed mpp_sim.c to use AR_compare for the CMPTxx instructions. 4. Upgraded sim_mpp_gen.f to compile and run with latest cft90 and generate correct data for/from the HLOG, HEXP, and HSQRT routines. Also added more test cases for string to float conversions. 5. Changed version numbering to drop the leading zero (version 50 will be stored as 50, not 050). 6. Changed packaging of arith data files. The default location is now the same directory as libm[v2].a on PVP systems and NO default on nonPVP systems. The CRAYLIBS environment variable is now used for both PVP and MPP simulation. Created a lib subdirectory below arith and $(USS)/arith containing platform subdirectories with the associated data file in each of these. Removed the .a files from the cpio files. Added arith_c1.mh and arith_mpp.mh to the corresponding cpio files. Edition 49: 1. Force ar_IEEE_denorm_behavior default to be consistent with intrinsic simulation platform (Keep on sparc, +0.0 on MPP, illegal on C1). Removed default declaration from miscmath.c. Replaced logic inside AR_IEEE_denorm_behavior to simply validate the input value and return a nonzero value if not equal to the default. 2. Fixed constant value for 'A' in arith_mpp.s. 3. Fixed subscripting bugs in cray1_sim.c and mpp_sim.c where libm[v2] version is consistency checked against that in arith_c1/mpp. 4. Added support for 64-bit pointers in arith.h, cvt.c, math.c and miscmath.c. These are required for Triton. 5. Made all calls to PRINTMSG have 8 arguments to support cft77 message routine. 6. Fixed end-case in mpp_sim.c because the CMPTxx instructions are exact and do not over/underflow. 7. Fixed spelling in arith.mk. Edition 48: 1. Fixed bug in ar_power (in mpp_sim.c) in which switch statement was based on basetype rather than resulttype. 2. Modified get.obj.arith to return latest validated version for each platform rather than the global validated version. Created 'latest' file in platform subdirectories in arith directory. Edition 47: 1. Fixed floating input conversion bug in which an all zero mantissa produced an AR_STAT_UNDEFINED. Edition 46: 1. Fixed floating input conversion bug in which a zero exponent still produces an AR_STAT_UNDEFINED if exponent is signed (e.g. 1.0e+0). Edition 45: 1. Added simulation interface identifiers in case later changes are necessary. 2. Converted register numbers to mnemonic names in mpp_sim.c 3. Fixed floating input conversion bug in which a zero exponent (e.g. 1.0e0) produced an AR_STAT_UNDEFINED because leading zeroes are skipped. 4. Make sure that the libm[v2].a returned by get.obj.arith RW by owner. 5. Add AR_NOINTRIN_ERROR routine to ctgen.c to resolve fintrin.o external. Edition 44: 1. get.obj.arith removes cray[12].o from arith.a when non-native intrinsic evaluation is used (eliminates trapmathlibabort missing external message). Removes misc_sim.o for native intrinsic evaluation. Tests for version >= 43 when deleting dummy_dc.o (vs dc_dummy.o). 2. Added simulation support for MPP LDS, STS, and S8ADDQ instructions. 3. Began using actual 32-bit algorithms for HEXP, HLOG, and HSQRT. 4. Updated README file to eliminate the USM mod creation. 5. Made complex division a pseudo-intrinsic such that native version (in intrin.c) calls a locally compiled Fortran routine which yields whatever the native algorithm might be (except for sparc which uses the previous algorithm). The simulation version (in misc_sim.c) currently uses the previous algorithm (originally in math.c). This may need to be replaced in the future with a simulation of what F90 does for the targeted system. Fixes SPRs 78056 and 78123. 6. Added complex division confidence tests (in itgen.c and confidence.c, added itgen.c support file itgenf.f). 7. Added 'ar_' prefix to the shift_{left,right} functions in misc_sim.c. Edition 43: 1. All known bugs are fixed (except complex divides for Solaris cft90). 2. Added support for -v ne and -v va to get.obj.arith. (Also -v xn is used in Makefile to build confidence test executables.) 3. Split intrinsic evaluation into 4 basic modes with no cross-over permitted. The modes are: a) No intrinsic function evaluation available (no_intrin.o) b) Use native intrinsic library routines (intrin.o) c) Simulate PVP intrinsic library routines (cray1_sim.o) d) Simulate MPP intrinsic library routines (mpp_sim.o) Get.obj.arith uses the code generator, language, and target options to construct an arith.a capable of folding in exactly one of these modes. The names in parentheses are the modules in the constructed arith.a corresponding to these modes. Modes a, c, and d should not require libm.a (libmv2.a) to be loaded into the compiler (at least for folding). 4. Allow 32 and 64-bit non-complex floats to be passed as operands to AR_leadz, AR_popcnt, and AR_poppar. The operand type is no longer required to match the result type. Also, updated messages with changes suggested by Pubs. 5. Increased output precision for float_to_string. 6. Add support for base 2 string_to_int conversions 7. Cleared part1 and part2 for 32-bit integer results in bits.c and math.c (ar_add_integer, ar_subtract_integer, bitoper, ar_dblshift, AR_leadz, AR_popcnt, AR_poppar). 8. Added 'c++' to the list of supported languages in get.obj.arith. Currently, the arith.a constructed for c++ does not support any math library intrinsic function evaluation (mode 3a above). 9. Add minimal support for 16-bit ints. Functions supported are AR_convert, AR_status, and all functions which permit operands or results of any size integer value. 10. Also, fixed AR_convert_str_to_int which claimed to work for any integer type, but really didn't. Part of the problem with this function (the value of the ar_bits_used argument) was "fixed" by a change in documentation. 11. Eliminated simulation of strtod/strtold in favor of the lower level routine defgu2sd. An interface routine, ar_unpack_float_str is called to unpack a string into simulated Cray words prior to simulating defgu2sd. 12. Made a small optimization by using hardware shift instructions if running on a Cray (in shift_left/right). 13. Added a cpio target in Makefile. This creates the different cpio files necessary for packaging arith with Craylibs and copies them out to the TLC_REL directory on USS. Added file arith.mk to be included in the cpio files. 14. Added the following simulation error messages (see arith.msg for details): 2014 - simulated intrinsic interface error 2015 - unsupported new intrinsic function 2016 - potentially different intrinsic function values (warning only) 2017 - intrinsic routine not loaded These are intended to support version consistency checks when arith is built into compilers in the field. 15. Changed a bunch of file and routine names from *_ieee* to *_mpp* since it appears likely that future IEEE Cray architectures may not exactly produce the same results as the MPP. If they happen to always produce identical results, then internal links to MPP versions can be used. 16. Moved conv routines into the results directory. The conv subdirectory is no longer needed. 17. Removed dc_dummy.c. Added dummy_dc.f in order to more easily maintain the Fortran naming conventions on multiple platforms. 18. Added HSQRT, HLOG, and HEXP to arith_mpp.s. These are still just interfaces to the 64-bit algorithms. However, the next edition of arith should automatically start using the actual 32-bit algorithms when they are put in the next Craylibs_m package. 19. Added external char variables AR_libmv2 and AR_arith_data. These contain a null string if simulation is not used. Otherwise, AR_libmv2 contains the libmv2.a version information, including the edition number (e.g., 81002). AR_arith_data contains the arith.a edition number of the arith_c1/mpp file (i.e., the arith.a edition number when the data file was built). Edition 42: 1. Added PVP and MPP intrinsic simulation for libm and floating input conversion routines. 2. Modified get.obj.arith to turn on simulation for ccg and mppcg code generators but disable it for rcg and cmcs. 3. Extensive modifications were made to the makefile for consistent packaging, easier testing, and to provide debug versions of arith. Added make targets to generate the intrinsic simulation data files and to generate the test data for the simulation confidence tests. 4. Updated the README, arith.msg, and arith.doc files. 5. Modified existing confidence tests to work with/without simulation enabled. Added simulation confidence tests. */ static char USMID [] = "\n%Z%%M% %I% %G% %U%\n"; static char rcsid [] = "$Id: edition.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $"; /* * Revision 2.46 1997/07/22 23:31:22 gbt * MIPS NaNs are the opposite of SPARC/T90-IEEE/Alpha NaNs: the * latter has the high bit of the mantissa clear for signalling * NaNs, and set for quiet ones; the former is the other way * around. * * Revision 2.45 1997/06/17 17:46:19 gbt * - Add status setting for AR_STAT_INEXACT in IEEE normalization. * - Makefile cleanup -- don't execute "target" if not on a Cray * machine, and in the "arith.a:" target, copy the arith.h file * into a "common" subdirectory. I had moved the common files * into a "common" subdir in the USS directory in edition 234, * and modified the get.obj.arith script accordingly, but I * needed to do the same thing in the build directory structure, * so that doing a "get.obj.arith -v xn ..." would work. * - Remove the use of /cray/uss/compiler/cost/bin/validate from * the get.obj.arith script. * * Revision 2.44 1997/06/02 19:14:16 gbt * Add AR_ibits(), and the corresponding internal tests. * * Revision 2.43 1997/05/01 15:25:18 gbt * Remove the use of <ctype.h> in strcvt.c. This allows us * to compile arith with 9.x #include files, and link it * with 8.x libraries, and have everything work right. It * doesn't hurt wide-character compatibility, because there * is quite a bit of code in strcvt.c that is incompatible * with wide characters already. * * Revision 2.42 1997/04/25 02:56:02 gbt * 1. Missed some modules that needed additions for 8-bit and * 16-bit integers. * 2. Add full support for determining the host architecture. * 3. Fix some minor divots in float-->string conversions. * 4. Add AR_ishft() and AR_ishftc(), for the corresponding f90 * intrinsics, and add code to testint.c to test these. * * Revision 2.41 1997/04/02 00:04:31 gbt * Add support for 8-bit and 16-bit integers. Update testing programs * appropriately. * * Revision 2.40 1997/03/17 21:19:11 gbt * 1. Bring in the MIPS quad changes from Rich Shapiro. * 2. Fix 703309 -- non-base-10 int-to-str conversions yielded * trash. * 3. Add appropriate casts to cray1_sim.c and mpp_sim.c, to * remove some warnings about mistyped assignments. * * Revision 2.39 1996/12/12 20:31:44 gbt * Undo the change that made negating IEEE 0.0 not yield -0.0 any more. The * standard says that negating 0.0 is *supposed* to yield -0.0. We hadn't * read the IEEE standard completely. * * Revision 2.38 1996/11/05 18:33:00 gbt * Remove the MIPS hack in native.c for the INDEX(), SCAN(), and VERIFY() * intrinsics. * * Revision 2.37 1996/10/30 21:01:21 gbt * Add a -n option to remote-builds.csh, to tell it not to do a * "make delete" before proceeding with the builds. Also, update * edition.c -- I had forgotten to do so on the last few changes. * * Revision 2.36 1996/10/29 21:53:39 gbt * - Clean up the code in various spots so that the Solaris and IRIX * compilers don't emit any warnings any more. * - Really support the IRIX platform. * - Allow re-updating of the current USS edition. * - Move the USS arith.{doc,h,msg}.* files into a "common" subdirectory * (aesthetics -- makes the directory easier to look at). * - Make sure all the files installed on USS have group-write access. * - Clean up get.obj.arith -- the indentation had gotten a little * odd over the years. * * Revision 2.35 1996/10/28 23:10:04 gbt * Expand the simulated stack size for Cray-1 style simulation, from 2 kwords * to 10 kwords. It wasn't big enough for the needs of all the intrinsics in * the 3.0 arith data file. * * Revision 2.34 1996/10/11 22:20:34 gbt * Make _numargs() work properly on T3E. The SSIB and DSIB weren't properly * set up before beginning simulation, nor was the CI register correct on * entry to the simulated intrinsic code. * * Revision 2.33 1996/10/03 19:24:26 gbt * Fix some preprocessing problems having to do with the _Solaris #if tests. * * Revision 2.32 1996/09/23 21:21:46 gbt * - Simulate byte-manipulation instructions properly for a T3E. * - Remove pdbgint support for MPP -- it couldn't have been made to * work anyway. * - Add environment variable control of ar_disasm debugging for MPP. * * Revision 2.31 1996/09/10 21:46:11 gbt * Allow for building on a TS (only building _on_ one, not _for_ one). * * Revision 2.30 1996/08/30 19:39:50 gbt * - Modifications to the self-tests to allow for correct results on * TS-IEEE (they've never been right before this). * - Continuing Makefile cleanup. * - MIPS real*16 support from Rich Shapiro. * - Added support for printing integers from MPP library code during * simulation. * * Revision 2.29 1996/08/20 20:07:35 gbt * Go back to using the UNICOS 8.3 #include files for C-90 and Y-MP. There's * no apparent way to safely use the 9.x ones, and still allow people to link * an arith.a thus compiled with 8.x libraries. * * Revision 2.28 1996/08/15 23:09:12 gbt * More closely follow the IEEE rules regarding NaNs as operands and results. * Also, do a little fixup in the Makefile. The YMP tests all pass now. * * Revision 2.27 1996/07/03 23:14:26 gbt * For version comparison between the arith data file and the * libm.a when simulating, do a better job of figuring out the * libm.a version. Also did some prettification of the version * checking code in mpp_sim.c, and a minor change to allow for * creating the MPP simulation data file on a C-90. * * Revision 2.26 1996/06/19 23:32:16 gbt * Oops. Send store_mpp_word() the _address_ of the register you * want to simulate storing, not the contents of it. Sheesh. * * Revision 2.25 1996/06/12 18:20:16 gbt * Large amounts of Makefile beautification, after Mark Cruciani * had some targeting problems. * Add a -z switch to get.obj.arith, to return sources, and add * a new target "install_source" to the Makefile, to install them * where the -z logic is expecting to find them. This new target * should be made after "update" is made. * Take out the -X1 for T3E builds temporarily. It's causing * problems with the currently-available hardware. * * Revision 2.24 1996/05/31 21:09:51 gbt * 1. IRIX/MIPS changes. Add fintrin_irix.f, fintrin_dc_irix.f, * fintrin_irix_f77.f. Update Makefile to understand about IRIX, * and build the three new modules. Update #ifdefs in confidence.c, * miscmath.c, native.c, simulate.c, strcvt.c, and test_ar_intrin.c * to do MIPS like we do Solaris. * * 2. Fix a problem in AR_make_complex (miscmath.c), where aliasing * result and op2 led to wrong results. * * 3. Set up the simulated stack differently in mpp_sim.c. For the * T3E, we had the simulated DSIB between the simulated frames of * the caller and callee. The latter two need to abut, or arg * addressing when simulating routines with more than 6 arguments * won't work. * * 4. Replace a sequence of '|' expressions in ar_convert_str_to_float() * with a sequence of '|=' assignments. The former is subject to * expression reordering which, although it apparently hasn't yet * occurred, would get the arguments to _defgu2sd() in the wrong * order if it happened. * * Revision 2.23 1996/05/10 22:02:22 ghg * Edition 223: * 1. Fix for spr 100775. Insure that 64 bit addressing is used * in Ar_put_real_address(). Previous cast to long it was * getting only the low order 32 bits. * * 2. Changed get.obj.arith to provide release 2 arith versions for * cft90 6.x or 6.X products. * * Revision 2.22 1996/05/01 22:00:10 ghg * 1. Changed header processing for cld a.out again. Do move * down over header after all segments are processed. Insure * that segment ids can't be redefined by an undefined segment. * * 2. Perform right shifts using macro with unsigned longs so no * sign extension takes place, even for Cray systems that sign * extend right shifts. The SHRIGHT64X macro specifically does * sign extension and will continue to sign extend. * * 3. Changed definitions of parcels to unsigned longs to insure * that sign extension doesn't take place. * * Revision 2.21 1996/04/23 23:42:44 ghg * '********************************************************' * Please send following email... * To: krz, bcn, mwm, knaak, homer, rlf, srp, pmk, bhj, kik, tbb, jk, gbt, lew, svc, ghg, mac * * Subject: New edition `cat release`.`cat edition` of arith * * Edition `cat release`.`cat edition` of arith is now available in $(USSARITH)/R`cat release`. * It can be accessed with get.obj.arith as follows: * * " get.obj.arith -v ne ..." * * It contains the following enhancements: * Edition 221: * 1. Changed segment definitions for cld a.out header. Defined dynamically * rather than static assignements. * 2. Spr 100747: Mod by Greg Titus. * arith.internal.h: Add ar_crnd128() declaration. * cvt.c: Call ar_crnd128() for 128-bit Cray floating * point round_int_div. * convert.c: Add ar_crnd128() body. * 3. SPR 101290: Mod by Greg Titus. * mpp_sim.c: Fix invalid type punning (IEEE complex to * IEEE float) in ar_pass_arg_value(). We * were passing a misaligned 32-bit IEEE * float to ar_convert_to_float() when we * were doing the real part of a 32-bit IEEE * complex. * * Revision 2.20 1996/04/17 18:22:50 ghg * Edition 220: * 1. Changed Makefile to build Cray-t3d and Cray-t3e targets. * * 2. Changes for native versions of Cray-t3d and Cray-t3e that use * Solaris simulation routines. * * Revision 2.19 1996/02/07 23:39:49 jhw * Edition 219: * 1. Changed mpp_sim.c to handle the segment identifier differences between * the t3d and t3e. open_intrinsics_file now looks at the segment * type field of the file header instead of the id, and * load/store_mpp_word now looks at variables corresponding to the * new segment identifiers. T3E data files built with mppldr should * not be used. Those produced by cld will be handled (hopefully) by * this mod. * * 2. Changed arith_mpp.s to add the 32-bit SCANI, VERIFYI, and INDEXI * intrinsics to the list of those needing to have their fcd arguments * converted to byte-lengths. * * Revision 2.18 1996/01/03 22:15:46 jhw * Edition 218: * 1. Triton-IEEE 0162 and 0163 divide instructions had the operands * reversed for the divide calls. This fixes SPRs: 95451, 96747, * 95582, 97309, 99176, 99366. * * Revision 2.17 1995/12/19 16:51:03 jhw * 12/19/95 jhw: * 1. MPP 0x18 instructions were being called illegal and arith was aborting. * These are now disassembled and ignored. For 0x18c (RPCC), the rtc * is moved into ra. This was in mpp_sim.c. * * 2. The mpp intrinsic simulations for index, scan, verify, and selected_ * real_kind for 32-bit integers were not supported. The appropriate * entry points are now in place however. This was in arith_mpp.s * and simulate.c * * Revision 2.16 1995/12/11 15:56:51 jhw * 12/11/95 jhw: This change fixes incorrect simulation of the 01xx4 (S-reg * load/store) instructions. Only two-parcels of the 3-parcel address * expressions were being used. This fixes SPR 98417. * * Revision 2.15 1995/11/30 21:34:37 jhw * 11/30/95 jhw: Changed cray1_sim.c so that the 174[1,2,3] instructions were * being simulated correctly. This fixes reshape sprs: 96747, 95628, 95627, * 97309, and 97842. Also modified get.obj.arith to manually set permissions * when copying arith.a. Makefile was modified to reference newer libraries * for building arith data files, and I added the capability of bumping a new * version to latest. * * Revision 2.14 1995/11/13 20:25:46 jhw * Edition 214: * * 1. Fixed bug in ar_itoc128 in which the resulting exponent was 1 too big. * (jhw) Altered this function to return the correct status. This fixes * SPR 90659. * * 2. Fixed bugs in ar_sim simulation of 026/027 instructions that were * causing unsimulated instruction errors and not using new A-reg operand * instructions. * * 3. Removed rounding in conversion of Cray 128-bit to 64-bit floating point * since all compilers internally just truncate (keep the first 64-bits). * * 4. Added tbb and svc to the change list, made the default uss results * repository to be in cray/uss/a6/jhw, and changed the c90 and triton * cc and libs setup to the correct directories in Makefile. * * Revision 2.13 1995/09/26 20:40:19 jk * Added check for compatible floating point format between result type and * opened arith data file. Made /opt/ctl/craylibs[_m]/craylibs[_m] first * default location for arith. Removed libm.a existance requirement for * all cross compilations. Added integer*8 versions of native power * functions. Added simulation of remaining cray-ts[,ieee] instructions * (currently unused but lowers risk if future Craylibs uses them). Changed * arith_mpp.s and mpp_sim.c to interface to either T3D or T3E libraries. * * Revision 2.12 1995/08/18 17:18:00 jk * Fixed some bugs in cray1_sim.c; added simulation for Vi Vj*[LU]Vk. * * Revision 2.11 1995/08/16 22:09:24 jk * Added full 128-bit IEEE support; removed all internal arith declarations * from arith.h; implemented partial support for multi-targetable arith * library; added support for native cray-ts, cray-ts-ieee. * * Revision 2.10 1995/04/18 23:17:52 jk * Fixed cast of int to 64-bit pointer problem; fixed problem with nonpackage * versions of Craylibs. Begin using Craylibs 2.0 for arith testing. * * Revision 2.9 1995/02/08 19:55:22 jk * Added support for non-package versions of Craylibs and asynchronous * updating of the arith data file. Changed severity of 2016 message to * Logfile_Warning. Allow 128-bit IEEE float types and 64-bit integer * types on sparc systems but internally work in reduced precision. Fixed * MPP simulation bugs--allow 46-bit integer type and set default dynamic * rounding modes and types. Added cray-ts as target in get.obj.arith. * Changed c++ product in get.obj.arith to be same as scc except for rcg. * No longer clear upper 8 bits of 64-bit pointers. * * Revision 2.8 1995/01/04 16:06:20 jk * Test for j==0 in simulation of Ai [PQZ]Sj. Changed DCMPLX to CMPLX where used * since cft90 no longer recognizes DCMPLX. * * Revision 2.7 1994/12/20 22:39:20 jk * Allow slop in stores also. Copy allowable ORE logic to mpp_sim.c. * * Revision 2.6 1994/12/16 18:02:18 jk * Added simulation of remaining PVP instructions except for system calls, * monitor mode instructions, half-precision multiply, and shared register usage. * Fixes problem when reshape calls %LDSV which uses some previously unsimulated * vector instructions. * * Revision 2.5 1994/12/13 23:00:44 jk * Fixed problem with simulated vector load in memchr reaching outside fcd * memory area. * * Revision 2.4 1994/12/13 14:51:38 jk * Changed back arg in _F90_{INDEX,SCAN,VERIFY} calls to be a pointer rather * than a value. Added declarations in arith.h for arith_vers_name, * arith_vers_ID, and arith_vers_number. Moved definition of EDITION macro * from edition.c to cc command line. Changed Makefile to build arith data * files on either YMP or C90 (in Y-mode). * * Revision 2.3 1994/11/29 23:37:14 jk * Added AR_cabs and ar_divide_complex to no_intrin.c. Added 3 NULL args * to 2016 PRINTMSG call. Fixed ar_cvt_str_to_float to return * AR_STAT_UNDERFLOW. Added what-lines to arith_c1/mpp.s. * * Revision 2.2 1994/10/19 20:54:52 jk * Fix bug in native.c--x**C was calling ARPOWCR. * * Revision 2.1 1994/10/18 19:48:35 jk * Major restructuring of intrinsic evaluation. Added AR_index, AR_scan, * AR_verify, AR_reshape, and AR_transfer. Added type AR_Logical. Added * AR_SEMI_VALID status value. Removed AR_IEEE_denorm_behavior. Removed * support for Cray-2 and Cray-XMP. Changed internal names to consistently * begin with 'ar_' while all external user-callable names begin with 'AR_'. * See edition.c Edition 201 notes for a complete list of changes. * * Revision 2.0 1994/08/11 16:21:30 jk * Increment development version to 2.0 * * Revision 1.53 1994/08/10 22:01:58 jk * Make changes to support release 1 branch; added logic to trap on denormalized * operands (for MPP only) in IEEE arithmetic routines; added product cam to * get.obj.arith. * * Revision 1.52 1994/08/05 22:27:03 jk * Add support for Fortran 90 modulo and selected_real_kind intrinsics. * * Revision 1.51 1994/06/16 18:06:58 jk * Fix bug in mpp_sim.c to prevent premature AR_STAT_UNDEFINED returned when * LDS instruction loads a NaN value. Add what-line chars in edition.c. * * Revision 1.50 1994/06/09 14:17:15 jk * Bug fixes, made AR_[ic]fcmp* routines internal, avoid using subtract for * IEEE compares (they must be exact and not over/underflow), changed version * numbering to 2-digit number, changed packaging for simulation (arith.a will * go in the compiler packages, arith data file will go in craylibs package * and be installed in the same location as libm.a/libmv2.a). * * Revision 1.49 1994/06/01 21:57:25 jk * Fixed problems to correctly handle denorm behavior, correctly test for * version consistency with libm/libmv2, and interface with cft77's version * of PRINTMSG. * * Revision 1.48 1994/05/27 18:34:46 jk * Fix bug in AR_power in mpp_sim.c for 32-bit float base operand--a 64-bit * value was being returned. * * Revision 1.47 1994/05/23 21:57:18 jk * Fixed bug in ar_unpack_float_str in which 0e1 was failing. * * Revision 1.46 1994/05/19 22:34:21 jk * Fixed another bug str to float conversions with 0 exponents. * * Revision 1.45 1994/05/19 16:51:17 jk * Add simulation interface ids to support future mods. Converted register * #s to mnemonics in mpp_sim.c. Fixed '..E0' bug in AR_convert_str_to_float. * Misc Makefile, get.obj.arith, confidence test fixes. * * Revision 1.44 1994/05/17 15:13:22 jk * Added simulation for the LDS, STS, and S8ADDQ MPP instructions plus the * actual 32-bit algorithms for HEXP, HLOG, and HSQRT. Made complex division * a pseudo-intrinsic (native version in intrin.c, simulation version in * misc_sim.c) to fix SPRs 78056 and 78123. Misc cleanup and bug fixes. * * Revision 1.43 1994/05/04 14:50:13 jk * Split intrinsic folding into 4 non-overlapping modes--none, native, PVP * simulation, and MPP simulation. Allow 32/64-bit non-complex floats in * AR_leadz, AR_popcnt, and AR_poppar. Add base 2 string_to_int conversion. * Clear part1 and part2 in integer results in bits.c and math.c. Added * minimal support for 16-bit integers. Began edition log in edition.c * for editions with large numbers of changes (see edition.c). * * Revision 1.42 1994/04/07 18:41:18 jk * Added PVP and MPP intrinsic simulation for libm and floating input conversion * routines. Modified get.obj.arith to turn on simulation for ccg and mppcg * code generators but disable it for rcg and cmcs. Extensive modifications * were made to the makefile for consistent packaging, easier testing, and * to provide debug versions of arith. Updated the README, arith.msg, and * arith.doc files. Modified existing confidence tests to work with/without * simulation enabled. Added simulation confidence tests. Added make targets * to generate the intrinsic simulation data files and to generate the test * data for the simulation confidence tests. * * Revision 1.41 1994/02/10 17:10:42 pmk * Fix problems with 32-bit IEEE intrinsic folding feature begun with last * version. Should affect only SPARC. * * Revision 1.40 1994/02/04 03:18:27 pmk * Fix SPARC/Solaris intrinsic folding so that 32-bit IEEE Fortran intrinsics * are not folded by conversion to/from 64-bit. * * Revision 1.39 1994/02/02 20:17:02 krz * Fix conversion of unsigned int to IEEE (SPR 74885). Incorrect member was * accessed when determining unsignedness of integer type. * * Revision 1.38 1993/12/01 01:39:01 pmk * Change complex division as requested by GSF to special-case zero * imaginary parts in denominators (only) -- SPR 70472. * Also fix conversions from 64-bit IEEE to 32-bit IEEE -- SPR 70042. * * Revision 1.37 1993/11/30 00:38:22 krz * Add support for Cray single-precision floating-point truncation. (SPR * 70042) * * Allow user-specified behavior for IEEE denorms. (SPR 66025) * * Provide functions to convert a host 64-bit int to an AR_DATA representation. * * Update arith.msg with changes made by pubs (Chris Brewster). * * Fix bug in AR_status for 32-bit IEEE floats (AR_STAT_ZERO was not reported * correctly). * * Fix AR_convert_float_to_str to correctly report Nan, +Inf, and -Inf for IEEE * floating-point numbers. * * Fix ar_convert_to_float (called by AR_convert) to allow conversions from * integral values to type AR_Float_Cray1_64_F. Previously, * AR_STAT_INVALID_TYPE was returned for such conversions. * * Revision 1.36 1993/11/12 02:08:39 krz * 1. Add a new function, AR_make_complex, which creates a complex number from * two floating-point numbers. * * 2. Update the messages file (arith.msg) with changes made by Pubs. * * 3. Fix the result from function AR_one for 32-bit ints. The unused upper * 32 bits of the word are now zeroed. * * 4. Fix the result from AR_convert_str_to_float for 32-bit floats when * executing on the Suns. The result was previously put into the wrong half of * the 64-bit word. * * Revision 1.35 1993/10/14 01:49:56 krz * The directory for arith has moved on the file server. Update references to * the arith directory in all files. * * Add support to build under the "solaris" environment. * * Revision 1.34 1993/09/23 00:57:35 krz * Add function AR_subtract_ptr_ptr to perform pointer minus pointer * evaluations. * * Change function AR_add_ptr_int to return an error status (it previously * always returned AR_STAT_OK). * * Don't make reference to ARERPFIX on platforms where it doesn't exist. * * Change uses of macros CRAY, CRAY1, and CRAY2 to the preferred * (standard-conforming) macros _CRAY, _CRAY1, and _CRAY2. * * Added a dummy AR_INTERNAL_ERROR function to ctgen.c to avoid the unsatisfied * external. Also link in PRINTMSG_dummy.c. * * Revision 1.33 1993/09/03 20:18:57 pmk * Fix cross-compiled exponentiation folding (IEEE on Cray hardware). * * Revision 1.32 1993/09/01 23:29:31 pmk * Revamp intrinsic processing, especially exponentiation, to support double * precision complex and to use system math libraries. Also fix a rounding bug * in convert.c. * * Revision 1.31 1993/08/12 20:55:41 krz * Add support to issue internal error messages through the PRINTMSG interface to the message system. * * Revision 1.30 1993/08/05 17:46:00 krz * 1. Added AR_convert_hex_str_to_float function. * * 2. Updated build procedures in README file to use generation compiler, library, and header files as jointly agreed upon by the compiler integrators. (Don't have to worry about signgam anymore!) * * 3. Added copyright notices and USMIDs to source files. * * 4. Added function prototypes for AR_c2fapprox in cray2_dummy.c and matherr in itgen.c. * * 5. Added descriptions for AR_convert_str_to_int, AR_convert_int_to_str, AR_convert_str_to_float, and AR_convert_float_to_str to arith.doc. * * 6. Clean up, standardize, and document the return values for AR_convert_str_to_int and AR_convert_str_to_float. * * Revision 1.29 1993/07/13 18:25:21 gbt * For reals raised to integer powers, AR_power() was checking the size of * the base, rather than the power, to determine whether the power was a * 32 bit int or a 64 bit one. The bug was introduced when 32 bit integer * support was added. * * Revision 1.28 1993/07/01 23:41:52 krz * This is a small commit to test the automatic mail feature of CVS. * * Revision 1.27 1993/06/15 00:59:27 krz * Add a dummy entry for the Cray-2 floating-point approximation function (and * associated data) for use on non-Cray-2 machines (to save code/data space * when the library is linked into executables on those machines). Add a * couple of workarounds for bugs found in the gcc compiler and library * headers. * * Revision 1.26 1993/05/20 02:59:28 krz * 1. Fix return value for AR_modulo, which incorrectly reported overflow in * cases where the numerator was negative and the result was zero. * * 2. Fix sprintf() calls for floats on non-Cray hosts. While the ar_ieee64 * union member is the same size as a double on a Sun, the parameter * passing mechanism is different for structs and doubles. Thus explicit * casts are necessary. Also, make all the format strings on those calls * right. * * 3. Comparisons of infinities with infinities are now fixed. * * Revision 1.25 1993/05/17 17:50:48 krz * Add a new function, AR_add_ptr_int to perform pointer arithmetic. * Fix some integral conversions that weren't sign extending correctly. * AR_status now allows and correctly handles 24 and 8 bit ints. * * Revision 1.24 1993/04/19 20:39:02 gbt * 1. Make sure all file errors increment the error counter in confidence.c. * 2. Add 32 bit signed and unsigned integer support. * 3. Modify testint.c to allow it to run on (SPARC) Suns. * * Revision 1.23 1993/04/09 22:36:35 pmk * Minor fixes to Cray double precision floating add and double precision * exponentiation, to yield proper results in end-case error situations. * * Revision 1.22 1993/04/09 03:51:04 krz * Change the data format for IEEE 32-bit floats so that the value is maintained in the lower 32 bits of a 64-bit word. Change the data format for IEEE 64-bit complex (2 32-bit floats) to match the format used at runtime. This change should be completely transparent since nobody is using these data types (yet). * * Revision 1.21 1993/03/11 23:29:15 pmk * Add new AR_round_int_div routine, and fix Cray-1 truncated multiplies * in the high-level interface. * * Revision 1.20 1993/02/09 21:07:19 pmk * Correct an abort in intrin.c when folding IEEE arithmetic on the Crays; * also, continue development and testing of 32-bit IEEE arithmetic. * * Revision 1.19 1993/02/04 23:40:25 pmk * Speed up integer multiplication, addition, and string conversion. * * Revision 1.18 1993/01/29 01:26:55 krz * Forgot to update the edition last time. This is edition 17. * * Revision 1.17 1993/01/27 22:52:21 pmk * Add Cray 128-bit float -> IEEE 64-bit conversion. * * Revision 1.16 1992/12/29 03:47:04 krz * Move the removal of the overflow flag for unsigned integer multiplication from ar_multiply_integer to AR_multiply so that AR_convert_str_to_int can check for overflow during conversion. * * Revision 1.15 1992/12/12 04:43:20 pmk * Implement AR_exp, AR_log, and AR_power routines for the evaluation * of exponentiation in intrin.c. * * Revision 1.14 1992/12/03 23:21:24 pmk * Add new AR_cabs function for bitwise accuracy with library. * * Revision 1.13 1992/11/25 21:23:52 krz * 1. Add tests for conversions from integral operands to integral results. * 2. When converting to integral value, return overflow status bit when * original operand value can not be represented in the result type. * 3. Fix integral addition, subtraction, division, and modulus to return * correct status when the result and an operand are the same object. * * Revision 1.12 1992/11/18 01:26:14 pmk * Fix complex absolute value and integer division overflow checking. * * Revision 1.11 1992/11/06 17:35:20 pmk * Break up bitopers.c, and support square root. * * Revision 1.10 1992/10/24 01:12:38 pmk * Compile with optimization enabled. * * Revision 1.9 1992/10/21 23:35:33 pmk * Correct status returns in complex operations. * * Revision 1.8 1992/10/19 19:52:20 pmk * Provide conversions between Cray and IEEE format floating-point numbers. * * Revision 1.7 1992/10/17 00:56:08 krz * Add arith.doc to repository. Add AR_Int_46_U back to arith.h. Fixed bugs in AR_convert_str_to_int. * * Revision 1.6 1992/10/16 23:08:34 krz * Finished testing of integral operations. Changed return status bits from integral operations where necessary. * * Revision 1.5 1992/10/12 16:19:56 pmk * Version 004 - fixes from Kent to bitopers.c and testint.c. * * Revision 1.4 1992/10/08 01:17:35 pmk * Version 003 - a fix to conversion from Kent in bitopers.c. * * Revision 1.3 1992/09/23 21:55:54 pmk * * Revision 1.2 1992/09/23 21:53:59 pmk * Correct minor problems with packaging. This is version V002. All * problems reported with V001 should have been addressed. * * Revision 1.1 1992/09/22 20:01:10 pmk * Set up build procedures. * */
43.657296
314
0.73315
[ "object", "vector" ]
95b1d689b2be3b9f98d266bc75d265012b004a95
6,683
h
C
ShellKit/Classes/ShellKit/SKTask.h
maximejf42/ShellKit
d1e972e9f8ff3cd6a8eea894606d1150145c3d64
[ "MIT" ]
87
2017-05-11T22:16:33.000Z
2021-08-02T02:25:48.000Z
ShellKit/Classes/ShellKit/SKTask.h
maximejf42/ShellKit
d1e972e9f8ff3cd6a8eea894606d1150145c3d64
[ "MIT" ]
1
2017-05-12T13:31:22.000Z
2017-05-12T13:31:22.000Z
ShellKit/Classes/ShellKit/SKTask.h
maximejf42/ShellKit
d1e972e9f8ff3cd6a8eea894606d1150145c3d64
[ "MIT" ]
9
2017-05-12T13:22:24.000Z
2019-03-12T09:18:51.000Z
/******************************************************************************* * The MIT License (MIT) * * Copyright (c) 2017 Jean-David Gadina - www.xs-labs.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ /*! * @header SKTask.h * @copyright (c) 2017, Jean-David Gadina - www.xs-labs.com */ #import <Foundation/Foundation.h> #import <ShellKit/SKObject.h> #import <ShellKit/SKRunableObject.h> NS_ASSUME_NONNULL_BEGIN @class SKTask; /*! * @typedef SKTaskOutputType * @abstract The type of output of a task * @discussion Used to differenciate output comming from a task's `stdout` * or `stderr`. */ typedef NS_ENUM( NSInteger, SKTaskOutputType ) { SKTaskOutputTypeStandardOutput, /*! `stdout` output type */ SKTaskOutputTypeStandardError /*! `stderr` output type */ }; /*! * @protocol SKTaskDelegate * @abstract Delegate for `SKTask` objects * @see SKTask */ @protocol SKTaskDelegate< NSObject > @optional /*! * @method taskWillStart: * @abstract Called when a task is about to be run * @dicussion This method is optional. * @param task The task object * @see SKTask */ - ( void )taskWillStart: ( SKTask * )task; /*! * @method task:didProduceOutput: * @abstract Called when a task has produced output on `stdout` or `stderr` * @dicussion This method is optional. * Note that the output may not be whole/complete lines, as this * method, if implemented by the delagete, will be called as * output is captured. * @param task The task object * @param output The produced output string * @param type The output type * @see SKTask * @see SKTaskOutputType */ - ( void )task: ( SKTask * )task didProduceOutput: ( NSString * )output forType: ( SKTaskOutputType )type; /*! * @method task:didEndWithStatus: * @abstract Called when a task has finished running * @dicussion This method is optional. * @param task The task object * @param status The task's exit status * @see SKTask */ - ( void )task: ( SKTask * )task didEndWithStatus: ( int )status; @end /*! * @class SKTask * @discussion Represents a shell task * @see SKRunableObject */ @interface SKTask: SKObject < SKRunableObject > /*! * @property delegate * @abstract The task's delegate * @see SKTaskDelegate */ @property( atomic, readwrite, weak ) id< SKTaskDelegate > delegate; /*! * @method taskWithShellScript: * @abstract Creates a task from a shell script * @param script The shell script to execute when the task is run * @result The task object */ + ( instancetype )taskWithShellScript: ( NSString * )script; /*! * @method taskWithShellScript:recoverTask: * @abstract Creates a task from a shell script * @discussion If a recovery task is passed, it will be executed upon failure. * If the recovery task then succeed, the primary task will also * succeed. * @param script The shell script to execute when the task is run * @param recover An optional task to execute as recovery if the task fails. * @result The task object */ + ( instancetype )taskWithShellScript: ( NSString * )script recoverTask: ( nullable SKTask * )recover; /*! * @method taskWithShellScript:recoverTasks: * @abstract Creates a task from a shell script * @discussion If recovery tasks are passed, they will be executed upon * failure, until one of them succeed. * If a recovery task then succeed, the primary task will also * succeed. * @param script The shell script to execute when the task is run * @param recover An optional array of tasks to execute as recovery if the task fails. * @result The task object */ + ( instancetype )taskWithShellScript: ( NSString * )script recoverTasks: ( nullable NSArray< SKTask * > * )recover; /*! * @method initWithShellScript: * @abstract Creates a task from a shell script * @param script The shell script to execute when the task is run * @result The task object */ - ( instancetype )initWithShellScript: ( NSString * )script; /*! * @method initWithShellScript:recoverTask: * @abstract Creates a task from a shell script * @discussion If a recovery task is passed, it will be executed upon failure. * If the recovery task then succeed, the primary task will also * succeed. * @param script The shell script to execute when the task is run * @param recover An optional task to execute as recovery if the task fails. * @result The task object */ - ( instancetype )initWithShellScript: ( NSString * )script recoverTask: ( nullable SKTask * )recover; /*! * @method initWithShellScript:recoverTasks: * @abstract Creates a task from a shell script * @discussion If recovery tasks are passed, they will be executed upon * failure, until one of them succeed. * If a recovery task then succeed, the primary task will also * succeed. * @param script The shell script to execute when the task is run * @param recover An optional array of tasks to execute as recovery if the task fails. * @result The task object */ - ( instancetype )initWithShellScript: ( NSString * )script recoverTasks: ( nullable NSArray< SKTask * > * )recover NS_DESIGNATED_INITIALIZER; @end NS_ASSUME_NONNULL_END
37.544944
142
0.659434
[ "object" ]
95b7812e58d2ba7db11f103cd2560a0a7870e7a3
2,992
h
C
src/mirheo/core/exchangers/interface.h
noabauma/Mirheo
bf7979bfbbf402d33c26ac5dc879f880e78e7017
[ "MIT" ]
22
2019-07-17T13:06:41.000Z
2021-12-15T14:45:24.000Z
src/mirheo/core/exchangers/interface.h
noabauma/Mirheo
bf7979bfbbf402d33c26ac5dc879f880e78e7017
[ "MIT" ]
63
2019-06-26T13:30:47.000Z
2021-02-23T10:13:10.000Z
src/mirheo/core/exchangers/interface.h
dimaleks/uDeviceX
2ad5e9dd9f118e3998b291cbfc35ee91205bbef8
[ "MIT" ]
9
2019-10-11T07:32:19.000Z
2021-05-17T11:25:35.000Z
// Copyright 2020 ETH Zurich. All Rights Reserved. #pragma once #include <mirheo/core/datatypes.h> #include <cuda_runtime.h> #include <memory> #include <vector> namespace mirheo { class ExchangeEntity; /** \brief Pack and unpack \c ParticleVector objects for exchange. The user should register one (or more) ExchangeEntity objects that represent the data to exchange. The functions interface functions can then be called in the correct order to pack and unpack the data. Designed to be used with an ExchangeEngine. */ class Exchanger { public: virtual ~Exchanger(); /** \brief register an ExchangeEntity in this exchanger. \param [in] e The ExchangeEntity object to register. Will pass ownership. */ void addExchangeEntity(std::unique_ptr<ExchangeEntity>&& e); /// \return ExchangeEntity with the given id (0 <= id < getNumExchangeEntities()). ExchangeEntity* getExchangeEntity(size_t id); const ExchangeEntity* getExchangeEntity(size_t id) const; ///< see getExchangeEntity() /// \return The number of registered ExchangeEntity. size_t getNumExchangeEntities() const; /** \brief Compute the sizes of the data to be communicated in the given ExchangeEntity. \param id The index of the concerned ExchangeEntity \param stream Execution stream After this call, the `send.sizes`, `send.sizeBytes`, `send.offsets` and `send.offsetsBytes` of the ExchangeEntity are available on the CPU. */ virtual void prepareSizes(size_t id, cudaStream_t stream) = 0; /** \brief Pack the data managed by the given ExchangeEntity \param id The index of the concerned ExchangeEntity \param stream Execution stream \note Must be executed after prepareSizes() */ virtual void prepareData (size_t id, cudaStream_t stream) = 0; /** \brief Unpack the received data. \param id The index of the concerned ExchangeEntity \param stream Execution stream After this call, the `recv.sizes`, `recv.sizeBytes`, `recv.offsets` and `recv.offsetsBytes` of the ExchangeEntity must be available on the CPU and GPU before this call. Furthermore, the recv buffers must already be on the device memory. \note Must be executed after prepareData() */ virtual void combineAndUploadData(size_t id, cudaStream_t stream) = 0; /** \brief Stats if the data of an ExchangeEntity needs to be exchanged. \param id The index of the concerned ExchangeEntity \return \c true if exchange is required, \c false otherwise If the ParticleVector didn't change since the last exchange, there is no need to run the exchange again. This function controls such behaviour. */ virtual bool needExchange(size_t id) = 0; private: /// list of ExchangeEntity that manages the data to exchange. std::vector<std::unique_ptr<ExchangeEntity>> helpers_; }; } // namespace mirheo
35.619048
106
0.705214
[ "object", "vector" ]
95c5700600e3da912b6cd98c7d8e7a6f56e94e1c
8,062
h
C
Libraries/RobsJuceModules/jura_processors/filters/jura_EngineersFilter.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
34
2017-04-19T18:26:02.000Z
2022-02-15T17:47:26.000Z
Libraries/RobsJuceModules/jura_processors/filters/jura_EngineersFilter.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
307
2017-05-04T21:45:01.000Z
2022-02-03T00:59:01.000Z
Libraries/RobsJuceModules/jura_processors/filters/jura_EngineersFilter.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
4
2017-09-05T17:04:31.000Z
2021-12-15T21:24:28.000Z
#ifndef jura_EngineersFilter_h #define jura_EngineersFilter_h // to quickly switch between old and new implementation during debugging - get rid later typedef rosic::rsEngineersFilterStereo EFLT; // elliptic bandpass (among others) doesn't work //typedef rosic::rsEngineersFilterOld EFLT; /** This class wraps rosic::EngineersFilter into a rosof::AudioModule to facilitate its use as plugIn. */ class EngineersFilterAudioModule : public AudioModule { friend class EngineersFilterModuleEditor; public: /** Constructor to use when you want to wrap an existing rosic::EngineersFilter object without this AudioModule taking ownership (suitable, if the object already exists a smember of some higher level dsp object). */ EngineersFilterAudioModule(CriticalSection *newPlugInLock, EFLT *sciFilterToWrap); /** Constructor to use ehen there's no existing rosic::EngineersFilter object to be wrapped. in this case, we'll create one here and take over ownership (i.e. will also delete it in our destructor). */ EngineersFilterAudioModule(CriticalSection *newPlugInLock); void init(); virtual ~EngineersFilterAudioModule(); AudioModuleEditor* createEditor(int type) override; virtual void setSampleRate(double newSampleRate) override { wrappedEngineersFilter->setSampleRate(newSampleRate); } virtual void processBlock(double **inOutBuffer, int numChannels, int numSamples) override { for(int n = 0; n < numSamples; n++) wrappedEngineersFilter->getSampleFrameStereo(&inOutBuffer[0][n], &inOutBuffer[1][n]); //wrappedEngineersFilter->getSampleFrameDirect1(&inOutBuffer[0][n], &inOutBuffer[1][n]); } virtual void reset() override { wrappedEngineersFilter->reset(); } protected: void createParameters(); EFLT *wrappedEngineersFilter; bool wrappedEngineersFilterIsOwned = false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EngineersFilterAudioModule) }; //================================================================================================= /** This class plots the frequency responses of a rosic::EngineersFilter object and allows for editing parameters like the cutoff frequencies. */ class EngineersFilterPlotEditor : virtual public rsSpectrumPlot, public ChangeBroadcaster , public ParameterObserver { /** Enumeration of the handles that can be grabbed and dragged by the mouse. */ enum dragHandles { NONE = 0, LOW_MID, MID_HIGH }; public: //----------------------------------------------------------------------------------------------- // construction/destruction: /** Constructor. */ EngineersFilterPlotEditor(const juce::String& name = "EngineersFilterPlotEditor"); /** Destructor. */ virtual ~EngineersFilterPlotEditor(); //----------------------------------------------------------------------------------------------- // setup: /** Passes a pointer the the actual rosic::EngineersFilter object which is to be edited. */ virtual void setEngineersFilterToEdit(EFLT* newEngineersFilterToEdit); // functions to assign the parameters, we observe (in order to update the plot) and possibly // later also to manipulated them: void assign(Parameter*& target, Parameter* p) { target = p; p->registerParameterObserver(this);} void assignParameterMode( Parameter* p) { assign(modeParam, p); } void assignParameterMethod( Parameter* p) { assign(methodParam, p); } void assignParameterOrder( Parameter* p) { assign(orderParam, p); } void assignParameterFrequency(Parameter* p) { assign(freqParam, p); } void assignParameterBandwidth(Parameter* p) { assign(bandwidthParam, p); } void assignParameterGain( Parameter* p) { assign(gainParam, p); } void assignParameterRipple( Parameter* p) { assign(rippleParam, p); } void assignParameterRejection(Parameter* p) { assign(rejectionParam, p); } //----------------------------------------------------------------------------------------------- // callbacks: virtual void parameterChanged(Parameter* param) override; //virtual void parameterChanged(Parameter* parameterThatHasChanged); //virtual void parameterWillBeDeleted(Parameter* parameterThatWillBeDeleted); /** This method is called when one of the assigned rosic::AutomatableParameters has been changed. We override it here in the subclass to do the actual GUI update. */ virtual void updateWidgetFromAssignedParameter(bool sendMessage = false); /** Overrides the changeListetnerCcallback in order to receive messages which this object sends to itself. */ virtual void changeListenerCallback(ChangeBroadcaster *objectThatHasChanged); /** Overrides mouseMove in order to update the cursor according to what is under the mouse. */ virtual void mouseMove(const MouseEvent &e); /** Overrides mouseDown for adjusting the frequency and resonance and lets a context menu pop up when the right button is clicked for MIDI-learn functionality. */ virtual void mouseDown(const MouseEvent& e); /** Overrides mouseDrag for adjusting the frequency and resonance. */ virtual void mouseDrag(const MouseEvent& e); /** Overrides mouseUp to reset the currentDragHandle to NONE. */ virtual void mouseUp(const MouseEvent& e); /** Overrides the resized-method. */ virtual void resized(); /** Updates the frequency response plot. */ virtual void updatePlot(); protected: /** Returns the handle for mouse grab/drag under the specified position (in pixels) as one of the values in enum dragHandles. */ virtual int getDragHandleAt(int x, int y); /** Does the setup of the filter according to some new mouse position) */ virtual void setupFilterAccordingToMousePosition(double mouseX, double mouseY); /** Overrides CurveFamilyPlot::plotCurveFamily in order to additionally draw the handles. */ virtual void plotCurveFamily(Graphics &g, juce::Image *targetImage = NULL, XmlElement *targetSVG = NULL); /** Pointer to the actual rosic::EngineersFilter object which is being edited. */ //rosic::rsEngineersFilterStereo* sciFilterToEdit; EFLT* sciFilterToEdit; // the parameters which wil cause re-plotting and therefore must be listened to: //Parameter *lowFreqParameter, *lowSlopeParameter, *highFreqParameter, *highSlopeParameter; Parameter *modeParam, *methodParam, *orderParam, *freqParam, *bandwidthParam, *gainParam, *rippleParam, *rejectionParam; // magnitude response display stuff: int numBins; double *frequencies, *magnitudes; //double *lowpassMagnitudes, *bandpassMagnitudes, *highpassMagnitudes; //double **allMagnitudes; int currentlyDraggedHandle; juce_UseDebuggingNewOperator; }; //================================================================================================= /** Editor for EngineersFilterAudioModule */ class EngineersFilterModuleEditor : public AudioModuleEditor, public ParameterObserver { public: //--------------------------------------------------------------------------------------------- // construction/destruction: EngineersFilterModuleEditor(CriticalSection *newPlugInLock, EngineersFilterAudioModule* newEngineersFilterAudioModule); // todo: get rid of newPlugInLock parameter virtual ~EngineersFilterModuleEditor(); //--------------------------------------------------------------------------------------------- // callbacks: virtual void resized() override; virtual void parameterChanged(Parameter* param) override; virtual void updateWidgetsAccordingToState() override; protected: virtual void createWidgets(); /** Makes currently required widgets visible and currently not required widgets invisible. */ virtual void updateWidgetVisibility(); EngineersFilterAudioModule *sciFilterModuleToEdit; EngineersFilterPlotEditor *plotEditor; RNamedComboBox *modeComboBox, *methodComboBox; RSlider *frequencySlider, *orderSlider, *bandwidthSlider, *gainSlider, *rippleSlider, *rejectionSlider; juce_UseDebuggingNewOperator; }; #endif
35.991071
100
0.692384
[ "object" ]
95d5d1d6003d75f0aa920ae373a905190da60bd6
32,011
c
C
sdk-6.5.20/src/bcm/dpp/failover.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/src/bcm/dpp/failover.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/src/bcm/dpp/failover.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/* * * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. */ #ifdef _ERR_MSG_MODULE_NAME #error "_ERR_MSG_MODULE_NAME redefined" #endif #define _ERR_MSG_MODULE_NAME BSL_BCM_FAILOVER #include <shared/bsl.h> #include "bcm_int/common/debug.h" #include <bcm_int/dpp/gport_mgmt.h> #include <bcm_int/dpp/utils.h> #include <bcm_int/dpp/error.h> #include <bcm_int/dpp/alloc_mngr.h> #include <bcm_int/dpp/switch.h> #include <bcm_int/control.h> #include <bcm/error.h> #include <bcm/debug.h> #include <bcm/l2.h> #include <bcm/failover.h> #include <bcm/multicast.h> #include <bcm_int/common/multicast.h> #include <bcm_int/dpp/multicast.h> #include <bcm_int/petra_dispatch.h> #include <bcm_int/dpp/failover.h> #include <soc/dpp/PPD/ppd_api_lif.h> #include <soc/dpp/PPD/ppd_api_vsi.h> #include <soc/dpp/PPD/ppd_api_lif_table.h> #include <soc/dpp/PPD/ppd_api_frwrd_fec.h> #include <soc/dpp/SAND/Utils/sand_framework.h> #include <soc/dpp/mbcm_pp.h> #include <soc/dpp/JER/jer_drv.h> #include <shared/swstate/access/sw_state_access.h> typedef struct _bcm_dpp_failover_bookkeeping_s { int initialized; /* Set to TRUE when Failover module initialized */ } _bcm_dpp_failover_bookkeeping_t; _bcm_dpp_failover_bookkeeping_t _bcm_dpp_failover_bk_info[BCM_MAX_NUM_UNITS] = { {0} }; /* SW state for Failover */ #define _DPP_FAILOVER_INFO(_unit_) (&_bcm_dpp_failover_bk_info[_unit_]) #define FAILOVER_ACCESS sw_state_access[unit].dpp.bcm.failover /* * Function: * bcm_dpp_failover_check_init * Purpose: * Check if failover is initialized * Parameters: * unit - Device Number * Returns: * BCM_E_XXX */ STATIC int _bcm_dpp_failover_check_init( int unit) { BCMDNX_INIT_FUNC_DEFS; BCM_DPP_UNIT_CHECK(unit); if (!_bcm_dpp_failover_bk_info[unit].initialized) { BCMDNX_ERR_EXIT_MSG(BCM_E_INIT, (_BSL_BCM_MSG("not initialized"))); } else { BCM_EXIT; } exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_flags_to_type * Purpose: * Converts failover creation BCM API flags to an internal Failover Type * that is used for encoding the Failover ID. * Parameters: * unit - Device Number * flags - The failover flags that were used by the BCM API function * failover_type - The returned failover type value that matches the selected * failover flags. * Returns: * BCM_E_PARAM - In case multiple failover ID flags are designated */ int _bcm_dpp_failover_flags_to_type( int unit, uint32 flags, int32 *failover_type) { uint32 nof_failover_type_flags; BCMDNX_INIT_FUNC_DEFS; /* Initiate the returned value in case no failover type flag is supplied */ *failover_type = DPP_FAILOVER_TYPE_NONE; nof_failover_type_flags = 0; /* Set the returned failover type according to the relevant flags*/ if (flags & BCM_FAILOVER_FEC) { *failover_type = DPP_FAILOVER_TYPE_FEC; nof_failover_type_flags++; } if (flags & BCM_FAILOVER_INGRESS) { *failover_type = DPP_FAILOVER_TYPE_INGRESS; nof_failover_type_flags++; } if (flags & BCM_FAILOVER_ENCAP) { *failover_type = DPP_FAILOVER_TYPE_ENCAP; nof_failover_type_flags++; } if (flags & BCM_FAILOVER_L2_LOOKUP) { *failover_type = DPP_FAILOVER_TYPE_L2_LOOKUP; nof_failover_type_flags++; } /* Return an error if more than one failover type flag was designated */ if (nof_failover_type_flags > 1) { *failover_type = DPP_FAILOVER_TYPE_NONE; BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Multiple failover ID flags aren't allowed"))); } exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_get_nof_failover_ids_by_type * Purpose: * Retrieve the number of failover IDs of a failover table per failover type * Parameters: * unit - Device Number * failover_type - The failover type of the failover table. * nof_failover_ids - The retrieved number of failover IDs for the table. * Returns: * BCM_E_INTERNAL - Unsupported failover type */ int _bcm_dpp_get_nof_failover_ids_by_type( int unit, int32 failover_type, uint32 *nof_failover_ids) { BCMDNX_INIT_FUNC_DEFS; switch (failover_type) { case DPP_FAILOVER_TYPE_L2_LOOKUP: case DPP_FAILOVER_TYPE_FEC: *nof_failover_ids = SOC_DPP_DEFS_GET(unit, nof_failover_fec_ids); break; case DPP_FAILOVER_TYPE_INGRESS: *nof_failover_ids = SOC_DPP_DEFS_GET(unit, nof_failover_ingress_ids); /* Coupled mode enables only half the valid range as 1 bit from the path pointer is used in the HW for the failover path value. */ if (SOC_IS_JERICHO(unit) && (SOC_DPP_IS_PROTECTION_INGRESS_COUPLED(unit))) { *nof_failover_ids >>= 1; } break; case DPP_FAILOVER_TYPE_ENCAP: *nof_failover_ids = SOC_DPP_DEFS_GET(unit, nof_failover_egress_ids); /* Coupled mode enables only half the valid range as 1 bit from the path pointer is used in the HW for the failover path value. */ if (SOC_IS_JERICHO(unit) && (SOC_DPP_IS_PROTECTION_EGRESS_COUPLED(unit))) { *nof_failover_ids >>= 1; } break; default: BCMDNX_ERR_EXIT_MSG(BCM_E_INTERNAL, (_BSL_BCM_MSG("Unsupported failover type"))); } exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_is_valid_type * Purpose: * Validates a failover type * Parameters: * unit - Device Number * failover_type - The validated failover type * Returns: * FALSE - The failover type is Invalid * TRUE - The failover type is Valid */ int _bcm_dpp_failover_is_valid_type( int unit, int32 failover_type) { BCMDNX_INIT_FUNC_DEFS; switch (failover_type) { case DPP_FAILOVER_TYPE_ENCAP: if (SOC_IS_ARADPLUS_AND_BELOW(unit)) { return FALSE; } case DPP_FAILOVER_TYPE_L2_LOOKUP: case DPP_FAILOVER_TYPE_FEC: case DPP_FAILOVER_TYPE_INGRESS: return TRUE; default: break; } return FALSE; BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_is_valid_id * Purpose: * Validates a failover ID by checking the value range that is appropriate * for the encoded failover type * Parameters: * unit - Device Number * failover_id - The validated failover ID * failover_type_match - The required Failover type to compare with the * failover type that is encoded in the failover ID * Returns: * BCM_E_NONE - The failover ID is Valid * BCM_E_XXX - The failover ID is Invalid */ int _bcm_dpp_failover_is_valid_id( int unit, int32 failover_id, int32 failover_type_match) { uint32 nof_failover_ids, failover_id_val; int32 failover_type; int rv; BCMDNX_INIT_FUNC_DEFS; /* Get the encoded failover type from the supplied failover ID */ DPP_FAILOVER_TYPE_GET(failover_type, failover_id); /* Verify that the encoded failover type matches the required failover type */ if (failover_type != failover_type_match) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("The failover ID has incompatible failover type %d, expected %d"), failover_type, failover_type_match)); } /* Get the upper range for the failover ID accrding to the failover type */ rv = _bcm_dpp_get_nof_failover_ids_by_type(unit, failover_type, &nof_failover_ids); BCMDNX_IF_ERR_EXIT(rv); /* Verify that the supplied failover ID is within the upper range */ DPP_FAILOVER_ID_GET(failover_id_val, failover_id); if (failover_id_val > nof_failover_ids) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("The failover ID is out of range - %d"), failover_id_val)); } return BCM_E_NONE; exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_state_hw_set * Purpose: * Set the failover state to the HW by calling the relevant SOC API * function according to the failover type * Parameters: * unit - Device Number * failover_id - The failover ID with no encoded failover type * failover_type - The type of failover to set * failover_status - The new failover state * Returns: * BCM_E_XXX - HW access failure */ int _bcm_dpp_failover_state_hw_set( int unit, int32 failover_id, int32 failover_type, uint8 failover_status) { unsigned int soc_sand_dev_id; uint32 soc_sand_rv; soc_error_t soc_rv; BCMDNX_INIT_FUNC_DEFS; soc_sand_dev_id = (unit); /* Up till Arad+, a common HW table is used */ if (SOC_IS_ARADPLUS_AND_BELOW(unit)) { soc_sand_rv = soc_ppd_frwrd_fec_protection_oam_instance_status_set(soc_sand_dev_id, failover_id, failover_status); SOCDNX_SAND_IF_ERR_EXIT(soc_sand_rv); } else { /* Set the HW state according to the failover type */ switch (failover_type) { case DPP_FAILOVER_TYPE_FEC: soc_sand_rv = soc_ppd_frwrd_fec_protection_oam_instance_status_set(soc_sand_dev_id, failover_id, failover_status); SOCDNX_SAND_IF_ERR_EXIT(soc_sand_rv); break; case DPP_FAILOVER_TYPE_INGRESS: soc_rv = (MBCM_PP_DRIVER_CALL(unit, mbcm_pp_ingress_protection_state_set,(unit, failover_id, failover_status))); BCMDNX_IF_ERR_EXIT(soc_rv); break; case DPP_FAILOVER_TYPE_ENCAP: soc_rv = (MBCM_PP_DRIVER_CALL(unit, mbcm_pp_egress_protection_state_set,(unit, failover_id, failover_status))); BCMDNX_IF_ERR_EXIT(soc_rv); break; default: BCMDNX_ERR_EXIT_MSG(BCM_E_INTERNAL, (_BSL_BCM_MSG("Failover type %d not supported"), failover_type)); } } exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_state_hw_get * Purpose: * Retrieve the failover state from the HW by calling the relevant SOC API * function according to the failover type * Parameters: * unit - Device Number * failover_id - The failover ID with no encoded failover type * failover_type - The type of failover to set * failover_status - The return failover state * Returns: * BCM_E_XXX - HW access failure */ int _bcm_dpp_failover_state_hw_get( int unit, int32 failover_id, int32 failover_type, uint8 *failover_status) { unsigned int soc_sand_dev_id; uint32 soc_sand_rv; int soc_rv; BCMDNX_INIT_FUNC_DEFS; soc_sand_dev_id = (unit); /* Up till Arad+, a common HW table is used */ if (SOC_IS_ARADPLUS_AND_BELOW(unit)) { soc_sand_rv = soc_ppd_frwrd_fec_protection_oam_instance_status_get(soc_sand_dev_id, failover_id, failover_status); SOCDNX_SAND_IF_ERR_EXIT(soc_sand_rv); } else { /* Set the HW state according to the failover type */ switch (failover_type) { case DPP_FAILOVER_TYPE_FEC: soc_sand_rv = soc_ppd_frwrd_fec_protection_oam_instance_status_get(soc_sand_dev_id, failover_id, failover_status); SOCDNX_SAND_IF_ERR_EXIT(soc_sand_rv); break; case DPP_FAILOVER_TYPE_INGRESS: soc_rv = (MBCM_PP_DRIVER_CALL(unit, mbcm_pp_ingress_protection_state_get,(unit, failover_id, failover_status))); BCMDNX_IF_ERR_EXIT(soc_rv); break; case DPP_FAILOVER_TYPE_ENCAP: soc_rv = (MBCM_PP_DRIVER_CALL(unit, mbcm_pp_egress_protection_state_get,(unit, failover_id, failover_status))); BCMDNX_IF_ERR_EXIT(soc_rv); break; default: BCMDNX_ERR_EXIT_MSG(BCM_E_INTERNAL, (_BSL_BCM_MSG("Failover type %d not supported"), failover_type)); } } exit: BCMDNX_FUNC_RETURN; } /* * Function: * _bcm_dpp_failover_create_verify * Purpose: * Validate the parameters that are supplied to bcm_petra_failover_create() * Parameters: * unit - Device Number * flags - The flags field that is supplied to bcm_petra_failover_create() * failover_id - The failover ID that is supplied to bcm_petra_failover_create() * failover_type - The failover type that was decoded from the failover_id * Returns: * BCM_E_XXX - Parameter validation failure */ int _bcm_dpp_failover_create_verify( int unit, uint32 flags, bcm_failover_t *failover_id, int32 failover_type) { int rv; BCMDNX_INIT_FUNC_DEFS; /* Verify that the failover module is initiated */ rv = _bcm_dpp_failover_check_init(unit); BCMDNX_IF_ERR_EXIT(rv); /* Verify that the failover ID contains a valid failover type */ if (failover_type == DPP_FAILOVER_TYPE_NONE) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("A failover type flag must be selected"))); } /* Verify that the supplied flags are consistent */ if( (flags & BCM_FAILOVER_REPLACE) && !(flags & BCM_FAILOVER_WITH_ID)) { /* Replace without ID*/ BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Supply REPLACE flag with WITH_ID flag"))); } /* Egress Protection isn't supported prior to the Jericho device */ if (!(SOC_IS_JERICHO(unit))) { if ((failover_type == DPP_FAILOVER_TYPE_ENCAP) || (flags & BCM_FAILOVER_PAIRED)) { BCMDNX_ERR_EXIT_MSG(BCM_E_UNAVAIL, (_BSL_BCM_MSG("Egress failover ID allocation isn't supported prior to the Jericho device"))); } } /* Verify that a request for an allocation of a pair of failover IDs is performed only in the context of Egress failover and only when in egress decoupled mode. */ if (flags & BCM_FAILOVER_PAIRED) { if (failover_type != DPP_FAILOVER_TYPE_ENCAP) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Allocating a pair of failover IDs is available only for Egress failover type"))); } if (SOC_DPP_IS_PROTECTION_EGRESS_COUPLED(unit)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Allocating a pair of failover IDs is available only when in Egress Decoupled mode"))); } } exit: BCMDNX_FUNC_RETURN; } /* * Function: * bcm_petra_failover_reset * Purpose: * Resets all failover SW object allocations. * The failover type L2_LOOKUP isn't supported as the failover ID in this * case represents a FEC entry that shouldn't be reset in other cases. * Parameters: * unit - Device Number * Returns: * BCM_E_XXX */ STATIC int bcm_petra_failover_reset( int unit) { int rv; int failover_id, failover_type, failover_types[] = { DPP_FAILOVER_TYPE_FEC, DPP_FAILOVER_TYPE_INGRESS, DPP_FAILOVER_TYPE_ENCAP }; uint32 nof_failover_tables, nof_failover_ids, failover_type_idx; BCMDNX_INIT_FUNC_DEFS; /* Set the Number of Failover tables to reset according to the device. Up till Arad+, one common failover table is used. */ nof_failover_tables = ((SOC_IS_ARADPLUS_AND_BELOW(unit)) ? 1 : (sizeof(failover_types) / sizeof(failover_types[0]))); /* Traverse the failover types that require reset */ for (failover_type_idx = 0; failover_type_idx < nof_failover_tables; ++failover_type_idx ) { /* Get the failover ID range for the type */ failover_type = failover_types[failover_type_idx]; rv = _bcm_dpp_get_nof_failover_ids_by_type(unit, failover_type, &nof_failover_ids); BCMDNX_IF_ERR_EXIT(rv); /* Traverse all the failover IDs for failover type */ for (failover_id = 1; failover_id < nof_failover_ids; ++failover_id) { /* Check whether the failover is allocated before de-allocation */ rv = bcm_dpp_am_failover_is_alloced(unit, failover_type, failover_id); if (rv != BCM_E_EXISTS) { continue; } rv = bcm_dpp_am_failover_dealloc(unit, failover_type, 1, failover_id); if (rv != BCM_E_NOT_FOUND) { BCMDNX_IF_ERR_EXIT(rv); } } } /* FIX: replace by one call for alloc-mngr to do it faster */ exit: BCMDNX_FUNC_RETURN; } /* initialize all SW/HW resource used by this module * if already initialized then "reset" status. * if not initialized allocate all need SW resources */ int bcm_petra_failover_init( int unit) { int rv; uint8 is_allocated; _bcm_dpp_failover_bookkeeping_t *failover_info = _DPP_FAILOVER_INFO(unit); BCMDNX_INIT_FUNC_DEFS; BCM_DPP_UNIT_CHECK(unit); if (!SOC_WARM_BOOT(unit)) { /* For Jericho, Allocate a SW DB for Egress Protection */ if (SOC_IS_JERICHO(unit)) { /* set up initial values for VLAN state */ BCMDNX_IF_ERR_EXIT(FAILOVER_ACCESS.is_allocated(unit, &is_allocated)); if (!is_allocated) { BCMDNX_IF_ERR_EXIT(FAILOVER_ACCESS.alloc(unit)); } } /* * This shouldn't be done in WB as the reset deletes alloc_mngr * allocations that were already restored as part of the WB init process. */ if (failover_info->initialized) { rv = bcm_petra_failover_reset(unit); BCMDNX_IF_ERR_EXIT(rv); } /* Set the HW status for ingress drop failover-id */ rv = _bcm_dpp_failover_state_hw_set(unit, _BCM_INGRESS_PROTECTION_POINTER_INVALID, DPP_FAILOVER_TYPE_INGRESS, 0); BCMDNX_IF_ERR_EXIT(rv); } /* FIX: allocate alloc-mngr if not initialized*/ failover_info->initialized = 1; exit: BCMDNX_FUNC_RETURN; } /* free all SW/HW resource used by this module */ int bcm_petra_failover_cleanup( int unit) { int rv; _bcm_dpp_failover_bookkeeping_t *failover_info = _DPP_FAILOVER_INFO(unit); BCMDNX_INIT_FUNC_DEFS; /* if not initialized yet, nothing to do */ if (FALSE == failover_info->initialized) { BCM_EXIT; } /* do the clean */ /* HW: * no need to update HW, as resource is not in use * when allocated it will be reset */ /* * SW: Destroy sw resources used for Failover-id */ rv = bcm_petra_failover_reset(unit); BCMDNX_IF_ERR_EXIT(rv); failover_info->initialized = 0; exit: BCMDNX_FUNC_RETURN; } /* * Function: * bcm_petra_failover_create * Purpose: * Creates a failover object. * The object is allocated in the SW using the alloc manager mechanism before * the HW entry can be used. * In general the failover object is a Protection Pointer, while for Ring * Protection (L2_LOOKUP) the object is a FEC entry. * Parameters: * unit - Device Number * flags - The failover flags that were used by the BCM API function * failover_id - The returned failover ID, encoded with the failover type. * In case of a REPLACE operation, the specified failover ID is * used, although the type doesn't have to be encoded in it. * Returns: * BCM_E_PARAM - In case multiple failover ID flags are designated */ int bcm_petra_failover_create( int unit, uint32 flags, bcm_failover_t *failover_id) { int rv = BCM_E_NONE; int alloc_flags = 0; unsigned int soc_sand_dev_id; uint32 soc_sand_rv; SOC_PPC_FEC_ID fec_id = 0; SOC_PPC_FRWRD_FEC_ENTRY_INFO hw_fec_entry_info; SOC_PPC_FRWRD_FEC_PROTECT_INFO protect_info; uint8 fec_success; int32 failover_type, nof_alloc_ids = 1, failover_id_idx; bcm_failover_t tmp_failover_id; BCMDNX_INIT_FUNC_DEFS; BCM_DPP_UNIT_CHECK(unit); soc_sand_dev_id = (unit); rv = _bcm_dpp_failover_check_init(unit); BCMDNX_IF_ERR_EXIT(rv); /* Convert the Failover creation flags to an internal failover type for encoding in the failover ID */ rv = _bcm_dpp_failover_flags_to_type(unit, flags, &failover_type); BCMDNX_IF_ERR_EXIT(rv); if (failover_type == DPP_FAILOVER_TYPE_NONE) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("A failover type flag must be selected"))); } /* Validate the parameters */ rv = _bcm_dpp_failover_create_verify(unit, flags, failover_id, failover_type); BCMDNX_IF_ERR_EXIT(rv); /* Set the alloc manager flags */ tmp_failover_id = 0; if (flags & BCM_FAILOVER_WITH_ID) { if ((failover_type == DPP_FAILOVER_TYPE_INGRESS) && (*failover_id == _BCM_INGRESS_PROTECTION_POINTER_INVALID)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover ID"))); } alloc_flags |= BCM_DPP_AM_FLAG_ALLOC_WITH_ID; DPP_FAILOVER_TYPE_RESET(tmp_failover_id, *failover_id); } /* L2 Lookup mode (Arad only) is a Ring Protection mode that requires a a special failover group. This group doesn't require any failover typical resources, but allocates a FEC object instead */ if ((failover_type == DPP_FAILOVER_TYPE_L2_LOOKUP)) { fec_id = tmp_failover_id; if (!(flags & BCM_FAILOVER_REPLACE)) { /* Allocate a SW DB entry for the allocated FEC */ rv = bcm_dpp_am_fec_alloc(unit, alloc_flags, 0, 1, &fec_id); BCMDNX_IF_ERR_EXIT(rv); /* Set a default HW FEC Entry. The FEC fields will be set again upon vlan-port associations to the failover group */ SOC_PPC_FRWRD_FEC_ENTRY_INFO_clear(&hw_fec_entry_info); hw_fec_entry_info.type = SOC_PPC_FEC_TYPE_SIMPLE_DEST; SOC_PPC_FRWRD_FEC_PROTECT_INFO_clear(&protect_info); soc_sand_rv = soc_ppd_frwrd_fec_entry_add(soc_sand_dev_id, fec_id, SOC_PPC_FRWRD_FEC_PROTECT_TYPE_NONE, &hw_fec_entry_info, /* Working */ NULL, /* Protection */ &protect_info, &fec_success); BCM_SAND_IF_ERR_EXIT(soc_sand_rv); } tmp_failover_id = fec_id; } else { /* If the allocation is for a pair of Egress failover IDs */ if (flags & BCM_FAILOVER_PAIRED) { nof_alloc_ids = 2; } /* For all non Ring-Protection failover types, a failover object should be allocated */ rv = bcm_dpp_am_failover_alloc(unit, alloc_flags, failover_type, nof_alloc_ids, &tmp_failover_id); BCMDNX_IF_ERR_EXIT(rv); /* Set the SW state for Egress failover to the number of subsequent failover ID allocations */ if (failover_type == DPP_FAILOVER_TYPE_ENCAP) { rv = FAILOVER_ACCESS.id_sequence.set(unit, tmp_failover_id, (uint8)nof_alloc_ids); BCMDNX_IF_ERR_EXIT(rv); } /* Clean up the HW status of the allocated failover-id */ for (failover_id_idx = 0; failover_id_idx < nof_alloc_ids; failover_id_idx++) { rv = _bcm_dpp_failover_state_hw_set(unit, tmp_failover_id + failover_id_idx, failover_type, 1); BCM_SAND_IF_ERR_EXIT(rv); } } /* Encode the failover type into the failover ID */ DPP_FAILOVER_TYPE_SET(*failover_id, tmp_failover_id, failover_type); exit: BCMDNX_FUNC_RETURN; } /* * Function: * bcm_petra_failover_destroy * Purpose: * Destroys a failover object. * The object is deallocated in the SW using the alloc manager mechanism. * In general the failover object is a Protection Pointer, while for Ring * Protection (L2_LOOKUP) the object is a FEC entry. * Parameters: * unit - Device Number * failover_id - The failover ID that should be destroyed. * The ID should include an encoded failover type in order to * address the relevant object. * Returns: * BCM_E_PARAM - In case multiple failover ID flags are designated */ int bcm_petra_failover_destroy( int unit, bcm_failover_t failover_id) { SOC_PPC_FEC_ID fec_id; int rv = BCM_E_NONE; uint32 soc_sand_rv, failover_id_val; unsigned int soc_sand_dev_id; int32 failover_type, nof_alloc_ids = 1, reset_value = 0; uint8 uint8_nof_alloc_ids; BCMDNX_INIT_FUNC_DEFS; BCM_DPP_UNIT_CHECK(unit); soc_sand_dev_id = (unit); rv = _bcm_dpp_failover_check_init(unit); BCMDNX_IF_ERR_EXIT(rv); /* Get the encoded failover type value from the supplied failover ID */ DPP_FAILOVER_TYPE_GET(failover_type, failover_id); /* Validate the failover type */ if (_bcm_dpp_failover_is_valid_type(unit, failover_type) == FALSE) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover type in Failover ID."))); } /* Get the encoded failover ID value from the supplied failover ID */ DPP_FAILOVER_ID_GET(failover_id_val, failover_id); if ((failover_type == DPP_FAILOVER_TYPE_INGRESS) && (failover_id_val == _BCM_INGRESS_PROTECTION_POINTER_INVALID)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover ID"))); } /* Check whether the failover id is of type L2 Lookup (Arad only) */ if ((DPP_FAILOVER_IS_L2_LOOKUP(failover_id))) { /* Free the HW Entry */ DPP_FAILOVER_TYPE_RESET(fec_id, failover_id); soc_sand_rv = soc_ppd_frwrd_fec_remove(soc_sand_dev_id, fec_id); BCM_SAND_IF_ERR_EXIT(soc_sand_rv); /* De-allocate the SW DB FEC entry */ rv = bcm_dpp_am_fec_dealloc(unit, 0 /*flags*/, 1 /*size*/, fec_id); BCMDNX_IF_ERR_EXIT(rv); BCM_EXIT; } /* De-allocate the failover ID */ /* If Egress failover, get the number of subsequent failover ID allocations from the SW DB, before resetting the value */ if (failover_type == DPP_FAILOVER_TYPE_ENCAP) { rv = FAILOVER_ACCESS.id_sequence.get(unit, failover_id_val, &uint8_nof_alloc_ids); BCMDNX_IF_ERR_EXIT(rv); nof_alloc_ids = uint8_nof_alloc_ids; uint8_nof_alloc_ids = reset_value; rv = FAILOVER_ACCESS.id_sequence.set(unit, failover_id_val, uint8_nof_alloc_ids); BCMDNX_IF_ERR_EXIT(rv); } /* Perform the de-allocation */ rv = bcm_dpp_am_failover_dealloc(unit, failover_type, nof_alloc_ids, failover_id_val); BCMDNX_IF_ERR_EXIT(rv); exit: BCMDNX_FUNC_RETURN; } /* * Function: * bcm_petra_failover_get * Purpose: * Retrieve a failover object state. * The state is retrieved from the appropriate HW failover table according * to the failover type that is encoded in the failover ID. * The failover type L2_LOOKUP isn't supported as the failover ID in this * case represents a FEC entry that has no state. * Parameters: * unit - Device Number * failover_id - The failover ID for which the state is retrieved. * The ID should include an encoded failover type in order to * address the relevant object. * enable - The retrieved failover state (0 / 1) * Returns: * BCM_E_PARAM - Unsupported failover ID value */ int bcm_petra_failover_get( int unit, bcm_failover_t failover_id, int * enable) { int rv = BCM_E_NONE; uint8 failover_status; int32 failover_type; uint32 failover_id_val; BCMDNX_INIT_FUNC_DEFS; rv = _bcm_dpp_failover_check_init(unit); BCMDNX_IF_ERR_EXIT(rv); /* Get the encoded failover type from the supplied failover ID */ DPP_FAILOVER_TYPE_GET(failover_type, failover_id); /* Validate the failover type */ if (_bcm_dpp_failover_is_valid_type(unit, failover_type) == FALSE) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover type in Failover ID."))); } /* Verify that the failover is allocated in a failover table */ DPP_FAILOVER_ID_GET(failover_id_val, failover_id); if ((failover_type == DPP_FAILOVER_TYPE_INGRESS) && (failover_id_val == _BCM_INGRESS_PROTECTION_POINTER_INVALID)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover ID"))); } rv = bcm_dpp_am_failover_is_alloced(unit, failover_type, failover_id_val); if (rv != BCM_E_EXISTS) { BCMDNX_ERR_EXIT_MSG(BCM_E_NOT_FOUND, (_BSL_BCM_MSG("Failover ID not allocated"))); } /* Get the failover state from the HW */ rv = _bcm_dpp_failover_state_hw_get(unit, failover_id_val, failover_type, &failover_status); BCMDNX_IF_ERR_EXIT(rv); /* Store the retrieved state*/ *enable = failover_status; exit: BCMDNX_FUNC_RETURN; } /* * Function: * bcm_petra_failover_set * Purpose: * Set a failover object state. * The state is set to the appropriate HW failover table according * to the failover type that is encoded in the failover ID. * The failover type L2_LOOKUP isn't supported as the failover ID in this * case represents a FEC entry that has no state. * Parameters: * unit - Device Number * failover_id - The failover ID to which the state is set. * The ID should include an encoded failover type in order to * address the relevant object. * enable - The failover state vlaue (TRUE / FALSE) * Returns: * BCM_E_PARAM - Unsupported failover ID or enable state */ int bcm_petra_failover_set( int unit, bcm_failover_t failover_id, int enable) { int rv = BCM_E_NONE; int32 failover_type; uint32 failover_id_val; BCMDNX_INIT_FUNC_DEFS; BCM_DPP_UNIT_CHECK(unit); rv = _bcm_dpp_failover_check_init(unit); BCMDNX_IF_ERR_EXIT(rv); /* Validate the failover state to set */ if ((enable < 0) || (enable > 1)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("enable has to be 0 or 1"))); } /* Get the encoded failover type from the supplied failover ID */ DPP_FAILOVER_TYPE_GET(failover_type, failover_id); /* Validate the failover type */ if (_bcm_dpp_failover_is_valid_type(unit, failover_type) == FALSE) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover type in Failover ID."))); } /* Verify that the failover is allocated in a failover table */ DPP_FAILOVER_ID_GET(failover_id_val, failover_id); if ((failover_type == DPP_FAILOVER_TYPE_INGRESS) && (failover_id_val == _BCM_INGRESS_PROTECTION_POINTER_INVALID)) { BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM, (_BSL_BCM_MSG("Invalid Failover ID"))); } rv = bcm_dpp_am_failover_is_alloced(unit, failover_type, failover_id_val); if (rv != BCM_E_EXISTS) { BCMDNX_ERR_EXIT_MSG(BCM_E_NOT_FOUND, (_BSL_BCM_MSG("Failover ID not allocated"))); } /* Set the failover state to the HW */ rv = _bcm_dpp_failover_state_hw_set(unit, failover_id_val, failover_type, enable); BCMDNX_IF_ERR_EXIT(rv); exit: BCMDNX_FUNC_RETURN; } #if defined(INCLUDE_L3) /* * Set a failover object to enable or disable (note that failover object * 0 is reserved. */ int bcm_petra_failover_status_set(int unit, bcm_failover_element_t *failover, int enable) { BCMDNX_INIT_FUNC_DEFS; BCMDNX_ERR_EXIT_MSG(BCM_E_UNAVAIL, (_BSL_BCM_MSG("Not supported use bcm_petra_failover_set"))); exit: BCMDNX_FUNC_RETURN; } /* * Get a failover object to enable or disable (note that failover object * 0 is reserved. */ int bcm_petra_failover_status_get(int unit, bcm_failover_element_t *failover, int *enable) { BCMDNX_INIT_FUNC_DEFS; BCMDNX_ERR_EXIT_MSG(BCM_E_UNAVAIL, (_BSL_BCM_MSG("Not supported use bcm_petra_failover_get"))); exit: BCMDNX_FUNC_RETURN; } #endif /* INCLUDE_L3 */
33.137681
146
0.678486
[ "object" ]
95d6e8a759fd4f5c70c30c4fc3ebc84985c37056
1,364
h
C
third_party/accessibility/ax/ax_event_bundle_sink.h
rhencke/engine
1016db292c4e73374a0a11536b18303c9522a224
[ "BSD-3-Clause" ]
null
null
null
third_party/accessibility/ax/ax_event_bundle_sink.h
rhencke/engine
1016db292c4e73374a0a11536b18303c9522a224
[ "BSD-3-Clause" ]
null
null
null
third_party/accessibility/ax/ax_event_bundle_sink.h
rhencke/engine
1016db292c4e73374a0a11536b18303c9522a224
[ "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_ACCESSIBILITY_AX_EVENT_BUNDLE_SINK_H_ #define UI_ACCESSIBILITY_AX_EVENT_BUNDLE_SINK_H_ #include <vector> #include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_tree_update.h" namespace gfx { class Point; } // namespace gfx namespace ui { struct AXEvent; class AXTreeID; // Interface for a consumer of groups of AXEvents. class AX_EXPORT AXEventBundleSink { public: // |tree_id|: ID of the accessibility tree that the events apply to. // |updates|: Zero or more updates to the accessibility tree to apply first. // |mouse location|: Current mouse location in screen coordinates. // |events|: Zero or more events to fire after the updates have been applied. // Callers may wish to std::move() into the vector params to avoid copies. virtual void DispatchAccessibilityEvents(const AXTreeID& tree_id, std::vector<AXTreeUpdate> updates, const gfx::Point& mouse_location, std::vector<AXEvent> events) = 0; protected: virtual ~AXEventBundleSink() {} }; } // namespace ui #endif // UI_ACCESSIBILITY_AX_EVENT_BUNDLE_SINK_H_
32.47619
79
0.692815
[ "vector" ]
95e5a31d9607cf1e4f7370a082867d0b267e0bd1
963
h
C
src/cmd.h
zhs007/holdem-core
dc75ea6e38b218e69cf8ec99dbee9e8632d33ba8
[ "MIT" ]
1
2017-05-16T07:26:46.000Z
2017-05-16T07:26:46.000Z
src/cmd.h
zhs007/holdem-core
dc75ea6e38b218e69cf8ec99dbee9e8632d33ba8
[ "MIT" ]
null
null
null
src/cmd.h
zhs007/holdem-core
dc75ea6e38b218e69cf8ec99dbee9e8632d33ba8
[ "MIT" ]
null
null
null
// // Created by zhs007 on 2017/5/16. // #ifndef HOLDEM_CORE_CMD_H #define HOLDEM_CORE_CMD_H #include <string> #include <vector> #include <cstring> #include <functional> #include <map> #include "holdemlogic.h" struct Command{ std::string strCmd; std::vector<std::string> lstParam; }; typedef std::function< void(Command&) > FuncCommand; class CommandMgr{ typedef std::map<std::string, FuncCommand> _Map; typedef std::pair<std::string, FuncCommand> _Pair; public: static CommandMgr& getSingleton(); public: Command* newCommand(const char* cmd); void deleteCommand(Command* pCmd); void procCommand(Command& cmd); void regCommand(const char* str, FuncCommand func); void getCmd(char* strbuf, int len); HoldemLogic& getLogic() { return m_logic; } protected: CommandMgr(); ~CommandMgr(); protected: _Map m_map; HoldemLogic m_logic; }; #endif //HOLDEM_CORE_CMD_H
19.653061
55
0.673936
[ "vector" ]
95e785f7315f2b8f6daaed8408b22d62cf681e47
3,907
h
C
ImageProcessing/Services/Headers/ActiveAreaComputer.h
Eng-RSMY/PorousMediaAnalysis
922327ad1c8d9729a44abe1dfcf35752589b3429
[ "MIT" ]
19
2015-03-13T13:21:56.000Z
2021-09-10T13:17:09.000Z
ImageProcessing/Services/Headers/ActiveAreaComputer.h
Eng-RSMY/PorousMediaAnalysis
922327ad1c8d9729a44abe1dfcf35752589b3429
[ "MIT" ]
2
2020-01-13T17:12:24.000Z
2021-06-15T19:10:11.000Z
ImageProcessing/Services/Headers/ActiveAreaComputer.h
MINATILO/PorousMediaAnalysis
922327ad1c8d9729a44abe1dfcf35752589b3429
[ "MIT" ]
6
2017-09-29T18:50:25.000Z
2021-09-10T13:17:11.000Z
// Copyright (c) 2013 Vasili Baranau // Distributed under the MIT software license // See the accompanying file License.txt or http://opensource.org/licenses/MIT #ifndef ImageProcessing_Services_Headers_ActiveAreaComputer_h #define ImageProcessing_Services_Headers_ActiveAreaComputer_h #include <vector> #include "Core/Headers/Types.h" #include "Core/Headers/Macros.h" #include "ImageProcessing/Model/Headers/Types.h" namespace Model { class Config; } namespace Services { class ActiveAreaComputer { public: ActiveAreaComputer(); void ComputeActiveAreas(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Model::Margin margin, Core::FLOAT_TYPE averageBytesPerPixel, std::vector<Model::ActiveArea>* activeAreas) const; virtual ~ActiveAreaComputer(); private: void FillPossiblePriorityAxes(const std::vector<Core::Axis::Type>& priorityAxes, std::vector<std::vector<Core::Axis::Type> >* possiblePriorityAxes) const; bool ComputeActiveAreasForExactPriorityAxes(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Model::Margin margin, Core::FLOAT_TYPE averageBytesPerPixel, std::vector<Model::ActiveArea>* activeAreas, Core::DiscreteSpatialVector* cellCounts) const; bool ComputeActiveAreasForExactPriorityAxes(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Model::Margin margin, const Core::SpatialVector& internalActiveAreaSize, std::vector<Model::ActiveArea>* activeAreas, Core::DiscreteSpatialVector* cellCounts) const; int GetImageReadsCount(const std::vector<Model::ActiveArea>& activeAreas) const; void CheckMemoryRequirements(const Model::Config& config, Core::FLOAT_TYPE averageBytesPerPixel, const std::vector<Model::ActiveArea>& activeAreas) const; void PrintStatistics(const Model::Config& config, Core::FLOAT_TYPE averageBytesPerPixel, const std::vector<Model::ActiveArea>& activeAreas, Core::DiscreteSpatialVector& cellCounts, int imageReadsCount) const; void FillCellCounts(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Model::Margin margin, Core::SpatialVector internalActiveAreaSize, Core::DiscreteSpatialVector* cellCounts) const; void FillCorrectPrirityAxes(const std::vector<Core::Axis::Type>& priorityAxes, std::vector<Core::Axis::Type>* correctPriorityAxes) const; void FillNonPriorityAxes(const std::vector<Core::Axis::Type>& priorityAxes, std::vector<Core::Axis::Type>* nonPriorityAxes) const; Core::FLOAT_TYPE GetPixelsCountForNonPriorityAxes(const Model::Config& config, Core::FLOAT_TYPE averageBytesPerPixel, const std::vector<Core::Axis::Type>& priorityAxes) const; void FillInternalActiveAreaSize(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Model::Margin margin, Core::FLOAT_TYPE averageBytesPerPixel, Core::SpatialVector* internalActiveAreaSize) const; void FillInternalActiveAreaSizeForZeroMargin(const Model::Config& config, const std::vector<Core::Axis::Type>& priorityAxes, Core::FLOAT_TYPE averageBytesPerPixel, Core::SpatialVector* internalActiveAreaSize) const; void FillActiveBox(const Model::Config& config, Model::Margin margin, const Core::DiscreteSpatialVector& internalActiveAreaSize, const Core::DiscreteSpatialVector& cellCounts, const Core::DiscreteSpatialVector& leftCornerIndexes, Model::Box* activeBox) const; void FillBoxWithMargins(const Model::Config& config, const Model::Box& activeBox, Model::Margin margin, Model::Box* boxWithMargins) const; DISALLOW_COPY_AND_ASSIGN(ActiveAreaComputer); }; } #endif /* ImageProcessing_Services_Headers_ActiveAreaComputer_h */
56.623188
183
0.746609
[ "vector", "model" ]
95e7b317de442e73e6800efc77c6d89e3942f67c
10,725
c
C
src/engine/unit/math/transform.unit.c
aburkhalter512/gameEngine
857b2d298b4a0b18673853574b522afa6b27bbea
[ "MIT" ]
null
null
null
src/engine/unit/math/transform.unit.c
aburkhalter512/gameEngine
857b2d298b4a0b18673853574b522afa6b27bbea
[ "MIT" ]
null
null
null
src/engine/unit/math/transform.unit.c
aburkhalter512/gameEngine
857b2d298b4a0b18673853574b522afa6b27bbea
[ "MIT" ]
null
null
null
#include "engine/unit/math/transform.unit.h" #include "engine/math/float.h" #include "engine/math/polygon.h" #include "engine/math/vec.h" #include "engine/util.h" #include "engine/unit/math/polygon.unit.h" #include <math.h> IMPLEMENT_TEST(getMatrix_transform) { char resultMessage[120]; transform t; MATRIX_TYPE(3, 3) expected; MATRIX_TYPE(3, 3) actual; /////////////////////////////////////////////////////////////////////////// // Scenario: No transformation /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position 0.0f, // rotation to_vec2f(1.0f, 1.0f), //scale }; expected = (MATRIX_TYPE(3, 3)) {{ {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "Scenario 1: matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } /////////////////////////////////////////////////////////////////////////// // Scenario: Only position /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(2.0f, -2.0f), // position 0.0f, // rotation to_vec2f(1.0f, 1.0f), //scale }; expected = (MATRIX_TYPE(3, 3)) {{ {1.0f, 0.0f, 2.0f}, {0.0f, 1.0f, -2.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "Scenario 2: matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } /////////////////////////////////////////////////////////////////////////// // Scenario: Only rotation /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position M_PI / 6, // rotation to_vec2f(1.0f, 1.0f), //scale }; expected = (MATRIX_TYPE(3, 3)) {{ {0.86602f, 0.5f, 0.0f}, {-0.5f, 0.86602f, 0.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "Scenario 3: matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } /////////////////////////////////////////////////////////////////////////// // Scenario: Only scale /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position 0.0f, // rotation to_vec2f(2.0f, -1.0f), //scale }; expected = (MATRIX_TYPE(3, 3)) {{ {2.0f, 0.0f, 0.0f}, {0.0f, -1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "Scenario 4: matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } /////////////////////////////////////////////////////////////////////////// // Scenario: Rotation and scale /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position M_PI / 6, // rotation to_vec2f(2.0f, -1.0f), //scale }; expected = (MATRIX_TYPE(3, 3)) {{ {1.7320, -0.5f, 0.0f}, {-1.0f, -0.86602f, 0.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "Scenario 5: matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } /////////////////////////////////////////////////////////////////////////// // Scenario: Combination of scale + rot + translate /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(2.0f, -2.0f), // position: not 1 or 0 M_PI / 6, // rotation: 30 deg to_vec2f(2.0f, -1.0f), // scale: not 1, 0, or position % 2 == 0 }; expected = (MATRIX_TYPE(3, 3)) {{ {1.7320, -0.5f, 2.0f}, {-1.0f, -0.86602f, -2.0f}, {0.0f, 0.0f, 1.0f}, }}; actual = getMatrix_transform(&t); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { if (!equal_f(actual.data[row][col], expected.data[row][col], DEFAULT_TOLERANCE)) { sprintf(resultMessage, "matrix[%zu][%zu] not computed correctly. Actual value: %.3f, Expected value: %.3f", row, col, actual.data[row][col], expected.data[row][col]); FAIL_TEST(resultMessage); } } } PASS_TEST(); } IMPLEMENT_TEST(_applymMatrix_vec2f) { int offset = 0; char resultMessage[120]; transform t; MATRIX_TYPE(3, 3) transformMatrix; vec2f expected; vec2f actual; /////////////////////////////////////////////////////////////////////////// // Scenario: No transformation /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position 0.0f, // rotation to_vec2f(1.0f, 1.0f), //scale }; transformMatrix = getMatrix_transform(&t); expected = to_vec2f(2.0f, -2.0f); actual = _applymMatrix_vec2f(to_vec2f(2.0f, -2.0f), &transformMatrix); if (!equal_f(0.0f, distance_vec2f(expected, actual), DEFAULT_TOLERANCE)) { offset += sprintf(resultMessage + offset, "Identity transform not applied correctly. expected: "); offset += sprint_vec2f(resultMessage + offset, &expected); offset += sprintf(resultMessage + offset, ", actual: "); offset += sprint_vec2f(resultMessage + offset, &actual); FAIL_TEST(resultMessage); } /////////////////////////////////////////////////////////////////////////// // Scenario: Only scale /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position 0.0f, // rotation to_vec2f(2.0f, 3.0f), //scale }; transformMatrix = getMatrix_transform(&t); expected = to_vec2f(4.0f, -6.0f); actual = _applymMatrix_vec2f(to_vec2f(2.0f, -2.0f), &transformMatrix); if (!equal_f(0.0f, distance_vec2f(expected, actual), DEFAULT_TOLERANCE)) { offset += sprintf(resultMessage + offset, "Scale transform not applied correctly. expected: "); offset += sprint_vec2f(resultMessage + offset, &expected); offset += sprintf(resultMessage + offset, ", actual: "); offset += sprint_vec2f(resultMessage + offset, &actual); FAIL_TEST(resultMessage); } /////////////////////////////////////////////////////////////////////////// // Scenario: Only rotation /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position M_PI / 6, // rotation to_vec2f(1.0f, 1.0f), //scale }; transformMatrix = getMatrix_transform(&t); expected = to_vec2f(0.7320, -2.7320); actual = _applymMatrix_vec2f(to_vec2f(2.0f, -2.0f), &transformMatrix); if (!equal_f(0.0f, distance_vec2f(expected, actual), DEFAULT_TOLERANCE)) { offset += sprintf(resultMessage + offset, "Rotation transform not applied correctly. expected: "); offset += sprint_vec2f(resultMessage + offset, &expected); offset += sprintf(resultMessage + offset, ", actual: "); offset += sprint_vec2f(resultMessage + offset, &actual); FAIL_TEST(resultMessage); } /////////////////////////////////////////////////////////////////////////// // Scenario: Scale and rotation /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(0.0f, 0.0f), // position M_PI / 6, // rotation to_vec2f(2.0f, -1.0f), //scale }; transformMatrix = getMatrix_transform(&t); expected = to_vec2f(4.4641f, -0.2680f); actual = _applymMatrix_vec2f(to_vec2f(2.0f, -2.0f), &transformMatrix); if (!equal_f(0.0f, distance_vec2f(expected, actual), DEFAULT_TOLERANCE)) { offset += sprintf(resultMessage + offset, "Scale + Rotation transform not applied correctly. expected: "); offset += sprint_vec2f(resultMessage + offset, &expected); offset += sprintf(resultMessage + offset, ", actual: "); offset += sprint_vec2f(resultMessage + offset, &actual); FAIL_TEST(resultMessage); } /////////////////////////////////////////////////////////////////////////// // Scenario: Scale, rotation, and position /////////////////////////////////////////////////////////////////////////// t = (transform) { to_vec2f(2.0f, 3.0f), // position M_PI / 6, // rotation to_vec2f(2.0f, -1.0f), //scale }; transformMatrix = getMatrix_transform(&t); expected = to_vec2f(6.4641f, 2.7320f); actual = _applymMatrix_vec2f(to_vec2f(2.0f, -2.0f), &transformMatrix); if (!equal_f(0.0f, distance_vec2f(expected, actual), DEFAULT_TOLERANCE)) { offset += sprintf(resultMessage + offset, "Scale + Rotation + position transform not applied correctly. expected: "); offset += sprint_vec2f(resultMessage + offset, &expected); offset += sprintf(resultMessage + offset, ", actual: "); offset += sprint_vec2f(resultMessage + offset, &actual); FAIL_TEST(resultMessage); } PASS_TEST(); } IMPLEMENT_TEST(applyTransform_polygon) { char resultMsg[320]; vec2f pVertices[3] = { to_vec2f(0.0f, 0.0f), to_vec2f(3.0f, 1.0f), to_vec2f(2.0f, 2.0f), }; polygon p = { pVertices, 3, }; transform t = (transform) { to_vec2f(2.0f, 3.0f), // position -M_PI / 6, // rotation to_vec2f(2.0f, -1.0f), //scale }; vec2f expectedVertices[3] = { to_vec2f(2.0f, 3.0f), to_vec2f(7.696f, 5.134f), to_vec2f(6.464f, 3.268f), }; polygon expected = { expectedVertices, 3, }; polygon actual; if (!applyTransform_polygon(&p, &t, &actual)) { FAIL_TEST("Memory allocation failed"); } if (!verifyPolygon(&actual, &expected, resultMsg, 0)) { FAIL_TEST(resultMsg); } free_polygon(&actual); PASS_TEST(); }
29.223433
182
0.540793
[ "transform" ]
95f13adf319c550a12649d90da01218a553c3cd7
14,101
h
C
source/xmc1_e_eeprom.h
Infineon/mtb-example-xmc-flash-eeprom
61cec70b2dfa846c570e1c3c7317741a6ed3c8db
[ "FSFAP" ]
null
null
null
source/xmc1_e_eeprom.h
Infineon/mtb-example-xmc-flash-eeprom
61cec70b2dfa846c570e1c3c7317741a6ed3c8db
[ "FSFAP" ]
null
null
null
source/xmc1_e_eeprom.h
Infineon/mtb-example-xmc-flash-eeprom
61cec70b2dfa846c570e1c3c7317741a6ed3c8db
[ "FSFAP" ]
null
null
null
/****************************************************************************** * File Name: e_eeprom_xmc1.h * * Description: Header file for emulated EEPROM implementation in XMC1000 MCUs. * It contains the necessary macro and structure definitions to use configure * flash memory as emulated EEPROM. * * Related Document: See README.md * ****************************************************************************** * * Copyright (c) 2015-2021, Infineon Technologies AG * All rights reserved. * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, * must be included in all copies of the Software, in whole or in part, and * all derivative works of the Software, unless such copies or derivative * works are solely in the form of machine-executable object code generated by * a source language processor. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * ***************************************************************************** * Change History * -------------- * * 2015-02-16: * - Initial version<br> * * 2015-04-24: * - E_EEPROM_XMC1_ReadBlockWithCRC API renamed to * E_EEPROM_XMC1_VerifyBlockCrcStatus<br> * - E_EEPROM_XMC1_OPERATION_STATUS_t enumeration parameter names * changed and additional status parameter * E_EEPROM_XMC1_OPERATION_STATUS_NO_CRC_WRITTEN added. * * 2016-07-08: * - Fixed incorrect case for an included header. * * 2021-01-08: * - Modified check for minimum XMCLib version *****************************************************************************/ #ifndef E_EEPROM_XMC1_H #define E_EEPROM_XMC1_H /***************************************************************************** * HEADER FILES ****************************************************************************/ #include "xmc_flash.h" //conf /* * Flash address and Size informations as per user configuration */ #define E_EEPROM_XMC1_FLASH_TOTAL_SIZE (4096U) #define E_EEPROM_XMC1_FLASH_BANK_SIZE (2048U) /* * EMULATED_EEPROM Bank, start and end addresses */ #define E_EEPROM_XMC1_FLASH_BANK0_BASE (0x10032000U) #define E_EEPROM_XMC1_FLASH_BANK0_END (0x100327ffU) #define E_EEPROM_XMC1_FLASH_BANK1_BASE (0x10032800U) #define E_EEPROM_XMC1_FLASH_BANK1_END (0x10032fffU) /* Total number of configured Data blocks */ #define E_EEPROM_XMC1_MAX_BLOCK_COUNT (1U) /* * Total number of pages per bank, resulting after division of banks * i.e. E_EEPROM_XMC1_BANK_PAGES = (E_EEPROM_XMC1_FLASH_TOTAL_SIZE in Bytes / ((256 Bytes * 2 Banks)) */ #define E_EEPROM_XMC1_BANK_PAGES (8U) //conf end #ifdef E_EEPROM_XMC1_CRC_SW_ENABLED #include "CRC_SW/crc_sw.h" #endif /***************************************************************************** * MACROS ****************************************************************************/ #define E_EEPROM_XMC1_XMC_LIB_MAJOR_VERSION 2 #define E_EEPROM_XMC1_XMC_LIB_MINOR_VERSION 0 #define E_EEPROM_XMC1_XMC_LIB_PATCH_VERSION 0 #if !((XMC_LIB_MAJOR_VERSION > E_EEPROM_XMC1_XMC_LIB_MAJOR_VERSION) ||\ ((XMC_LIB_MAJOR_VERSION == E_EEPROM_XMC1_XMC_LIB_MAJOR_VERSION) && (XMC_LIB_MINOR_VERSION > E_EEPROM_XMC1_XMC_LIB_MINOR_VERSION)) ||\ ((XMC_LIB_MAJOR_VERSION == E_EEPROM_XMC1_XMC_LIB_MAJOR_VERSION) && (XMC_LIB_MINOR_VERSION == E_EEPROM_XMC1_XMC_LIB_MINOR_VERSION) && (XMC_LIB_PATCH_VERSION >= E_EEPROM_XMC1_XMC_LIB_PATCH_VERSION))) #error "E_EEPROM_XMC1 requires XMC Peripheral Library v2.0.0 or higher" #endif /** Physical flash Block size and Page size defined*/ #define E_EEPROM_XMC1_FLASH_BLOCK_SIZE (16U) #define E_EEPROM_XMC1_FLASH_PAGE_SIZE (256U) /* * These are global variables used only for internal testing purpose. * Application code shall not use these variables by enabling E_EEPROM_XMC1_TEST_HOOK_ENABLE macro definition. */ #ifdef E_EEPROM_XMC1_TEST_HOOK_ENABLE uint32_t e_eeprom_xmc1_test_hook_readblock; uint32_t e_eeprom_xmc1_test_hook_writeblock; uint32_t e_eeprom_xmc1_test_hook_writepage; uint32_t e_eeprom_xmc1_test_hook_erasepage; uint32_t e_eeprom_xmc1_test_hook_readword; uint32_t e_eeprom_xmc1_test_hook_getflashstatus; #endif /***************************************************************************** * ENUMS *****************************************************************************/ /** Defines the error codes for E_EEPROM_XMC1 APP. */ typedef enum E_EEPROM_XMC1_STATUS { E_EEPROM_XMC1_STATUS_SUCCESS = 0U, /**< Successful completion of APP initialization */ E_EEPROM_XMC1_STATUS_FAILURE = 1U, /**< Initialization failed due to internal operational error*/ E_EEPROM_XMC1_STATUS_UNINITIALIZED = 2U, /**< APP is in Uninitialized state*/ E_EEPROM_XMC1_STATUS_IDLE = 3U, /**< APP is in IDLE state. Only used in E_EEPROM_XMC1_GetStatus() API */ E_EEPROM_XMC1_STATUS_BUSY = 4U /**< APP is in BUSY state. Only used in E_EEPROM_XMC1_GetStatus() API */ } E_EEPROM_XMC1_STATUS_t; /** * Defines current status for E_EEPROM_XMC1 APP. */ typedef enum E_EEPROM_XMC1_OPERATION_STATUS { E_EEPROM_XMC1_OPERATION_STATUS_SUCCESS = 0U, /**< Successful completion of operation*/ E_EEPROM_XMC1_OPERATION_STATUS_FAILURE = 1U, /**< APP failed due to internal flash operational errors*/ E_EEPROM_XMC1_OPERATION_STATUS_INCONSISTENT_BLOCK = 2U, /**< Targeted block is inconsistent*/ E_EEPROM_XMC1_OPERATION_STATUS_INVALID_BLOCK = 3U, /**< The latest copy of the targeted block was invalidated */ E_EEPROM_XMC1_OPERATION_STATUS_CRC_FAILED = 4U, /**< CRC verification failed for the targeted block*/ E_EEPROM_XMC1_OPERATION_STATUS_NOT_ALLOWED = 5U, /**< Operation not allowed to continue*/ E_EEPROM_XMC1_OPERATION_STATUS_MEMORY_BANK_FULL = 6U, /**< Write/Invalidate operation failed when bank has no space. Call E_EEPROM_XMC1_StartGarbageCollection API to proceed */ E_EEPROM_XMC1_OPERATION_STATUS_NO_CRC_WRITTEN = 7U /**< Written block does not have CRC checksum enabled.*/ } E_EEPROM_XMC1_OPERATION_STATUS_t; /***************************************************************************** * * DATA STRUCTURES *****************************************************************************/ /** Data structure to configure the Data Block parameters */ typedef struct E_EEPROM_XMC1_BLOCK { uint8_t block_number; /**< Logical block number (Block ID) */ uint32_t size; /**< Size of the logical block */ } E_EEPROM_XMC1_BLOCK_t; /** Data structure to hold the header information about a particular user data block */ typedef struct E_EEPROM_XMC1_BLOCK_HEADER { uint8_t block_number; /**< User data block number */ uint8_t status; /**< User data block status */ } E_EEPROM_XMC1_BLOCK_HEADER_t; /*lint -e46 */ /** Bit field data structure holds the overall information about a particular user data block */ typedef struct E_EEPROM_XMC1_CACHE_STATUS { uint32_t valid : 1; /**< Indicates the data block stored in the flash is valid or invalid */ uint32_t consistent : 1; /**< Indicates the data block stored in the flash is faulty or not */ uint32_t copied : 1; /**< Indicates the data blocks are copied or not to free bank during GC */ uint32_t crc : 1; /**< Indicates if the block is enabled with a valid 16 bit CRC */ uint32_t unused : 28; /* unused */ } E_EEPROM_XMC1_CACHE_STATUS_t; /*lint -e46 */ /** Data structure to hold the information about the physical address and status of a user data block */ typedef struct E_EEPROM_XMC1_CACHE { uint32_t address; /**< It has the actual physical address of the flash where the written data block starts */ E_EEPROM_XMC1_CACHE_STATUS_t status; /**< Status information of the written user data block (Valid/Consistent/CRC)*/ } E_EEPROM_XMC1_CACHE_t; /** Data structure to hold the count of flash physical blocks and status of a user data block */ typedef struct E_EEPROM_XMC1_TRAVERSE_BLOCK_RESULT { uint32_t block_count; /**< Number of physical flash blocks required for a particular data block */ E_EEPROM_XMC1_CACHE_STATUS_t status; /**< status of the user data block */ } E_EEPROM_XMC1_TRAVERSE_BLOCK_RESULT_t; /** Data structure to hold the complete state data information of Emulation APP (Run Time Handler)*/ typedef struct E_EEPROM_XMC1_DATA { E_EEPROM_XMC1_CACHE_t *block_info;/**< User data block informations are stored here*/ E_EEPROM_XMC1_TRAVERSE_BLOCK_RESULT_t block_result; /**< get previous data block read result information*/ uint32_t current_bank; /**< Stores the current Bank on which blocks write operation will be done */ uint32_t gc_dest_addr; /**< Destination address for copying data during GC */ uint32_t gc_src_addr; /**< Source address from which data needs to be copied during GC */ uint32_t curr_bank_end_addr; /**< Current bank end address */ uint32_t prev_bank_end_addr; /**< previous bank end address */ uint32_t next_free_block_addr; /**< Stores the next available flash address for next block write */ uint32_t curr_bank_src_addr; /**< Used for cache update and later stores the current Bank base address */ uint32_t gc_block_counter; /**< Tracks number of flash blocks read/written during GC process */ uint32_t written_block_counter; /**< Keeps track of the number of flash blocks written for an user data block */ uint8_t read_write_buffer[E_EEPROM_XMC1_FLASH_BLOCK_SIZE]; /**< Internal buffer to load and store single block */ uint32_t crc_buffer; /**< Keeps track the CRC 16 bit CRC value */ uint8_t page_write_buffer[E_EEPROM_XMC1_FLASH_PAGE_SIZE]; /**< Internal buffer to load and store single page */ uint32_t user_write_bytes_count; /**< Keeps track of the number of bytes written */ uint32_t gc_state; /**< State variable to keep track of the current state of the garbage collection procedure */ uint32_t init_gc_state; /**< Stores the current state for initialization process */ uint32_t gc_log_block_count; /**< Tracks the number of logical blocks covered during GC process */ uint32_t cache_state; /**< Stores current state of the cache update process */ uint32_t updated_cache_index; /**< Keeps track of the current block for which cache update is ongoing */ uint32_t user_write_state; /**< Current status of the user write */ uint32_t read_start_address; /**< Current flash starting address to read the data */ } E_EEPROM_XMC1_DATA_t; /** Data structure to configure the APP properties. Use @ref E_EEPROM_XMC1_t type for accessing the members */ typedef struct E_EEPROM_XMC1 { E_EEPROM_XMC1_BLOCK_t *block_config_ptr; /**< Pointer to user block configurations */ E_EEPROM_XMC1_DATA_t *data_ptr; /**< Pointer to the state variable data structure */ #ifdef E_EEPROM_XMC1_CRC_SW_ENABLED CRC_SW_t* const crc_handle_ptr; /**< CRC APP handle pointer*/ #endif E_EEPROM_XMC1_STATUS_t state; /**< Current state of the APP instance*/ const uint8_t block_count; /**< Number of configured user data blocks */ const uint8_t erase_all_auto_recovery; /**< Erase Complete emulation area and recover to default state */ const uint8_t data_block_crc; /**< Allow to calculate CRC for each data block on write */ const uint8_t garbage_collection; /**< Enables garbage collection when no space available for new write*/ } E_EEPROM_XMC1_t; typedef E_EEPROM_XMC1_t* E_EEPROM_XMC1_HANDLE_PTR_t; /**< Defines a pointer to APP Handle*/ /** *@} */ #ifdef __cplusplus extern "C" { #endif /***************************************************************************** * API Prototypes ****************************************************************************/ E_EEPROM_XMC1_STATUS_t E_EEPROM_XMC1_Init(E_EEPROM_XMC1_t *const handle_ptr); E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_Write(uint8_t block_number, uint8_t *data_buffer_ptr); E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_Read(uint8_t block_number, uint32_t block_offset, uint8_t *data_buffer_ptr, uint32_t length ); E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_StartGarbageCollection(void); E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_InvalidateBlock(uint8_t block_number); E_EEPROM_XMC1_STATUS_t E_EEPROM_XMC1_GetStatus(void); bool E_EEPROM_XMC1_IsGarbageCollectionNeeded(uint8_t block_number); #ifdef E_EEPROM_XMC1_CRC_SW_ENABLED E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_VerifyBlockCrcStatus(uint8_t block_number, uint8_t *data_buffer_ptr); #endif E_EEPROM_XMC1_OPERATION_STATUS_t E_EEPROM_XMC1_GetPreviousData(uint8_t block_number, uint32_t block_offset, uint8_t *data_buffer_ptr, uint32_t length ); #ifdef __cplusplus } #endif #endif /* E_EEPROM_XMC1_H_ */
41.967262
203
0.683498
[ "object" ]
250ee6332b28365666df247ce7a462fc75952930
1,254
h
C
plugins/petsc/src/vector.h
cedricga91/alien
2cb1c80a6125dd6f70d4a57d7bbb55c9461b0bb0
[ "Apache-2.0" ]
8
2021-09-30T08:29:44.000Z
2022-02-23T18:39:32.000Z
plugins/petsc/src/vector.h
cedricga91/alien
2cb1c80a6125dd6f70d4a57d7bbb55c9461b0bb0
[ "Apache-2.0" ]
42
2021-07-01T17:32:05.000Z
2022-03-03T14:53:56.000Z
plugins/petsc/src/vector.h
cedricga91/alien
2cb1c80a6125dd6f70d4a57d7bbb55c9461b0bb0
[ "Apache-2.0" ]
9
2021-09-28T12:59:32.000Z
2022-03-18T06:35:01.000Z
/* * Copyright 2020 IFPEN-CEA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include <alien/core/impl/IVectorImpl.h> #include <petscvec.h> namespace Alien::PETSc { class Vector : public IVectorImpl { public: explicit Vector(const MultiVectorImpl* multi_impl); ~Vector() override; public: void setProfile(int ilower, int iupper); void setValues(Arccore::ConstArrayView<double> values); void getValues(Arccore::ArrayView<double> values) const; void assemble(); Vec internal() { return m_vec; } Vec internal() const { return m_vec; } private: Vec m_vec; MPI_Comm m_comm; Arccore::UniqueArray<Arccore::Integer> m_rows; }; } // namespace Alien::PETSc
22.392857
75
0.727273
[ "vector" ]
25112dfb44bc67748003f0e614e2e3e5767f4e73
6,141
h
C
Source/WebCore/platform/graphics/ImageBufferBackend.h
jacadcaps/webkitty
9aebd2081349f9a7b5d168673c6f676a1450a66d
[ "BSD-2-Clause" ]
6
2021-07-05T16:09:39.000Z
2022-03-06T22:44:42.000Z
Source/WebCore/platform/graphics/ImageBufferBackend.h
jacadcaps/webkitty
9aebd2081349f9a7b5d168673c6f676a1450a66d
[ "BSD-2-Clause" ]
7
2022-03-15T13:25:39.000Z
2022-03-15T13:25:44.000Z
Source/WebCore/platform/graphics/ImageBufferBackend.h
jacadcaps/webkitty
9aebd2081349f9a7b5d168673c6f676a1450a66d
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (C) 2020 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. OR * CONTRIBUTORS 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. */ #pragma once #include "AlphaPremultiplication.h" #include "ColorSpace.h" #include "FloatRect.h" #include "GraphicsTypesGL.h" #include "ImagePaintingOptions.h" #include "IntRect.h" #include "NativeImage.h" #include "PlatformLayer.h" #include <wtf/RefPtr.h> #include <wtf/Vector.h> namespace WebCore { class GraphicsContextGLOpenGL; class HostWindow; class Image; class ImageData; enum BackingStoreCopy { CopyBackingStore, // Guarantee subsequent draws don't affect the copy. DontCopyBackingStore // Subsequent draws may affect the copy. }; enum class PreserveResolution : uint8_t { No, Yes, }; enum class ColorFormat : uint8_t { RGBA, BGRA }; class ImageBufferBackend { public: WEBCORE_EXPORT virtual ~ImageBufferBackend() = default; WEBCORE_EXPORT static IntSize calculateBackendSize(const FloatSize&, float resolutionScale); virtual GraphicsContext& context() const = 0; virtual void flushContext() { } IntSize logicalSize() const { return m_logicalSize; } IntSize backendSize() const { return m_backendSize; } float resolutionScale() const { return m_resolutionScale; } ColorSpace colorSpace() const { return m_colorSpace; } virtual AffineTransform baseTransform() const { return AffineTransform(); } virtual size_t memoryCost() const { return 4 * m_backendSize.area().unsafeGet(); } virtual size_t externalMemoryCost() const { return 0; } virtual NativeImagePtr copyNativeImage(BackingStoreCopy) const = 0; virtual RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const = 0; WEBCORE_EXPORT virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; WEBCORE_EXPORT virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0; WEBCORE_EXPORT virtual NativeImagePtr sinkIntoNativeImage(); WEBCORE_EXPORT virtual RefPtr<Image> sinkIntoImage(PreserveResolution); WEBCORE_EXPORT virtual void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); WEBCORE_EXPORT void convertToLuminanceMask(); virtual void transformColorSpace(ColorSpace, ColorSpace) { } virtual String toDataURL(const String& mimeType, Optional<double> quality, PreserveResolution) const = 0; virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const = 0; virtual Vector<uint8_t> toBGRAData() const = 0; virtual RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const = 0; virtual void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) = 0; virtual PlatformLayer* platformLayer() const { return nullptr; } virtual bool copyToPlatformTexture(GraphicsContextGLOpenGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const { return false; } virtual bool isAccelerated() const { return false; } protected: WEBCORE_EXPORT ImageBufferBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace); virtual unsigned bytesPerRow() const { return 4 * m_backendSize.width(); } virtual ColorFormat backendColorFormat() const { return ColorFormat::RGBA; } template<typename T> T toBackendCoordinates(T t) const { static_assert(std::is_same<T, IntPoint>::value || std::is_same<T, IntSize>::value || std::is_same<T, IntRect>::value); if (m_resolutionScale != 1) t.scale(m_resolutionScale); return t; } IntRect logicalRect() const { return IntRect(IntPoint::zero(), m_logicalSize); }; IntRect backendRect() const { return IntRect(IntPoint::zero(), m_backendSize); }; WEBCORE_EXPORT virtual void copyImagePixels( AlphaPremultiplication srcAlphaFormat, ColorFormat srcColorFormat, unsigned srcBytesPerRow, uint8_t* srcRows, AlphaPremultiplication destAlphaFormat, ColorFormat destColorFormat, unsigned destBytesPerRow, uint8_t* destRows, const IntSize&) const; WEBCORE_EXPORT Vector<uint8_t> toBGRAData(void* data) const; WEBCORE_EXPORT RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, void* data) const; WEBCORE_EXPORT void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat, void* data); IntSize m_logicalSize; IntSize m_backendSize; float m_resolutionScale; ColorSpace m_colorSpace; }; } // namespace WebCore
44.5
240
0.76144
[ "vector" ]
2514de00d1b3faa8912033383ad52d3cb3b2f9f0
2,183
h
C
src/ripple/core/TimeKeeper.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
5
2019-01-23T04:36:03.000Z
2020-02-04T07:10:39.000Z
src/ripple/core/TimeKeeper.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
null
null
null
src/ripple/core/TimeKeeper.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
2
2019-05-14T07:26:59.000Z
2020-06-15T07:25:01.000Z
//此源码被清华学神尹成大魔王专业翻译分析并修改 //尹成QQ77025077 //尹成微信18510341407 //尹成所在QQ群721929980 //尹成邮箱 yinc13@mails.tsinghua.edu.cn //尹成毕业于清华大学,微软区块链领域全球最有价值专家 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 //———————————————————————————————————————————————————————————————————————————————————————————————————————————————— /* 此文件是Rippled的一部分:https://github.com/ripple/rippled 版权所有(c)2012,2013 Ripple Labs Inc. 使用、复制、修改和/或分发本软件的权限 特此授予免费或不收费的目的,前提是 版权声明和本许可声明出现在所有副本中。 本软件按“原样”提供,作者不作任何保证。 关于本软件,包括 适销性和适用性。在任何情况下,作者都不对 任何特殊、直接、间接或后果性损害或任何损害 因使用、数据或利润损失而导致的任何情况,无论是在 合同行为、疏忽或其他侵权行为 或与本软件的使用或性能有关。 **/ //============================================================== #ifndef RIPPLE_CORE_TIMEKEEPER_H_INCLUDED #define RIPPLE_CORE_TIMEKEEPER_H_INCLUDED #include <ripple/beast/clock/abstract_clock.h> #include <ripple/beast/utility/Journal.h> #include <ripple/basics/chrono.h> #include <string> #include <vector> namespace ripple { /*管理服务器使用的各种时间。*/ class TimeKeeper : public beast::abstract_clock<NetClock> { public: virtual ~TimeKeeper() = default; /*启动内部线程。 内部线程同步本地网络时间 使用提供的sntp服务器列表。 **/ virtual void run (std::vector<std::string> const& servers) = 0; /*返回墙时间的估计值(以网络时间为单位)。 网络时间是根据纹波调整的壁面时间。 纪元,2000年1月1日开始。每个服务器 可以计算不同的网络时间值。其他 网络时间的服务器值不能直接观察到, 但是通过查看验证器可以做出很好的猜测 关闭时间的位置。 服务器通过调整本地墙计算网络时间 时钟使用sntp,然后调整为时代。 **/ virtual time_point now() const override = 0; /*返回关闭时间(网络时间)。 Close Time是网络同意 如果分类帐现在已关闭,则为已关闭的分类帐。 关闭时间代表概念上的“中心” 网络的。每个服务器假定其时钟 是正确的,并试图将结束时间拉向 它对网络时间的度量。 **/ virtual time_point closeTime() const = 0; /*调整关闭时间。 这是为了响应收到的验证而调用的。 **/ virtual void adjustCloseTime (std::chrono::duration<std::int32_t> amount) = 0; //这可能返回负值 virtual std::chrono::duration<std::int32_t> nowOffset() const = 0; //这可能返回负值 virtual std::chrono::duration<std::int32_t> closeOffset() const = 0; }; extern std::unique_ptr<TimeKeeper> make_TimeKeeper(beast::Journal j); } //涟漪 #endif
18.818966
114
0.606047
[ "vector" ]
25195a78d85863204b57a8062fa30fc60393594a
4,669
h
C
PurchaseHelper/PurchaseHelper.h
exsortis/PurchaseHelper
a8e64e1d19c7babdbf28ea51cce0aeeb9ff25e27
[ "MIT" ]
3
2016-01-06T23:31:29.000Z
2018-02-20T02:14:14.000Z
PurchaseHelper/PurchaseHelper.h
paulyhedral/PurchaseHelper
a8e64e1d19c7babdbf28ea51cce0aeeb9ff25e27
[ "MIT" ]
2
2017-06-08T18:10:14.000Z
2017-10-19T19:27:46.000Z
PurchaseHelper/PurchaseHelper.h
exsortis/PurchaseHelper
a8e64e1d19c7babdbf28ea51cce0aeeb9ff25e27
[ "MIT" ]
1
2020-05-25T00:32:30.000Z
2020-05-25T00:32:30.000Z
// // RPGPurchaseHelper.h // RPGKit // // Created by Paul Schifferer on 9/3/14. // Copyright (c) 2014 Pilgrimage Software. All rights reserved. // @import Foundation; @import StoreKit; #if TARGET_OS_IPHONE @import UIKit; #endif typedef NSString *ProductIdentifier NS_EXTENSIBLE_STRING_ENUM; /** Type definition for the request products completion callback. @param success Boolean value indicating whether the request succeeded or not. @param products An array of SKProduct objects. */ typedef void (^RequestProductsCompletionHandler)(BOOL success, NSArray<SKProduct *>* _Nonnull products); /** Type definition for the a production information request. @param success Boolean value indicating whether the request succeeded or not. @param product The product that was request, or <code>NULL</code> if no product was found. */ typedef void (^RequestProductInfoCompletionHandler)(BOOL success, SKProduct* _Nullable product); /** String constant name of the notification that is sent when a product is purchased. */ #if TARGET_OS_IPHONE UIKIT_EXTERN #else OBJC_EXTERN #endif NSString *_Nonnull const ProductPurchasedNotification; /** String constant name of the notification that is sent when a product purchase is canceled. */ #if TARGET_OS_IPHONE UIKIT_EXTERN #else OBJC_EXTERN #endif NSString* const ProductPurchaseCanceledNotification; /** String constant name of the user info dictionary key containing the product identifier of the product that was purchased. */ #if TARGET_OS_IPHONE UIKIT_EXTERN #else OBJC_EXTERN #endif NSString *_Nonnull const ProductPurchasedNotificationProductIdentifierKey; /** Instances of this class handle product purchasing, including tracking of previously purchased products using a specified keychain account. */ @interface PurchaseHelper : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver> /** The keychain account that is used for storing purchase entries in the user's keychain. */ @property(nonatomic, nonnull, copy) NSString *keychainAccount; /** Indicates whether the helper is operating in "test mode". Enabling this mode causes the helper to skip some checks for purchased products, allowing the app developer to test purchase functionality without having to actually perform purchases, even with an iTunes test account. */ @property(nonatomic, assign) BOOL testMode; /** Instantiate this class to help manage in-app purchases. Designated initializer. @param productIdentifiers A collection of unique identifiers for the purchasable products that the app will use. @param keychainAccount The name of the keychain account to use for storing and managing product purchases. */ - (nonnull instancetype)initWithProductIdentifiers:(nonnull NSSet<ProductIdentifier>*)productIdentifiers keychainAccount:(nonnull NSString*)keychainAccount NS_DESIGNATED_INITIALIZER; /** Initiate a request from the iTunes store for the products that correspond to the product identifiers provided during instantiation. The specified function will be called when the request completes. @param completionHandler A block to call when the request completes. @see RequestProductsCompletionHandler */ - (void)requestProductsWithCompletionHandler:(nonnull RequestProductsCompletionHandler)completionHandler; /** Initiate a purchase request for the specified product. @param productIdentifier The identifier for the product to purchase. This must be an identifier that was provided during instantation. */ - (void)buyProduct:(nonnull ProductIdentifier)productIdentifier NS_SWIFT_NAME(buy(productIdentifier:)); /** Check if the specified product was purchased. This method uses the keychain as a record of purchased products, which is automatically updated when a purchase succeeds. @param productIdentifier The identifier of the product to check. @return A boolean indicating whether there is a record in the keychain for the purchase of this product. */ - (BOOL)productPurchased:(nonnull ProductIdentifier)productIdentifier NS_SWIFT_NAME(isProductPurchased(productIdentifier:)); /** Initiate a request to restore completed transactions. Each completed transaction will be recorded in the keychain. */ - (void)restoreCompletedTransactions; /** Returns a product for the specified identifier. @param productIdentifier The identifier of the product. @return An SKProduct object for the product, or null if one does not match. */ - (nullable SKProduct*)productInfo:(nonnull ProductIdentifier)productIdentifier NS_SWIFT_NAME(productInfo(for:)); /** Clears the keychain of purchase history items. */ - (void)clearPurchaseHistory; @end
33.833333
124
0.79653
[ "object" ]
251c6748bcf63f7d1721f94a42012fac2ffa0cac
517
h
C
src/perf/wrappers/popsift_wrapper.h
maelaubert/VulkanSift
a7e8407b9d0ae3af2cd7cf21eca261720bc5cb1d
[ "MIT" ]
33
2021-06-03T09:39:12.000Z
2022-02-18T06:59:32.000Z
src/perf/wrappers/popsift_wrapper.h
AkillesAILimited/VulkanSift
a7e8407b9d0ae3af2cd7cf21eca261720bc5cb1d
[ "MIT" ]
1
2021-07-15T08:05:09.000Z
2021-08-22T14:50:58.000Z
src/perf/wrappers/popsift_wrapper.h
maelaubert/VulkanSift
a7e8407b9d0ae3af2cd7cf21eca261720bc5cb1d
[ "MIT" ]
6
2021-09-26T08:51:29.000Z
2022-01-14T02:39:29.000Z
#ifndef PERF_POPSIFT_WRAPPER_H #define PERF_POPSIFT_WRAPPER_H #include "perf/wrappers/wrapper.h" #include "popsift/src/popsift.h" class PopSiftDetector : public AbstractSiftDetector { public: bool init() override; void terminate() override; void detectSIFT(cv::Mat image, std::vector<cv::KeyPoint> &keypoints, cv::Mat &descs, bool convert_and_copy_to_cv_format) override; bool useFloatImage() override { return false; } private: std::shared_ptr<PopSift> detector; }; #endif // PERF_POPSIFT_WRAPPER_H
27.210526
132
0.769826
[ "vector" ]
2522f85df5d2c9eb8763de84591a7bfdf475cef1
4,939
h
C
model/mosesdecoder/moses2/TargetPhrase.h
saeedesm/UNMT_AH
cc171bf66933b5c0ad8a0ab87e57f7364312a7df
[ "Apache-2.0" ]
3
2019-12-02T14:53:29.000Z
2020-08-12T18:01:49.000Z
model/mosesdecoder/moses2/TargetPhrase.h
saeedesm/UNMT_AH
cc171bf66933b5c0ad8a0ab87e57f7364312a7df
[ "Apache-2.0" ]
null
null
null
model/mosesdecoder/moses2/TargetPhrase.h
saeedesm/UNMT_AH
cc171bf66933b5c0ad8a0ab87e57f7364312a7df
[ "Apache-2.0" ]
2
2019-11-26T05:27:16.000Z
2019-12-17T01:53:43.000Z
/* * TargetPhrase.h * * Created on: 26 Apr 2016 * Author: hieu */ #pragma once #include <sstream> #include "PhraseImplTemplate.h" #include "System.h" #include "Scores.h" #include "AlignmentInfoCollection.h" #include "TranslationModel/PhraseTable.h" namespace Moses2 { class AlignmentInfo; template<typename WORD> class TargetPhrase: public PhraseImplTemplate<WORD> { public: typedef PhraseImplTemplate<WORD> Parent; const PhraseTable &pt; mutable void **ffData; SCORE *scoreProperties; TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system, size_t size) : PhraseImplTemplate<WORD>(pool, size) , pt(pt) , scoreProperties(NULL) , m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo()) { m_scores = new (pool.Allocate<Scores>()) Scores(system, pool, system.featureFunctions.GetNumScores()); } Scores &GetScores() { return *m_scores; } const Scores &GetScores() const { return *m_scores; } virtual SCORE GetScoreForPruning() const = 0; SCORE *GetScoresProperty(int propertyInd) const { return scoreProperties ? scoreProperties + propertyInd : NULL; } const AlignmentInfo &GetAlignTerm() const { return *m_alignTerm; } void SetAlignTerm(const AlignmentInfo &alignInfo) { m_alignTerm = &alignInfo; } // ALNREP = alignment representation, // see AlignmentInfo constructors for supported representations template<typename ALNREP> void SetAlignTerm(const ALNREP &coll) { m_alignTerm = AlignmentInfoCollection::Instance().Add(coll); } virtual void SetAlignmentInfo(const std::string &alignString) { AlignmentInfo::CollType alignTerm; std::vector<std::string> toks = Tokenize(alignString); for (size_t i = 0; i < toks.size(); ++i) { std::vector<size_t> alignPair = Tokenize<size_t>(toks[i], "-"); UTIL_THROW_IF2(alignPair.size() != 2, "Wrong alignment format"); size_t sourcePos = alignPair[0]; size_t targetPos = alignPair[1]; alignTerm.insert(std::pair<size_t,size_t>(sourcePos, targetPos)); } SetAlignTerm(alignTerm); // cerr << "TargetPhrase::SetAlignmentInfo(const StringPiece &alignString) this:|" << *this << "|\n"; //cerr << "alignTerm=" << alignTerm.size() << endl; //cerr << "alignNonTerm=" << alignNonTerm.size() << endl; } void OutputToStream(const System &system, const Phrase<WORD> &inputPhrase, std::ostream &out) const { // get placeholders FactorType placeholderFactor = system.options.input.placeholder_factor; std::map<size_t, const Factor*> placeholders; if (placeholderFactor != NOT_FOUND) { // creates map of target position -> factor for placeholders placeholders = GetPlaceholders(system, inputPhrase); } size_t size = PhraseImplTemplate<WORD>::GetSize(); for (size_t i = 0; i < size; ++i) { // output placeholder, if any std::map<size_t, const Factor*>::const_iterator iter = placeholders.find(i); if (iter == placeholders.end()) { const WORD &word = (*this)[i]; word.OutputToStream(system, out); } else { const Factor *factor = iter->second; out << *factor; } out << " "; } } std::map<size_t, const Factor*> GetPlaceholders(const System &system, const Phrase<WORD> &inputPhrase) const { FactorType placeholderFactor = system.options.input.placeholder_factor; std::map<size_t, const Factor*> ret; //std::cerr << "inputPhrase=" << inputPhrase.Debug(system) << std::endl; for (size_t sourcePos = 0; sourcePos < inputPhrase.GetSize(); ++sourcePos) { const Factor *factor = inputPhrase[sourcePos][placeholderFactor]; if (factor) { //std::cerr << "factor=" << *factor << std::endl; //std::cerr << "tp=" << Debug(system) << std::endl; std::set<size_t> targetPos = GetAlignTerm().GetAlignmentsForSource(sourcePos); UTIL_THROW_IF2(targetPos.size() != 1, "Placeholder should be aligned to 1, and only 1, word:" << targetPos.size() << "!=1"); ret[*targetPos.begin()] = factor; } } return ret; } virtual std::string Debug(const System &system) const { std::stringstream out; out << Phrase<WORD>::Debug(system); out << " pt=" << pt.GetName() << " "; out << " SCORES:" << GetScores().Debug(system); out << " ALIGN-T:"; out << GetAlignTerm().Debug(system); return out.str(); } protected: Scores *m_scores; const AlignmentInfo *m_alignTerm; }; /////////////////////////////////////////////////////////////////////// template<typename TP> struct CompareScoreForPruning { bool operator()(const TP *a, const TP *b) const { return a->GetScoreForPruning() > b->GetScoreForPruning(); } bool operator()(const TP &a, const TP &b) const { return a.GetScoreForPruning() > b.GetScoreForPruning(); } }; } /* namespace Moses2a */
29.933333
112
0.648107
[ "vector" ]
2525fa3719f7da658da1c6c9a0ec97ecfc502903
8,216
h
C
modules/3rd_party/choc/text/choc_HTML.h
jbloit/tracktion_engine
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
[ "MIT", "Unlicense" ]
1,711
2018-12-03T13:49:34.000Z
2022-03-29T09:22:03.000Z
modules/3rd_party/choc/text/choc_HTML.h
jbloit/tracktion_engine
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
[ "MIT", "Unlicense" ]
100
2018-11-16T18:04:08.000Z
2022-03-31T17:47:53.000Z
modules/3rd_party/choc/text/choc_HTML.h
jbloit/tracktion_engine
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
[ "MIT", "Unlicense" ]
123
2018-11-16T15:51:50.000Z
2022-03-29T12:21:27.000Z
// // ██████ ██  ██  ██████  ██████ // ██      ██  ██ ██    ██ ██       ** Clean Header-Only Classes ** // ██  ███████ ██  ██ ██ // ██  ██   ██ ██  ██ ██ https://github.com/Tracktion/choc //  ██████ ██  ██  ██████   ██████ // // CHOC is (C)2021 Tracktion Corporation, and is offered under the terms of the ISC license: // // Permission to use, copy, modify, and/or distribute this software for any purpose with or // without fee is hereby granted, provided that the above copyright notice and this permission // notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, // WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef CHOC_HTML_HEADER_INCLUDED #define CHOC_HTML_HEADER_INCLUDED #include <sstream> #include <string_view> namespace choc::html { //============================================================================== /** A very minimal helper class for building trees of HTML elements which can then be printed as text. */ struct HTMLElement { HTMLElement() = default; explicit HTMLElement (std::string elementName) : name (std::move (elementName)) {} /** Creates, adds and returns a reference to a new child element inside this one. */ HTMLElement& addChild (std::string elementName) { children.emplace_back (std::move (elementName)); return children.back(); } /** Appends and returns a given child element to this one. */ HTMLElement& addChild (HTMLElement&& childToAdd) { children.emplace_back (std::move (childToAdd)); return children.back(); } /** Adds and returns a 'a' element with the given href property. */ HTMLElement& addLink (std::string_view linkURL) { return addChild ("a").setProperty ("href", linkURL); } /** Adds and returns a 'div' element. */ HTMLElement& addDiv() { return addChild ("div"); } /** Adds and returns a 'div' element with a given class name. */ HTMLElement& addDiv (std::string_view className) { return addDiv().setClass (className); } /** Adds and returns a 'p' element. */ HTMLElement& addParagraph() { return addChild ("p").setInline (true); } /** Adds and returns a 'span' element with the given class property. */ HTMLElement& addSpan (std::string_view classToUse) { return addChild ("span").setInline (true).setClass (classToUse); } /** Adds a property for this element. */ HTMLElement& setProperty (const std::string& propertyName, std::string_view value) { properties.push_back (propertyName + "=\"" + escapeHTMLString (value, true) + '"'); return *this; } /** Sets the 'id' property of this element. */ HTMLElement& setID (std::string_view value) { return setProperty ("id", std::move (value)); } /** Sets the 'class' property of this element. */ HTMLElement& setClass (std::string_view value) { return setProperty ("class", std::move (value)); } /** Appends a content element to this element's list of children. Note that this returns the parent object, not the new child, to allow chaining. */ HTMLElement& addContent (std::string_view text) { return addRawContent (escapeHTMLString (text, false)); } /** Appends a 'br' element to this element's content. */ HTMLElement& addLineBreak() { return addRawContent ("<br>"); } /** Appends an &nbsp; to this element's content. */ HTMLElement& addNBSP (size_t number = 1) { std::string s; for (size_t i = 0; i < number; ++i) s += "&nbsp;"; return addRawContent (std::move (s)); } /** Sets the element to be "inline", which means that it won't add any space or newlines between its child elements. For things like spans or 'p' elements, you probably want them to be inline. */ HTMLElement& setInline (bool shouldBeInline) { contentIsInline = shouldBeInline; return *this; } /** Returns a text version of this element. */ std::string toDocument (bool includeHeader) const { std::ostringstream out; writeToStream (out, includeHeader); return out.str(); } /** Writes this element to some kind of stream object. */ template <typename Output> void writeToStream (Output& out, bool includeHeader) const { if (includeHeader) out << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">" << std::endl; print (out, 0, { true, false }); } const std::vector<HTMLElement>& getChildren() const { return children; } std::vector<HTMLElement>& getChildren() { return children; } private: std::string name; bool isContent = false, contentIsInline = false; std::vector<std::string> properties; std::vector<HTMLElement> children; HTMLElement& addRawContent (std::string text) { auto& child = addChild (std::move (text)); child.isContent = true; return *this; } struct PrintStatus { bool isAtStartOfLine, isFollowingContent; }; template <typename Output> PrintStatus print (Output& out, size_t indent, PrintStatus status) const { if (! (status.isAtStartOfLine || status.isFollowingContent)) { if (! contentIsInline) out << '\n'; status.isAtStartOfLine = true; } bool openTagIndented = status.isAtStartOfLine && ! contentIsInline; if (openTagIndented) out << std::string (indent, ' '); status.isAtStartOfLine = false; out << '<' << name; for (auto& p : properties) out << ' ' << p; out << '>'; status.isFollowingContent = false; for (auto& c : children) { if (c.isContent) { out << c.name; status.isFollowingContent = true; } else { status = c.print (out, indent + 1, status); } } if (openTagIndented && ! (children.empty() || status.isFollowingContent)) out << "\n" << std::string (indent, ' '); out << "</" << name << ">"; status.isFollowingContent = false; return status; } static bool isCharLegal (uint32_t c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c < 127 && std::string_view (" .,;:-()_+=?!$#@[]/|*%~{}\\").find ((char) c) != std::string_view::npos); } static std::string escapeHTMLString (std::string_view text, bool escapeNewLines) { std::string result; for (auto character : text) { auto unicodeChar = static_cast<uint32_t> (character); if (isCharLegal (unicodeChar)) { result += character; } else { switch (unicodeChar) { case '<': result += "&lt;"; break; case '>': result += "&gt;"; break; case '&': result += "&amp;"; break; case '"': result += "&quot;"; break; default: if (! escapeNewLines && (unicodeChar == '\n' || unicodeChar == '\r')) result += character; else result += "&#" + std::to_string (unicodeChar) + ';'; break; } } } return result; } }; } // namespace choc::html #endif // CHOC_HTML_HEADER_INCLUDED
36.678571
163
0.55684
[ "object", "vector" ]
252c8b2ce6f655a65bb32246c5fa222657d328a1
2,131
h
C
dali/kernels/common/copy.h
matthew-frank/DALI
978ce4046083d1f66f963d253259c4af4de0f020
[ "ECL-2.0", "Apache-2.0" ]
1
2019-02-25T22:51:46.000Z
2019-02-25T22:51:46.000Z
dali/kernels/common/copy.h
matthew-frank/DALI
978ce4046083d1f66f963d253259c4af4de0f020
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
dali/kernels/common/copy.h
matthew-frank/DALI
978ce4046083d1f66f963d253259c4af4de0f020
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef DALI_KERNELS_COMMON_COPY_H_ #define DALI_KERNELS_COMMON_COPY_H_ #include <cuda_runtime.h> #include "dali/kernels/tensor_view.h" #include "dali/kernels/backend_tags.h" namespace dali { namespace kernels { template <typename Storage1, typename T1, int ndim1, typename Storage2, typename T2, int ndim2> void copy(const TensorView<Storage1, T1, ndim1> &out, const TensorView<Storage2, T2, ndim2> &in, cudaStream_t stream = 0) { static_assert(sizeof(T1) == sizeof(T2), "Tensor elements must be of equal size!"); static_assert(!std::is_const<T1>::value, "Cannot copy to a tensor of const elements!"); assert(in.shape == out.shape); if (!is_gpu_accessible<Storage1>::value) { if (is_cpu_accessible<Storage2>::value) { if (is_gpu_accessible<Storage2>::value) cudaStreamSynchronize(stream); // or cudaDeviceSynchronize? memcpy(out.data, in.data, in.num_elements() * sizeof(T1)); } else { cudaMemcpyAsync(out.data, in.data, in.num_elements() * sizeof(T1), cudaMemcpyDeviceToHost, stream); } } else { if (is_gpu_accessible<Storage2>::value) { cudaMemcpyAsync(out.data, in.data, in.num_elements() * sizeof(T1), cudaMemcpyDeviceToDevice, stream); } else { cudaMemcpyAsync(out.data, in.data, in.num_elements() * sizeof(T1), cudaMemcpyHostToDevice, stream); } } } } // namespace kernels } // namespace dali #endif // DALI_KERNELS_COMMON_COPY_H_
37.385965
95
0.695448
[ "shape" ]
d76dda09b5db54dc6b5afb47b2829722c33ce1fb
13,685
h
C
src/cfdapi_convert_mnemonic_to_seed_json.h
cryptogarageinc/cg-cfd-js
05af38708215e144ea167207fd920719c3112c7e
[ "MIT" ]
null
null
null
src/cfdapi_convert_mnemonic_to_seed_json.h
cryptogarageinc/cg-cfd-js
05af38708215e144ea167207fd920719c3112c7e
[ "MIT" ]
null
null
null
src/cfdapi_convert_mnemonic_to_seed_json.h
cryptogarageinc/cg-cfd-js
05af38708215e144ea167207fd920719c3112c7e
[ "MIT" ]
null
null
null
// Copyright 2019 CryptoGarage /** * @file cfdapi_convert_mnemonic_to_seed_json.h * * @brief JSONマッピングファイル (自動生成) */ #ifndef CFD_JS_SRC_CFDAPI_CONVERT_MNEMONIC_TO_SEED_JSON_H_ #define CFD_JS_SRC_CFDAPI_CONVERT_MNEMONIC_TO_SEED_JSON_H_ #include <set> #include <string> #include <vector> #include "cfdcore/cfdcore_json_mapping_base.h" #include "cfdjs/cfdjs_struct.h" namespace cfd { namespace js { namespace api { namespace json { using cfd::core::JsonClassBase; using cfd::core::JsonObjectVector; using cfd::core::JsonValueVector; using cfd::core::JsonVector; // clang-format off // @formatter:off // ------------------------------------------------------------------------ // ConvertMnemonicToSeedRequest // ------------------------------------------------------------------------ /** * @brief JSON-API(ConvertMnemonicToSeedRequest)クラス */ class ConvertMnemonicToSeedRequest : public cfd::core::JsonClassBase<ConvertMnemonicToSeedRequest> { public: ConvertMnemonicToSeedRequest() { CollectFieldName(); } virtual ~ConvertMnemonicToSeedRequest() { // do nothing } /** * @brief フィールド名を収集する. */ static void CollectFieldName(); /** * @brief mnemonic 取得処理 * @return mnemonic */ JsonValueVector<std::string>& GetMnemonic() { // NOLINT return mnemonic_; } /** * @brief mnemonic 設定処理 * @param[in] mnemonic 設定値 */ void SetMnemonic( // line separate const JsonValueVector<std::string>& mnemonic) { // NOLINT this->mnemonic_ = mnemonic; } /** * @brief mnemonic データ型の取得処理 * @return mnemonicのデータ型 */ static std::string GetMnemonicFieldType() { return "JsonValueVector<std::string>"; // NOLINT } /** * @brief mnemonic フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetMnemonicString( // line separate const ConvertMnemonicToSeedRequest& obj) { // NOLINT // Serialize内部のpre/post処理でメンバ変数の置換が起こり得るためconstにしない return obj.mnemonic_.Serialize(); } /** * @brief mnemonic フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetMnemonicString( // line separate ConvertMnemonicToSeedRequest& obj, // NOLINT const UniValue& json_value) { obj.mnemonic_.DeserializeUniValue(json_value); } /** * @brief passphrase 取得処理 * @return passphrase */ std::string GetPassphrase() const { return passphrase_; } /** * @brief passphrase 設定処理 * @param[in] passphrase 設定値 */ void SetPassphrase( // line separate const std::string& passphrase) { // NOLINT this->passphrase_ = passphrase; } /** * @brief passphrase データ型の取得処理 * @return passphraseのデータ型 */ static std::string GetPassphraseFieldType() { return "std::string"; } /** * @brief passphrase フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetPassphraseString( // line separate const ConvertMnemonicToSeedRequest& obj) { // NOLINT return cfd::core::ConvertToString(obj.passphrase_); } /** * @brief passphrase フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetPassphraseString( // line separate ConvertMnemonicToSeedRequest& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.passphrase_, json_value); } /** * @brief strictCheck 取得処理 * @return strictCheck */ bool GetStrictCheck() const { return strict_check_; } /** * @brief strictCheck 設定処理 * @param[in] strict_check 設定値 */ void SetStrictCheck( // line separate const bool& strict_check) { // NOLINT this->strict_check_ = strict_check; } /** * @brief strictCheck データ型の取得処理 * @return strictCheckのデータ型 */ static std::string GetStrictCheckFieldType() { return "bool"; } /** * @brief strictCheck フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetStrictCheckString( // line separate const ConvertMnemonicToSeedRequest& obj) { // NOLINT return cfd::core::ConvertToString(obj.strict_check_); } /** * @brief strictCheck フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetStrictCheckString( // line separate ConvertMnemonicToSeedRequest& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.strict_check_, json_value); } /** * @brief language 取得処理 * @return language */ std::string GetLanguage() const { return language_; } /** * @brief language 設定処理 * @param[in] language 設定値 */ void SetLanguage( // line separate const std::string& language) { // NOLINT this->language_ = language; } /** * @brief language データ型の取得処理 * @return languageのデータ型 */ static std::string GetLanguageFieldType() { return "std::string"; } /** * @brief language フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetLanguageString( // line separate const ConvertMnemonicToSeedRequest& obj) { // NOLINT return cfd::core::ConvertToString(obj.language_); } /** * @brief language フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetLanguageString( // line separate ConvertMnemonicToSeedRequest& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.language_, json_value); } /** * @brief useIdeographicSpace 取得処理 * @return useIdeographicSpace */ bool GetUseIdeographicSpace() const { return use_ideographic_space_; } /** * @brief useIdeographicSpace 設定処理 * @param[in] use_ideographic_space 設定値 */ void SetUseIdeographicSpace( // line separate const bool& use_ideographic_space) { // NOLINT this->use_ideographic_space_ = use_ideographic_space; } /** * @brief useIdeographicSpace データ型の取得処理 * @return useIdeographicSpaceのデータ型 */ static std::string GetUseIdeographicSpaceFieldType() { return "bool"; } /** * @brief useIdeographicSpace フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetUseIdeographicSpaceString( // line separate const ConvertMnemonicToSeedRequest& obj) { // NOLINT return cfd::core::ConvertToString(obj.use_ideographic_space_); } /** * @brief useIdeographicSpace フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetUseIdeographicSpaceString( // line separate ConvertMnemonicToSeedRequest& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.use_ideographic_space_, json_value); } /** * @brief 無視対象アイテムを設定する。 * @param[in] key 無視対象アイテムのキー名称 */ void SetIgnoreItem(const std::string& key) { ignore_items.insert(key); } /** * @brief 構造体からクラスへ変換する. * @param[in] data 構造体データ */ void ConvertFromStruct( const ConvertMnemonicToSeedRequestStruct& data); /** * @brief クラスから構造体へ変換する. * @return 構造体データ */ ConvertMnemonicToSeedRequestStruct ConvertToStruct() const; protected: /** * @brief Mapテーブルの型名定義 */ using ConvertMnemonicToSeedRequestMapTable = cfd::core::JsonTableMap<ConvertMnemonicToSeedRequest>; /** * @brief JSONマッピングオブジェクトを取得する。 * @return JSONマッピングオブジェクト * @see cfd::core::JsonClassBase::GetJsonMapper() */ virtual const ConvertMnemonicToSeedRequestMapTable& GetJsonMapper() const { // NOLINT return json_mapper; } /** * @brief JSONマッピングのアイテム一覧を取得する。 * 対象の変数名を、定義順序に従い一覧取得する。 * @return JSONマッピングのアイテム一覧 * @see cfd::core::JsonClassBase::GetJsonItemList() */ virtual const std::vector<std::string>& GetJsonItemList() const { return item_list; } /** * @brief JSONマッピング時に無視するアイテム一覧を取得する。 * Serialize時に対象の変数を無視する。 * @return JSONマッピング時に無視するアイテム一覧 * @see cfd::core::JsonClassBase::GetIgnoreItem() */ virtual const std::set<std::string>& GetIgnoreItem() const { return ignore_items; } private: /** * @brief JsonFunctionMapテーブル */ static ConvertMnemonicToSeedRequestMapTable json_mapper; /** * @brief フィールド名リスト */ static std::vector<std::string> item_list; /** * @brief 無視リスト */ std::set<std::string> ignore_items; /** * @brief JsonAPI(mnemonic) のvalue */ JsonValueVector<std::string> mnemonic_; // NOLINT /** * @brief JsonAPI(passphrase) のvalue */ std::string passphrase_ = ""; /** * @brief JsonAPI(strictCheck) のvalue */ bool strict_check_ = false; /** * @brief JsonAPI(language) のvalue */ std::string language_ = ""; /** * @brief JsonAPI(useIdeographicSpace) のvalue */ bool use_ideographic_space_ = false; }; // ------------------------------------------------------------------------ // ConvertMnemonicToSeedResponse // ------------------------------------------------------------------------ /** * @brief JSON-API(ConvertMnemonicToSeedResponse)クラス */ class ConvertMnemonicToSeedResponse : public cfd::core::JsonClassBase<ConvertMnemonicToSeedResponse> { public: ConvertMnemonicToSeedResponse() { CollectFieldName(); } virtual ~ConvertMnemonicToSeedResponse() { // do nothing } /** * @brief フィールド名を収集する. */ static void CollectFieldName(); /** * @brief seed 取得処理 * @return seed */ std::string GetSeed() const { return seed_; } /** * @brief seed 設定処理 * @param[in] seed 設定値 */ void SetSeed( // line separate const std::string& seed) { // NOLINT this->seed_ = seed; } /** * @brief seed データ型の取得処理 * @return seedのデータ型 */ static std::string GetSeedFieldType() { return "std::string"; } /** * @brief seed フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetSeedString( // line separate const ConvertMnemonicToSeedResponse& obj) { // NOLINT return cfd::core::ConvertToString(obj.seed_); } /** * @brief seed フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetSeedString( // line separate ConvertMnemonicToSeedResponse& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.seed_, json_value); } /** * @brief entropy 取得処理 * @return entropy */ std::string GetEntropy() const { return entropy_; } /** * @brief entropy 設定処理 * @param[in] entropy 設定値 */ void SetEntropy( // line separate const std::string& entropy) { // NOLINT this->entropy_ = entropy; } /** * @brief entropy データ型の取得処理 * @return entropyのデータ型 */ static std::string GetEntropyFieldType() { return "std::string"; } /** * @brief entropy フィールドのJSON文字列取得処理 * @param[in,out] obj クラスオブジェクト * @return JSON文字列 */ static std::string GetEntropyString( // line separate const ConvertMnemonicToSeedResponse& obj) { // NOLINT return cfd::core::ConvertToString(obj.entropy_); } /** * @brief entropy フィールドへのJSON情報設定処理 * @param[in,out] obj クラスオブジェクト * @param[in] json_value JSON情報 */ static void SetEntropyString( // line separate ConvertMnemonicToSeedResponse& obj, // NOLINT const UniValue& json_value) { cfd::core::ConvertFromUniValue( // line separate obj.entropy_, json_value); } /** * @brief 無視対象アイテムを設定する。 * @param[in] key 無視対象アイテムのキー名称 */ void SetIgnoreItem(const std::string& key) { ignore_items.insert(key); } /** * @brief 構造体からクラスへ変換する. * @param[in] data 構造体データ */ void ConvertFromStruct( const ConvertMnemonicToSeedResponseStruct& data); /** * @brief クラスから構造体へ変換する. * @return 構造体データ */ ConvertMnemonicToSeedResponseStruct ConvertToStruct() const; protected: /** * @brief Mapテーブルの型名定義 */ using ConvertMnemonicToSeedResponseMapTable = cfd::core::JsonTableMap<ConvertMnemonicToSeedResponse>; /** * @brief JSONマッピングオブジェクトを取得する。 * @return JSONマッピングオブジェクト * @see cfd::core::JsonClassBase::GetJsonMapper() */ virtual const ConvertMnemonicToSeedResponseMapTable& GetJsonMapper() const { // NOLINT return json_mapper; } /** * @brief JSONマッピングのアイテム一覧を取得する。 * 対象の変数名を、定義順序に従い一覧取得する。 * @return JSONマッピングのアイテム一覧 * @see cfd::core::JsonClassBase::GetJsonItemList() */ virtual const std::vector<std::string>& GetJsonItemList() const { return item_list; } /** * @brief JSONマッピング時に無視するアイテム一覧を取得する。 * Serialize時に対象の変数を無視する。 * @return JSONマッピング時に無視するアイテム一覧 * @see cfd::core::JsonClassBase::GetIgnoreItem() */ virtual const std::set<std::string>& GetIgnoreItem() const { return ignore_items; } private: /** * @brief JsonFunctionMapテーブル */ static ConvertMnemonicToSeedResponseMapTable json_mapper; /** * @brief フィールド名リスト */ static std::vector<std::string> item_list; /** * @brief 無視リスト */ std::set<std::string> ignore_items; /** * @brief JsonAPI(seed) のvalue */ std::string seed_ = ""; /** * @brief JsonAPI(entropy) のvalue */ std::string entropy_ = ""; }; // @formatter:on // clang-format on } // namespace json } // namespace api } // namespace js } // namespace cfd #endif // CFD_JS_SRC_CFDAPI_CONVERT_MNEMONIC_TO_SEED_JSON_H_
24.881818
89
0.648666
[ "vector" ]
d76e994ec564dc2f2cc3d21fd749b410ab4cc04a
823
h
C
IMKit/Sections/Conversation/RCConversationCSUtil.h
eyolo2021/ios-ui-sdk-set
a8897320c356ddd6dbfe964ef68eb76701759f03
[ "MIT" ]
14
2021-03-06T08:47:30.000Z
2022-02-11T09:42:24.000Z
IMKit/Sections/Conversation/RCConversationCSUtil.h
eyolo2021/ios-ui-sdk-set
a8897320c356ddd6dbfe964ef68eb76701759f03
[ "MIT" ]
3
2021-03-19T11:12:42.000Z
2021-11-29T14:56:33.000Z
IMKit/Sections/Conversation/RCConversationCSUtil.h
Zuzi007/ios-ui-sdk-set
2e51added5d697b4d1ab1ba2887ad297b408e7b0
[ "MIT" ]
12
2021-07-02T02:44:52.000Z
2022-03-01T05:15:22.000Z
// // RCConversationCSUtil.h // RongIMKit // // Created by Sin on 2020/6/16. // Copyright © 2020 RongCloud. All rights reserved. // #import <Foundation/Foundation.h> #import "RCConversationViewController.h" //聊天页面客服相关功能 @interface RCConversationCSUtil : NSObject - (instancetype)init:(RCConversationViewController *)chatVC; /*! 用户的详细信息,此数据用于上传用户信息到客服后台,数据的nickName和portraitUrl必须填写。 */ @property (nonatomic, strong) RCCustomerServiceInfo *csInfo; @property (nonatomic, assign) RCCustomerServiceStatus currentServiceStatus; //客服开始 - (void)startCustomerService; - (void)stopCSTimer; - (void)startNotReciveMessageAlertTimer; - (void)startNotSendMessageAlertTimer; - (void)didTapCSPullLeaveMessage:(RCMessageModel *)model; - (void)customerServiceLeftCurrentViewController; - (void)robotSwitchButtonDidTouch; @end
22.861111
75
0.788578
[ "model" ]
d78475c3493f926e7e4700569bd87961a30d8f90
436
h
C
opengl_basic/opengl_basic/src/Texture.h
madhavsharma1808/opengl_basic
f53a0fb534166331e42dfdb8e0205ffaef13bb54
[ "Apache-2.0" ]
null
null
null
opengl_basic/opengl_basic/src/Texture.h
madhavsharma1808/opengl_basic
f53a0fb534166331e42dfdb8e0205ffaef13bb54
[ "Apache-2.0" ]
null
null
null
opengl_basic/opengl_basic/src/Texture.h
madhavsharma1808/opengl_basic
f53a0fb534166331e42dfdb8e0205ffaef13bb54
[ "Apache-2.0" ]
null
null
null
#pragma once #include "Render.h" class Texture { private: unsigned int m_RendererID; std::string m_FilePath; unsigned char* m_LocalBuffer; int m_Width; int m_Height; int m_BPP; //Bits Per Pixel public : Texture(const std::string& path); ~Texture(); void Bind(unsigned int slot=0) const; void Unbind() const; inline int GetWidth() const { return m_Width; } inline int GetHeight() const { return m_Height; }; };
14.533333
38
0.699541
[ "render" ]
d7859f6a24127d87f66254b1cc9dfa9693074134
1,093
h
C
src/Executable.h
ryuichiueda/GlueLang
7ad3e5b1d631d8482bb49c397abc6b2b3f38e249
[ "MIT" ]
40
2015-01-13T15:05:47.000Z
2021-11-17T11:05:55.000Z
src/Executable.h
ryuichiueda/GlueLang
7ad3e5b1d631d8482bb49c397abc6b2b3f38e249
[ "MIT" ]
13
2015-01-02T13:19:50.000Z
2021-04-20T12:23:00.000Z
src/Executable.h
ryuichiueda/GlueLang
7ad3e5b1d631d8482bb49c397abc6b2b3f38e249
[ "MIT" ]
3
2015-02-04T23:11:46.000Z
2019-04-28T06:38:58.000Z
// Copyright 2014 Ryuichi Ueda // Released under the MIT License. #ifndef __COMMAND_LINE_H_ #define __COMMAND_LINE_H_ #include "Element.h" #include <iostream> #include <vector> using namespace std; class Element; class Feeder; class Arg; class DefFile; class DefStr; class Environment; class Where; class Executable : public Element { public: Executable(Feeder *f,Environment *env, vector<int> *scopes); virtual ~Executable(); virtual bool parse(void) = 0; void parseArgs(void); virtual void appendArg(string a){m_add_args.push_back(a);} virtual void clearAppendArg(void){m_add_args.clear();} virtual int exec(DefFile *f, DefStr *s); virtual bool eval(void); void setPipe(int *pip,int prev); int getPrevPipe(void){return m_pipe_prev;}; bool m_is_wait; bool m_is_break; char** makeArgv(void); protected: virtual void execChild(DefFile *f, DefStr *s) = 0; void execErrorExit(void); void childPipeProc(void); void parentPipeProc(void); void prepareFile(void); int m_pipe[2]; int m_pipe_prev; void vOptProc(char const *arg); vector<string> m_add_args; }; #endif
19.175439
61
0.745654
[ "vector" ]
d79ba19c3d4e967ee2fe7b5620a66acd1770fa2c
3,131
h
C
essbasic/include/tencentcloud/essbasic/v20210526/model/DescribeResourceUrlsByFlowsResponse.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
null
null
null
essbasic/include/tencentcloud/essbasic/v20210526/model/DescribeResourceUrlsByFlowsResponse.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
null
null
null
essbasic/include/tencentcloud/essbasic/v20210526/model/DescribeResourceUrlsByFlowsResponse.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_ESSBASIC_V20210526_MODEL_DESCRIBERESOURCEURLSBYFLOWSRESPONSE_H_ #define TENCENTCLOUD_ESSBASIC_V20210526_MODEL_DESCRIBERESOURCEURLSBYFLOWSRESPONSE_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/essbasic/v20210526/model/FlowResourceUrlInfo.h> namespace TencentCloud { namespace Essbasic { namespace V20210526 { namespace Model { /** * DescribeResourceUrlsByFlows返回参数结构体 */ class DescribeResourceUrlsByFlowsResponse : public AbstractModel { public: DescribeResourceUrlsByFlowsResponse(); ~DescribeResourceUrlsByFlowsResponse() = default; CoreInternalOutcome Deserialize(const std::string &payload); std::string ToJsonString() const; /** * 获取流程资源对应链接信息 * @return FlowResourceUrlInfos 流程资源对应链接信息 */ std::vector<FlowResourceUrlInfo> GetFlowResourceUrlInfos() const; /** * 判断参数 FlowResourceUrlInfos 是否已赋值 * @return FlowResourceUrlInfos 是否已赋值 */ bool FlowResourceUrlInfosHasBeenSet() const; /** * 获取创建消息,对应多个合同ID, 成功为“”,创建失败则对应失败消息 * @return ErrorMessages 创建消息,对应多个合同ID, 成功为“”,创建失败则对应失败消息 */ std::vector<std::string> GetErrorMessages() const; /** * 判断参数 ErrorMessages 是否已赋值 * @return ErrorMessages 是否已赋值 */ bool ErrorMessagesHasBeenSet() const; private: /** * 流程资源对应链接信息 */ std::vector<FlowResourceUrlInfo> m_flowResourceUrlInfos; bool m_flowResourceUrlInfosHasBeenSet; /** * 创建消息,对应多个合同ID, 成功为“”,创建失败则对应失败消息 */ std::vector<std::string> m_errorMessages; bool m_errorMessagesHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_ESSBASIC_V20210526_MODEL_DESCRIBERESOURCEURLSBYFLOWSRESPONSE_H_
32.957895
87
0.563718
[ "vector", "model" ]
d7a294ab6577ffd658f76fed3a7b711756ad7448
21,110
h
C
cusp/system/cuda/detail/multiply/coo_flat_spmv.h
Raman-sh/cusplibrary
99dcde05991ef59cbc4546aeced6eb3bd49c90c9
[ "Apache-2.0" ]
270
2015-01-12T19:40:50.000Z
2022-03-28T00:58:21.000Z
cusp/system/cuda/detail/multiply/coo_flat_spmv.h
njh19/cusplibrary
4f72f152804dee592fec86719049af2b5469295a
[ "Apache-2.0" ]
41
2015-01-08T18:07:42.000Z
2022-02-27T02:37:38.000Z
cusp/system/cuda/detail/multiply/coo_flat_spmv.h
njh19/cusplibrary
4f72f152804dee592fec86719049af2b5469295a
[ "Apache-2.0" ]
106
2015-02-27T19:30:58.000Z
2022-03-29T13:55:53.000Z
/* * Copyright 2008-2014 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <thrust/extrema.h> #include <cusp/system/cuda/arch.h> #include <cusp/system/cuda/utils.h> #include <cusp/system/cuda/detail/multiply/coo_serial.h> #include <thrust/device_ptr.h> // Note: Unlike the other kernels this kernel implements y += A*x namespace cusp { namespace system { namespace cuda { namespace detail { // segmented reduction in shared memory template <typename IndexType, typename ValueType, typename BinaryFunction> __device__ ValueType segreduce_warp(const IndexType thread_lane, IndexType row, ValueType val, IndexType * rows, ValueType * vals, BinaryFunction reduce) { rows[threadIdx.x] = row; vals[threadIdx.x] = val; if( thread_lane >= 1 && row == rows[threadIdx.x - 1] ) { vals[threadIdx.x] = val = reduce(val, vals[threadIdx.x - 1]); } if( thread_lane >= 2 && row == rows[threadIdx.x - 2] ) { vals[threadIdx.x] = val = reduce(val, vals[threadIdx.x - 2]); } if( thread_lane >= 4 && row == rows[threadIdx.x - 4] ) { vals[threadIdx.x] = val = reduce(val, vals[threadIdx.x - 4]); } if( thread_lane >= 8 && row == rows[threadIdx.x - 8] ) { vals[threadIdx.x] = val = reduce(val, vals[threadIdx.x - 8]); } if( thread_lane >= 16 && row == rows[threadIdx.x - 16] ) { vals[threadIdx.x] = val = reduce(val, vals[threadIdx.x - 16]); } return val; } template <typename IndexType, typename ValueType, typename BinaryFunction> __device__ void segreduce_block(const IndexType * idx, ValueType * val, BinaryFunction reduce) { ValueType left = 0; if( threadIdx.x >= 1 && idx[threadIdx.x] == idx[threadIdx.x - 1] ) { left = val[threadIdx.x - 1]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 2 && idx[threadIdx.x] == idx[threadIdx.x - 2] ) { left = val[threadIdx.x - 2]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 4 && idx[threadIdx.x] == idx[threadIdx.x - 4] ) { left = val[threadIdx.x - 4]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 8 && idx[threadIdx.x] == idx[threadIdx.x - 8] ) { left = val[threadIdx.x - 8]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 16 && idx[threadIdx.x] == idx[threadIdx.x - 16] ) { left = val[threadIdx.x - 16]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 32 && idx[threadIdx.x] == idx[threadIdx.x - 32] ) { left = val[threadIdx.x - 32]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 64 && idx[threadIdx.x] == idx[threadIdx.x - 64] ) { left = val[threadIdx.x - 64]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 128 && idx[threadIdx.x] == idx[threadIdx.x - 128] ) { left = val[threadIdx.x - 128]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); if( threadIdx.x >= 256 && idx[threadIdx.x] == idx[threadIdx.x - 256] ) { left = val[threadIdx.x - 256]; } __syncthreads(); val[threadIdx.x] = reduce(val[threadIdx.x], left); left = 0; __syncthreads(); } ////////////////////////////////////////////////////////////////////////////// // COO SpMV kernel which flattens data irregularity (segmented reduction) ////////////////////////////////////////////////////////////////////////////// // // spmv_coo_flat // The input coo_matrix must be sorted by row. Columns within each row // may appear in any order and duplicate entries are also acceptable. // This sorted COO format is easily obtained by expanding the row pointer // of a CSR matrix (csr.Ap) into proper row indices and then copying // the arrays containing the CSR column indices (csr.Aj) and nonzero values // (csr.Ax) verbatim. A segmented reduction is used to compute the per-row // sums. // // spmv_coo_flat_tex // Same as spmv_coo_flat, except that the texture cache is // used for accessing the x vector. // // spmv_coo_flat_kernel // // In this kernel each warp processes an interval of the nonzero values. // For example, if the matrix contains 128 nonzero values and there are // two warps and interval_size is 64, then the first warp (warp_id == 0) // will process the first set of 64 values (interval [0, 64)) and the // second warp will process // the second set of 64 values // (interval [64, 128)). Note that the number of nonzeros is not always // a multiple of 32 (the warp size) or 32 * the number of active warps, // so the last active warp will not always process a "full" interval of // interval_size. // // The first thread in each warp (thread_lane == 0) has a special role: // it is responsible for keeping track of the "carry" values from one // iteration to the next. The carry values consist of the row index and // partial sum from the previous batch of 32 elements. In the example // mentioned before with two warps and 128 nonzero elements, the first // warp iterates twice and looks at the carry of the first iteration to // decide whether to include this partial sum into the current batch. // Specifically, if a row extends over a 32-element boundary, then the // partial sum is carried over into the new 32-element batch. If, // on the other hand, the _last_ row index of the previous batch (the carry) // differs from the _first_ row index of the current batch (the row // read by the thread with thread_lane == 0), then the partial sum // is written out to memory. // // Each warp iterates over its interval, processing 32 elements at a time. // For each batch of 32 elements, the warp does the following // 1) Fetch the row index, column index, and value for a matrix entry. These // values are loaded from I[n], J[n], and V[n] respectively. // The row entry is stored in the shared memory array idx. // 2) Fetch the corresponding entry from the input vector. Specifically, for a // nonzero entry (i,j) in the matrix, the thread must load the value x[j] // from memory. We use the function fetch_x to control whether the texture // cache is used to load the value (UseCache == True) or whether a normal // global load is used (UseCache == False). // 3) The matrix value A(i,j) (which was stored in V[n]) is multiplied by the // value x[j] and stored in the shared memory array val. // 4) The first thread in the warp (thread_lane == 0) considers the "carry" // row index and either includes the carried sum in its own sum, or it // updates the output vector (y) with the carried sum. // 5) With row indices in the shared array idx and sums in the shared array // val, the warp conducts a segmented scan. The segmented scan operation // looks at the row entries for each thread (stored in idx) to see whether // two values belong to the same segment (segments correspond to matrix rows). // Consider the following example which consists of 3 segments // (note: this example uses a warp size of 16 instead of the usual 32) // // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # thread_lane // idx [ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] # row indices // val [ 4, 6, 5, 0, 8, 3, 2, 8, 3, 1, 4, 9, 2, 5, 2, 4] # A(i,j) * x(j) // // After the segmented scan the result will be // // val [ 4,10,15,15,23,26, 2,10,13,14, 4,13,15,20,22,26] # A(i,j) * x(j) // // 6) After the warp computes the segmented scan operation // each thread except for the last (thread_lane == 31) looks // at the row index of the next thread (threadIdx.x + 1) to // see if the segment ends here, or continues into the // next thread. The thread at the end of the segment writes // the sum into the output vector (y) at the corresponding row // index. // 7) The last thread in each warp (thread_lane == 31) writes // its row index and partial sum into the designated spote in the // carry_idx and carry_val arrays. The carry arrays are indexed // by warp_lane which is a number in [0, BLOCK_SIZE / 32). // // These steps are repeated until the warp reaches the end of its interval. // The carry values at the end of each interval are written to arrays // temp_rows and temp_vals, which are processed by a second kernel. // template <typename IndexType, typename RowIterator, typename ColumnIterator, typename ValueIterator1, typename ValueIterator2, typename ValueIterator3, typename IndexIterator, typename ValueIterator4, typename BinaryFunction1, typename BinaryFunction2, unsigned int BLOCK_SIZE> __launch_bounds__(BLOCK_SIZE,1) __global__ void spmv_coo_flat_kernel(const IndexType num_nonzeros, const IndexType interval_size, const RowIterator I, const ColumnIterator J, const ValueIterator1 V, const ValueIterator2 x, ValueIterator3 y, IndexIterator temp_rows, ValueIterator4 temp_vals, BinaryFunction1 combine, BinaryFunction2 reduce) { typedef typename thrust::iterator_value<ValueIterator1>::type ValueType; __shared__ volatile IndexType rows[48 *(BLOCK_SIZE/32)]; __shared__ volatile ValueType vals[BLOCK_SIZE]; const IndexType thread_id = BLOCK_SIZE * blockIdx.x + threadIdx.x; // global thread index const IndexType thread_lane = threadIdx.x & (WARP_SIZE-1); // thread index within the warp const IndexType warp_id = thread_id / WARP_SIZE; // global warp index const IndexType interval_begin = warp_id * interval_size; // warp's offset into I,J,V const IndexType interval_end = thrust::min(interval_begin + interval_size, num_nonzeros); // end of warps's work const IndexType idx = 16 * (threadIdx.x/32 + 1) + threadIdx.x; // thread's index into padded rows array rows[idx - 16] = -1; // fill padding with invalid row index if(interval_begin >= interval_end) // warp has no work to do return; if (thread_lane == 31) { // initialize the carry in values rows[idx] = I[interval_begin]; vals[threadIdx.x] = ValueType(0); } for(IndexType n = interval_begin + thread_lane; n < interval_end; n += WARP_SIZE) { IndexType row = I[n]; // row index (i) ValueType val = combine(V[n], x[ J[n] ]); // A(i,j) * x(j) if (thread_lane == 0) { if(row == rows[idx + 31]) val = reduce(val, ValueType(vals[threadIdx.x + 31])); // row continues else y[rows[idx + 31]] = reduce(y[rows[idx + 31]], ValueType(vals[threadIdx.x + 31])); // row terminated } rows[idx] = row; vals[threadIdx.x] = val; if(row == rows[idx - 1]) { vals[threadIdx.x] = val = reduce(val, ValueType(vals[threadIdx.x - 1])); } if(row == rows[idx - 2]) { vals[threadIdx.x] = val = reduce(val, ValueType(vals[threadIdx.x - 2])); } if(row == rows[idx - 4]) { vals[threadIdx.x] = val = reduce(val, ValueType(vals[threadIdx.x - 4])); } if(row == rows[idx - 8]) { vals[threadIdx.x] = val = reduce(val, ValueType(vals[threadIdx.x - 8])); } if(row == rows[idx - 16]) { vals[threadIdx.x] = val = reduce(val, ValueType(vals[threadIdx.x - 16])); } if(thread_lane < 31 && row != rows[idx + 1]) y[row] = reduce(y[row], ValueType(vals[threadIdx.x])); // row terminated } if(thread_lane == 31) { // write the carry out values temp_rows[warp_id] = IndexType(rows[idx]); temp_vals[warp_id] = ValueType(vals[threadIdx.x]); } } // The second level of the segmented reduction operation template <typename IndexIterator, typename ValueIterator1, typename ValueIterator2, typename BinaryFunction, unsigned int BLOCK_SIZE> __launch_bounds__(BLOCK_SIZE,1) __global__ void spmv_coo_reduce_update_kernel(const unsigned int num_warps, const IndexIterator temp_rows, const ValueIterator1 temp_vals, ValueIterator2 y, BinaryFunction reduce) { typedef typename thrust::iterator_value<IndexIterator>::type IndexType; typedef typename thrust::iterator_value<ValueIterator1>::type ValueType; __shared__ IndexType rows[BLOCK_SIZE + 1]; __shared__ ValueType vals[BLOCK_SIZE + 1]; const IndexType end = num_warps - (num_warps & (BLOCK_SIZE - 1)); if (threadIdx.x == 0) { rows[BLOCK_SIZE] = (IndexType) -1; vals[BLOCK_SIZE] = (ValueType) 0; } __syncthreads(); IndexType i = threadIdx.x; while (i < end) { // do full blocks rows[threadIdx.x] = temp_rows[i]; vals[threadIdx.x] = temp_vals[i]; __syncthreads(); segreduce_block(rows, vals, reduce); if (rows[threadIdx.x] != rows[threadIdx.x + 1]) y[rows[threadIdx.x]] = reduce(y[rows[threadIdx.x]], vals[threadIdx.x]); __syncthreads(); i += BLOCK_SIZE; } if (end < num_warps) { if (i < num_warps) { rows[threadIdx.x] = temp_rows[i]; vals[threadIdx.x] = temp_vals[i]; } else { rows[threadIdx.x] = (IndexType) -1; vals[threadIdx.x] = (ValueType) 0; } __syncthreads(); segreduce_block(rows, vals, reduce); if (i < num_warps) if (rows[threadIdx.x] != rows[threadIdx.x + 1]) y[rows[threadIdx.x]] = reduce(y[rows[threadIdx.x]], vals[threadIdx.x]); } } template <bool InitializeY, typename DerivedPolicy, typename MatrixType, typename VectorType1, typename VectorType2, typename UnaryFunction, typename BinaryFunction1, typename BinaryFunction2> void __spmv_coo_flat(cuda::execution_policy<DerivedPolicy>& exec, const MatrixType& A, const VectorType1& x, VectorType2& y, UnaryFunction initialize, BinaryFunction1 combine, BinaryFunction2 reduce) { typedef typename MatrixType::index_type IndexType; typedef typename VectorType2::value_type ValueType; typedef typename MatrixType::row_indices_array_type::const_iterator RowIterator; typedef typename MatrixType::column_indices_array_type::const_iterator ColumnIterator; typedef typename MatrixType::values_array_type::const_iterator ValueIterator1; typedef typename VectorType1::const_iterator ValueIterator2; typedef typename VectorType2::iterator ValueIterator3; typedef typename cusp::array1d<IndexType,cusp::device_memory>::iterator IndexIterator; typedef typename cusp::array1d<ValueType,cusp::device_memory>::iterator ValueIterator4; if (InitializeY) thrust::fill(y.begin(), y.begin() + A.num_rows, ValueType(0)); cudaStream_t s = stream(thrust::detail::derived_cast(exec)); if(A.num_entries == 0) { // empty matrix return; } else if (A.num_entries < static_cast<size_t>(WARP_SIZE)) { // small matrix spmv_coo_serial_kernel<RowIterator, ColumnIterator, ValueIterator1, ValueIterator2, ValueIterator3, BinaryFunction1, BinaryFunction2> <<<1,1,0,s>>> (A.num_entries, A.row_indices.begin(), A.column_indices.begin(), A.values.begin(), x.begin(), y.begin(), combine, reduce); return; } const unsigned int BLOCK_SIZE = 256; const unsigned int MAX_BLOCKS = cusp::system::cuda::detail::max_active_blocks( spmv_coo_flat_kernel<IndexType, RowIterator, ColumnIterator, ValueIterator1, ValueIterator2, ValueIterator3, IndexIterator, ValueIterator4, BinaryFunction1, BinaryFunction2, BLOCK_SIZE>, BLOCK_SIZE, (size_t) 0); const unsigned int WARPS_PER_BLOCK = BLOCK_SIZE / WARP_SIZE; const unsigned int num_units = A.num_entries / WARP_SIZE; const unsigned int num_warps = std::min(num_units, WARPS_PER_BLOCK * MAX_BLOCKS); const unsigned int num_blocks = DIVIDE_INTO(num_warps, WARPS_PER_BLOCK); const unsigned int num_iters = DIVIDE_INTO(num_units, num_warps); const unsigned int interval_size = WARP_SIZE * num_iters; const IndexType tail = num_units * WARP_SIZE; // do the last few nonzeros separately (fewer than WARP_SIZE elements) const unsigned int active_warps = (interval_size == 0) ? 0 : DIVIDE_INTO(tail, interval_size); cusp::array1d<IndexType,cusp::device_memory> temp_rows(active_warps); cusp::array1d<ValueType,cusp::device_memory> temp_vals(active_warps); spmv_coo_flat_kernel<IndexType, RowIterator, ColumnIterator, ValueIterator1, ValueIterator2, ValueIterator3, IndexIterator, ValueIterator4, BinaryFunction1, BinaryFunction2, BLOCK_SIZE> <<<num_blocks, BLOCK_SIZE, 0, s>>> (tail, interval_size, A.row_indices.begin(), A.column_indices.begin(), A.values.begin(), x.begin(), y.begin(), temp_rows.begin(), temp_vals.begin(), combine, reduce); spmv_coo_reduce_update_kernel<IndexIterator, ValueIterator4, ValueIterator3, BinaryFunction2, BLOCK_SIZE> <<<1, BLOCK_SIZE, 0, s>>> (active_warps, temp_rows.begin(), temp_vals.begin(), y.begin(), reduce); spmv_coo_serial_kernel<RowIterator, ColumnIterator, ValueIterator1, ValueIterator2, ValueIterator3, BinaryFunction1, BinaryFunction2> <<<1,1,0,s>>> (A.num_entries - tail, A.row_indices.begin() + tail, A.column_indices.begin() + tail, A.values.begin() + tail, x.begin(), y.begin(), combine, reduce); } #if THRUST_VERSION < 100800 template <typename DerivedPolicy, typename MatrixType, typename VectorType1, typename VectorType2, typename BinaryFunction1, typename BinaryFunction2> void multiply(cuda::execution_policy<DerivedPolicy>& exec, const MatrixType& A, const VectorType1& x, VectorType2& y, thrust::identity<typename MatrixType::value_type> initialize, BinaryFunction1 combine, BinaryFunction2 reduce, coo_format, array1d_format, array1d_format) { __spmv_coo_flat<false>(exec, A, x, y, initialize, combine, reduce); } template <typename DerivedPolicy, typename MatrixType, typename VectorType1, typename VectorType2, typename UnaryFunction, typename BinaryFunction1, typename BinaryFunction2> void multiply(cuda::execution_policy<DerivedPolicy>& exec, const MatrixType& A, const VectorType1& x, VectorType2& y, UnaryFunction initialize, BinaryFunction1 combine, BinaryFunction2 reduce, coo_format, array1d_format, array1d_format) { __spmv_coo_flat<true>(exec, A, x, y, initialize, combine, reduce); } #endif } // end namespace detail } // end namespace cuda } // end namespace system } // end namespace cusp
41.150097
155
0.619943
[ "vector" ]
d7a3b893017d5032bed3ba3f8bb2eb114396a264
4,603
h
C
venv/lib/python3.7/site-packages/torch/include/ATen/Parallel.h
davidglavas/sgan-experiments
b1f53440dcb014e8b971a1406ce14ac216a7b512
[ "MIT" ]
15
2019-08-10T02:36:38.000Z
2021-07-14T13:45:32.000Z
aten/src/ATen/Parallel.h
wxwoods/mctorch
7cd6eb51fdd01fa75ed9245039a4f145ba342de2
[ "BSD-3-Clause" ]
7
2019-10-21T03:08:51.000Z
2022-03-11T23:54:28.000Z
aten/src/ATen/Parallel.h
wxwoods/mctorch
7cd6eb51fdd01fa75ed9245039a4f145ba342de2
[ "BSD-3-Clause" ]
5
2019-09-27T02:41:40.000Z
2021-11-05T20:40:49.000Z
#pragma once #include <ATen/ATen.h> #include <c10/core/thread_pool.h> #include <atomic> #include <cstddef> #include <exception> #ifdef _OPENMP #include <omp.h> #endif namespace at { namespace internal { // This parameter is heuristically chosen to determine the minimum number of // work that warrants paralellism. For example, when summing an array, it is // deemed inefficient to parallelise over arrays shorter than 32768. Further, // no parallel algorithm (such as parallel_reduce) should split work into // smaller than GRAIN_SIZE chunks. constexpr int64_t GRAIN_SIZE = 32768; } // namespace internal inline int64_t divup(int64_t x, int64_t y) { return (x + y - 1) / y; } // Called during new thread initialization CAFFE2_API void init_num_threads(); // Sets the number of threads to be used in parallel region CAFFE2_API void set_num_threads(size_t); // Returns the number of threads used in parallel region CAFFE2_API size_t get_num_threads(); // Returns the current thread number (starting from 0) // in the current parallel region, or 0 in the sequential region inline int get_thread_num() { #ifdef _OPENMP return omp_get_thread_num(); #else return 0; #endif } inline bool in_parallel_region() { #ifdef _OPENMP return omp_in_parallel(); #else return false; #endif } template <class F> inline void parallel_for( const int64_t begin, const int64_t end, const int64_t grain_size, const F& f) { #ifdef _OPENMP std::atomic_flag err_flag = ATOMIC_FLAG_INIT; std::exception_ptr eptr; #pragma omp parallel if (!omp_in_parallel() && ((end - begin) >= grain_size)) { int64_t num_threads = omp_get_num_threads(); int64_t tid = omp_get_thread_num(); int64_t chunk_size = divup((end - begin), num_threads); int64_t begin_tid = begin + tid * chunk_size; if (begin_tid < end) { try { f(begin_tid, std::min(end, chunk_size + begin_tid)); } catch (...) { if (!err_flag.test_and_set()) { eptr = std::current_exception(); } } } } if (eptr) { std::rethrow_exception(eptr); } #else if (begin < end) { f(begin, end); } #endif } /* parallel_reduce begin: index at which to start applying reduction end: index at which to stop applying reduction grain_size: number of elements per chunk. impacts number of elements in intermediate results tensor and degree of parallelization. ident: identity for binary combination function sf. sf(ident, x) needs to return x. f: function for reduction over a chunk. f needs to be of signature scalar_t f(int64_t partial_begin, int64_t partial_end, scalar_t identifiy) sf: function to combine two partial results. sf needs to be of signature scalar_t sf(scalar_t x, scalar_t y) For example, you might have a tensor of 10000 entires and want to sum together all the elements. Parallel_reduce with a grain_size of 2500 will then allocate an intermediate result tensor with 4 elements. Then it will execute the function "f" you provide and pass the beginning and end index of these chunks, so 0-2499, 2500-4999, etc. and the combination identity. It will then write out the result from each of these chunks into the intermediate result tensor. After that it'll reduce the partial results from each chunk into a single number using the combination function sf and the identity ident. For a total summation this would be "+" and 0 respectively. This is similar to tbb's approach [1], where you need to provide a function to accumulate a subrange, a function to combine two partial results and an identity. [1] https://software.intel.com/en-us/node/506154 */ template <class scalar_t, class F, class SF> inline scalar_t parallel_reduce( const int64_t begin, const int64_t end, const int64_t grain_size, const scalar_t ident, const F f, const SF sf) { if (get_num_threads() == 1) { return f(begin, end, ident); } else { const int64_t num_results = divup((end - begin), grain_size); std::vector<scalar_t> results(num_results); scalar_t* results_data = results.data(); #pragma omp parallel for if ((end - begin) >= grain_size) for (int64_t id = 0; id < num_results; id++) { int64_t i = begin + id * grain_size; results_data[id] = f(i, i + std::min(end - i, grain_size), ident); } return std::accumulate( results_data, results_data + results.size(), ident, sf); } } class CAFFE2_API PTThreadPool : public c10::ThreadPool { public: explicit PTThreadPool( std::size_t pool_size, int numa_node_id = -1); void init_thread() override; }; } // namespace at
29.50641
80
0.719748
[ "vector" ]
d7a3f4c6d70d42b77591e872109e68398d6b6b10
1,845
c
C
d/antioch/greaterantioch/rooms/keep/keep6.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/antioch/greaterantioch/rooms/keep/keep6.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/antioch/greaterantioch/rooms/keep/keep6.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include "../../gantioch.h" #include <daemons.h> inherit ROOM; void create(){ ::create(); set_name("keep6"); set_terrain(CITY); set_travel(PAVED_ROAD); set_property("indoors",1); set_property("light",3); set_property("no teleport",0); set_short("%^BOLD%^%^YELLOW%^A Large Office%^RESET%^"); set_long("%^BOLD%^%^WHITE%^This large %^RESET%^%^ORANGE%^office %^BOLD%^%^WHITE%^seems well organized. A"+ " large %^RESET%^%^ORANGE%^desk %^BOLD%^%^WHITE%^sits in the back of the room with a man sitting behind it. On the right side of the"+ " room is a massive %^BOLD%^%^YELLOW%^bookshelf %^BOLD%^%^WHITE%^and a %^BOLD%^%^CYAN%^portrait %^BOLD%^%^WHITE%^next to it on the wall. On the left side of the room"+ " is a small chest, along with a smaller bookshelf. The %^BOLD%^%^BLUE%^rug %^BOLD%^%^WHITE%^here"+ " fits the room perfectly."); set_smell("default","\n%^RESET%^%^ORANGE%^You smell old books and parchment.%^RESET%^"); set_listen("default","%^BOLD%^%^YELLOW%^It is quiet here, only the sounds from outside are heard.%^RESET%^"); set_items(([ "rug" : "%^BOLD%^%^BLUE%^The rug here is plush and thick, actually looking like some sort of fur, except that it is blue.", "desk" : "%^RESET%^%^ORANGE%^The solid oak desk has plenty of papers neatly stacked on it.", "bookshelf" : "%^BOLD%^%^GREEN%^This beautifully crafted bookshelf has various books on it, ranging from anthropology to relgion, it seems to cover an entire gambit of social and metaphysical subjects.", "portrait" : "The portrait on the wall seems to be only a frame, obviously it has not been hung completely yet.", ]) ); set_exits(([ "east" : KEEP"keep3", ])); } void reset(){ ::reset(); if(!present("zathon")) new(MON+"zathon")->move(this_object()); }
40.108696
209
0.646612
[ "solid" ]
d7a7f6412744901a02ed2cf7afabf7a62a63c088
3,067
h
C
lesson03/shader.h
lkkmpn/opengl-cpp-course
952f64c1e2457290143d930f076ee62b23e08b9b
[ "AFL-3.0" ]
7
2019-09-24T15:05:17.000Z
2022-03-04T09:36:26.000Z
lesson03/shader.h
lkkmpn/opengl-cpp-course
952f64c1e2457290143d930f076ee62b23e08b9b
[ "AFL-3.0" ]
1
2019-03-08T08:07:22.000Z
2019-03-08T08:07:22.000Z
lesson03/shader.h
ifilot/opengl-cpp-course
0fafd1c8b538f6d173663809b4e2cb52d94cb45c
[ "AFL-3.0" ]
3
2018-08-13T08:03:33.000Z
2021-09-21T16:19:16.000Z
/************************************************************************** * * * Author: Ivo Filot <ivo@ivofilot.nl> * * * * This file is distributed under the Academic Free License 3.0 * * 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. * * * **************************************************************************/ #ifndef _SHADER_H #define _SHADER_H #include <string> #include <vector> #include <iostream> #include <fstream> #ifdef WIN32 #pragma comment (lib, "glew32s.lib") #define GLEW_STATIC #endif #include <GL/glew.h> /** * @brief Shader class * * Handles loading GLSL programs */ class Shader { private: GLuint program; //!< id of the program GLuint shaders[2]; //!< hold shader references std::vector<std::string> attributes; //!< attribute names public: /** * @brief Constructs Shader object. * * @param[in] path path to the shader files */ Shader(const std::string& path); /** * @brief add an attribute name * * @param[in] name attribute name */ void add_attribute(const std::string& name); /** * @brief build shader */ void build(); /** * @brief Gets the uniform location. * * @param[in] name uniform name * * @return The uniform location. */ inline GLuint get_uniform_location(const std::string& name) { return glGetUniformLocation(this->program, name.c_str()); } /** * @brief use the program */ inline void use() { glUseProgram(this->program); } /** * @brief get the Shader reference * * @return the reference */ inline GLuint get_id() const { return this->program; } private: /** * @brief check shader for error * * @param[in] shader shader reference * @param[in] flag which flag to check * @param[in] is_program whether to check linking or validation * @param[in] error_message The error message */ void check_shader_error(GLuint shader, GLuint flag, bool is_program, const std::string& error_message); /** * @brief load a shader * * @param[in] path path to the shader * @param[in] shader_type shader type */ void load_shader(const std::string& path, GLenum shader_type); /** * @brief load shader code from file * * @param[in] path path to file * * @return shader code */ std::string load_shader_code(const std::string& path); }; #endif // _SHADER_H
26.903509
107
0.495598
[ "object", "vector" ]
d7b17b1f129cb69edfe3757e91fa0a154b546146
22,674
h
C
src/plugins/win32/drawdeviceIrrlicht/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
miahmie/krkrz
e4948f61393ca4a2acac0301a975165dd4efc643
[ "Unlicense", "Apache-2.0", "Libpng", "FTL", "IJG" ]
2
2020-02-25T15:18:53.000Z
2020-08-24T13:30:34.000Z
src/plugins/win32/drawdeviceIrrlicht/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
miahmie/krkrz
e4948f61393ca4a2acac0301a975165dd4efc643
[ "Unlicense", "Apache-2.0", "Libpng", "FTL", "IJG" ]
null
null
null
src/plugins/win32/drawdeviceIrrlicht/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
miahmie/krkrz
e4948f61393ca4a2acac0301a975165dd4efc643
[ "Unlicense", "Apache-2.0", "Libpng", "FTL", "IJG" ]
1
2019-11-25T05:29:30.000Z
2019-11-25T05:29:30.000Z
// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ #define __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ #include "IrrCompileConfig.h" #ifdef _IRR_COMPILE_WITH_OPENGL_ #include "COpenGLDriver.h" #include "IMaterialRenderer.h" #if defined(_IRR_USE_OSX_DEVICE_) #define GL_COMBINE_EXT 0x8570 #define GL_COMBINE_RGB_EXT 0x8571 #define GL_COMBINE_ALPHA_EXT 0x8572 #define GL_RGB_SCALE_EXT 0x8573 #define GL_ADD_SIGNED_EXT 0x8574 #define GL_INTERPOLATE_EXT 0x8575 #define GL_CONSTANT_EXT 0x8576 #define GL_PRIMARY_COLOR_EXT 0x8577 #define GL_PREVIOUS_EXT 0x8578 #define GL_SOURCE0_RGB_EXT 0x8580 #define GL_SOURCE1_RGB_EXT 0x8581 #define GL_SOURCE2_RGB_EXT 0x8582 #define GL_SOURCE3_RGB_EXT 0x8583 #define GL_SOURCE4_RGB_EXT 0x8584 #define GL_SOURCE5_RGB_EXT 0x8585 #define GL_SOURCE6_RGB_EXT 0x8586 #define GL_SOURCE7_RGB_EXT 0x8587 #define GL_SOURCE0_ALPHA_EXT 0x8588 #define GL_SOURCE1_ALPHA_EXT 0x8589 #define GL_SOURCE2_ALPHA_EXT 0x858A #define GL_SOURCE3_ALPHA_EXT 0x858B #define GL_SOURCE4_ALPHA_EXT 0x858C #define GL_SOURCE5_ALPHA_EXT 0x858D #define GL_SOURCE6_ALPHA_EXT 0x858E #define GL_SOURCE7_ALPHA_EXT 0x858F #define GL_OPERAND0_RGB_EXT 0x8590 #define GL_OPERAND1_RGB_EXT 0x8591 #define GL_OPERAND2_RGB_EXT 0x8592 #define GL_OPERAND3_RGB_EXT 0x8593 #define GL_OPERAND4_RGB_EXT 0x8594 #define GL_OPERAND5_RGB_EXT 0x8595 #define GL_OPERAND6_RGB_EXT 0x8596 #define GL_OPERAND7_RGB_EXT 0x8597 #define GL_OPERAND0_ALPHA_EXT 0x8598 #define GL_OPERAND1_ALPHA_EXT 0x8599 #define GL_OPERAND2_ALPHA_EXT 0x859A #define GL_OPERAND3_ALPHA_EXT 0x859B #define GL_OPERAND4_ALPHA_EXT 0x859C #define GL_OPERAND5_ALPHA_EXT 0x859D #define GL_OPERAND6_ALPHA_EXT 0x859E #define GL_OPERAND7_ALPHA_EXT 0x859F #endif namespace irr { namespace video { //! Base class for all internal OpenGL material renderers class COpenGLMaterialRenderer : public IMaterialRenderer { public: //! Constructor COpenGLMaterialRenderer(video::COpenGLDriver* driver) : Driver(driver) { } protected: video::COpenGLDriver* Driver; }; //! Solid material renderer class COpenGLMaterialRenderer_SOLID : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_SOLID(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { // thanks to Murphy, the following line removed some // bugs with several OpenGL implementations. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } }; //! Generic Texture Blend class COpenGLMaterialRenderer_ONETEXTURE_BLEND : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_ONETEXTURE_BLEND(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); // if (material.MaterialType != lastMaterial.MaterialType || // material.MaterialTypeParam != lastMaterial.MaterialTypeParam || // resetAllRenderstates) { E_BLEND_FACTOR srcFact,dstFact; E_MODULATE_FUNC modulate; unpack_texureBlendFunc ( srcFact, dstFact, modulate, material.MaterialTypeParam ); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32) modulate ); glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) ); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) ) { glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); } } } virtual void OnUnsetMaterial() { glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); } private: u32 getGLBlend ( E_BLEND_FACTOR factor ) const { u32 r = 0; switch ( factor ) { case EBF_ZERO: r = GL_ZERO; break; case EBF_ONE: r = GL_ONE; break; case EBF_DST_COLOR: r = GL_DST_COLOR; break; case EBF_ONE_MINUS_DST_COLOR: r = GL_ONE_MINUS_DST_COLOR; break; case EBF_SRC_COLOR: r = GL_SRC_COLOR; break; case EBF_ONE_MINUS_SRC_COLOR: r = GL_ONE_MINUS_SRC_COLOR; break; case EBF_SRC_ALPHA: r = GL_SRC_ALPHA; break; case EBF_ONE_MINUS_SRC_ALPHA: r = GL_ONE_MINUS_SRC_ALPHA; break; case EBF_DST_ALPHA: r = GL_DST_ALPHA; break; case EBF_ONE_MINUS_DST_ALPHA: r = GL_ONE_MINUS_DST_ALPHA; break; case EBF_SRC_ALPHA_SATURATE: r = GL_SRC_ALPHA_SATURATE; break; } return r; } u32 getTexelAlpha ( E_BLEND_FACTOR factor ) const { u32 r; switch ( factor ) { case EBF_SRC_ALPHA: r = 1; break; case EBF_ONE_MINUS_SRC_ALPHA: r = 1; break; case EBF_DST_ALPHA: r = 1; break; case EBF_ONE_MINUS_DST_ALPHA: r = 1; break; case EBF_SRC_ALPHA_SATURATE: r = 1; break; default: r = 0; break; } return r; } }; //! Solid 2 layer material renderer class COpenGLMaterialRenderer_SOLID_2_LAYER : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_SOLID_2_LAYER(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(2); Driver->setTexture(1, material.getTexture(1)); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); Driver->extGlActiveTexture(GL_TEXTURE0_ARB); } glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } }; //! Transparent add color material renderer class COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates) { glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_BLEND); } } virtual void OnUnsetMaterial() { glDisable(GL_BLEND); } //! Returns if the material is transparent. virtual bool isTransparent() const { return true; } }; //! Transparent vertex alpha material renderer class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT ); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } } virtual void OnUnsetMaterial() { // default values glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT ); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glDisable(GL_BLEND); } //! Returns if the material is transparent. virtual bool isTransparent() const { return true; } }; //! Transparent alpha channel material renderer class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); f32 refValue = material.MaterialTypeParam; if ( refValue == 0.0f ) refValue = 0.5f; glAlphaFunc(GL_GREATER, refValue); } } virtual void OnUnsetMaterial() { glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); } //! Returns if the material is transparent. virtual bool isTransparent() const { return true; } }; //! Transparent alpha channel material renderer class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } } virtual void OnUnsetMaterial() { glDisable(GL_ALPHA_TEST); } //! Returns if the material is transparent. virtual bool isTransparent() const { return false; // this material is not really transparent because it does no blending. } }; //! material renderer for all kinds of lightmaps class COpenGLMaterialRenderer_LIGHTMAP : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_LIGHTMAP(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(2); Driver->setTexture(1, material.getTexture(1)); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { // diffuse map glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); switch (material.MaterialType) { case EMT_LIGHTMAP_LIGHTING: case EMT_LIGHTMAP_LIGHTING_M2: case EMT_LIGHTMAP_LIGHTING_M4: glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); break; case EMT_LIGHTMAP_ADD: case EMT_LIGHTMAP: case EMT_LIGHTMAP_M2: case EMT_LIGHTMAP_M4: default: glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); break; } glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR ); if (Driver->queryFeature(EVDF_MULTITEXTURE)) { // lightmap Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); if (material.MaterialType == EMT_LIGHTMAP_ADD) glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_ARB); else glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); switch (material.MaterialType) { case EMT_LIGHTMAP_M4: case EMT_LIGHTMAP_LIGHTING_M4: glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 4.0f); break; case EMT_LIGHTMAP_M2: case EMT_LIGHTMAP_LIGHTING_M2: glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f); break; default: glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); } } } } virtual void OnUnsetMaterial() { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); Driver->extGlActiveTexture(GL_TEXTURE0_ARB); } } }; //! detail map material renderer class COpenGLMaterialRenderer_DETAIL_MAP : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_DETAIL_MAP(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(2); Driver->setTexture(1, material.getTexture(1)); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { // diffuse map glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); if (Driver->queryFeature(EVDF_MULTITEXTURE)) { // detail map Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT); glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR); Driver->extGlActiveTexture(GL_TEXTURE0_ARB); } } } }; //! sphere map material renderer class COpenGLMaterialRenderer_SPHERE_MAP : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_SPHERE_MAP(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(1); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); } } virtual void OnUnsetMaterial() { glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } }; //! reflection 2 layer material renderer class COpenGLMaterialRenderer_REFLECTION_2_LAYER : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_REFLECTION_2_LAYER(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(2); Driver->setTexture(1, material.getTexture(1)); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); } glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); } } virtual void OnUnsetMaterial() { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } }; //! reflection 2 layer material renderer class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COpenGLMaterialRenderer { public: COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COpenGLDriver* d) : COpenGLMaterialRenderer(d) {} virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) { Driver->disableTextures(2); Driver->setTexture(1, material.getTexture(1)); Driver->setTexture(0, material.getTexture(0)); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT ); Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); } glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glEnable(GL_BLEND); } } virtual void OnUnsetMaterial() { if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); if (Driver->queryFeature(EVDF_MULTITEXTURE)) { Driver->extGlActiveTexture(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } glDisable(GL_BLEND); } //! Returns if the material is transparent. virtual bool isTransparent() const { return true; } }; } // end namespace video } // end namespace irr #endif #endif
31.711888
93
0.764135
[ "solid" ]
d7b3f3045ba19fc645624c9cc8815da37600d0b9
4,153
h
C
src/ListableGamePgn.h
metiscus/tarrasch-chess-gui
5bb37ad1279aa107f927a4e783f89624d89c74a7
[ "MIT" ]
75
2015-01-03T22:46:04.000Z
2022-03-01T20:34:24.000Z
src/ListableGamePgn.h
metiscus/tarrasch-chess-gui
5bb37ad1279aa107f927a4e783f89624d89c74a7
[ "MIT" ]
31
2016-01-01T15:07:35.000Z
2022-01-15T01:57:31.000Z
src/ListableGamePgn.h
metiscus/tarrasch-chess-gui
5bb37ad1279aa107f927a4e783f89624d89c74a7
[ "MIT" ]
20
2015-04-03T14:18:13.000Z
2022-01-21T02:37:56.000Z
/**************************************************************************** * A ListableGame that was originally created for the list in the PgnDialog * Author: Bill Forster * License: MIT license. Full text of license is in associated file LICENSE * Copyright 2010-2015, Bill Forster <billforsternz at gmail dot com> ****************************************************************************/ #ifndef LISTABLE_GAME_PGN_H #define LISTABLE_GAME_PGN_H #include "GameDocument.h" #include "CompactGame.h" #include "PackedGame.h" #include "CompressMoves.h" void ReadGameFromPgn( int pgn_handle, long fposn, GameDocument &gd ); void *ReadGameFromPgnInLoop( int pgn_handle, long fposn, CompactGame &pact, void *context, bool end=true ); class ListableGamePgn : public ListableGame { private: int pgn_handle; long fposn; PackedGame pack; bool in_memory; public: ListableGamePgn( int pgn_handle, long fposn ) { this->pgn_handle=pgn_handle, this->fposn = fposn; in_memory=false; } virtual long GetFposn() { return fposn; } virtual void SetFposn( long posn ) { fposn=posn; } virtual bool GetPgnHandle( int &pgn_handle_ ) { pgn_handle_=this->pgn_handle; return true; } virtual void SetPgnHandle( int pgn_handle_ ) { this->pgn_handle = pgn_handle_; } virtual void *LoadIntoMemory( void *context, bool end ) { if( pack.Empty() ) { CompactGame pact; context = ReadGameFromPgnInLoop( pgn_handle, fposn, pact, context, end ); pack.Pack(pact); } in_memory = true; return context; } virtual void GetCompactGame( CompactGame &pact ) { if( pack.Empty() ) LoadIntoMemory( NULL, true ); pack.Unpack(pact); pact.game_id = game_id; } // For editing the roster virtual void SetRoster( Roster &r ) { CompactGame pact; if( pack.Empty() ) LoadIntoMemory( NULL, true ); pack.Unpack(pact); pact.r = r; pack.Pack(pact); } virtual void ConvertToGameDocument(GameDocument &gd) { ReadGameFromPgn(pgn_handle, fposn, gd); gd.game_id = game_id; } virtual Roster &RefRoster() { static CompactGame pact; GetCompactGame( pact ); return pact.r; } virtual std::vector<thc::Move> &RefMoves() { static CompactGame pact; GetCompactGame( pact ); return pact.moves; } virtual thc::ChessPosition &RefStartPosition() { static CompactGame pact; GetCompactGame( pact ); return pact.start_position; } // For now at least, the following are used for fast sorting on column headings // (only available after LoadInMemory() called - games are loaded from file // when user clicks on a column heading virtual const char *White() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.White(); } virtual const char *Black() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Black(); } virtual const char *Event() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Event(); } virtual const char *Site() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Site(); } virtual const char *Result() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Result(); } virtual const char *Round() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Round() ; } virtual const char *Date() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Date(); } virtual const char *Eco() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Eco(); } virtual const char *WhiteElo() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.WhiteElo(); } virtual const char *BlackElo() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.BlackElo(); } virtual const char *Fen() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Fen(); } virtual const char *CompressedMoves() { if(!in_memory) LoadIntoMemory(NULL,true); return pack.Blob(); } }; #endif // LISTABLE_GAME_PGN_H
38.813084
121
0.62798
[ "vector" ]
d7be49ac1fac110d9019e72adeba5741fd8e1119
3,601
h
C
svSolver-master/Code/FlowSolvers/ThreeDSolver/svSolver/common_blocks/conpar.h
mccsssk2/SimVascularPM3_March2020
3cce6cc7be66545bea5dc3915a2db50a3892bf04
[ "BSD-3-Clause" ]
null
null
null
svSolver-master/Code/FlowSolvers/ThreeDSolver/svSolver/common_blocks/conpar.h
mccsssk2/SimVascularPM3_March2020
3cce6cc7be66545bea5dc3915a2db50a3892bf04
[ "BSD-3-Clause" ]
null
null
null
svSolver-master/Code/FlowSolvers/ThreeDSolver/svSolver/common_blocks/conpar.h
mccsssk2/SimVascularPM3_March2020
3cce6cc7be66545bea5dc3915a2db50a3892bf04
[ "BSD-3-Clause" ]
null
null
null
c Copyright (c) 2014-2015 The Regents of the University of California. c All Rights Reserved. c c Portions of the code Copyright (c) 2009-2011 Open Source Medical c Software Corporation, University of California, San Diego. c c Portions of the code Copyright (c) 2000-2007, Stanford University, c Rensselaer Polytechnic Institute, Kenneth E. Jansen, c Charles A. Taylor. c c See SimVascular Acknowledgements file for additional c contributors to the source code. c c Redistribution and use in source and binary forms, with or without c modification, are permitted provided that the following conditions c are met: c c Redistributions of source code must retain the above copyright notice, c this list of conditions and the following disclaimer. c Redistributions in binary form must reproduce the above copyright c notice, this list of conditions and the following disclaimer in the c documentation and/or other materials provided with the distribution. c Neither the name of the Stanford University or Rensselaer Polytechnic c Institute nor the names of its contributors may be used to endorse or c promote products derived from this software without specific prior c written permission. c c THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS c "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT c LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS c FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE c COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, c INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, c BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS c OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED c AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, c OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF c THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH c DAMAGE. c---------------------------------------------------------------------- c c.... common /conpar/ : input constants c c numnp : number of nodal points c numel : number of elements c numelb : number of boundary elements c numpbc : number of nodes having a boundary condition c nen : maximum number of element nodes c nfaces : maximum number of element faces c nsd : number of space dimensions c numflx : number of flux boundary nodes c ndof : number of degrees of freedom per node c iALE : ALE formulation flag c navier : Navier-Stokes calculation flag c necho : input echo parameter c ichem : equilibrium chemistry flag (for outchem.step dump) c iRK : Runge-Kutta flag c nshg : global number of shape functions (degrees of freedom, c or equations). Computed from the specified p-order, c the number of edges, and the number of faces (in the c entire mesh) c c---------------------------------------------------------------------- c \\Common Block variables for "conpar" c INTEGER numnp,numel,numelb,numpbc,nen,nfaces,numflx,ndof INTEGER iALE,navier,necho,ichem,iRK,nedof INTEGER nshg, nnz, istop, nflow, nnz_tot, idtn common /conpar/ numnp, numel, numelb, numpbc, nen, nfaces, & numflx, ndof, iALE, navier, & necho, ichem, iRK, nedof, & nshg, nnz, istop, nflow, nnz_tot, idtn
48.662162
73
0.683144
[ "mesh", "shape" ]
01eefe4b06d710f46fec0c0612b8d7ca244164e5
1,050
h
C
src/tdme/engine/subsystems/rendering/fwd-tdme.h
mahula/tdme2
0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64
[ "BSD-3-Clause" ]
null
null
null
src/tdme/engine/subsystems/rendering/fwd-tdme.h
mahula/tdme2
0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64
[ "BSD-3-Clause" ]
null
null
null
src/tdme/engine/subsystems/rendering/fwd-tdme.h
mahula/tdme2
0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64
[ "BSD-3-Clause" ]
null
null
null
// Forward declarations for tdme.engine.subsystems.object #pragma once namespace tdme { namespace engine { namespace subsystems { namespace rendering { class AnimationState; class BatchRendererPoints; class BatchRendererTriangles; class ModelUtilitiesInternal; class ModelStatistics; class Object3DAnimation; class Object3DBase; class Object3DBase_TransformedFacesIterator; class Object3DGroup; class Object3DGroupMesh; class Object3DGroupRenderer; class Object3DInternal; class Object3DModelInternal; class Object3DRenderer; class Object3DRenderer_InstancedRenderFunctionParameters; class Object3DRenderer_TransparentRenderFacesGroupPool; class RenderTransparentRenderPointsPool; struct TransparentRenderFace; class TransparentRenderFacesGroup; class TransparentRenderFacesPool; class TransparentRenderFacesPool_TransparentRenderFacesPool; struct TransparentRenderPoint; class TransparentRenderPointsPool; class ObjectBuffer; } // namespace rendering } // namespace subsystems } // namespace engine } // namespace tdme
28.378378
61
0.848571
[ "object" ]
01f4b7c9d6118bd333aae7e5d19a4fdd84e25602
1,692
h
C
Source/EditorLib/UIEventBoard.h
Qt-Widgets/TexGraph
8fe72cea1afcf5e235c810003bf4ee062bb3fc13
[ "MIT" ]
35
2017-04-07T22:49:41.000Z
2021-08-03T13:59:20.000Z
Source/EditorLib/UIEventBoard.h
Qt-Widgets/TexGraph
8fe72cea1afcf5e235c810003bf4ee062bb3fc13
[ "MIT" ]
1
2017-04-13T17:43:54.000Z
2017-04-15T04:17:37.000Z
Source/EditorLib/UIEventBoard.h
Qt-Widgets/TexGraph
8fe72cea1afcf5e235c810003bf4ee062bb3fc13
[ "MIT" ]
7
2019-03-11T19:26:53.000Z
2021-03-04T07:17:10.000Z
#pragma once #include <EditorLib/editorlib_global.h> #include <vector> /// Base-type for a UIEvent to dispatch. struct EDITORLIB_EXPORT UIEvent { unsigned eventID_; void* source_ = 0x0; /// Construct and specify the ID. UIEvent(unsigned id, void* src = 0x0) : eventID_(id), source_(0x0) { } unsigned GetID() { return eventID_; } }; /// For event receivers/static-board data. /// ALL UIEventBoard instances will be have Process() called for all events. /// Purpose: /// Although QT supports user events through QEvent the use of QEvent still /// requires a tight coupling as it's necessary to know who to send the QEvent /// for it to "bubble up" from. /// "Trickle down" dispatch could be brute-forced but would not be ideal, /// as it would require a full traversal of the Widget tree. /// Instead UIEventBoard maintains a list of those objects/widgets that need /// to know about both extraordinary situations and things for which any written /// coupling is not tenable (in that coupling combinations would explode). /// Being brain-dead is deliberate. class EDITORLIB_EXPORT UIEventBoard { static std::vector<UIEventBoard*> receivers_; static std::vector<UIEvent*> events_; protected: /// Construct. UIEventBoard(); /// Destruct. virtual ~UIEventBoard(); public: /// Call to execute the processing of all events. static void ProcessEvents(); /// Push an event to the queue for processing. static void PushEvent(UIEvent* event); /// Will be called on the instance to check for processing an event. virtual void ProcessEvent(UIEvent* event) { } };
33.84
81
0.687943
[ "vector" ]
bf051a4155c0ce5d489989081d9a7602ae54ff47
1,468
h
C
TxtMiru2/TxtMiru.h
gearsns/TxtMiru2
f829803721354e0639e791ba63962bd702aebfd1
[ "MIT" ]
5
2019-09-28T09:41:24.000Z
2020-08-28T07:38:32.000Z
TxtMiru2/TxtMiru.h
gearsns/TxtMiru2
f829803721354e0639e791ba63962bd702aebfd1
[ "MIT" ]
null
null
null
TxtMiru2/TxtMiru.h
gearsns/TxtMiru2
f829803721354e0639e791ba63962bd702aebfd1
[ "MIT" ]
null
null
null
#ifndef __TXTMIRU_H__ #define __TXTMIRU_H__ #include "TxtParam.h" #include <vector> class CGrLoadDllFunc; class CGrTxtMiru { public: static CGrTxtMiru &theApp(); static LPCTSTR ClassName(){ return _T("TxtMiru"); } static LPCTSTR AppName(){ return _T("TxtMiru"); } // HACCEL GetAccelerator(){ return m_haccel; } void SetAccelerator(HACCEL haccel){ m_haccel=haccel; } // void SetMouseCapture(HWND hwnd); void ReleaseMouseCapture(); void PostMouseCaptureMessage(MSG &msg); // void SetUseAccelerator(bool bUseAcess){ m_bUseAcess = bUseAcess; } void SetUseDialogMessage(bool bUseDlgMes){ m_bUseDlgMes = bUseDlgMes; } bool IsUseAccelerator(){ return m_bUseAcess; } bool IsUseDialogMessage(){ return m_bUseDlgMes; } CGrTxtParam &Param(){ return m_param; } BOOL IsDialogMessage(HWND hwnd, MSG &msg); void SetWatting(bool bwait); bool IsWaitting(){ return m_bWatting; } static LPCTSTR GetDataPath(); static void MoveDataDir(); static LPCTSTR GetWorkPath(); enum class DLLFncType { TxtFuncBookmark, MaxNum }; HRESULT InstallDLLFunc(DLLFncType id, CGrLoadDllFunc *pdll); HRESULT UninstallDLLFunc(DLLFncType id); CGrLoadDllFunc *GetDllFunc(DLLFncType id); private: CGrTxtMiru(); CGrTxtParam m_param; bool m_bUseAcess = true; bool m_bUseDlgMes = false; bool m_bWatting = false; HACCEL m_haccel = NULL; HWND m_hMouseCaptureWnd = NULL; CGrLoadDllFunc* m_dllList[static_cast<int>(DLLFncType::MaxNum)] = {}; }; #endif // __TXTMIRU_H__
26.690909
72
0.754087
[ "vector" ]
bf062bd72dcd8b493e76d76304faff77cf1ad7cc
13,030
h
C
LuaWrapper.h
bycicleashphae/socketforioswinandroid
c5245b547c30ef8b2719564b35a04d7d5657b255
[ "BSD-2-Clause" ]
1
2018-02-22T23:49:24.000Z
2018-02-22T23:49:24.000Z
LuaWrapper.h
bycicleashphae/socketforioswinandroid
c5245b547c30ef8b2719564b35a04d7d5657b255
[ "BSD-2-Clause" ]
null
null
null
LuaWrapper.h
bycicleashphae/socketforioswinandroid
c5245b547c30ef8b2719564b35a04d7d5657b255
[ "BSD-2-Clause" ]
null
null
null
#ifndef _flsdjlfalskjfa_sdWrapper_h #define _flsdjlfalskjfa_sdWrapper_h #include "lua.hpp" #define NULL (0) #define LUNPLUS_METHOD_BEGIN(ClassName) lua::LuaPlus<ClassName>::RegFunction ClassName::functions[] = { #define LUNPLUS_METHOD_DECLARE(ClassName, name) {#name, &ClassName::name}, #define LUNPLUS_METHOD_END {NULL,NULL} \ }; #define LUNPLUS_DECLARE_INTERFACE(ClassName) static const char className[]; \ static lua::LuaPlus<ClassName>::RegFunction functions[]; \ char m_instClassName[256] #define LUNPLUS_DEFINE_INTERFACE(ClassName) const char ClassName::className[] = #ClassName #define _L lua::state::Instance()->get_handle() #define LUA_CALL(L, narg, nret) lua_pcall(L, narg, nret, 0) namespace lua { /*! \class state state wrapper, make a global lua_Stat* */ class state { lua_State* L; public: state(bool bOpenLibs = true) { L = NULL; } ~state() { //lua_gc(L, LUA_GCCOLLECT, 0); //lua_close(L); } void recreate(bool bOpenLibs = true) { // if ( L ) // { // lua_close(L); // } // L = lua_open(); //if( bOpenLibs ) //{ // luaL_openlibs(L); //} } lua_State* get_handle() { return L; } void setHook() { int startStackIndex = lua_gettop(L); const char* chunk = "" "function __ERROR_TRACKBACK__(errMsg)\n" " local err = \"LUA ERROR: \" .. tostring(errMsg)\n" " err = err .. debug.traceback()\n" " return err\n" "end"; if (luaL_loadstring(L, chunk) == 0) { lua_pcall(L, 0, 0, 0); } while (lua_gettop(L) > startStackIndex) lua_remove(L, startStackIndex + 1); } void set_handle(lua_State* l) { L = l; } static state* Instance() { static state S; return &S; } }; template <typename T> class LuaPlus { typedef struct { T *pT; } userdataType; public: typedef int (T::*mfp)(lua_State *L); typedef struct { const char *name; mfp mfunc; } RegFunction; static void Register(lua_State *L) { lua_newtable(L); int methods = lua_gettop(L); luaL_newmetatable(L, T::className); int metatable = lua_gettop(L); // store method table in globals so that // scripts can add functions written in Lua. lua_pushvalue(L, methods); set(L, LUA_GLOBALSINDEX, T::className); // hide metatable from Lua getmetatable() lua_pushvalue(L, methods); set(L, metatable, "__metatable"); lua_pushvalue(L, methods); set(L, metatable, "__index"); lua_pushstring(L, T::className); lua_pushcclosure(L, tostring_T, 1); set(L, metatable, "__tostring"); lua_pushcfunction(L, gc_T); set(L, metatable, "__gc"); lua_newtable(L); // mt for method table lua_pushstring(L, T::className); lua_pushcclosure(L, new_T, 1); lua_pushvalue(L, -1); // dup new_T function set(L, methods, "new"); // add new_T to method table set(L, -3, "__call"); // mt.__call = new_T lua_setmetatable(L, methods); // fill method table with methods from class T for (RegFunction *l = T::functions; l->name; l++) { lua_pushstring(L, l->name); lua_pushlightuserdata(L, (void*)l); lua_pushstring(L, T::className); lua_pushcclosure(L, thunk, 2); lua_settable(L, methods); } lua_pop(L, 2); // drop metatable and method table } static int RegisteSocketClassL(lua_State *L) { bool hasParentTable = lua_gettop(L) > 1; size_t len; const char* className = luaL_checklstring(L, 1, &len); const char* parentTableName = NULL; if (hasParentTable) { parentTableName = luaL_checklstring(L, 2, &len); } lua_newtable(L); int methods = lua_gettop(L); luaL_newmetatable(L, className); int metatable = lua_gettop(L); if (hasParentTable) { lua_getglobal(L, parentTableName); if (lua_isnil(L, -1)) { lua_pop(L, 1); lua_newtable(L); int flassClasses = lua_gettop(L); lua_pushvalue(L, flassClasses); set(L, LUA_GLOBALSINDEX, parentTableName); } lua_pushvalue(L, methods); set(L, -3, className); lua_pop(L, 1); } else { lua_pushvalue(L, methods); set(L, LUA_GLOBALSINDEX, className); } // hide metatable from Lua getmetatable() lua_pushvalue(L, methods); set(L, metatable, "__metatable"); lua_pushvalue(L, methods); set(L, metatable, "__index"); lua_pushstring(L, className); lua_pushcclosure(L, tostring_T, 1); set(L, metatable, "__tostring"); lua_pushcfunction(L, gc_T); set(L, metatable, "__gc"); lua_newtable(L); // mt for method table lua_pushstring(L, className); lua_pushcclosure(L, new_T, 1); lua_pushvalue(L, -1); // dup new_T function set(L, methods, "new"); // add new_T to method table set(L, -3, "__call"); // mt.__call = new_T lua_setmetatable(L, methods); // fill method table with methods from class T for (RegFunction *l = T::functions; l->name; l++) { lua_pushstring(L, l->name); lua_pushlightuserdata(L, (void*)l); lua_pushstring(L, className); lua_pushcclosure(L, thunk, 2); lua_settable(L, methods); } lua_pop(L, 2); // drop metatable and method table return 0; } //check named lua method exist or not. static bool hasfunction(lua_State *L, const char *method, const char *className) { int base = lua_gettop(L); if (!luaL_checkudata(L, base, className)) { return false; } lua_pushstring(L, method); lua_gettable(L, base); if (lua_isnil(L, -1)) { lua_pop(L, 1); return false; } else { lua_pop(L, 1); return true; } } // call named lua method from userdata method table static int call(lua_State *L, const char *method, const char *className, int nargs=0, int nresults=LUA_MULTRET, int errfunc=0) { int base = lua_gettop(L) - nargs; // userdata index if (!luaL_checkudata(L, base, className)) { lua_settop(L, base-1); // drop userdata and args lua_pushfstring(L, "not a valid %s userdata", className); return -1; } lua_pushstring(L, method); // method name lua_gettable(L, base); // get method from userdata if (lua_isnil(L, -1)) { // no method? lua_settop(L, base-1); // drop userdata and args lua_pushfstring(L, "%s missing method '%s'", className, method); return -1; } lua_insert(L, base); // put method under userdata, args int status = lua_pcall(L, 1+nargs, nresults, errfunc); // call method if (status) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error with no message)"; lua_pushfstring(L, "%s:%s status = %d\n%s", className, method, status, msg); lua_remove(L, base); // remove old message return -1; } return lua_gettop(L) - base + 1; // number of results } // push onto the Lua stack a userdata containing a pointer to T object static int push(lua_State *L, T *obj, bool gc, const char* className) { if (!obj) { lua_pushnil(L); return 0; } luaL_getmetatable(L, className); // lookup metatable in Lua registry if (lua_isnil(L, -1)) luaL_error(L, "%s missing metatable", className); int mt = lua_gettop(L); subtable(L, mt, "userdata", "v"); userdataType *ud = static_cast<userdataType*>(pushuserdata(L, obj, sizeof(userdataType))); if (ud) { ud->pT = obj; // store pointer to object in userdata lua_pushvalue(L, mt); lua_setmetatable(L, -2); if (gc == false) { lua_checkstack(L, 3); subtable(L, mt, "do not trash", "k"); lua_pushvalue(L, -2); lua_pushboolean(L, 1); lua_settable(L, -3); lua_pop(L, 1); } } lua_replace(L, mt); lua_settop(L, mt); return mt; // index of userdata containing pointer to T object } // get userdata from Lua stack and return pointer to T object static T *check(lua_State *L, int narg, const char* className) { userdataType *ud = static_cast<userdataType*>(luaL_checkudata(L, narg, className)); if(!ud) { luaL_typerror(L, narg, className); return NULL; } return ud->pT; // pointer to T object } private: LuaPlus(); // hide default constructor // member function dispatcher static int thunk(lua_State *L) { // get member function from upvalue RegFunction *l = static_cast<RegFunction*>(lua_touserdata(L, lua_upvalueindex(1))); const char* className = lua_tostring(L, lua_upvalueindex(2)); // stack has userdata, followed by method args T *obj = check(L, 1, className); // get 'self', or if you prefer, 'this' lua_remove(L, 1); // remove self so member function args start at index 1 return (obj->*(l->mfunc))(L); // call member function } // create a new T object and // push onto the Lua stack a userdata containing a pointer to T object static int new_T(lua_State *L) { lua_remove(L, 1); // use classname:new(), instead of classname.new() const char* className = lua_tostring(L, lua_upvalueindex(1)); T *obj = new T(className); // call constructor for T objects push(L, obj, true, className); // gc_T will delete this object return 1; // userdata containing pointer to T object } // garbage collection metamethod static int gc_T(lua_State *L) { if (luaL_getmetafield(L, 1, "do not trash")) { lua_pushvalue(L, 1); // dup userdata lua_gettable(L, -2); if (!lua_isnil(L, -1)) return 0; // do not delete object } userdataType *ud = static_cast<userdataType*>(lua_touserdata(L, 1)); if (ud) { T *obj = ud->pT; if (obj){ delete obj; // call destructor for T objects ud->pT = NULL; } } return 0; } static int tostring_T (lua_State *L) { const char* className = lua_tostring(L, lua_upvalueindex(1)); char buff[32]; userdataType *ud = static_cast<userdataType*>(lua_touserdata(L, 1)); T *obj = ud->pT; sprintf(buff, "%p", (void*)obj); lua_pushfstring(L, "%s (%s)", className, buff); return 1; } static void set(lua_State *L, int table_index, const char *key) { lua_pushstring(L, key); lua_insert(L, -2); // swap value and key lua_settable(L, table_index); } static void weaktable(lua_State *L, const char *mode) { lua_newtable(L); lua_pushvalue(L, -1); // table is its own metatable lua_setmetatable(L, -2); lua_pushliteral(L, "__mode"); lua_pushstring(L, mode); lua_settable(L, -3); // metatable.__mode = mode } static void subtable(lua_State *L, int tindex, const char *name, const char *mode) { lua_pushstring(L, name); lua_gettable(L, tindex); if (lua_isnil(L, -1)) { lua_pop(L, 1); lua_checkstack(L, 3); weaktable(L, mode); lua_pushstring(L, name); lua_pushvalue(L, -2); lua_settable(L, tindex); } } static void *pushuserdata(lua_State *L, void *key, size_t sz) { void *ud = 0; lua_pushlightuserdata(L, key); lua_gettable(L, -2); // lookup[key] if (lua_isnil(L, -1)) { lua_pop(L, 1); // drop nil lua_checkstack(L, 3); ud = lua_newuserdata(L, sz); // create new userdata lua_pushlightuserdata(L, key); lua_pushvalue(L, -2); // dup userdata lua_settable(L, -4); // lookup[key] = userdata } return ud; } }; void RegisteClassToScript(); void RegisteGlobalFunctions(); }; #endif
31.47343
104
0.549117
[ "object" ]
bf06305f8bb6caae2332c77d6393c6bdfa98bdfc
1,983
h
C
IfcPlusPlus/src/ifcpp/IFC4/include/IfcBSplineSurfaceForm.h
linsipese/ifcppstudy
e09f05d276b5e129fcb6be65800472979cd4c800
[ "MIT" ]
1
2018-10-23T09:43:07.000Z
2018-10-23T09:43:07.000Z
IfcPlusPlus/src/ifcpp/IFC4/include/IfcBSplineSurfaceForm.h
linsipese/ifcppstudy
e09f05d276b5e129fcb6be65800472979cd4c800
[ "MIT" ]
null
null
null
IfcPlusPlus/src/ifcpp/IFC4/include/IfcBSplineSurfaceForm.h
linsipese/ifcppstudy
e09f05d276b5e129fcb6be65800472979cd4c800
[ "MIT" ]
null
null
null
/* -*-c++-*- IfcPlusPlus - www.ifcplusplus.com - Copyright (C) 2011 Fabian Gerold * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library 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 * OpenSceneGraph Public License for more details. */ #pragma once #include <vector> #include <map> #include <sstream> #include <string> #include "ifcpp/model/shared_ptr.h" #include "ifcpp/model/IfcPPObject.h" #include "ifcpp/model/IfcPPGlobal.h" // TYPE IfcBSplineSurfaceForm = ENUMERATION OF (PLANE_SURF ,CYLINDRICAL_SURF ,CONICAL_SURF ,SPHERICAL_SURF ,TOROIDAL_SURF ,SURF_OF_REVOLUTION ,RULED_SURF ,GENERALISED_CONE ,QUADRIC_SURF ,SURF_OF_LINEAR_EXTRUSION ,UNSPECIFIED); class IFCPP_EXPORT IfcBSplineSurfaceForm : virtual public IfcPPObject { public: enum IfcBSplineSurfaceFormEnum { ENUM_PLANE_SURF, ENUM_CYLINDRICAL_SURF, ENUM_CONICAL_SURF, ENUM_SPHERICAL_SURF, ENUM_TOROIDAL_SURF, ENUM_SURF_OF_REVOLUTION, ENUM_RULED_SURF, ENUM_GENERALISED_CONE, ENUM_QUADRIC_SURF, ENUM_SURF_OF_LINEAR_EXTRUSION, ENUM_UNSPECIFIED }; IfcBSplineSurfaceForm(); IfcBSplineSurfaceForm( IfcBSplineSurfaceFormEnum e ) { m_enum = e; } ~IfcBSplineSurfaceForm(); virtual const char* className() const { return "IfcBSplineSurfaceForm"; } virtual shared_ptr<IfcPPObject> getDeepCopy( IfcPPCopyOptions& options ); virtual void getStepParameter( std::stringstream& stream, bool is_select_type = false ) const; static shared_ptr<IfcBSplineSurfaceForm> createObjectFromSTEP( const std::wstring& arg ); IfcBSplineSurfaceFormEnum m_enum; };
38.134615
227
0.771054
[ "vector", "model" ]
bf0fcee80b39f9e72b39075de54e71e001e4f155
6,594
h
C
core/put/source/ecs/ecs_utilities.h
polymonster/pmtech
a51df48bad07c489fbf71928f10c56a415c87c4d
[ "MIT" ]
661
2018-01-20T00:34:35.000Z
2022-03-28T02:22:17.000Z
core/put/source/ecs/ecs_utilities.h
ford442/pmtech
99fa197653e3b6d73c2c1be46d61cb0aaea3769c
[ "MIT" ]
54
2017-03-16T22:25:26.000Z
2021-09-18T12:52:01.000Z
core/put/source/ecs/ecs_utilities.h
ford442/pmtech
99fa197653e3b6d73c2c1be46d61cb0aaea3769c
[ "MIT" ]
38
2019-03-22T03:05:44.000Z
2022-03-09T14:06:46.000Z
// ecs_utilities.h // Copyright 2014 - 2019 Alex Dixon. // License: https://github.com/polymonster/pmtech/blob/master/license.md #pragma once #include "ecs/ecs_scene.h" #include "hash.h" #include <vector> namespace put { namespace ecs { struct scene_tree { s32 entity_index; std::vector<scene_tree> children; }; namespace e_clone_mode { enum clone_mode_t { instantiate, copy, move }; } typedef e_clone_mode::clone_mode_t clone_mode; ecs_ref allocate_ref(ecs_scene* scene, u32 entity); void free_ref(ecs_scene* scene, ecs_ref ref); ecs_ref get_ref_from_id(ecs_scene* scene, hash_id idname); ecs_ref get_child_ref_from_id(ecs_scene* scene, hash_id idname, s32 parent); u32 get_child_index_from_id(ecs_scene* scene, hash_id idname, s32 parent); u32 get_index_from_id(ecs_scene* scene, hash_id idname); u32 get_index_from_ref(ecs_scene* scene, ecs_ref ref); u32 get_ref_from_index(ecs_scene* scene, u32 index); u32* get_children_of_type(ecs_scene* scene, u32 parent, u32 cmp_flags); u32 get_next_entity(ecs_scene* scene); // gets next entity index u32 get_new_entity(ecs_scene* scene); // allocates a new entity at the next index o(1) void get_new_entities_contiguous(ecs_scene* scene, s32 num, s32& start, s32& end); // finds contiguous space o(n) void get_new_entities_append(ecs_scene* scene, s32 num, s32& start, s32& end); // appends them on the end o(1) void insert_new_entities(ecs_scene* scene, s32 pos, s32 num); u32 clone_entity(ecs_scene* scene, u32 src, s32 dst = -1, s32 parent = -1, clone_mode mode = e_clone_mode::instantiate, vec3f offset = vec3f::zero(), const c8* suffix = "_cloned"); void swap_entities(ecs_scene* scene, u32 a, s32 b); void clone_selection_hierarchical(ecs_scene* scene, u32** selection_list, const c8* suffix); void instance_entity_range(ecs_scene* scene, u32 master_node, u32 num_nodes); void bake_entities_to_vb(ecs_scene* scene, u32 parent, u32* node_list); void set_entity_parent(ecs_scene* scene, u32 parent, u32 child); void set_entity_parent_validate(ecs_scene* scene, u32& parent, u32& child); void trim_entities(ecs_scene* scene); // trim entites setting num_entities to the last allocated u32 bind_animation_to_rig(ecs_scene* scene, anim_handle anim_handle, u32 node_index, u32 flags = 0); void tree_to_entity_index_list(const scene_tree& tree, s32 start_node, std::vector<s32>& list_out); void build_scene_tree(ecs_scene* scene, s32 start_node, scene_tree& tree_out); void build_heirarchy_node_list(ecs_scene* scene, s32 start_node, std::vector<s32>& node_list); void scene_tree_enumerate(ecs_scene* scene, const scene_tree& tree); void scene_tree_add_entity(scene_tree& tree, scene_tree& node, std::vector<s32>& heirarchy); Str read_parsable_string(const u32** data); Str read_parsable_string(std::ifstream& ifs); void write_parsable_string(const Str& str, std::ofstream& ofs); void write_parsable_string_u32(const Str& str, std::ofstream& ofs); // inlines pen_inline ecs_ref allocate_ref(ecs_scene* scene, u32 entity) { // allocate a ref slot /* ecs_ref ref_slot = 0; if(scene->ref_free_list_head) { ref_slot = scene->ref_free_list_head->node; scene->ref_free_list_head = scene->ref_free_list_head->next; } */ ecs_ref ref_slot = sb_count(scene->ecs_refs); sb_push(scene->ecs_refs, entity); return ref_slot; } pen_inline void free_ref(ecs_scene* scene, ecs_ref ref) { //scene->ecs_ref[ref] = 0; } pen_inline ecs_ref get_ref_from_id(ecs_scene* scene, hash_id idname) { for(u32 i = 0; i < scene->num_entities; ++i) if(idname == scene->id_name[i]) return scene->ref_slot[i]; return -1; } pen_inline ecs_ref get_child_ref_from_id(ecs_scene* scene, hash_id idname, s32 parent) { for(u32 i = parent; i < scene->num_entities; ++i) { if(idname == scene->id_name[i]) return scene->ref_slot[i]; u32 p = scene->parents[i]; if(p == i && i != parent) { break; } } return -1; } pen_inline u32 get_child_index_from_id(ecs_scene* scene, hash_id idname, s32 parent) { for(u32 i = parent; i < scene->num_entities; ++i) { if(idname == scene->id_name[i]) return i; u32 p = scene->parents[i]; if(p == i && i != parent) { break; } } return -1; } pen_inline u32 get_index_from_id(ecs_scene* scene, hash_id idname) { for(u32 i = 0; i < scene->num_entities; ++i) if(idname == scene->id_name[i]) return i; return -1; } pen_inline u32 get_index_from_ref(ecs_scene* scene, ecs_ref ref) { return scene->ecs_refs[ref]; } pen_inline ecs_ref get_ref_from_index(ecs_scene* scene, u32 index) { return scene->ref_slot[index]; } pen_inline u32* get_children_of_type(ecs_scene* scene, u32 parent, u32 cmp_flags) { u32* children = nullptr; for (u32 i = parent; i < scene->num_entities; ++i) { u32 p = scene->parents[i]; if (p == i && i != parent) { break; } if (scene->entities[i] & cmp_flags) sb_push(children, i); } return children; } } // namespace ecs } // namespace put
39.25
125
0.549287
[ "vector" ]
bf0ff3a6f1d925b85ce1a16b3ecd157b345d2563
4,457
h
C
lib/include/xnetwork/algorithms/centrality/flow_matrix.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
1
2020-03-31T06:10:58.000Z
2020-03-31T06:10:58.000Z
lib/include/xnetwork/algorithms/centrality/flow_matrix.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
null
null
null
lib/include/xnetwork/algorithms/centrality/flow_matrix.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
1
2020-04-08T05:56:26.000Z
2020-04-08T05:56:26.000Z
// Helpers for current-flow betweenness && current-flow closness // Lazy computations for inverse Laplacian && flow-matrix rows. #include <xnetwork.hpp> // as xn auto flow_matrix_row(G, weight=None, dtype=double, solver="lu") { // Generate a row of the current-flow matrix import numpy as np from scipy import sparse from scipy.sparse import linalg solvername = {"full": FullInverseLaplacian, "lu": SuperLUInverseLaplacian, "cg": CGInverseLaplacian} n = G.number_of_nodes(); L = laplacian_sparse_matrix(G, nodelist=range(n), weight=weight, dtype=dtype, format="csc"); C = solvername[solver](L, dtype=dtype); // initialize solver w = C.w // w is the Laplacian matrix width // row-by-row flow matrix for (auto [u, v] : sorted(sorted((u, v)) for u, v : G.edges()) { B = np.zeros(w, dtype=dtype); c = G[u][v].get(weight, 1.0); B[u % w] = c B[v % w] = -c // get only the rows needed : the inverse laplacian // && multiply to get the flow matrix row row = np.dot(B, C.get_rows(u, v)); yield row, (u, v); // Class to compute the inverse laplacian only for specified rows // Allows computation of the current-flow matrix without storing entire // inverse laplacian matrix class InverseLaplacian: public object { explicit _Self( L, width=None, dtype=None) { global np import numpy as np auto [n, n] = L.shape this->dtype = dtype this->n = n; if (width.empty()) { this->w = this->width(L); } else { this->w = width this->C = np.zeros((this->w, n), dtype=dtype); this->L1 = L[1:, 1:]; this->init_solver(L); auto init_solver( L) { // pass; auto solve( r) { raise("Implement solver"); auto solve_inverse( r) { raise("Implement solver"); auto get_rows( r1, r2) { for (auto r : range(r1, r2 + 1) { this->C[r % this->w, 1:] = this->solve_inverse(r); return this->C auto get_row( r) { this->C[r % this->w, 1:] = this->solve_inverse(r); return this->C[r % this->w]; auto width( L) { m = 0.; for (auto i, row : enumerate(L) { w = 0.; x, y = np.nonzero(row); if (len(y) > 0) { v = y - i w = v.max() - v.min() + 1 m = max(w, m); return m class FullInverseLaplacian(InverseLaplacian) { auto init_solver( L) { this->IL = np.zeros(L.shape, dtype=this->dtype); this->IL[1:, 1:] = np.linalg.inv(this->L1.todense()); auto solve( rhs) { s = np.zeros(rhs.shape, dtype=this->dtype); s = np.dot(this->IL, rhs); return s auto solve_inverse( r) { return this->IL[r, 1:]; class SuperLUInverseLaplacian(InverseLaplacian) { auto init_solver( L) { from scipy.sparse import linalg this->lusolve = linalg.factorized(this->L1.tocsc()); auto solve_inverse( r) { rhs = np.zeros(this->n, dtype=this->dtype); rhs[r] = 1; return this->lusolve(rhs[1:]); auto solve( rhs) { s = np.zeros(rhs.shape, dtype=this->dtype); s[1:] = this->lusolve(rhs[1:]); return s class CGInverseLaplacian(InverseLaplacian) { auto init_solver( L) { global linalg from scipy.sparse import linalg ilu = linalg.spilu(this->L1.tocsc()); n = this->n - 1 this->M = linalg.LinearOperator(shape=(n, n), matvec=ilu.solve); auto solve( rhs) { s = np.zeros(rhs.shape, dtype=this->dtype); s[1:] = linalg.cg(this->L1, rhs[1:], M=this->M)[0]; return s auto solve_inverse( r) { rhs = np.zeros(this->n, this->dtype); rhs[r] = 1; return linalg.cg(this->L1, rhs[1:], M=this->M)[0]; // graph laplacian, sparse version, will move to linalg/laplacianmatrix.py auto laplacian_sparse_matrix(G, nodelist=None, weight=None, dtype=None, format="csr") { import numpy as np import scipy.sparse A = xn::to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, dtype=dtype, format=format); auto [n, n] = A.shape data = np.asarray(A.sum(axis=1).T); D = scipy.sparse.spdiags(data, 0, n, n, format=format); return D - A
32.064748
74
0.555531
[ "object", "shape" ]
bf17eaaa1b27a68e385f4dc3812f76a3a5a0cc5d
4,551
h
C
util/eudm_planner/inc/eudm_planner/eudm_manager.h
GallopWind/epsilon-learn
74dc723fbc9797f3bd05bee30f6f9b9acceeec17
[ "MIT" ]
186
2020-09-22T10:57:57.000Z
2022-03-30T15:52:15.000Z
util/eudm_planner/inc/eudm_planner/eudm_manager.h
Yufei-Wei/EPSILON
155f1b1c4dae3ae29287d5b0b967d7d6ce230c73
[ "MIT" ]
16
2020-10-19T02:55:49.000Z
2022-01-14T08:17:06.000Z
util/eudm_planner/inc/eudm_planner/eudm_manager.h
Yufei-Wei/EPSILON
155f1b1c4dae3ae29287d5b0b967d7d6ce230c73
[ "MIT" ]
66
2020-09-28T01:51:57.000Z
2022-03-25T08:39:04.000Z
#ifndef _CORE_EUDM_PLANNER_INC_EUDM_PLANNER_EUDM_MANAGER_H_ #define _CORE_EUDM_PLANNER_INC_EUDM_PLANNER_EUDM_MANAGER_H_ #include "eudm_planner/eudm_itf.h" #include "eudm_planner/eudm_planner.h" #include "eudm_planner/map_adapter.h" /** * @brief since eudm itself is completely stateless, we use a manager to * track the input and output of the eudm, to satisfy task level * constraints. */ namespace planning { class EudmManager { public: using DcpLatAction = planning::DcpTree::DcpLatAction; using DcpLonAction = planning::DcpTree::DcpLonAction; using DcpAction = planning::DcpTree::DcpAction; using LateralBehavior = common::LateralBehavior; using LongitudinalBehavior = common::LongitudinalBehavior; using CostStructure = planning::EudmPlanner::CostStructure; enum class LaneChangeTriggerType { kStick = 0, kActive }; struct ReplanningContext { bool is_valid = false; decimal_t seq_start_time; std::vector<DcpAction> action_seq; }; struct ActivateLaneChangeRequest { decimal_t trigger_time; decimal_t desired_operation_time; int ego_lane_id; LateralBehavior lat = LateralBehavior::kLaneKeeping; }; struct LaneChangeProposal { bool valid = false; decimal_t trigger_time = 0.0; decimal_t operation_at_seconds = 0.0; int ego_lane_id; LateralBehavior lat = LateralBehavior::kLaneKeeping; }; struct LaneChangeContext { bool completed = true; bool trigger_when_appropriate = false; decimal_t trigger_time = 0.0; decimal_t desired_operation_time = 0.0; int ego_lane_id = 0; LateralBehavior lat = LateralBehavior::kLaneKeeping; LaneChangeTriggerType type; }; struct Snapshot { bool valid = false; int original_winner_id; int processed_winner_id; common::State plan_state; std::vector<std::vector<DcpAction>> action_script; std::vector<bool> sim_res; std::vector<bool> risky_res; std::vector<std::string> sim_info; std::vector<decimal_t> final_cost; std::vector<std::vector<CostStructure>> progress_cost; std::vector<CostStructure> tail_cost; vec_E<vec_E<common::Vehicle>> forward_trajs; std::vector<std::vector<LateralBehavior>> forward_lat_behaviors; std::vector<std::vector<LongitudinalBehavior>> forward_lon_behaviors; vec_E<std::unordered_map<int, vec_E<common::Vehicle>>> surround_trajs; common::Lane ref_lane; double plan_stamp = 0.0; double time_cost = 0.0; }; EudmManager() {} void Init(const std::string& config_path, const decimal_t work_rate); ErrorType Run( const decimal_t stamp, const std::shared_ptr<semantic_map_manager::SemanticMapManager>& map_ptr, const planning::eudm::Task& task); void Reset(); void ConstructBehavior(common::SemanticBehavior* behavior); EudmPlanner& planner(); int original_winner_id() const { return last_snapshot_.original_winner_id; } int processed_winner_id() const { return last_snapshot_.processed_winner_id; } std::shared_ptr<semantic_map_manager::SemanticMapManager> map() { return map_adapter_.map(); } private: decimal_t GetNearestFutureDecisionPoint(const decimal_t& stamp, const decimal_t& delta); bool IsTriggerAppropriate(const LateralBehavior& lat); ErrorType Prepare( const decimal_t stamp, const std::shared_ptr<semantic_map_manager::SemanticMapManager>& map_ptr, const planning::eudm::Task& task); ErrorType EvaluateReferenceVelocity(const planning::eudm::Task& task, decimal_t* ref_vel); bool GetReplanDesiredAction(const decimal_t current_time, DcpAction* desired_action); void SaveSnapshot(Snapshot* snapshot); ErrorType ReselectByContext(const decimal_t stamp, const Snapshot& snapshot, int* new_seq_id); void UpdateLaneChangeContextByTask(const decimal_t stamp, const planning::eudm::Task& task); ErrorType GenerateLaneChangeProposal(const decimal_t& stamp, const planning::eudm::Task& task); EudmPlanner bp_; EudmPlannerMapAdapter map_adapter_; decimal_t work_rate_{20.0}; int ego_lane_id_; ReplanningContext context_; Snapshot last_snapshot_; planning::eudm::Task last_task_; LaneChangeContext lc_context_; LaneChangeProposal last_lc_proposal_; std::vector<ActivateLaneChangeRequest> preliminary_active_requests_; }; } // namespace planning #endif
32.276596
80
0.719402
[ "vector" ]
bf17ef1bd756f25c9a0d0ecfb4913e13756067ab
1,662
h
C
books/coding_interviews/p041_stream_median/solution.h
shinexia/algorithm-labs
c9af67865fab9760faeedd64cdd0475f4dff4b4a
[ "MIT" ]
null
null
null
books/coding_interviews/p041_stream_median/solution.h
shinexia/algorithm-labs
c9af67865fab9760faeedd64cdd0475f4dff4b4a
[ "MIT" ]
null
null
null
books/coding_interviews/p041_stream_median/solution.h
shinexia/algorithm-labs
c9af67865fab9760faeedd64cdd0475f4dff4b4a
[ "MIT" ]
null
null
null
#pragma once #include <algorithm> #include <functional> #include <vector> template <typename T> class DynamicArray { public: DynamicArray* Insert(T num) { size_t size = upper_.size() + lower_.size(); if ((size & 1) == 0) { // add to upper if (!lower_.empty() && num < lower_[0]) { lower_.push_back(num); std::push_heap(lower_.begin(), lower_.end(), std::less<T>()); num = lower_[0]; std::pop_heap(lower_.begin(), lower_.end(), std::less<T>()); lower_.pop_back(); } upper_.push_back(num); std::push_heap(upper_.begin(), upper_.end(), std::greater<T>()); } else { // add to lower if (num > upper_[0]) { upper_.push_back(num); std::push_heap(upper_.begin(), upper_.end(), std::greater<T>()); num = upper_[0]; std::pop_heap(upper_.begin(), upper_.end(), std::greater<T>()); upper_.pop_back(); } lower_.push_back(num); std::push_heap(lower_.begin(), lower_.end(), std::less<T>()); } return this; } double getMedian() { size_t size = upper_.size() + lower_.size(); if ((size & 1) == 1) { // odd return upper_[0]; } else { // even T a = lower_[0]; T b = upper_[0]; int left = (a & 1) + (b & 1); return (a >> 1) + (b >> 1) + (left * 0.5); } } private: std::vector<T> upper_; std::vector<T> lower_; };
30.218182
80
0.453069
[ "vector" ]
bf346bf75611e8806b6d122192813eb7347609d5
2,100
h
C
Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOSTypes.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOSTypes.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOSTypes.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "OnlineSubsystemTypes.h" #include "OnlineSubsystemIOSPackage.h" /** * GameCenter specific implementation of the unique net id */ class FUniqueNetIdGameCenter : public FUniqueNetId { PACKAGE_SCOPE: /** Holds the net id for a player */ uint64 UniqueNetId; /** Hidden on purpose */ FUniqueNetIdGameCenter() : UniqueNetId(0) { } /** * Copy Constructor * * @param Src the id to copy */ explicit FUniqueNetIdGameCenter(const FUniqueNetIdGameCenter& Src) : UniqueNetId(Src.UniqueNetId) { } public: /** * Constructs this object with the specified net id * * @param InUniqueNetId the id to set ours to */ explicit FUniqueNetIdGameCenter(uint64 InUniqueNetId) : UniqueNetId(InUniqueNetId) { } /** * Get the raw byte representation of this net id * This data is platform dependent and shouldn't be manipulated directly * * @return byte array of size GetSize() */ virtual const uint8* GetBytes() const override { return (uint8*)&UniqueNetId; } /** * Get the size of the id * * @return size in bytes of the id representation */ virtual int32 GetSize() const override { return sizeof(uint64); } /** * Check the validity of the id * * @return true if this is a well formed ID, false otherwise */ virtual bool IsValid() const override { return UniqueNetId != 0; } /** * Platform specific conversion to string representation of data * * @return data in string form */ virtual FString ToString() const override { return FString::Printf(TEXT("%I64d"), UniqueNetId); } /** * Get a human readable representation of the net id * Shouldn't be used for anything other than logging/debugging * * @return id in string form */ virtual FString ToDebugString() const override { return FString::Printf(TEXT("0%I64X"), UniqueNetId); } /** Needed for TMap::GetTypeHash() */ friend uint32 GetTypeHash(const FUniqueNetIdGameCenter& A) { return (uint32)(A.UniqueNetId) + ((uint32)((A.UniqueNetId) >> 32 ) * 23); } };
20.38835
75
0.691429
[ "object" ]
bf3521398253bf32b108d3484c3d5c69b96c37ef
3,583
h
C
include/scaf/Utilities/ControlSpecIterators.h
sgh185/SCAF
715a5e50fca0fbff2dc8e3cddafa2d71ae7aa018
[ "MIT" ]
22
2020-08-01T18:09:11.000Z
2022-03-22T08:56:05.000Z
include/scaf/Utilities/ControlSpecIterators.h
sgh185/SCAF
715a5e50fca0fbff2dc8e3cddafa2d71ae7aa018
[ "MIT" ]
4
2021-02-23T01:27:53.000Z
2021-04-19T22:11:39.000Z
include/scaf/Utilities/ControlSpecIterators.h
sgh185/SCAF
715a5e50fca0fbff2dc8e3cddafa2d71ae7aa018
[ "MIT" ]
4
2020-09-17T17:24:22.000Z
2022-03-22T09:12:19.000Z
// This file declares four types of iterators, which operate on the SPECULATIVE // CFG. // // - BBSuccIterator: iterate over the successors of a basic block. // - BBPredIterator: iterate over the predecessors of a basic block. // - LoopBBSuccIterator: iterate over the successors of a basic block within a // single iteration of a loop. // - LoopBBPredIterator: iterate over the predecessors of a basic block within a // single iteration of a loop. // // Don't instantiate these directly; instead use // methods ControlSpeculation::pred_begin, ControlSpeculation::succ_begin, etc #ifndef LLVM_LIBERTY_SPEC_PRIV_CTRL_SPEC_ITERATORS_H #define LLVM_LIBERTY_SPEC_PRIV_CTRL_SPEC_ITERATORS_H #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "scaf/Utilities/LoopDominators.h" #include <set> namespace liberty { using namespace llvm; struct ControlSpeculation; // An iterator over the successors of a block struct BBSuccIterator { // Construct a begin iterator BBSuccIterator(Instruction *ti, ControlSpeculation &cs); // Construnct an end iterator BBSuccIterator(Instruction *ti); BasicBlock *operator*() const; BasicBlock *operator->() const; BBSuccIterator &operator++(); bool operator!=(const BBSuccIterator &other) const; bool operator==(const BBSuccIterator &other) const; private: ControlSpeculation *ctrlspec; Instruction *term; unsigned sn; void skipDead(); }; // An iterator over the predecessors of a block. struct BBPredIterator { // Construct a begin iterator BBPredIterator(BasicBlock *bb, ControlSpeculation &cs); // Construnct an end iterator BBPredIterator(BasicBlock *bb); BasicBlock *operator*() const; BasicBlock *operator->() const; BBPredIterator &operator++(); bool operator!=(const BBPredIterator &other) const; bool operator==(const BBPredIterator &other) const; private: ControlSpeculation *ctrlspec; BasicBlock *succ; pred_iterator piter; void skipDead(); }; // An iterator over the successors of a block in LOOP CFG struct LoopBBSuccIterator { // Construct a begin iterator LoopBBSuccIterator(Loop *l, ControlSpeculation::LoopBlock lb, ControlSpeculation &cs); // Construnct an end iterator LoopBBSuccIterator(Loop *l, ControlSpeculation::LoopBlock lb); ControlSpeculation::LoopBlock operator*() const; ControlSpeculation::LoopBlock operator->() const; LoopBBSuccIterator &operator++(); bool operator!=(const LoopBBSuccIterator &other) const; bool operator==(const LoopBBSuccIterator &other) const; private: Loop *loop; ControlSpeculation *ctrlspec; ControlSpeculation::LoopBlock pred; unsigned sn; void skipDead(); }; // An iterator over the predecessors of a block in LOOP CFG. struct LoopBBPredIterator { // Construct a begin iterator LoopBBPredIterator(Loop *l, ControlSpeculation::LoopBlock lb, ControlSpeculation &cs); // Construnct an end iterator LoopBBPredIterator(Loop *l, ControlSpeculation::LoopBlock lb); ControlSpeculation::LoopBlock operator*() const; ControlSpeculation::LoopBlock operator->() const; LoopBBPredIterator &operator++(); bool operator!=(const LoopBBPredIterator &other) const; bool operator==(const LoopBBPredIterator &other) const; private: Loop *loop; ControlSpeculation *ctrlspec; ControlSpeculation::LoopBlock succ; unsigned pn; typedef std::vector<ControlSpeculation::LoopBlock> LBList; LBList list; bool isEndIterator() const; }; } // namespace liberty #endif
26.153285
80
0.747697
[ "vector" ]
bf371967a00083facf1076e362eb7d110aafb6eb
64,431
c
C
main/sx127x_driver.c
aerodesic/LastLink
12c19f418852fa84f629871ab42e89919ce6d2b8
[ "Apache-2.0" ]
1
2022-03-23T02:54:27.000Z
2022-03-23T02:54:27.000Z
main/sx127x_driver.c
aerodesic/LastLink
12c19f418852fa84f629871ab42e89919ce6d2b8
[ "Apache-2.0" ]
null
null
null
main/sx127x_driver.c
aerodesic/LastLink
12c19f418852fa84f629871ab42e89919ce6d2b8
[ "Apache-2.0" ]
null
null
null
/* * sx127x_driver.c * * The driver for all SX127x chips. Supports SPI currently but is rather agnostic to the interface * type. The caller who instantiates this handler supplies pointers to read and write register and * buffer functions, as well as some ancillary (e.g. attach to interrupt) functions that allows * performing the lower-level platform specific operations. */ #undef USE_FHSS #include "sdkconfig.h" #undef DISPLAY_HANDLER_STATE /* * Driver for sx127x chip. */ #ifdef CONFIG_LASTLINK_RADIO_SX127x_ENABLED #define LORA_HEADER_OVERHEAD 22 #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include "esp_system.h" #include "esp_log.h" #include "radio.h" #include "packets.h" #include "os_specific.h" #include "sx127x_driver.h" #include "linklayer.h" #include "simpletimer.h" #if CONFIG_LASTLINK_EXTRA_DEBUG_COMMANDS #include "commands.h" #endif #ifdef CONFIG_LASTLINK_CRC16_PACKETS #include "crc16.h" #endif #define TAG "sx127x_driver" #undef MEASURE_RX_TIME static bool radio_stop(radio_t* radio); /* Stop and disassemble the radio */ static bool set_sleep_mode(radio_t* radio); /* Set sleeping mode (low power) */ static bool set_standby_mode(radio_t* radio); /* Set standby mode */ static bool set_receive_mode(radio_t* radio); /* Set "real" receive mode */ static bool set_cad_detect_mode(radio_t* radio); /* Set cad detect mode */ static bool set_inactive(radio_t* radio, bool inactive); /* Set inactive/active mode */ static bool set_txpower(radio_t* radio, int power); /* Set transmitter power level */ static int get_txpower(radio_t* radio); /* Get current transmit power */ static int set_channel(radio_t* radio, int channel); /* Set channel */ static int get_channel(radio_t* radio); /* Get channel */ static int set_datarate(radio_t* radio, int datarate); /* Set datarate */ static int get_datarate(radio_t* radio); /* Get datarate */ typedef struct sx127x_private_data sx127x_private_data_t; // Forward ref static void catch_interrupt(void *param); static void rx_handle_interrupt(radio_t* radio, sx127x_private_data_t *data); #ifdef USE_FHSS static void fhss_handle_interrupt(radio_t* radio, sx127x_private_data_t *data); #endif /* USE_FHSS */ #if CONFIG_LASTLINK_EXTRA_DEBUG_COMMANDS void print_status(command_context_t* context, radio_t *radio); #endif static bool tx_handle_interrupt(radio_t* radio, sx127x_private_data_t *data); static void transmit_start(radio_t *radio); static void global_interrupt_handler(void* param); static bool radio_stop(radio_t* radio); static bool release_lock(radio_t* radio); static bool radio_start(radio_t* radio); static int get_packet_snr(radio_t* radio); static bool set_transmit_mode(radio_t* radio); static int get_packet_rssi(radio_t* radio); static bool acquire_lock(radio_t* radio); static bool release_lock(radio_t* radio); static bool set_bandwidth(radio_t* radio, int bw); static bool set_spreading_factor(radio_t*, int spreading_factor); static int get_message_time(radio_t* radio, int length); static int set_coding_rate(radio_t* radio, int rate); static int set_preamble_length(radio_t* radio, int length); #ifdef NOTUSED static int get_preamble_length(radio_t* radio); static int get_coding_rate(radio_t* radio); static int get_spreading_factor(radio_t* radio); #endif static int set_enable_crc(radio_t* radio, bool enable); static bool set_hop_period(radio_t* radio, int hop_period); static bool set_implicit_header(radio_t* radio, bool implicit_header); static bool set_sync_word(radio_t* radio, uint8_t sync); static bool enable_irq(radio_t* radio, uint8_t mask); static bool disable_irq(radio_t* radio, uint8_t mask); static void update_data_rate(radio_t* radio); /* Define the selected frequency domain */ #include "sx127x_table.h" typedef enum { HS_STARTUP, HS_WAITING, /* Handler is waiting (default state) */ HS_WAITING_TIMER, /* Handler is waiting for cad_restart timer */ HS_CAD_RESTART, /* CAD timeout so restart */ HS_RECEIVING, /* Handler is receiving */ HS_RECEIVE_DONE, /* Handler is finished receiving */ HS_TRANSMIT_DONE, /* Handler is finished transmitting */ HS_TRANSMIT_DONE_PRIORITY, /* Handler is finished transmitting priority packet */ HS_WAIT_TX_INT, /* Wait for TX to finish */ } handler_state_t; #if defined(CONFIG_LASTLINK_EXTRA_DEBUG_COMMANDS) || defined(DISPLAY_HANDLER_STATE) inline const char *handler_state_of(handler_state_t state) { switch (state) { case HS_STARTUP: return "HS_STARTUP"; case HS_WAITING: return "HS_WAITING"; case HS_WAITING_TIMER: return "HS_WAITING_TIMER"; case HS_CAD_RESTART: return "HS_CAD_RESTART"; case HS_RECEIVING: return "HS_RECEIVING"; case HS_RECEIVE_DONE: return "HS_RECEIVE_DONE"; case HS_TRANSMIT_DONE: return "HS_TRANSMIT_DONE"; case HS_TRANSMIT_DONE_PRIORITY: return "HS_TRANSMIT_DONE"; case HS_WAIT_TX_INT: return "HS_WAIT_TX_INT"; default: return "UNKNONWN"; } } #endif /* Define private data structure */ typedef struct sx127x_private_data { uint8_t sync_word; uint8_t preamble_length; uint8_t coding_rate; bool implicit_header; bool implicit_header_set; int hop_period; bool enable_crc; int channel; int datarate; int bandwidth; uint8_t spreading_factor; int data_rate_bps; uint8_t tx_power; packet_t *rx_next_packet; int rx_interrupts; #ifdef MEASURE_RX_TIME uint64_t rx_start_time; uint64_t rx_end_time; #endif #define RX_TIMEOUT_TIME 1000 int tx_interrupts; #define TX_TIMEOUT_TIME 1000 #ifdef USE_FHSS int fhss_interrupts; #endif /* USE_FHSS */ os_mutex_t rlock; int packet_memory_failed; packet_t *current_packet; int current_packet_window; /* Calculated window number for this packet */ int packet_crc_errors; int cad_interrupts; int cad_last_interrupts; int cad_detected; int cad_timeouts; int tx_timeouts; int rx_timeouts; int wakeup_ticks; //#define CAD_TIMEOUT_TIME 100 int handler_cycles; os_timer_t handler_wakeup_timer_id; /* ID of radio wakeup timer in case things hang */ os_timer_t cad_restart_timer_id; /* If used, is timer id of cad restart timer */ #define HANDLER_WAKEUP_TIMER_PERIOD 1000 /* Once a second */ simpletimer_t handler_wakeup_timer_status; /* So we can check status of non-readble timer */ uint8_t irq_flags; /* Flags acquired at irq scan time */ handler_state_t handler_state; #ifdef DISPLAY_HANDLER_STATE handler_state_t last_handler_state; #endif int window_number; int window_width; os_timer_t window_timer_id; int window_event_count; #define TX_MAX_TIMEOUT 5000 /* 5 second timeout */ } sx127x_private_data_t; static os_thread_t global_interrupt_handler_thread; static os_queue_t global_interrupt_handler_queue; static void global_interrupt_handler(void* param); static int global_number_radios_active; #define MAX_IRQ_PENDING 50 #define GPIO_DIO0 0 #define GPIO_DIO1 1 #define CAD_DIO_MAPPING 0b10101111 /* DIO0 to CAD_DONE; DIO1 to CAD_DETECTED; DIO2 to undefined */ #define RX_DIO_MAPPING 0b00001111 /* DIO0 to RX_DONE; DIO1 to RX_TIMEOUT; DIO2 to undefined */ #define TX_DIO_MAPPING 0b01111111 /* DIO0 to TX_DONE; DIO1 to undefined; DIO2 to undefined */ #define GLOBAL_IRQ_THREAD_STACK 8192 #define GLOBAL_IRQ_THREAD_PRIORITY (configMAX_PRIORITIES-1) /* Highest priority */ #define WANTED_VERSION 0x12 typedef struct handler_queue_event { radio_t *radio; enum { HQI_INTERRUPT=1, /* A hardware interrupt */ HQI_RESET, /* Reset from hung software */ HQI_WINDOW, /* A window */ } type; union { handler_state_t state; int window; }; } handler_queue_event_t; /* Called when radio's wakeup timer fires - generates 'interrupt' to handler */ static void handler_wakeup_timer(os_timer_t timer_id) { radio_t *radio = (radio_t*) os_get_timer_data(timer_id); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; if (radio->inactive) { /* inactive initiated */ ESP_LOGD(TAG, "%s: inactive detected", __func__); /* Stop the periodic wakeup timer */ os_stop_timer(data->handler_wakeup_timer_id); } else { if (data->cad_last_interrupts == data->cad_interrupts) { /* No CAD interrupts detected in the past few cycles, so reset state via event */ handler_queue_event_t event = { .type = HQI_RESET, .radio = radio, .state = data->handler_state, }; printf("%s: radio %d timeout\n", __func__, radio->radio_num); os_put_queue_with_timeout(global_interrupt_handler_queue, (os_queue_item_t) &event, 0); } else { data->cad_last_interrupts = data->cad_interrupts; } data->wakeup_ticks++; /* Restart the software timer that is used to indicate system timer status, which we cannot read. */ simpletimer_start(&data->handler_wakeup_timer_status, HANDLER_WAKEUP_TIMER_PERIOD); } } inline static int calculate_window_number(radio_t *radio, packet_t *packet) { int window; if (radio->transmit_windows != 1) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; window = (get_uint_field(data->current_packet, HEADER_ORIGIN_ADDRESS, ADDRESS_LEN) * get_uint_field(data->current_packet, HEADER_DEST_ADDRESS, ADDRESS_LEN) * get_uint_field(data->current_packet, HEADER_SENDER_ADDRESS, ADDRESS_LEN) + 2 * get_uint_field(data->current_packet, HEADER_SEQUENCE_NUMBER, SEQUENCE_NUMBER_LEN)) % radio->transmit_windows; } else { window = 0; } return window; } /* * Called to update the window. */ static void window_timer(os_timer_t timer_id) { radio_t *radio = (radio_t*) os_get_timer_data(timer_id); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; /* Set interval in case we were short cycled to get here */ os_set_timer(timer_id, data->window_width); /* Change the window */ data->window_number = (data->window_number + 1) % radio->transmit_windows; /* Count the number of window events */ data->window_event_count++; /* Send the window event */ handler_queue_event_t event = { .type = HQI_WINDOW, .radio = radio, .window = data->window_number, }; os_put_queue_with_timeout(global_interrupt_handler_queue, (os_queue_item_t) &event, 0); } /* * Create an instance of a SX127x device. * * Entry: * radio Pointer to value to receive pointer to SX127x control information * * Returns: * true if successful * */ bool sx127x_create(radio_t* radio) { if (radio != NULL) { /* Start global interrupt processing thread if not yet running */ if (global_interrupt_handler_thread == NULL) { global_interrupt_handler_queue = os_create_queue(MAX_IRQ_PENDING, sizeof(handler_queue_event_t)); global_interrupt_handler_thread = os_create_thread_on_core(global_interrupt_handler, "sx127x_handler", GLOBAL_IRQ_THREAD_STACK, GLOBAL_IRQ_THREAD_PRIORITY, NULL, 0); } /* Add callouts into the driver. All are called with radio as first parameter */ radio->stop = radio_stop; radio->set_sleep_mode = set_sleep_mode; radio->set_standby_mode = set_standby_mode; #if CONFIG_LASTLINK_EXTRA_DEBUG_COMMANDS radio->print_status = print_status; #endif radio->set_receive_mode = set_cad_detect_mode; radio->set_txpower = set_txpower; radio->get_txpower = get_txpower; radio->set_channel = set_channel; radio->get_channel = get_channel; radio->set_datarate = set_datarate; radio->get_datarate = get_datarate; radio->transmit_start = transmit_start; radio->get_message_time = get_message_time; radio->set_inactive = set_inactive; /* Allocate a data block for local data */ radio->driver_private_data = malloc(sizeof(sx127x_private_data_t)); if (radio->driver_private_data != NULL) { memset(radio->driver_private_data, 0, sizeof(sx127x_private_data_t)); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; /* Initialize defaults */ data->sync_word = 0x12; /* 0x34 LoRaWAN; 0x12 LoRa */ data->preamble_length = 32; /* Was 8 */ data->coding_rate = 5; data->implicit_header = false; data->implicit_header_set = false; //data->hop_period = 0; data->enable_crc = true; data->bandwidth = 125000; data->spreading_factor = 10; data->tx_power = 2; //data->rx_interrupts = 0; //data->tx_interrupts = 0; //data->rx_timeouts = 0; //data->tx_timeouts = 0; //data->cad_interrupts = 0; //data->cad_detected = 0; //data->handler_cycles = 0; //data->window_number = 0; data->rlock = os_create_recursive_mutex(); data->handler_state = HS_STARTUP; #ifdef DISPLAY_HANDLER_STATE data->last_handler_state = -1; #endif /* Create the wakeup timer and start it */ data->handler_wakeup_timer_id = os_create_repeating_timer("wakeup_timer", HANDLER_WAKEUP_TIMER_PERIOD, radio, handler_wakeup_timer); os_start_timer(data->handler_wakeup_timer_id); /* Create window event timer */ data->window_timer_id = os_create_timer("wakeup_timer", HANDLER_WAKEUP_TIMER_PERIOD, radio, window_timer); /* Send initial wakeup call to handler */ handler_queue_event_t event = { .radio = radio, .type = HQI_INTERRUPT, }; os_put_queue_with_timeout(global_interrupt_handler_queue, (os_queue_item_t) &event, 0); } ++global_number_radios_active; } return radio != NULL && radio->driver_private_data != NULL && radio_start(radio); } /* * radio_delete * * stop and remove radio from system. * * TODO */ /************************************************************************************ * Thread base interrupt handler * * As interrupts are detected, flags are passed in parameters * and the radio element is queued to the global_interrupt_handler_queue. * * This thread processes these elements one at a time and processes each * passing, the radio and irq flags value at time of interrupt. * ************************************************************************************/ static void rx_handle_interrupt(radio_t* radio, sx127x_private_data_t *data) { data->rx_interrupts++; /* Clear rx interrupt */ data->irq_flags &= ~SX127x_IRQ_RX_DONE; uint8_t fifo_current = radio->read_register(radio, SX127x_REG_RX_FIFO_CURRENT); if (fifo_current != 0) { ESP_LOGE(TAG, "%s: FIFO_CURRENT not 0: %d (%02x)", __func__, fifo_current, fifo_current); } radio->write_register(radio, SX127x_REG_FIFO_PTR, fifo_current); int length; if (data->implicit_header) { length = radio->read_register(radio, SX127x_REG_PAYLOAD_LENGTH); } else { length = radio->read_register(radio, SX127x_REG_RX_NUM_BYTES); } /* Cannot reliably capture packet if CRC error so don't even try */ if ((data->irq_flags & (SX127x_IRQ_VALID_HEADER | SX127x_IRQ_PAYLOAD_CRC_ERROR )) == 0) { /* Get a packet */ packet_t* packet = data->rx_next_packet; if (packet != NULL) { data->rx_next_packet = NULL; if (radio->read_buffer(radio, SX127x_REG_FIFO, packet->buffer, length)) { #ifdef CONFIG_LASTLINK_CRC16_PACKETS bool crcok = false; if (length >= 3) { /* Check the add crc on the packets */ crcok = calc_crc16(CRC16_SEED, packet->buffer, length) == 0; if (crcok) { length = length - 2; } #if 0 else { /* Calculate crc on the base and display calculated and wanted values for debugging */ unsigned crc_wanted = calc_crc16(CRC16_SEED, packet->buffer, length - 2); unsigned crc_found = (packet->buffer[length - 2] << 8) | packet->buffer[length - 1]; ESP_LOGE(TAG, "%s: packet length %d crc_wanted %04x crc_found %04x", __func__, length, crc_wanted, crc_found); } #endif } #else bool crcok = true; #endif /* Buffer has been read. Set length */ packet->length = length; packet->crc_ok = crcok; packet->rssi = get_packet_rssi(radio); packet->snr = get_packet_snr(radio); packet->radio_num = radio->radio_num; /* Pass it to protocol layer */ radio->on_receive(ref_packet(packet)); /* Calculate window and starting point */ int window = calculate_window_number(radio, packet); int time_of_flight = get_message_time(radio, packet->length); #ifdef MEASURE_RX_TIME int measured = (int) (data->rx_end_time - data->rx_start_time); printf("%s: rx msg time: calc %d measured %d delta %d\n", __func__, time_of_flight, measured, time_of_flight - measured); #endif /* MEASURE_RX_TIME */ /* Synchronize window to align to next assumed slot (it is reset inside interval handler) */ os_stop_timer(data->window_timer_id); data->window_number = window; os_set_timer(data->window_timer_id, data->window_width - time_of_flight); } release_packet(packet); } else { data->packet_memory_failed++; } } else { //ESP_LOGE(TAG, "%s: errors %02x", __func__, data->irq_flags); if ((data->irq_flags & SX127x_IRQ_PAYLOAD_CRC_ERROR) != 0) { ESP_LOGE(TAG, "%s: rxint with crc", __func__); data->packet_crc_errors++; } data->irq_flags &= ~(SX127x_IRQ_PAYLOAD_CRC_ERROR | SX127x_IRQ_VALID_HEADER | SX127x_IRQ_PAYLOAD_CRC_ERROR); } } #ifdef USE_FHSS /* THIS NEEDS WORK */ static void fhss_handle_interrupt(radio_t* radio, sx127x_private_data_t *data) { #ifdef NOTUSED radio->write_register(radio, SX127x_FHSS_HOP_CHANNEL, next_channel); #endif data->fhss_interrupts++; } #endif /* USE_FHSS */ static bool start_packet(radio_t* radio) { return set_standby_mode(radio) && radio->write_register(radio, SX127x_REG_FIFO_PTR, TX_FIFO_BASE) && radio->write_register(radio, SX127x_REG_TX_FIFO_BASE, TX_FIFO_BASE) ; } static bool write_packet(radio_t* radio, packet_t* packet) { bool ok = false; #ifdef CONFIG_LASTLINK_CRC16_PACKETS /* Compute crc to add to message. Can't modify packet as it may be sent more * than one place. Need to compute and send crc separately. */ unsigned short crc = calc_crc16(CRC16_SEED, packet->buffer, packet->length); unsigned char crcbuf[2]; crcbuf[0] = crc >> 8; crcbuf[1] = crc & 0xFF; radio->write_buffer(radio, SX127x_REG_FIFO, packet->buffer, packet->length); radio->write_buffer(radio, SX127x_REG_FIFO, crcbuf, sizeof(crcbuf)); /* Set the new length of the payload in process */ radio->write_register(radio, SX127x_REG_PAYLOAD_LENGTH, packet->length + 2); #else radio->write_buffer(radio, SX127x_REG_FIFO, packet->buffer, packet->length); radio->write_register(radio, SX127x_REG_PAYLOAD_LENGTH, packet->length); #endif ok = true; return ok; } /* Called upon interrupt */ static bool tx_handle_interrupt(radio_t *radio, sx127x_private_data_t *data) { /* Remove flag so we don't call again until next interrupt */ data->irq_flags &= ~SX127x_IRQ_TX_DONE; data->tx_interrupts++; if (radio->activity_indicator != NULL) { radio->activity_indicator(radio, false); } bool priority = false; /* Discard current queue entry */ if (data->current_packet != NULL) { priority = (get_uint_field(data->current_packet, HEADER_FLAGS, FLAGS_LEN) & HEADER_FLAGS_PRIORITY) != 0; data->current_packet->transmitting--; /* Count as transmitted */ data->current_packet->transmitted++; /* * No critical race with respect to packet fields and the packet will not * enter transmitting mode if it is locked by another thread. Only * when the current 'winner' finishes the thread will the next one be * able to lock and start a transmit. */ /* Only do when all radios have finished. */ if (data->current_packet->transmitting == 0) { /* Tell any interested listener that it has been transmitted */ packet_tell_transmitted_callback(data->current_packet, radio); } assert(packet_unlock(data->current_packet)); release_packet(data->current_packet); data->current_packet = NULL; } return priority; } /* * Called when we want to start a new packet. */ static bool tx_next_packet(radio_t *radio, sx127x_private_data_t *data) { /* Get a new packet if we have none */ if (data->current_packet == NULL) { if (os_get_queue_with_timeout(radio->transmit_queue, (os_queue_item_t) &data->current_packet, 0)) { /* Fetched a new packet, so calculate it's window */ data->current_packet_window = calculate_window_number(radio, data->current_packet); //printf("%s: window %d\n", __func__, data->current_packet_window); } } return data->current_packet != NULL; } /* * Move current packet to end of transmit queue for sending later. */ static void tx_recycle_packet(radio_t *radio, sx127x_private_data_t *data) { if (data->current_packet != NULL) { if (os_put_queue_with_timeout(radio->transmit_queue, (os_queue_item_t) &data->current_packet, 0)) { data->current_packet = NULL; } } } static void tx_start_packet(radio_t *radio, sx127x_private_data_t *data) { start_packet(radio); write_packet(radio, data->current_packet); set_transmit_mode(radio); if (radio->activity_indicator != NULL) { radio->activity_indicator(radio, true); } } /* Force start transmit interrupt handler */ static void transmit_start(radio_t *radio) { #if 0 if (acquire_lock(radio)) { release_lock(radio); } else { ESP_LOGE(TAG, "%s: Cannot acquire lock", __func__); } #endif } static void cad_restart(os_timer_t timer_id) { ESP_LOGD(TAG, "%s", __func__); radio_t *radio = (radio_t*) os_get_timer_data(timer_id); set_cad_detect_mode(radio); } /* * Need to pass in a 'code' for the reason. * * reasons: Interrupt; Timer * * Normal operation is via direct interrupts, specifically receive and CAD interrupts (for * scanning channel available and read-packet detection. Transmit is controlled by items * coming from the input queue and the 'window' tick timer. * * When a packet is ready to transmit, a determination is made as to how close it is * to the window edge and a timer is activated to start the operation at that time. * * The window determination is federated: each node is responsible for self-synchronizing * to the window period. For example, when a packet is read, after the interrupt the * window starting point is calculated to be: * <current time> - <'time of flight' of the packet> * This value is used to reset the next window event detection interrupt time. * * When the window heartbeat is detected, the system determines if a packet exists that * hashes to the current window interval and if so, launches it. * * Window interval hashing is a work-in-progress but is based upon a hash of the * origin, destination and sequence number of the packet. This hash is reduced to * an N bit number and this drives the window cycle. * * For example when a packet is received, the window hash for that packet is calculated * and used to reset the current window number and this becomes the basis for the next * window to be delivered to the handler. * * The rate of the window number update is based on the maximum time-of-flight for a * packet at the current bandwidth / coding_rate / spreading_factor. * */ /* Param is ignored */ static void global_interrupt_handler(void* param) { bool running = true; ESP_LOGD(TAG, "%s: running", __func__); while (running) { handler_queue_event_t event; if (os_get_queue(global_interrupt_handler_queue, (os_queue_item_t) &event)) { radio_t *radio = event.radio; if (radio != NULL) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; if (event.type == HQI_RESET) { /* Force state transition */ data->handler_state = event.state; data->cad_timeouts++; } #if 0 if (event.type == HQI_WINDOW) { printf("window %d\n", event.window); } #endif data->handler_cycles++; if (acquire_lock(radio)) { /* Remember what we have */ data->irq_flags |= radio->read_register(radio, SX127x_REG_IRQ_FLAGS); /* Physically clear the interrupts detected */ radio->write_register(radio, SX127x_REG_IRQ_FLAGS, data->irq_flags & 0xFF); #ifdef USE_FHSS if (data->irq_flags & SX127x_IRQ_FHSS_CHANGE_CHANNEL) { fhss_handle_interrupt(radio, data); data->irq_flags &= ~SX127x_IRQ_FHSS_CHANGE_CHANNEL; } #endif /* USE_FHSS */ // printf("%s %02x %02x\n", handler_state_of(data->handler_state), data->irq_flags, radio->read_register(radio, SX127x_REG_IRQ_FLAGS_MASK)); #ifdef DISPLAY_HANDLER_STATE if (data->handler_state != data->last_handler_state) { printf("Handler state %s\n", handler_state_of(data->handler_state)); data->last_handler_state = data->handler_state; } #endif /* Allocate a new receive packet if we can */ if (data->rx_next_packet == NULL) { data->rx_next_packet = allocate_packet(); /* * If no packets, release from the transmit queue until we find one. They will be regenereted * at some point if needed. * * Note that it is possible we can release the entire transmit queue and not actually * get any packets due to they might be on other queues and still have ref's. * * At any rate, this gets rid of the oldest outgoing packets in a packet-starved situation * and many of the packets on the queue may newer copies of these old ones. */ if (data->rx_next_packet == NULL) { bool done = false; packet_t *packet; int count = 0; do { if (os_get_queue_with_timeout(radio->transmit_queue, (os_queue_item_t) &packet, 0)) { ++count; release_packet(packet); data->rx_next_packet = allocate_packet(); } else { done = true; } } while (!done && data->rx_next_packet == NULL); if (data->rx_next_packet != NULL) { printf("%s: found free packet after %d releases of transmit queue\n", __func__, count); } } } switch (data->handler_state) { default: case HS_STARTUP: { /* Default state of receiving until interrupt seen or transmit packet is ready to go. * To start transmit, caller places packet into the transmit queue and puts a radio* * pointer into the handler queue. The handler sees this pointer and determines if * it can start a new packet at that time. If the handerl is in receive mode and * the transmit delay timer has expired, it attempts to start the packet. */ break; } /* * Waiting in Carrier Detect mode. When we get an input signal, go to receive mode. * If we get a packet to send, go to transmit mode if it's been long enough since * lasst receive/transmit. */ case HS_WAITING: { if ((data->irq_flags & (SX127x_IRQ_CAD_DONE)) != 0) { data->cad_interrupts++; if ((data->irq_flags & (SX127x_IRQ_CAD_DETECTED)) != 0) { data->cad_detected++; data->handler_state = HS_RECEIVING; } data->irq_flags &= ~(SX127x_IRQ_CAD_DONE | SX127x_IRQ_CAD_DETECTED); } if ((data->handler_state == HS_WAITING) && (event.type == HQI_WINDOW)) { //printf("%s: window %d\n", __func__, data->current_packet_window); /* If packet exists and it's window id is for the current window, start it going */ if (tx_next_packet(radio, data)) { if (data->current_packet_window == event.window) { if (packet_lock(data->current_packet)) { /* Remains locked through the interrupt return */ tx_start_packet(radio, data); data->handler_state = HS_WAIT_TX_INT; } else { /* Recycle packet to end of queue in hopes we can do some other work while waiting. */ /* If not, we'll keep moving it back into the queue on each CAD interrupt for a while. */ tx_recycle_packet(radio, data); } } //else { printf("%s: window %d want %d\n", __func__, event.window, data->current_packet_window); } } } break; } /* * A carrier was detected. Attempt to receive the packet or wait for timeout. */ case HS_RECEIVING: { if (data->irq_flags & SX127x_IRQ_RX_DONE) { /* Packet arrived. Process it */ #ifdef MEASURE_RX_TIME data->rx_end_time = get_milliseconds(); #endif /* MEASURE_RX_TIME */ rx_handle_interrupt(radio, data); /* Allocate a new packet if we can */ if (data->rx_next_packet == NULL) { data->rx_next_packet = data->rx_next_packet; } data->handler_state = HS_RECEIVE_DONE; } else if (((data->irq_flags & (SX127x_IRQ_RX_TIMEOUT)) != 0)) { data->rx_timeouts++; /* Receive attempt timed out. Return to active mode and clear receive busy */ data->irq_flags &= ~(SX127x_IRQ_RX_TIMEOUT); data->handler_state = HS_CAD_RESTART; } break; } /* Actively transmitting - wait for interrupt */ case HS_WAIT_TX_INT: { if (data->irq_flags & SX127x_IRQ_TX_DONE) { /* Turns off indicator and releases packet */ data->handler_state = tx_handle_interrupt(radio, data) ? HS_TRANSMIT_DONE_PRIORITY : HS_TRANSMIT_DONE; } break; } } switch (data->handler_state) { case HS_STARTUP: case HS_CAD_RESTART: { set_cad_detect_mode(radio); data->handler_state = HS_WAITING; break; } case HS_WAITING: { if (radio->cad_restart_delay != 0) { // Fire a timer in <cad_restart_delay> ms to check start cad waiting again if (data->cad_restart_timer_id == NULL) { ESP_LOGD(TAG, "%s: creating cad_restart_timer_id", __func__); data->cad_restart_timer_id = os_create_timer("cad_restart", radio->cad_restart_delay, radio, cad_restart); } os_start_timer(data->cad_restart_timer_id); data->handler_state = HS_WAITING_TIMER; } else { set_cad_detect_mode(radio); data->handler_state = HS_WAITING; } break; } case HS_WAITING_TIMER: { // Stall break; } case HS_RECEIVING: { set_receive_mode(radio); #ifdef MEASURE_RX_TIME data->rx_start_time = get_milliseconds(); #endif /* MEASURE_RX_TIME */ break; } case HS_RECEIVE_DONE: { set_cad_detect_mode(radio); /* And go back to waiting */ data->handler_state = HS_WAITING; break; } case HS_TRANSMIT_DONE_PRIORITY: { set_standby_mode(radio); set_cad_detect_mode(radio); /* And go back to waiting */ data->handler_state = HS_WAITING; break; } case HS_TRANSMIT_DONE: { set_standby_mode(radio); set_cad_detect_mode(radio); /* And go back to waiting */ data->handler_state = HS_WAITING; break; } case HS_WAIT_TX_INT: { break; } } release_lock(radio); } else { ESP_LOGE(TAG, "%s: unable to acquire lock", __func__); } } else { /* NULL delivered - shut down */ running = false; printf("sx127x_driver handler stopped\n"); } } else { ESP_LOGE(TAG, "%s: interrupt queue failed to read - exiting", __func__); running = false; } } ESP_LOGD(TAG, "%s: stopped", __func__); os_exit_thread(); } static bool radio_stop(radio_t* radio) { bool ok = false; sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; if (acquire_lock(radio)) { /* Disable all interrupts */ ok = disable_irq(radio, 0xFF) && radio->attach_interrupt(radio, GPIO_DIO0, false, false, GPIO_PIN_INTR_DISABLE, NULL) #ifdef GPIO_DIO1 && radio->attach_interrupt(radio, GPIO_DIO1, false, false, GPIO_PIN_INTR_DISABLE, NULL) #endif ; /* Kill handler window timer */ os_delete_timer(data->window_timer_id); data->window_timer_id = NULL; /* Kill handler wakeup timer */ os_delete_timer(data->handler_wakeup_timer_id); data->handler_wakeup_timer_id = NULL; if (ok && --global_number_radios_active == 0) { /* Kill interrupt thread and queue */ os_delete_thread(global_interrupt_handler_thread); global_interrupt_handler_thread = NULL; /* Remove global queue */ os_delete_queue(global_interrupt_handler_queue); global_interrupt_handler_queue = NULL; } release_lock(radio); } return ok; } static bool acquire_lock(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; //ESP_LOGI(TAG, "%s: acquiring radio lock", __func__); bool ok = os_acquire_recursive_mutex(data->rlock); //ESP_LOGI(TAG, "%s: acquire lock %s", __func__, ok ? "SUCCESS" : "FAILED"); return ok; } static bool release_lock(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; //ESP_LOGI(TAG, "%s: releasing radio lock", __func__); return os_release_recursive_mutex(data->rlock); } static bool enable_irq(radio_t* radio, uint8_t mask) { bool ok = false; int cur_mask = radio->read_register(radio, SX127x_REG_IRQ_FLAGS_MASK); if (cur_mask >= 0) { ok = radio->write_register(radio, SX127x_REG_IRQ_FLAGS_MASK, (uint8_t) cur_mask & ~mask); } return ok; } static bool disable_irq(radio_t* radio, uint8_t mask) { bool ok = false; int cur_mask = radio->read_register(radio, SX127x_REG_IRQ_FLAGS_MASK); if (cur_mask >= 0) { ok = radio->write_register(radio, SX127x_REG_IRQ_FLAGS_MASK, (uint8_t) cur_mask | mask); } return ok; } static bool radio_start(radio_t* radio) { bool ok = false; if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; radio->reset_device(radio); /* Read version */ int version = -1; int max_tries = 5; while (version != WANTED_VERSION && max_tries != 0) { version = radio->read_register(radio, SX127x_REG_VERSION); max_tries--; } if (version != WANTED_VERSION) { ESP_LOGE(TAG, "Wrong version detected: %02x wanted %02x", version, WANTED_VERSION); } else { /* Put receiver in standby */ set_sleep_mode(radio); /* Set initial default parameters parameters */ set_bandwidth(radio, data->bandwidth); set_spreading_factor(radio, data->spreading_factor); set_txpower(radio, data->tx_power); set_implicit_header(radio, data->implicit_header); set_coding_rate(radio, data->coding_rate); set_preamble_length(radio, data->preamble_length); set_sync_word(radio, data->sync_word); set_enable_crc(radio, data->enable_crc); set_hop_period(radio, data->hop_period); /* LNA Boost */ radio->write_register(radio, SX127x_REG_LNA, radio->read_register(radio, SX127x_REG_LNA) | 0x03); /* auto AGC enable */ radio->write_register(radio, SX127x_REG_MODEM_CONFIG_3, 0x04); /* FIFO Bases */ radio->write_register(radio, SX127x_REG_TX_FIFO_BASE, TX_FIFO_BASE); radio->write_register(radio, SX127x_REG_RX_FIFO_BASE, RX_FIFO_BASE); /* Mask all IRQs */ disable_irq(radio, 0xFF); /* Clear all interrupts */ radio->write_register(radio, SX127x_REG_IRQ_FLAGS, 0xFF); /* Capture receive/transmit interrupts */ radio->attach_interrupt(radio, GPIO_DIO0, true, false, GPIO_PIN_INTR_POSEDGE, catch_interrupt); #ifdef GPIO_DIO1 radio->attach_interrupt(radio, GPIO_DIO1, true, false, GPIO_PIN_INTR_POSEDGE, catch_interrupt); #endif #ifdef USE_FHSS if (data->hop_period != 0) { /* Enable FHSS interrupt */ enable_irq(radio, SX127x_IRQ_FHSS_CHANGE_CHANNEL); } #endif /* Configure the unit for receive channel 0; probably overriden by caller */ set_channel(radio, 0); ESP_LOGD(TAG, "SX127x radio started"); ok = true; } release_lock(radio); } return ok; } static int get_packet_rssi(radio_t* radio) { int rssi = -9999; if (acquire_lock(radio)) { rssi = radio->read_register(radio, SX127x_REG_PACKET_RSSI) - 157; if (channel_table.low_domain_freq < 868E6) { rssi = rssi + 7; } } release_lock(radio); return rssi; } /* Returns SNR in .1 db units (e.g. 1 db SNR would return 10 */ static int get_packet_snr(radio_t* radio) { int snr = -9999; if (acquire_lock(radio)) { snr = (int) ((radio->read_register(radio, SX127x_REG_PACKET_SNR) * 10.0) / 4.0); release_lock(radio); } return snr; } static bool set_standby_mode(radio_t* radio) { bool ok = false; // ESP_LOGD(TAG, "%s: radio %d", __func__, radio->radio_num); if (acquire_lock(radio)) { ok = disable_irq(radio, 0xFF) && radio->write_register(radio, SX127x_REG_OP_MODE, SX127x_MODE_LONG_RANGE | SX127x_MODE_STANDBY) ; release_lock(radio); } return ok; } static bool set_sleep_mode(radio_t* radio) { bool ok = false; // ESP_LOGD(TAG, "%s: radio %d", __func__, radio->radio_num); if (acquire_lock(radio)) { ok = disable_irq(radio, 0xFF) && radio->write_register(radio, SX127x_REG_OP_MODE, SX127x_MODE_LONG_RANGE | SX127x_MODE_SLEEP); release_lock(radio); } return ok; } /* * Set receive mode */ static bool set_receive_mode(radio_t* radio) { bool ok = false; // ESP_LOGI(TAG, "%s: radio %d", __func__, radio->radio_num); if (acquire_lock(radio)) { if (radio->inactive) { /* Leave in sleep mode */ ok = radio->set_sleep_mode(radio); } else { ok = disable_irq(radio, SX127x_IRQ_CAD_DONE | SX127x_IRQ_CAD_DETECTED | SX127x_IRQ_TX_DONE) && radio->write_register(radio, SX127x_REG_DIO_MAPPING_1, RX_DIO_MAPPING) && radio->write_register(radio, SX127x_REG_OP_MODE, SX127x_MODE_LONG_RANGE | SX127x_MODE_RX_SINGLE) && enable_irq(radio, SX127x_IRQ_RX_DONE | SX127x_IRQ_RX_TIMEOUT) ; } if (!ok) ESP_LOGE(TAG, "%s: failed", __func__); release_lock(radio); } return ok; } static bool set_cad_detect_mode(radio_t* radio) { bool ok = false; /* Just put the unit into continuous receive */ if (acquire_lock(radio)) { set_standby_mode(radio); ok = disable_irq(radio, SX127x_IRQ_TX_DONE | SX127x_IRQ_RX_DONE | SX127x_IRQ_RX_TIMEOUT) && radio->write_register(radio, SX127x_REG_DIO_MAPPING_1, CAD_DIO_MAPPING) && radio->write_register(radio, SX127x_REG_OP_MODE, SX127x_MODE_LONG_RANGE | SX127x_MODE_CAD_DETECTION) && enable_irq(radio, SX127x_IRQ_CAD_DETECTED | SX127x_IRQ_CAD_DONE) //&& enable_irq(radio, SX127x_IRQ_CAD_DONE) ; if (!ok) ESP_LOGE(TAG, "%s: failed", __func__); release_lock(radio); } return ok; } static bool set_transmit_mode(radio_t* radio) { bool ok = false; if (acquire_lock(radio)) { ok = disable_irq(radio, SX127x_IRQ_CAD_DETECTED | SX127x_IRQ_CAD_DONE | SX127x_IRQ_RX_DONE | SX127x_IRQ_RX_TIMEOUT) && enable_irq(radio, SX127x_IRQ_TX_DONE) && radio->write_register(radio, SX127x_REG_DIO_MAPPING_1, TX_DIO_MAPPING) && radio->write_register(radio, SX127x_REG_OP_MODE, SX127x_MODE_LONG_RANGE | SX127x_MODE_TX) ; release_lock(radio); } return ok; } /* Used to power down radio to standy mode */ static bool set_inactive(radio_t* radio, bool inactive) { bool ok = true; ESP_LOGD(TAG, "%s: radio %d %sactive", __func__, radio->radio_num, inactive ? "in" : ""); if (acquire_lock(radio)) { if (inactive != radio->inactive) { radio->inactive = inactive; /* Do the work to change active mode */ if (inactive == 0) { radio->set_receive_mode(radio); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; /* Restart wakeup timer */ os_start_timer(data->handler_wakeup_timer_id); } release_lock(radio); } } return ok; } /* * Set power from -15 to +17 dbm. Chose PA mode as apprpriate */ static bool set_txpower(radio_t* radio, int power) { bool ok = false; ESP_LOGI(TAG, "%s: power %d", __func__, power); if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; if (power < -4) { power = -4; } else if (power > 17) { power = 17; } data->tx_power = power; if (power >= 2) { /* BOOST mode on */ radio->write_register(radio, SX127x_REG_PA_CONFIG, SX127x_PA_BOOST | (power - 2)); #ifdef NOTUSED /* TEST */ radio->read_register(radio, SX127x_REG_PA_CONFIG); /* END TEST */ #endif } else { /* BOOST mode off (close enough) */ power -= 4; radio->write_register(radio, SX127x_REG_PA_CONFIG, power); } release_lock(radio); ok = true; } return ok; } static int get_txpower(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->tx_power; } /* * set_channel * * selects the channel and sets the datarate to the lowest for the channel. * * Returns old channel if successful else -1. */ static int set_channel(radio_t* radio, int channel) { int old_channel = -1; ESP_LOGI(TAG, "%s: channel %d", __func__, channel); if (channel >= 0 && channel < ELEMENTS_OF(channel_table.channels)) { old_channel = get_channel(radio); if (acquire_lock(radio)) { set_sleep_mode(radio); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; const channel_entry_sx127x_t *chanp = &channel_table_sx127x.channels[channel]; /* Set frequency control */ radio->write_register(radio, SX127x_REG_FREQ_MSB, chanp->freq_high); radio->write_register(radio, SX127x_REG_FREQ_MID, chanp->freq_mid); radio->write_register(radio, SX127x_REG_FREQ_LSB, chanp->freq_low); //#ifdef NOTUSED /*TEST*/ radio->read_register(radio, SX127x_REG_FREQ_MSB); radio->read_register(radio, SX127x_REG_FREQ_MID); radio->read_register(radio, SX127x_REG_FREQ_LSB); /*END TEST*/ //#endif radio->set_datarate(radio, 0); //set_datarate(radio, 3); radio->set_txpower(radio, channel_table_sx127x.datarates[chanp->datarate_group][0].tx); data->channel = channel; radio->set_receive_mode(radio); release_lock(radio); } } return old_channel; } static int get_channel(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->channel; } /* * Set the datarate. * * Return old datarate if successful, otherwise -1. */ static int set_datarate(radio_t* radio, int datarate) { int old_datarate = -1; if (acquire_lock(radio)) { old_datarate = get_datarate(radio); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; int datarate_group = channel_table_sx127x.channels[data->channel].datarate_group; const datarate_entry_sx127x_t* dataratep = channel_table.datarates[datarate_group]; if (datarate >= 0 && datarate < ELEMENTS_OF(channel_table.datarates[datarate_group]) && dataratep[datarate].payload != 0) { int sf = dataratep[datarate].sf; int bw = dataratep[datarate].bw; int cr = dataratep[datarate].cr; int tx = dataratep[datarate].tx; if (!set_bandwidth(radio, bw) || !set_spreading_factor(radio, sf) || !set_coding_rate(radio, cr) || !set_txpower(radio, tx)) { /* Restore datarate (caution - recursion); better not be an error on the old datarate. */ set_datarate(radio, data->datarate); old_datarate = -1; } else { /* Ok */ data->datarate = datarate; } } release_lock(radio); } return old_datarate; } static int get_datarate(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->datarate; } /* * Set bandwidth */ static bool set_bandwidth(radio_t* radio, int bw) { bool ok = false; if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; ESP_LOGI(TAG, "%s: %d", __func__, bw); int bwcode = -1; int bwindex = 0; /* Look for bandwidth in code table */ while (bwcode < 0 && bwindex < ELEMENTS_OF(channel_table_sx127x.bandwidth_bins)) { if (bw == channel_table_sx127x.bandwidth_bins[bwindex]) { bwcode = bwindex; } else { bwindex++; } } if (bwcode >= 0) { ok = radio->write_register(radio, SX127x_REG_MODEM_CONFIG_1, (radio->read_register(radio, SX127x_REG_MODEM_CONFIG_1) & 0x0f) | (bwcode << 4)); } if (ok) { data->bandwidth = bw; } release_lock(radio); } update_data_rate(radio); return ok; } #ifdef NOTUSED static int get_bandwidth(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->bandwidth; } #endif static bool set_spreading_factor(radio_t* radio, int spreading_factor) { bool ok = false; ESP_LOGI(TAG, "%s: sf %d", __func__, spreading_factor); if (spreading_factor >= 6 && spreading_factor <= 12) { if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; data->spreading_factor = spreading_factor; /* Set 'low data rate' flag if long symbol time otherwise clear it */ int config3 = radio->read_register(radio, SX127x_REG_MODEM_CONFIG_3); if (config3 >= 0) { if (1000.0 / ((float) data->bandwidth / (float) (1<<spreading_factor)) > -1) { config3 |= 0x08; } else { config3 &= ~0x08; } int config2 = radio->read_register(radio, SX127x_REG_MODEM_CONFIG_2); if (config2 >= 0) { ok = radio->write_register(radio, SX127x_REG_MODEM_CONFIG_3, config3) && radio->write_register(radio, SX127x_REG_DETECTION_OPTIMIZE, (spreading_factor == 6) ? 0xc5 : 0xc3) && radio->write_register(radio, SX127x_REG_DETECTION_THRESHOLD, (spreading_factor == 6) ? 0x0c : 0x0a) && radio->write_register(radio, SX127x_REG_MODEM_CONFIG_2, (config2 & 0x0F) | (spreading_factor << 4)); ; /*TEST*/ radio->read_register(radio, SX127x_REG_MODEM_CONFIG_2); /* READBACK */ /* END TEST */ } } release_lock(radio); } } update_data_rate(radio); return ok; } #ifdef NOTUSED static int get_spreading_factor(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->spreading_factor; } #endif static int set_coding_rate(radio_t* radio, int rate) { bool ok = false; if (rate >= 5 && rate <= 8) { ESP_LOGI(TAG, "%s: %d", __func__, rate); if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; data->coding_rate = rate; int config1 = radio->read_register(radio, SX127x_REG_MODEM_CONFIG_1); if (config1 >= 0) { ok = radio->write_register(radio, SX127x_REG_MODEM_CONFIG_1, (config1 & 0xF1) | ((rate - 4) << 1)); } release_lock(radio); } } update_data_rate(radio); return ok; } #ifdef NOTUSED static int get_coding_rate(radio_t* radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->coding_rate; } #endif static int set_preamble_length(radio_t* radio, int length) { bool ok = false; ESP_LOGI(TAG, "%s: length %d", __func__, length); if (acquire_lock(radio)) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; data->preamble_length = length; ok = radio->write_register(radio, SX127x_REG_PREAMBLE_MSB, (length >> 8)) && radio->write_register(radio, SX127x_REG_PREAMBLE_LSB, length); release_lock(radio); } update_data_rate(radio); return ok; } #ifdef NOTUSED static int get_preamble_lengt(radio_t *radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; return data->preamble_length; } #endif static int set_enable_crc(radio_t* radio, bool enable) { bool ok = false; ESP_LOGI(TAG, "%s: enable %s", __func__, enable ? "TRUE" : "FALSE"); if (acquire_lock(radio)) { int config2 = radio->read_register(radio, SX127x_REG_MODEM_CONFIG_2); if (config2 >= 0) { if (enable) { config2 |= 0x04; } else { config2 &= ~0x04; } ok = radio->write_register(radio, SX127x_REG_MODEM_CONFIG_2, config2); #if 0 /*TEST*/ /* Read back to verify */ radio->read_register(radio, SX127x_REG_MODEM_CONFIG_2); /*END TEST*/ #endif } release_lock(radio); } return ok; } static bool set_hop_period(radio_t* radio, int hop_period) { bool ok = false; if (acquire_lock(radio)) { ok = radio->write_register(radio, SX127x_REG_HOP_PERIOD, hop_period); release_lock(radio); } return ok; } static bool set_sync_word(radio_t* radio, uint8_t sync) { bool ok = false; ESP_LOGI(TAG, "%s: sync %02x", __func__, sync); if (acquire_lock(radio)) { ok = radio->write_register(radio, SX127x_REG_SYNC_WORD, sync); release_lock(radio); } return ok; } static bool set_implicit_header(radio_t* radio, bool implicit_header) { bool ok = false; ESP_LOGI(TAG, "%s: enable %s", __func__, implicit_header ? "TRUE" : "FALSE"); sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; if (acquire_lock(radio)) { int config1 = radio->read_register(radio, SX127x_REG_MODEM_CONFIG_1); if (config1 >= 0) { if (implicit_header) { config1 |= 0x01; } else { config1 &= ~0x01; } ok = radio->write_register(radio, SX127x_REG_MODEM_CONFIG_1, config1); } data->implicit_header = implicit_header; data->implicit_header_set = true; release_lock(radio); } return ok; } /* * Calculates BPS for selected data rate */ static void update_data_rate(radio_t *radio) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; data->data_rate_bps = (data->spreading_factor * 4 * data->bandwidth) / (data->coding_rate * (1 << data->spreading_factor)); /* Set the width of the transmit window in milliseconds */ data->window_width = (get_message_time(radio, MAX_PACKET_LEN) * radio->window_width_percent) / 100; /* Change the window update rate. Things may be a bit wonky until the first packet is received */ os_set_timer(data->window_timer_id, data->window_width); } /* * Return message time in milliseconds for a packet of given length in bytes (plus preamble overhead.) */ static int get_message_time(radio_t* radio, int length) { sx127x_private_data_t* data = (sx127x_private_data_t*) radio->driver_private_data; int time = ((length + data->preamble_length + LORA_HEADER_OVERHEAD) * 8 * 1000) / data->data_rate_bps; //ESP_LOGI(TAG, "%s: sf %d bw %d length %d is %d", __func__, get_spreading_factor(radio), get_bandwidth(radio), length, time); return time; } /* * All interrupts come here and are queued for later processing by a global handling thread. */ static void catch_interrupt(void *param) { radio_t *radio = (radio_t*) param; bool awakened; handler_queue_event_t event = { .radio = radio, .type = HQI_INTERRUPT, }; os_put_queue_from_isr(global_interrupt_handler_queue, (os_queue_item_t) &event, &awakened); if (awakened) { portYIELD_FROM_ISR(); } } #if CONFIG_LASTLINK_EXTRA_DEBUG_COMMANDS void print_status(command_context_t* context, radio_t *radio) { sx127x_private_data_t data; bool ok = false; int live_irq_flags; int live_irq_mask; if (acquire_lock(radio)) { memcpy(&data, radio->driver_private_data, sizeof(sx127x_private_data_t)); live_irq_flags = radio->read_register(radio, SX127x_REG_IRQ_FLAGS); live_irq_mask = radio->read_register(radio, SX127x_REG_IRQ_FLAGS_MASK); release_lock(radio); ok = true; } if (ok) { command_reply(context, "D", "Radio %d:", radio->radio_num); command_reply(context, "D", "Transmit queue length: %d", os_items_in_queue(radio->transmit_queue)); command_reply(context, "D", "Waiting output: %s", data.current_packet ? "YES" : "NO"); command_reply(context, "D", "sync_word: %02x", data.sync_word); command_reply(context, "D", "preamble_length: %d", data.preamble_length); command_reply(context, "D", "coding_rate: %d", data.coding_rate); command_reply(context, "D", "implicit_header: %s", data.implicit_header ? "YES" : "NO"); command_reply(context, "D", "hop_period: %d", data.hop_period); command_reply(context, "D", "enable_crc: %s", data.enable_crc ? "YES" : "NO"); command_reply(context, "D", "channel: %d", data.channel); command_reply(context, "D", "datarate: %d", data.datarate); command_reply(context, "D", "bandwidth: %d", data.bandwidth); command_reply(context, "D", "spreading_factor: %d", data.spreading_factor); command_reply(context, "D", "tx_power: %d", data.tx_power); command_reply(context, "D", "rx_interrupts: %d", data.rx_interrupts); command_reply(context, "D", "rx_timeouts: %d", data.rx_timeouts); command_reply(context, "D", "tx_interrupts: %d", data.tx_interrupts); command_reply(context, "D", "tx_timeouts: %d", data.tx_timeouts); command_reply(context, "D", "cad_interrupts: %d", data.cad_interrupts); command_reply(context, "D", "cad_detected: %d", data.cad_detected); command_reply(context, "D", "cad_timeouts: %d", data.cad_timeouts); #ifdef USE_FHSS command_reply(context, "D", "fhss_interrupts: %d", data.fhss_interrupts); #endif /* USE_FHSS */ command_reply(context, "D", "packet_memory_failed: %d", data.packet_memory_failed); command_reply(context, "D", "packet_crc_errors: %d", data.packet_crc_errors); command_reply(context, "D", "saved irq_flags: %02x", data.irq_flags); command_reply(context, "D", "live irq_flags: %02x", live_irq_flags); command_reply(context, "D", "live irq_mask: %02x", live_irq_mask); command_reply(context, "D", "handler_state: %s", handler_state_of(data.handler_state)); command_reply(context, "D", "handler_cycles: %d", data.handler_cycles); command_reply(context, "D", "wakeup_ticks: %d", data.wakeup_ticks); command_reply(context, "D", "window_number: %d", data.window_number); command_reply(context, "D", "current_packet_window: %d", data.current_packet_window); command_reply(context, "D", "window_width: %d", data.window_width); command_reply(context, "D", "window_event_count: %d", data.window_event_count); int wakeup_timer_remaining = simpletimer_remaining(&data.handler_wakeup_timer_status); if (simpletimer_is_running(&data.handler_wakeup_timer_status)) { command_reply(context, "D", "wakeup_timer: %d", wakeup_timer_remaining); } else { command_reply(context, "D", "wakeup_timer: %s", simpletimer_is_expired(&data.handler_wakeup_timer_status) ? "expired" : "stopped"); } } else { command_reply(context, "E", "Unable to lock data"); } } #endif #endif
34.884136
153
0.592525
[ "cad" ]
bf491a864f0d6754d40fb8d949ffb0a2b91f1bd7
7,151
c
C
d/underdark/lower/dragon/mon/rathargh.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/underdark/lower/dragon/mon/rathargh.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
null
null
null
d/underdark/lower/dragon/mon/rathargh.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include <magic.h> #include <daemons.h> #include "../lair.h" inherit MONSTER; int rath, active; void create() { object equipment; ::create(); set_name("Rath'argh"); set_id(({ "drow", "rathargh", "rath'argh", "Rath'argh" })); set_short("%^RESET%^%^RED%^Rath'argh%^RESET%^"); set_long("%^RESET%^%^MAGENTA%^This agile creature moves with a grace bordering on the su%^RED%^p%^MAGENTA%^ernatural. " "Most of his features are shrouded within the hooded clo%^BOLD%^%^BLACK%^a%^RESET%^%^MAGENTA%^k he wears, which swirls " "around him and reaches nearly to the ground. Jet black, when he stands motionless he is hard to separate from the shad" "%^BLUE%^o%^MAGENTA%^ws. Beneath the cloak's hood, gleaming c%^BOLD%^%^RED%^r%^RESET%^%^MAGENTA%^imson eyes and whisps " "of bone-w%^RESET%^h%^MAGENTA%^ite hair give enough hints to deduce that he is a drow, but not enough features are " "visible to set him apart from any other of his species. An obsid%^BOLD%^%^BLACK%^i%^RESET%^%^MAGENTA%^an dagger is held " "in his hand, and from the precision of his movements you would assume he knows how to use it.%^RESET%^"); set_race("drow"); set_gender("male"); set_body_type("humanoid"); set_alignment(9); set_size(2); set_exp(1); set_hd(50, 6); set_class("thief"); set_mlevel("thief", 40); set_guild_level("thief", 40); set_class("mage"); set_mlevel("mage", 40); set_guild_level("mage", 40); set_property("full attacks", 1); set_max_hp(2500); set_hp(query_max_hp()); set_property("weapon resistance", 4); set_mob_magic_resistance("average"); set_property("spell penetration", 60); set_property("no animate", 1); set_property("no steal", 1); set_property("no hold", 1); set_property("no dominate", 1); set_property("no bows", 1); set_property("no knockdown", 1); set_property("no tripped", 1); set_property("no web", 1); set_overall_ac(-22); set_funcs(({ "bladefan", "bladefan", "darts", "darts", "stabfun", "stabfun", "silencedust" })); set_func_chance(75); equipment = new(OBJ "sheoldagger"); equipment->set_property("monsterweapon", 1); equipment->move(TO); command("wield dagger"); } void init() { string whoami; ::init(); whoami = TP->query_name(); if (whoami != "Arkhon Bloodscale" && !TP->query_true_invis()) { // TO->force_me("kill "+whoami+""); TO->add_attacker(TP); TP->add_attacker(TO); } } void bladefan(object target) { object* vars; int i; tell_room(ETO, "%^RESET%^%^BLUE%^With a flick of his wrist, Rath'argh sends a fan of %^RESET%^glinting%^BLUE%^ blades " "whirling through the air!%^RESET%^"); vars = all_living(ETO); vars = filter_array(vars, "is_non_immortal_player", FILTERS_D); if (!sizeof(vars)) { return; } for (i = 0; i < 5; i++) { target = vars[random(sizeof(vars))]; if (!objectp(target)) { continue; } if (!interactive(target)) { continue; } tell_object(target, "%^CYAN%^A blade slices through your skin!%^RESET%^"); target->cause_typed_damage(target, target->return_target_limb(), 50 + random(50), "slashing"); } return; } void darts(object target) { object* vars; vars = all_living(ETO); vars = filter_array(vars, "is_non_immortal_player", FILTERS_D); if (!sizeof(vars)) { return; } target = vars[random(sizeof(vars))]; if (!objectp(target)) { return; } if (!interactive(target)) { return; } tell_room(ETO, "%^RESET%^%^MAGENTA%^Rath'argh produces a tiny %^CYAN%^dart %^MAGENTA%^from beneath the folds of his " "cloak, and he flings it directly at " + target->QCN + "!%^RESET%^", target); tell_object(target, "%^RESET%^%^MAGENTA%^Rath'argh produces a tiny %^CYAN%^dart %^MAGENTA%^from beneath the folds of " "his cloak, and he flings it directly at you! A momentary numbness races through your limbs as the %^GREEN%^po%^BOLD%^i" "%^RESET%^%^GREEN%^son %^MAGENTA%^takes hold.%^RESET%^"); target->set_paralyzed(20, "%^GREEN%^You're still trying to fight off the haze of the poison!%^RESET%^"); } void stabfun(object target) { object* vars; vars = all_living(ETO); vars = filter_array(vars, "is_non_immortal_player", FILTERS_D); if (!sizeof(vars)) { return; } target = vars[random(sizeof(vars))]; if (!objectp(target)) { return; } if (!interactive(target)) { return; } tell_room(ETO, "%^RESET%^%^BLUE%^Rath'argh swirls his %^BOLD%^%^BLACK%^sh%^RESET%^ad%^BOLD%^%^BLACK%^owy cloak %^RESET%^" "%^BLUE%^around himself and disappears!%^RESET%^"); tell_object(target, "%^RESET%^%^RED%^Suddenly he solidifies from the shadows behind you, and %^BOLD%^seari%^MAGENTA%^n" "%^RED%^g pain %^RESET%^%^RED%^erupts through your back as he stabs his dagger viciously between your " "shoulders!%^RESET%^"); tell_room(ETO, "%^RESET%^%^RED%^Suddenly he solidifies from the shadows behind " + target->QCN + ", and his dagger %^BOLD%^" "gleams %^RESET%^%^RED%^as he stabs it viciously between " + target->QP + " shoulders!%^RESET%^", target); target->cause_typed_damage(target, target->return_target_limb(), 150 + random(75), "slashing"); } void silencedust(object target) { object* vars, dustobj; vars = all_living(ETO); vars = filter_array(vars, "is_non_immortal_player", FILTERS_D); if (!sizeof(vars)) { return; } target = vars[random(sizeof(vars))]; if (!objectp(target)) { return; } if (!interactive(target)) { return; } tell_object(target, "%^GREEN%^You find yourself choking and coughing suddenly, as Rath'argh casts a handful of " "%^ORANGE%^dust %^GREEN%^directly into your face!%^RESET%^"); tell_room(ETO, "%^GREEN%^" + target->QCN + " suddenly starts coughing and spluttering, as Rath'argh casts a handful of " "%^ORANGE%^choking dust %^GREEN%^directly into " + target->QP + " face!%^RESET%^", target); if (dustobj = present("choking-dust-obj", target)) { dustobj->remove(); } new(OBJ "chokingdust")->move(target); } void die(object ob) { tell_room(ETO, "%^BLUE%^%^Rath'argh staggers back, %^RED%^gr%^BOLD%^i%^RESET%^%^RED%^evously %^BLUE%^wounded and with " "one hand clutched to his side.%^RESET%^"); tell_room(ETO, "%^BOLD%^%^BLACK%^His eyes narrow as he appraises the state of the battle. Quickly coming to a " "conclusion, he swirls his cloak about himself and melts away into the shadows.%^RESET%^"); if (present("Arkhon Bloodscale", ETO)) { tell_room(ETO, "%^BOLD%^%^RED%^Arkhon lets out an enraged roar as his ally vanishes, and turns upon you with renewed " "vigor!%^RESET%^"); } TO->move("/d/shadowgate/void"); TO->remove(); }
38.446237
136
0.609425
[ "object" ]
bf50f2756529633cf427194814f73e061ee3b5ca
5,558
c
C
nitan/cmds/skill/perform.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/cmds/skill/perform.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/cmds/skill/perform.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// perform.c #include <ansi.h> inherit F_CLEAN_UP; protected int do_perform(object me, string arg); int main(object me, string arg) { string and; int result; int busy; int lvl; string msg; string *fams; seteuid(getuid()); if (me->is_busy()) return notify_fail("( 你上一個動作還沒有完成,不能施用外功。)\n"); if (! arg) return notify_fail("你要用外功做什麼?\n"); if (query_temp("forget", me)) return notify_fail(HIR "你發現自己遺忘了絕招如何使用。\n" NOR); if (me->query_condition("no_perform")) return notify_fail(HIR "你只覺全身力道竟似渙散了一般,全然無法控制。\n" NOR); if (query_temp("freeze", me) && time()-query_temp("last_perform_time", me) < 1) return notify_fail(HIR "你處於冰凍不良的狀態下,動作緩慢,無法如此快速連續使用絕招。\n" NOR); if (sscanf(arg, "%s and %s", arg, and) == 2 || sscanf(arg, "%s twice", arg) == 1 && (and = arg)) { lvl = me->query_skill("zuoyou-hubo", 1); if (! lvl) return notify_fail("你要幹什麼?以為自己有三頭六臂啊!\n"); if( me->query_skill("count",1) && !query("special_skill/capture", me) ) return notify_fail("你雜學太多,心頭煩亂,難以分心二用。\n"); if (lvl <= 100) return notify_fail("你的左右互搏修為太淺,難以分心二用。\n"); if( query("int", me)>24 && query("int", me)<40 ) return notify_fail("你試圖分心二用,但是手就是不聽使喚。\n"); if( (!arrayp(fams = query("reborn/fams", me)) || (member_array("全真教", fams) == -1 && member_array("古墓派", fams) == -1)) && (! me->query_family() || ( me->query_family() != "全真教" && me->query_family() != "古墓派" ))) return notify_fail("你試圖分心二用,但是手就是不聽使喚。\n"); if (! me->is_fighting()) return notify_fail("只有戰鬥中才能施展左右互搏。\n"); if (lvl < 360 && random(lvl) < 100) { me->start_busy(1); write("你試圖分心二用,但是手就是不聽使喚。\n"); return 1; } } if (and) set_temp("use_hubo", 1, me); result = do_perform(me, arg); if (! and) return result; if (! result) write(query_notify_fail()); else { switch (random(4)) { case 0: msg = HIY "$N" HIY "大喝一聲,雙手分" "使兩招,一起攻出。\n" NOR; break; case 1: msg = HIY "$N" HIY "雙手齊出,分使不" "同招式,令人眼花繚亂。\n" NOR; break; case 2: msg = HIY "$N" HIY "左右手分使兩招," "毫不停滯,宛如兩人同時攻出。\n" NOR; break; case 3: msg = HIY "$N" HIY "左手一招,右手一" "招,兩招來路各異,令人難以低檔!\n" NOR; break; } message_combatd(msg, me); } busy = me->query_busy(); me->interrupt_busy(0); result = do_perform(me, and); if (! result) write(query_notify_fail()); if (intp(busy) && intp(me->query_busy()) && busy > me->query_busy()) { me->interrupt_busy(0); me->start_busy(); } delete_temp("use_hubo", me); return 1; } protected int do_perform(object me, string arg) { object weapon; string martial, skill; int result; if (sscanf(arg, "%s.%s", martial, arg) != 2) { if( weapon=query_temp("weapon", me) ) martial=query("skill_type", weapon); else martial = "unarmed"; } me->clean_up_enemy(); if (stringp(skill = me->query_skill_mapped(martial))) { notify_fail("你所使用的外功中沒有這種功能。\n"); if (SKILL_D(skill)->perform_action(me, arg)) { set_temp("last_perform_time", time(), me); if (random(120) < (int)me->query_skill(skill)) me->improve_skill(skill, 1, 1); return 1; } else if (SKILL_D(martial)->perform_action(me, arg)) { set_temp("last_perform_time", time(), me); if (random(120) < (int)me->query_skill(martial, 1)) me->improve_skill(martial, 1, 1); return 1; } return 0; } return notify_fail("你現在的" + to_chinese(martial)[4..7] + "(" + martial + ")中並沒有這種外功。\n"); } int help (object me) { write(@HELP 指令格式:perform | yong [<武功種類>.]<招式名稱> [<施用對象>] perform | yong 招式1 [<對象1>] and 招式2 [<對象2>] perform | yong 招式1 [<對象1>] twice 如果你所學的外功(拳腳、劍法、刀法....)有一些特殊的攻擊方式或 招式,可以用這個指令來使用,你必須先用 enable 指令指定你使用 的武功,不指定武功種類時,空手的外功是指你的拳腳功夫,使用武 器時則是兵刃的武功。 若是你的外功中有種類不同,但是招式名稱相同的,或者不屬於拳腳 跟武器技能的武功(如輕功),可以用 <武功>.<招式> 的方式指定, 如: perform sword.chan 換句話説,只要是 enable 中的武功有特殊招式的,都可以用這個指 令使用。 如果你精通左右互搏,可以同時使用兩個招式攻擊同一對手或則分別 攻擊兩人。左右互搏修煉的越是精深,則成功率越高。 使用 twice 參數表示左右手使用同樣的招式。 HELP ); return 1; }
29.407407
87
0.442965
[ "object" ]
bf5612f6dc4220e5dad987a93402519e280120cf
3,935
h
C
Libraries/Data/Data.h
hung0913208/Base
420b4ce8e08f9624b4e884039218ffd233b88335
[ "BSD-3-Clause" ]
null
null
null
Libraries/Data/Data.h
hung0913208/Base
420b4ce8e08f9624b4e884039218ffd233b88335
[ "BSD-3-Clause" ]
null
null
null
Libraries/Data/Data.h
hung0913208/Base
420b4ce8e08f9624b4e884039218ffd233b88335
[ "BSD-3-Clause" ]
2
2020-11-04T08:00:37.000Z
2020-11-06T08:33:33.000Z
#ifndef DATA_FORMAT_H_ #define DATA_FORMAT_H_ #include <Config.h> #if USE_BASE_WITH_FULL_PATH_HEADER #include <Base/Auto.h> #include <Base/Type.h> #else #include <Auto.h> #include <Type.h> #endif #include <typeinfo> namespace Base { namespace Data { class List{ public: UInt Size(); UInt Insert(Any value); UInt Insert(Auto value); ErrorCodeE Remove(UInt index); template<typename Type> Type& At(UInt index){ return (*this)[index].Get<Type>(); } template<typename Type> Type& At(ULong index){ return (*this)[index].Get<Type>(); } template<typename Type> Type& At(Int index){ return (*this)[index].Get<Type>(); } template<typename Type> Type& At(Long index){ return (*this)[index].Get<Type>(); } Auto& operator[](UInt index); Auto& operator[](ULong index); Auto& operator[](Int index); Auto& operator[](Long index); private: Vector<Auto> _Values; }; class Dict{ public: UInt Size(); ErrorCodeE InsertKey(Any key); ErrorCodeE InsertKey(Auto key); ErrorCodeE InsertValue(Any value); ErrorCodeE InsertValue(Auto value); ErrorCodeE Insert(String name, Auto value); ErrorCodeE Remove(String name); Bool Find(String name); Bool Find(String name, const std::type_info& type); ErrorCodeE Insert(UInt name, Auto value); ErrorCodeE Remove(UInt name); Bool Find(UInt name); Bool Find(UInt name, const std::type_info& type); ErrorCodeE Insert(Int name, Auto value); ErrorCodeE Remove(Int name); Bool Find(Int name); Bool Find(Int name, const std::type_info& type); ErrorCodeE Insert(ULong name, Auto value); ErrorCodeE Remove(ULong name); Bool Find(ULong name); Bool Find(ULong name, const std::type_info& type); ErrorCodeE Insert(Long name, Auto value); ErrorCodeE Remove(Long name); Bool Find(Long name); Bool Find(Long name, const std::type_info& type); ErrorCodeE Insert(Byte name, Auto value); ErrorCodeE Remove(Byte name); Bool Find(Byte name); Bool Find(Byte name, const std::type_info& type); ErrorCodeE Insert(Bool name, Auto value); ErrorCodeE Remove(Bool name); Bool Find(Bool name); Bool Find(Bool name, const std::type_info& type); ErrorCodeE Insert(Float name, Auto value); ErrorCodeE Remove(Float name); Bool Find(Float name); Bool Find(Float name, const std::type_info& type); ErrorCodeE Insert(Double name, Auto value); ErrorCodeE Remove(Double name); Bool Find(Double name); Bool Find(Double name, const std::type_info& type); template<typename Key> Auto& Get(Key UNUSED(key)) { throw Except(ENoSupport, Base::Nametype<Key>()); } Auto& Get(String key); Auto& Get(UInt key); Auto& Get(Int key); Auto& Get(ULong key); Auto& Get(Long key); Auto& Get(Byte key); Auto& Get(Bool key); Auto& Get(Float key); Auto& Get(Double key); Auto& operator[](String name); Auto& operator[](UInt name); Auto& operator[](Int name); Auto& operator[](ULong name); Auto& operator[](Long name); Auto& operator[](Byte name); Auto& operator[](Bool name); Auto& operator[](Float name); Auto& operator[](Double name); private: Auto _Key; Map<Long, Auto> _Long; Map<Bool, Auto> _Boolean; Map<Double, Auto> _Double; Map<String, Auto> _String; }; class Struct { public: explicit Struct(Map<String, Base::Auto> definition); virtual ~Struct(); /* @NOTE: get the whole defenition of this Struct */ Map<String, Base::Auto>& Mapping(); /* @NOTE: get how many element of this Struct */ UInt Size(); /* @NOTE: get each element of this Struct */ Base::Auto& operator[](const CString name); private: Map<String, Base::Auto> _Definition; }; } // namespace Data class Parser{ public: protected: virtual ErrorCodeE Parse(UInt index, Byte c) = 0; virtual ErrorCodeE Record(Byte value) = 0; }; class Generator{ public: protected: virtual ErrorCodeE Generate() = 0; }; } // namespace Base #endif // DATA_FORMAT_H_
22.745665
54
0.686658
[ "vector" ]
bf650a001ca4958fb11c8948312647cc68b5a19e
1,022
h
C
Doge/src/Doge/Renderer/RenderDataManager.h
batuhanbozyel/RendererFramework
6f63094dc2a3f5a1bd455a3f29bea706a0bafb20
[ "Apache-2.0" ]
2
2020-07-31T13:28:33.000Z
2020-08-04T19:21:48.000Z
Doge/src/Doge/Renderer/RenderDataManager.h
batuhanbozyel/RendererFramework
6f63094dc2a3f5a1bd455a3f29bea706a0bafb20
[ "Apache-2.0" ]
null
null
null
Doge/src/Doge/Renderer/RenderDataManager.h
batuhanbozyel/RendererFramework
6f63094dc2a3f5a1bd455a3f29bea706a0bafb20
[ "Apache-2.0" ]
null
null
null
#pragma once namespace Doge { class VertexBuffer; class IndexBuffer; class Mesh; class Material; struct RenderData { RenderData(const std::vector<std::shared_ptr<VertexBuffer>>& vertexBuffers, const std::shared_ptr<IndexBuffer>& indexBuffer, const std::shared_ptr<Material>& mat, const glm::mat4& model = glm::mat4(1.0f)) : VBOs(vertexBuffers), IBO(indexBuffer), material(mat), modelMatrix(model) { } std::vector<std::shared_ptr<VertexBuffer>> VBOs; std::shared_ptr<IndexBuffer> IBO; std::shared_ptr<Material> material; glm::mat4 modelMatrix; }; class RenderDataManager { public: static RenderData ConstructBatched(const std::vector<Mesh>& meshes, const std::shared_ptr<Material>& material, const glm::mat4& model = glm::mat4(1.0f)); static RenderData Construct(const Mesh& mesh, const std::shared_ptr<Material>& material, const glm::mat4& model = glm::mat4(1.0f)); private: static Mesh BatchMeshes(const std::vector<Mesh>& meshes); }; }
28.388889
156
0.702544
[ "mesh", "vector", "model" ]
bf661ed4406f9b2f48d89c4ffd26a5fcccd88d5e
243,803
c
C
vendor/haproxy-1.9.1/src/proto_http.c
junsulee/c-goof
240c979dd014ed3bb9c8dddf5d0e66afb6a8c2f2
[ "Apache-2.0" ]
2
2021-11-25T13:42:35.000Z
2022-02-05T07:58:14.000Z
vendor/haproxy-1.9.1/src/proto_http.c
junsulee/c-goof
240c979dd014ed3bb9c8dddf5d0e66afb6a8c2f2
[ "Apache-2.0" ]
null
null
null
vendor/haproxy-1.9.1/src/proto_http.c
junsulee/c-goof
240c979dd014ed3bb9c8dddf5d0e66afb6a8c2f2
[ "Apache-2.0" ]
15
2021-11-24T15:40:54.000Z
2022-03-02T09:17:03.000Z
/* * HTTP protocol analyzer * * Copyright 2000-2011 Willy Tarreau <w@1wt.eu> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * */ #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <time.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <common/base64.h> #include <common/cfgparse.h> #include <common/chunk.h> #include <common/compat.h> #include <common/config.h> #include <common/debug.h> #include <common/h1.h> #include <common/memory.h> #include <common/mini-clist.h> #include <common/standard.h> #include <common/ticks.h> #include <common/time.h> #include <common/uri_auth.h> #include <common/version.h> #include <types/capture.h> #include <types/cli.h> #include <types/filters.h> #include <types/global.h> #include <types/cache.h> #include <types/stats.h> #include <proto/acl.h> #include <proto/action.h> #include <proto/arg.h> #include <proto/auth.h> #include <proto/backend.h> #include <proto/channel.h> #include <proto/checks.h> #include <proto/cli.h> #include <proto/compression.h> #include <proto/stats.h> #include <proto/fd.h> #include <proto/filters.h> #include <proto/frontend.h> #include <proto/log.h> #include <proto/hdr_idx.h> #include <proto/hlua.h> #include <proto/pattern.h> #include <proto/proto_tcp.h> #include <proto/proto_http.h> #include <proto/proxy.h> #include <proto/queue.h> #include <proto/sample.h> #include <proto/server.h> #include <proto/session.h> #include <proto/stream.h> #include <proto/stream_interface.h> #include <proto/task.h> #include <proto/pattern.h> #include <proto/vars.h> /* status codes available for the stats admin page (strictly 4 chars length) */ const char *stat_status_codes[STAT_STATUS_SIZE] = { [STAT_STATUS_DENY] = "DENY", [STAT_STATUS_DONE] = "DONE", [STAT_STATUS_ERRP] = "ERRP", [STAT_STATUS_EXCD] = "EXCD", [STAT_STATUS_NONE] = "NONE", [STAT_STATUS_PART] = "PART", [STAT_STATUS_UNKN] = "UNKN", }; /* This function handles a server error at the stream interface level. The * stream interface is assumed to be already in a closed state. An optional * message is copied into the input buffer. * The error flags are set to the values in arguments. Any pending request * in this buffer will be lost. */ static void http_server_error(struct stream *s, struct stream_interface *si, int err, int finst, const struct buffer *msg) { if (IS_HTX_STRM(s)) return htx_server_error(s, si, err, finst, msg); FLT_STRM_CB(s, flt_http_reply(s, s->txn->status, msg)); channel_auto_read(si_oc(si)); channel_abort(si_oc(si)); channel_auto_close(si_oc(si)); channel_erase(si_oc(si)); channel_auto_close(si_ic(si)); channel_auto_read(si_ic(si)); if (msg) co_inject(si_ic(si), msg->area, msg->data); if (!(s->flags & SF_ERR_MASK)) s->flags |= err; if (!(s->flags & SF_FINST_MASK)) s->flags |= finst; } /* This function returns the appropriate error location for the given stream * and message. */ struct buffer *http_error_message(struct stream *s) { const int msgnum = http_get_status_idx(s->txn->status); if (IS_HTX_STRM(s)) return htx_error_message(s); if (s->be->errmsg[msgnum].area) return &s->be->errmsg[msgnum]; else if (strm_fe(s)->errmsg[msgnum].area) return &strm_fe(s)->errmsg[msgnum]; else return &http_err_chunks[msgnum]; } void http_reply_and_close(struct stream *s, short status, struct buffer *msg) { if (IS_HTX_STRM(s)) return htx_reply_and_close(s, status, msg); s->txn->flags &= ~TX_WAIT_NEXT_RQ; FLT_STRM_CB(s, flt_http_reply(s, status, msg)); si_retnclose(&s->si[0], msg); } /* Parse the URI from the given transaction (which is assumed to be in request * phase) and look for the "/" beginning the PATH. If not found, return NULL. * It is returned otherwise. */ char *http_txn_get_path(const struct http_txn *txn) { struct ist ret; if (!txn->req.chn->buf.size) return NULL; ret = http_get_path(ist2(ci_head(txn->req.chn) + txn->req.sl.rq.u, txn->req.sl.rq.u_l)); return ret.ptr; } /* Returns a 302 for a redirectable request that reaches a server working in * in redirect mode. This may only be called just after the stream interface * has moved to SI_ST_ASS. Unprocessable requests are left unchanged and will * follow normal proxy processing. NOTE: this function is designed to support * being called once data are scheduled for forwarding. */ void http_perform_server_redirect(struct stream *s, struct stream_interface *si) { struct http_txn *txn; struct server *srv; char *path; int len, rewind; if (IS_HTX_STRM(s)) return htx_perform_server_redirect(s, si); /* 1: create the response header */ trash.data = strlen(HTTP_302); memcpy(trash.area, HTTP_302, trash.data); srv = __objt_server(s->target); /* 2: add the server's prefix */ if (trash.data + srv->rdr_len > trash.size) return; /* special prefix "/" means don't change URL */ if (srv->rdr_len != 1 || *srv->rdr_pfx != '/') { memcpy(trash.area + trash.data, srv->rdr_pfx, srv->rdr_len); trash.data += srv->rdr_len; } /* 3: add the request URI. Since it was already forwarded, we need * to temporarily rewind the buffer. */ txn = s->txn; c_rew(&s->req, rewind = http_hdr_rewind(&txn->req)); path = http_txn_get_path(txn); len = b_dist(&s->req.buf, path, c_ptr(&s->req, txn->req.sl.rq.u + txn->req.sl.rq.u_l)); c_adv(&s->req, rewind); if (!path) return; if (trash.data + len > trash.size - 4) /* 4 for CRLF-CRLF */ return; memcpy(trash.area + trash.data, path, len); trash.data += len; if (unlikely(txn->flags & TX_USE_PX_CONN)) { memcpy(trash.area + trash.data, "\r\nProxy-Connection: close\r\n\r\n", 29); trash.data += 29; } else { memcpy(trash.area + trash.data, "\r\nConnection: close\r\n\r\n", 23); trash.data += 23; } /* prepare to return without error. */ si_shutr(si); si_shutw(si); si->err_type = SI_ET_NONE; si->state = SI_ST_CLO; /* send the message */ txn->status = 302; http_server_error(s, si, SF_ERR_LOCAL, SF_FINST_C, &trash); /* FIXME: we should increase a counter of redirects per server and per backend. */ srv_inc_sess_ctr(srv); srv_set_sess_last(srv); } /* Return the error message corresponding to si->err_type. It is assumed * that the server side is closed. Note that err_type is actually a * bitmask, where almost only aborts may be cumulated with other * values. We consider that aborted operations are more important * than timeouts or errors due to the fact that nobody else in the * logs might explain incomplete retries. All others should avoid * being cumulated. It should normally not be possible to have multiple * aborts at once, but just in case, the first one in sequence is reported. * Note that connection errors appearing on the second request of a keep-alive * connection are not reported since this allows the client to retry. */ void http_return_srv_error(struct stream *s, struct stream_interface *si) { int err_type = si->err_type; /* set s->txn->status for http_error_message(s) */ s->txn->status = 503; if (err_type & SI_ET_QUEUE_ABRT) http_server_error(s, si, SF_ERR_CLICL, SF_FINST_Q, http_error_message(s)); else if (err_type & SI_ET_CONN_ABRT) http_server_error(s, si, SF_ERR_CLICL, SF_FINST_C, (s->txn->flags & TX_NOT_FIRST) ? NULL : http_error_message(s)); else if (err_type & SI_ET_QUEUE_TO) http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_Q, http_error_message(s)); else if (err_type & SI_ET_QUEUE_ERR) http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_Q, http_error_message(s)); else if (err_type & SI_ET_CONN_TO) http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_C, (s->txn->flags & TX_NOT_FIRST) ? NULL : http_error_message(s)); else if (err_type & SI_ET_CONN_ERR) http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_C, (s->flags & SF_SRV_REUSED) ? NULL : http_error_message(s)); else if (err_type & SI_ET_CONN_RES) http_server_error(s, si, SF_ERR_RESOURCE, SF_FINST_C, (s->txn->flags & TX_NOT_FIRST) ? NULL : http_error_message(s)); else { /* SI_ET_CONN_OTHER and others */ s->txn->status = 500; http_server_error(s, si, SF_ERR_INTERNAL, SF_FINST_C, http_error_message(s)); } } extern const char sess_term_cond[8]; extern const char sess_fin_state[8]; extern const char *monthname[12]; DECLARE_POOL(pool_head_http_txn, "http_txn", sizeof(struct http_txn)); DECLARE_POOL(pool_head_uniqueid, "uniqueid", UNIQUEID_LEN); struct pool_head *pool_head_requri = NULL; struct pool_head *pool_head_capture = NULL; /* * Capture headers from message starting at <som> according to header list * <cap_hdr>, and fill the <cap> pointers appropriately. */ void http_capture_headers(char *som, struct hdr_idx *idx, char **cap, struct cap_hdr *cap_hdr) { char *eol, *sol, *col, *sov; int cur_idx; struct cap_hdr *h; int len; sol = som + hdr_idx_first_pos(idx); cur_idx = hdr_idx_first_idx(idx); while (cur_idx) { eol = sol + idx->v[cur_idx].len; col = sol; while (col < eol && *col != ':') col++; sov = col + 1; while (sov < eol && HTTP_IS_LWS(*sov)) sov++; for (h = cap_hdr; h; h = h->next) { if (h->namelen && (h->namelen == col - sol) && (strncasecmp(sol, h->name, h->namelen) == 0)) { if (cap[h->index] == NULL) cap[h->index] = pool_alloc(h->pool); if (cap[h->index] == NULL) { ha_alert("HTTP capture : out of memory.\n"); continue; } len = eol - sov; if (len > h->len) len = h->len; memcpy(cap[h->index], sov, len); cap[h->index][len]=0; } } sol = eol + idx->v[cur_idx].cr + 1; cur_idx = idx->v[cur_idx].next; } } /* convert an HTTP/0.9 request into an HTTP/1.0 request. Returns 1 if the * conversion succeeded, 0 in case of error. If the request was already 1.X, * nothing is done and 1 is returned. */ int http_upgrade_v09_to_v10(struct http_txn *txn) { int delta; char *cur_end; struct http_msg *msg = &txn->req; if (msg->sl.rq.v_l != 0) return 1; /* RFC 1945 allows only GET for HTTP/0.9 requests */ if (txn->meth != HTTP_METH_GET) return 0; cur_end = ci_head(msg->chn) + msg->sl.rq.l; if (msg->sl.rq.u_l == 0) { /* HTTP/0.9 requests *must* have a request URI, per RFC 1945 */ return 0; } /* add HTTP version */ delta = b_rep_blk(&msg->chn->buf, cur_end, cur_end, " HTTP/1.0\r\n", 11); http_msg_move_end(msg, delta); cur_end += delta; cur_end = (char *)http_parse_reqline(msg, HTTP_MSG_RQMETH, ci_head(msg->chn), cur_end + 1, NULL, NULL); if (unlikely(!cur_end)) return 0; /* we have a full HTTP/1.0 request now and we know that * we have either a CR or an LF at <ptr>. */ hdr_idx_set_start(&txn->hdr_idx, msg->sl.rq.l, *cur_end == '\r'); return 1; } /* Parse the Connection: header of an HTTP request, looking for both "close" * and "keep-alive" values. If we already know that some headers may safely * be removed, we remove them now. The <to_del> flags are used for that : * - bit 0 means remove "close" headers (in HTTP/1.0 requests/responses) * - bit 1 means remove "keep-alive" headers (in HTTP/1.1 reqs/resp to 1.1). * Presence of the "Upgrade" token is also checked and reported. * The TX_HDR_CONN_* flags are adjusted in txn->flags depending on what was * found, and TX_CON_*_SET is adjusted depending on what is left so only * harmless combinations may be removed. Do not call that after changes have * been processed. */ void http_parse_connection_header(struct http_txn *txn, struct http_msg *msg, int to_del) { struct hdr_ctx ctx; const char *hdr_val = "Connection"; int hdr_len = 10; if (txn->flags & TX_HDR_CONN_PRS) return; if (unlikely(txn->flags & TX_USE_PX_CONN)) { hdr_val = "Proxy-Connection"; hdr_len = 16; } ctx.idx = 0; txn->flags &= ~(TX_CON_KAL_SET|TX_CON_CLO_SET); while (http_find_header2(hdr_val, hdr_len, ci_head(msg->chn), &txn->hdr_idx, &ctx)) { if (ctx.vlen >= 10 && word_match(ctx.line + ctx.val, ctx.vlen, "keep-alive", 10)) { txn->flags |= TX_HDR_CONN_KAL; if (to_del & 2) http_remove_header2(msg, &txn->hdr_idx, &ctx); else txn->flags |= TX_CON_KAL_SET; } else if (ctx.vlen >= 5 && word_match(ctx.line + ctx.val, ctx.vlen, "close", 5)) { txn->flags |= TX_HDR_CONN_CLO; if (to_del & 1) http_remove_header2(msg, &txn->hdr_idx, &ctx); else txn->flags |= TX_CON_CLO_SET; } else if (ctx.vlen >= 7 && word_match(ctx.line + ctx.val, ctx.vlen, "upgrade", 7)) { txn->flags |= TX_HDR_CONN_UPG; } } txn->flags |= TX_HDR_CONN_PRS; return; } /* Apply desired changes on the Connection: header. Values may be removed and/or * added depending on the <wanted> flags, which are exclusively composed of * TX_CON_CLO_SET and TX_CON_KAL_SET, depending on what flags are desired. The * TX_CON_*_SET flags are adjusted in txn->flags depending on what is left. */ void http_change_connection_header(struct http_txn *txn, struct http_msg *msg, int wanted) { struct hdr_ctx ctx; const char *hdr_val = "Connection"; int hdr_len = 10; ctx.idx = 0; if (unlikely(txn->flags & TX_USE_PX_CONN)) { hdr_val = "Proxy-Connection"; hdr_len = 16; } txn->flags &= ~(TX_CON_CLO_SET | TX_CON_KAL_SET); while (http_find_header2(hdr_val, hdr_len, ci_head(msg->chn), &txn->hdr_idx, &ctx)) { if (ctx.vlen >= 10 && word_match(ctx.line + ctx.val, ctx.vlen, "keep-alive", 10)) { if (wanted & TX_CON_KAL_SET) txn->flags |= TX_CON_KAL_SET; else http_remove_header2(msg, &txn->hdr_idx, &ctx); } else if (ctx.vlen >= 5 && word_match(ctx.line + ctx.val, ctx.vlen, "close", 5)) { if (wanted & TX_CON_CLO_SET) txn->flags |= TX_CON_CLO_SET; else http_remove_header2(msg, &txn->hdr_idx, &ctx); } } if (wanted == (txn->flags & (TX_CON_CLO_SET|TX_CON_KAL_SET))) return; if ((wanted & TX_CON_CLO_SET) && !(txn->flags & TX_CON_CLO_SET)) { txn->flags |= TX_CON_CLO_SET; hdr_val = "Connection: close"; hdr_len = 17; if (unlikely(txn->flags & TX_USE_PX_CONN)) { hdr_val = "Proxy-Connection: close"; hdr_len = 23; } http_header_add_tail2(msg, &txn->hdr_idx, hdr_val, hdr_len); } if ((wanted & TX_CON_KAL_SET) && !(txn->flags & TX_CON_KAL_SET)) { txn->flags |= TX_CON_KAL_SET; hdr_val = "Connection: keep-alive"; hdr_len = 22; if (unlikely(txn->flags & TX_USE_PX_CONN)) { hdr_val = "Proxy-Connection: keep-alive"; hdr_len = 28; } http_header_add_tail2(msg, &txn->hdr_idx, hdr_val, hdr_len); } return; } void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg) { struct proxy *fe = strm_fe(s); int tmp = TX_CON_WANT_KAL; if (IS_HTX_STRM(s)) return htx_adjust_conn_mode(s, txn); if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN) tmp = TX_CON_WANT_TUN; if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) tmp = TX_CON_WANT_SCL; if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_CLO || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_CLO) tmp = TX_CON_WANT_CLO; if ((txn->flags & TX_CON_WANT_MSK) < tmp) txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | tmp; if (!(txn->flags & TX_HDR_CONN_PRS) && (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { /* parse the Connection header and possibly clean it */ int to_del = 0; if ((msg->flags & HTTP_MSGF_VER_11) || ((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL && !((fe->options2|s->be->options2) & PR_O2_FAKE_KA))) to_del |= 2; /* remove "keep-alive" */ if (!(msg->flags & HTTP_MSGF_VER_11)) to_del |= 1; /* remove "close" */ http_parse_connection_header(txn, msg, to_del); } /* check if client or config asks for explicit close in KAL/SCL */ if (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) && ((txn->flags & TX_HDR_CONN_CLO) || /* "connection: close" */ (!(msg->flags & HTTP_MSGF_VER_11) && !(txn->flags & TX_HDR_CONN_KAL)) || /* no "connection: k-a" in 1.0 */ !(msg->flags & HTTP_MSGF_XFER_LEN) || /* no length known => close */ fe->state == PR_STSTOPPED)) /* frontend is stopping */ txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO; } /* This stream analyser waits for a complete HTTP request. It returns 1 if the * processing can continue on next analysers, or zero if it either needs more * data or wants to immediately abort the request (eg: timeout, error, ...). It * is tied to AN_REQ_WAIT_HTTP and may may remove itself from s->req.analysers * when it has nothing left to do, and may remove any analyser when it wants to * abort. */ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) { /* * We will parse the partial (or complete) lines. * We will check the request syntax, and also join multi-line * headers. An index of all the lines will be elaborated while * parsing. * * For the parsing, we use a 28 states FSM. * * Here is the information we currently have : * ci_head(req) = beginning of request * ci_head(req) + msg->eoh = end of processed headers / start of current one * ci_tail(req) = end of input data * msg->eol = end of current header or line (LF or CRLF) * msg->next = first non-visited byte * * At end of parsing, we may perform a capture of the error (if any), and * we will set a few fields (txn->meth, sn->flags/SF_REDIRECTABLE). * We also check for monitor-uri, logging, HTTP/0.9 to 1.0 conversion, and * finally headers capture. */ int cur_idx; struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->req; struct hdr_ctx ctx; if (IS_HTX_STRM(s)) return htx_wait_for_request(s, req, an_bit); DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, req, req->rex, req->wex, req->flags, ci_data(req), req->analysers); /* we're speaking HTTP here, so let's speak HTTP to the client */ s->srv_error = http_return_srv_error; /* If there is data available for analysis, log the end of the idle time. */ if (c_data(req) && s->logs.t_idle == -1) s->logs.t_idle = tv_ms_elapsed(&s->logs.tv_accept, &now) - s->logs.t_handshake; /* There's a protected area at the end of the buffer for rewriting * purposes. We don't want to start to parse the request if the * protected area is affected, because we may have to move processed * data later, which is much more complicated. */ if (c_data(req) && msg->msg_state < HTTP_MSG_ERROR) { if (txn->flags & TX_NOT_FIRST) { if (unlikely(!channel_is_rewritable(req))) { if (req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) goto failed_keep_alive; /* some data has still not left the buffer, wake us once that's done */ channel_dont_connect(req); req->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ req->flags |= CF_WAKE_WRITE; return 0; } if (unlikely(ci_tail(req) < c_ptr(req, msg->next) || ci_tail(req) > b_wrap(&req->buf) - global.tune.maxrewrite)) channel_slow_realign(req, trash.area); } if (likely(msg->next < ci_data(req))) /* some unparsed data are available */ http_msg_analyzer(msg, &txn->hdr_idx); } /* 1: we might have to print this header in debug mode */ if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && msg->msg_state >= HTTP_MSG_BODY)) { char *eol, *sol; sol = ci_head(req); /* this is a bit complex : in case of error on the request line, * we know that rq.l is still zero, so we display only the part * up to the end of the line (truncated by debug_hdr). */ eol = sol + (msg->sl.rq.l ? msg->sl.rq.l : ci_data(req)); debug_hdr("clireq", s, sol, eol); sol += hdr_idx_first_pos(&txn->hdr_idx); cur_idx = hdr_idx_first_idx(&txn->hdr_idx); while (cur_idx) { eol = sol + txn->hdr_idx.v[cur_idx].len; debug_hdr("clihdr", s, sol, eol); sol = eol + txn->hdr_idx.v[cur_idx].cr + 1; cur_idx = txn->hdr_idx.v[cur_idx].next; } } /* * Now we quickly check if we have found a full valid request. * If not so, we check the FD and buffer states before leaving. * A full request is indicated by the fact that we have seen * the double LF/CRLF, so the state is >= HTTP_MSG_BODY. Invalid * requests are checked first. When waiting for a second request * on a keep-alive stream, if we encounter and error, close, t/o, * we note the error in the stream flags but don't set any state. * Since the error will be noted there, it will not be counted by * process_stream() as a frontend error. * Last, we may increase some tracked counters' http request errors on * the cases that are deliberately the client's fault. For instance, * a timeout or connection reset is not counted as an error. However * a bad request is. */ if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* * First, let's catch bad requests. */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { stream_inc_http_req_ctr(s); stream_inc_http_err_ctr(s); proxy_inc_fe_req_ctr(sess->fe); goto return_bad_req; } /* 1: Since we are in header mode, if there's no space * left for headers, we won't be able to free more * later, so the stream will never terminate. We * must terminate it now. */ if (unlikely(channel_full(req, global.tune.maxrewrite))) { /* FIXME: check if URI is set and return Status * 414 Request URI too long instead. */ stream_inc_http_req_ctr(s); stream_inc_http_err_ctr(s); proxy_inc_fe_req_ctr(sess->fe); if (msg->err_pos < 0) msg->err_pos = ci_data(req); goto return_bad_req; } /* 2: have we encountered a read error ? */ else if (req->flags & CF_READ_ERROR) { if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; if (sess->fe->options & PR_O_IGNORE_PRB) goto failed_keep_alive; /* we cannot return any message on error */ if (msg->err_pos >= 0) { http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); stream_inc_http_err_ctr(s); } txn->status = 400; msg->err_state = msg->msg_state; msg->msg_state = HTTP_MSG_ERROR; http_reply_and_close(s, txn->status, NULL); req->analysers &= AN_REQ_FLT_END; stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return 0; } /* 3: has the read timeout expired ? */ else if (req->flags & CF_READ_TIMEOUT || tick_is_expired(req->analyse_exp, now_ms)) { if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLITO; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; if (sess->fe->options & PR_O_IGNORE_PRB) goto failed_keep_alive; /* read timeout : give up with an error message. */ if (msg->err_pos >= 0) { http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); stream_inc_http_err_ctr(s); } txn->status = 408; msg->err_state = msg->msg_state; msg->msg_state = HTTP_MSG_ERROR; http_reply_and_close(s, txn->status, http_error_message(s)); req->analysers &= AN_REQ_FLT_END; stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return 0; } /* 4: have we encountered a close ? */ else if (req->flags & CF_SHUTR) { if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; if (sess->fe->options & PR_O_IGNORE_PRB) goto failed_keep_alive; if (msg->err_pos >= 0) http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); txn->status = 400; msg->err_state = msg->msg_state; msg->msg_state = HTTP_MSG_ERROR; http_reply_and_close(s, txn->status, http_error_message(s)); req->analysers &= AN_REQ_FLT_END; stream_inc_http_err_ctr(s); stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return 0; } channel_dont_connect(req); req->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */ if (sess->listener->options & LI_O_NOQUICKACK && ci_data(req)) { /* We need more data, we have to re-enable quick-ack in case we * previously disabled it, otherwise we might cause the client * to delay next data. */ conn_set_quickack(objt_conn(sess->origin), 1); } if ((msg->msg_state != HTTP_MSG_RQBEFORE) && (txn->flags & TX_WAIT_NEXT_RQ)) { /* If the client starts to talk, let's fall back to * request timeout processing. */ txn->flags &= ~TX_WAIT_NEXT_RQ; req->analyse_exp = TICK_ETERNITY; } /* just set the request timeout once at the beginning of the request */ if (!tick_isset(req->analyse_exp)) { if ((msg->msg_state == HTTP_MSG_RQBEFORE) && (txn->flags & TX_WAIT_NEXT_RQ) && tick_isset(s->be->timeout.httpka)) req->analyse_exp = tick_add(now_ms, s->be->timeout.httpka); else req->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.httpreq); } /* we're not ready yet */ return 0; failed_keep_alive: /* Here we process low-level errors for keep-alive requests. In * short, if the request is not the first one and it experiences * a timeout, read error or shutdown, we just silently close so * that the client can try again. */ txn->status = 0; msg->msg_state = HTTP_MSG_RQBEFORE; req->analysers &= AN_REQ_FLT_END; s->logs.logwait = 0; s->logs.level = 0; s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */ http_reply_and_close(s, txn->status, NULL); return 0; } /* OK now we have a complete HTTP request with indexed headers. Let's * complete the request parsing by setting a few fields we will need * later. At this point, we have the last CRLF at req->buf.data + msg->eoh. * If the request is in HTTP/0.9 form, the rule is still true, and eoh * points to the CRLF of the request line. msg->next points to the first * byte after the last LF. msg->sov points to the first byte of data. * msg->eol cannot be trusted because it may have been left uninitialized * (for instance in the absence of headers). */ stream_inc_http_req_ctr(s); proxy_inc_fe_req_ctr(sess->fe); /* one more valid request for this FE */ if (txn->flags & TX_WAIT_NEXT_RQ) { /* kill the pending keep-alive timeout */ txn->flags &= ~TX_WAIT_NEXT_RQ; req->analyse_exp = TICK_ETERNITY; } /* Maybe we found in invalid header name while we were configured not * to block on that, so we have to capture it now. */ if (unlikely(msg->err_pos >= 0)) http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); /* * 1: identify the method */ txn->meth = find_http_meth(ci_head(req), msg->sl.rq.m_l); /* we can make use of server redirect on GET and HEAD */ if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD) s->flags |= SF_REDIRECTABLE; else if (txn->meth == HTTP_METH_OTHER && msg->sl.rq.m_l == 3 && memcmp(ci_head(req), "PRI", 3) == 0) { /* PRI is reserved for the HTTP/2 preface */ msg->err_pos = 0; goto return_bad_req; } /* * 2: check if the URI matches the monitor_uri. * We have to do this for every request which gets in, because * the monitor-uri is defined by the frontend. */ if (unlikely((sess->fe->monitor_uri_len != 0) && (sess->fe->monitor_uri_len == msg->sl.rq.u_l) && !memcmp(ci_head(req) + msg->sl.rq.u, sess->fe->monitor_uri, sess->fe->monitor_uri_len))) { /* * We have found the monitor URI */ struct acl_cond *cond; s->flags |= SF_MONITOR; HA_ATOMIC_ADD(&sess->fe->fe_counters.intercepted_req, 1); /* Check if we want to fail this monitor request or not */ list_for_each_entry(cond, &sess->fe->mon_fail_cond, list) { int ret = acl_exec_cond(cond, sess->fe, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (cond->pol == ACL_COND_UNLESS) ret = !ret; if (ret) { /* we fail this request, let's return 503 service unavail */ txn->status = 503; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_LOCAL; /* we don't want a real error here */ goto return_prx_cond; } } /* nothing to fail, let's reply normally */ txn->status = 200; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_LOCAL; /* we don't want a real error here */ goto return_prx_cond; } /* * 3: Maybe we have to copy the original REQURI for the logs ? * Note: we cannot log anymore if the request has been * classified as invalid. */ if (unlikely(s->logs.logwait & LW_REQ)) { /* we have a complete HTTP request that we must log */ if ((txn->uri = pool_alloc(pool_head_requri)) != NULL) { int urilen = msg->sl.rq.l; if (urilen >= global.tune.requri_len ) urilen = global.tune.requri_len - 1; memcpy(txn->uri, ci_head(req), urilen); txn->uri[urilen] = 0; if (!(s->logs.logwait &= ~(LW_REQ|LW_INIT))) s->do_log(s); } else { ha_alert("HTTP logging : out of memory.\n"); } } /* RFC7230#2.6 has enforced the format of the HTTP version string to be * exactly one digit "." one digit. This check may be disabled using * option accept-invalid-http-request. */ if (!(sess->fe->options2 & PR_O2_REQBUG_OK)) { if (msg->sl.rq.v_l != 8) { msg->err_pos = msg->sl.rq.v; goto return_bad_req; } if (ci_head(req)[msg->sl.rq.v + 4] != '/' || !isdigit((unsigned char)ci_head(req)[msg->sl.rq.v + 5]) || ci_head(req)[msg->sl.rq.v + 6] != '.' || !isdigit((unsigned char)ci_head(req)[msg->sl.rq.v + 7])) { msg->err_pos = msg->sl.rq.v + 4; goto return_bad_req; } } else { /* 4. We may have to convert HTTP/0.9 requests to HTTP/1.0 */ if (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(txn)) goto return_bad_req; } /* ... and check if the request is HTTP/1.1 or above */ if ((msg->sl.rq.v_l == 8) && ((ci_head(req)[msg->sl.rq.v + 5] > '1') || ((ci_head(req)[msg->sl.rq.v + 5] == '1') && (ci_head(req)[msg->sl.rq.v + 7] >= '1')))) msg->flags |= HTTP_MSGF_VER_11; /* "connection" has not been parsed yet */ txn->flags &= ~(TX_HDR_CONN_PRS | TX_HDR_CONN_CLO | TX_HDR_CONN_KAL | TX_HDR_CONN_UPG); /* if the frontend has "option http-use-proxy-header", we'll check if * we have what looks like a proxied connection instead of a connection, * and in this case set the TX_USE_PX_CONN flag to use Proxy-connection. * Note that this is *not* RFC-compliant, however browsers and proxies * happen to do that despite being non-standard :-( * We consider that a request not beginning with either '/' or '*' is * a proxied connection, which covers both "scheme://location" and * CONNECT ip:port. */ if ((sess->fe->options2 & PR_O2_USE_PXHDR) && ci_head(req)[msg->sl.rq.u] != '/' && ci_head(req)[msg->sl.rq.u] != '*') txn->flags |= TX_USE_PX_CONN; /* transfer length unknown*/ msg->flags &= ~HTTP_MSGF_XFER_LEN; /* 5: we may need to capture headers */ if (unlikely((s->logs.logwait & LW_REQHDR) && s->req_cap)) http_capture_headers(ci_head(req), &txn->hdr_idx, s->req_cap, sess->fe->req_cap); /* 6: determine the transfer-length according to RFC2616 #4.4, updated * by RFC7230#3.3.3 : * * The length of a message body is determined by one of the following * (in order of precedence): * * 1. Any response to a HEAD request and any response with a 1xx * (Informational), 204 (No Content), or 304 (Not Modified) status * code is always terminated by the first empty line after the * header fields, regardless of the header fields present in the * message, and thus cannot contain a message body. * * 2. Any 2xx (Successful) response to a CONNECT request implies that * the connection will become a tunnel immediately after the empty * line that concludes the header fields. A client MUST ignore any * Content-Length or Transfer-Encoding header fields received in * such a message. * * 3. If a Transfer-Encoding header field is present and the chunked * transfer coding (Section 4.1) is the final encoding, the message * body length is determined by reading and decoding the chunked * data until the transfer coding indicates the data is complete. * * If a Transfer-Encoding header field is present in a response and * the chunked transfer coding is not the final encoding, the * message body length is determined by reading the connection until * it is closed by the server. If a Transfer-Encoding header field * is present in a request and the chunked transfer coding is not * the final encoding, the message body length cannot be determined * reliably; the server MUST respond with the 400 (Bad Request) * status code and then close the connection. * * If a message is received with both a Transfer-Encoding and a * Content-Length header field, the Transfer-Encoding overrides the * Content-Length. Such a message might indicate an attempt to * perform request smuggling (Section 9.5) or response splitting * (Section 9.4) and ought to be handled as an error. A sender MUST * remove the received Content-Length field prior to forwarding such * a message downstream. * * 4. If a message is received without Transfer-Encoding and with * either multiple Content-Length header fields having differing * field-values or a single Content-Length header field having an * invalid value, then the message framing is invalid and the * recipient MUST treat it as an unrecoverable error. If this is a * request message, the server MUST respond with a 400 (Bad Request) * status code and then close the connection. If this is a response * message received by a proxy, the proxy MUST close the connection * to the server, discard the received response, and send a 502 (Bad * Gateway) response to the client. If this is a response message * received by a user agent, the user agent MUST close the * connection to the server and discard the received response. * * 5. If a valid Content-Length header field is present without * Transfer-Encoding, its decimal value defines the expected message * body length in octets. If the sender closes the connection or * the recipient times out before the indicated number of octets are * received, the recipient MUST consider the message to be * incomplete and close the connection. * * 6. If this is a request message and none of the above are true, then * the message body length is zero (no message body is present). * * 7. Otherwise, this is a response message without a declared message * body length, so the message body length is determined by the * number of octets received prior to the server closing the * connection. */ ctx.idx = 0; /* set TE_CHNK and XFER_LEN only if "chunked" is seen last */ while (http_find_header2("Transfer-Encoding", 17, ci_head(req), &txn->hdr_idx, &ctx)) { if (ctx.vlen == 7 && strncasecmp(ctx.line + ctx.val, "chunked", 7) == 0) msg->flags |= HTTP_MSGF_TE_CHNK; else if (msg->flags & HTTP_MSGF_TE_CHNK) { /* chunked not last, return badreq */ goto return_bad_req; } } /* Chunked requests must have their content-length removed */ ctx.idx = 0; if (msg->flags & HTTP_MSGF_TE_CHNK) { while (http_find_header2("Content-Length", 14, ci_head(req), &txn->hdr_idx, &ctx)) http_remove_header2(msg, &txn->hdr_idx, &ctx); } else while (http_find_header2("Content-Length", 14, ci_head(req), &txn->hdr_idx, &ctx)) { signed long long cl; if (!ctx.vlen) { msg->err_pos = ctx.line + ctx.val - ci_head(req); goto return_bad_req; } if (strl2llrc(ctx.line + ctx.val, ctx.vlen, &cl)) { msg->err_pos = ctx.line + ctx.val - ci_head(req); goto return_bad_req; /* parse failure */ } if (cl < 0) { msg->err_pos = ctx.line + ctx.val - ci_head(req); goto return_bad_req; } if ((msg->flags & HTTP_MSGF_CNT_LEN) && (msg->chunk_len != cl)) { msg->err_pos = ctx.line + ctx.val - ci_head(req); goto return_bad_req; /* already specified, was different */ } msg->flags |= HTTP_MSGF_CNT_LEN; msg->body_len = msg->chunk_len = cl; } /* even bodyless requests have a known length */ msg->flags |= HTTP_MSGF_XFER_LEN; /* Until set to anything else, the connection mode is set as Keep-Alive. It will * only change if both the request and the config reference something else. * Option httpclose by itself sets tunnel mode where headers are mangled. * However, if another mode is set, it will affect it (eg: server-close/ * keep-alive + httpclose = close). Note that we avoid to redo the same work * if FE and BE have the same settings (common). The method consists in * checking if options changed between the two calls (implying that either * one is non-null, or one of them is non-null and we are there for the first * time. */ if (!(txn->flags & TX_HDR_CONN_PRS) || ((sess->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE))) http_adjust_conn_mode(s, txn, msg); /* we may have to wait for the request's body */ if ((s->be->options & PR_O_WREQ_BODY) && (msg->body_len || (msg->flags & HTTP_MSGF_TE_CHNK))) req->analysers |= AN_REQ_HTTP_BODY; /* * RFC7234#4: * A cache MUST write through requests with methods * that are unsafe (Section 4.2.1 of [RFC7231]) to * the origin server; i.e., a cache is not allowed * to generate a reply to such a request before * having forwarded the request and having received * a corresponding response. * * RFC7231#4.2.1: * Of the request methods defined by this * specification, the GET, HEAD, OPTIONS, and TRACE * methods are defined to be safe. */ if (likely(txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD || txn->meth == HTTP_METH_OPTIONS || txn->meth == HTTP_METH_TRACE)) txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; /* end of job, return OK */ req->analysers &= ~an_bit; req->analyse_exp = TICK_ETERNITY; return 1; return_bad_req: /* We centralize bad requests processing here */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) { /* we detected a parsing error. We want to archive this request * in the dedicated proxy area for later troubleshooting. */ http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); } txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 400; http_reply_and_close(s, txn->status, http_error_message(s)); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); return_prx_cond: if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; req->analysers &= AN_REQ_FLT_END; req->analyse_exp = TICK_ETERNITY; return 0; } /* This function prepares an applet to handle the stats. It can deal with the * "100-continue" expectation, check that admin rules are met for POST requests, * and program a response message if something was unexpected. It cannot fail * and always relies on the stats applet to complete the job. It does not touch * analysers nor counters, which are left to the caller. It does not touch * s->target which is supposed to already point to the stats applet. The caller * is expected to have already assigned an appctx to the stream. */ int http_handle_stats(struct stream *s, struct channel *req) { struct stats_admin_rule *stats_admin_rule; struct stream_interface *si = &s->si[1]; struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->req; struct uri_auth *uri_auth = s->be->uri_auth; const char *uri, *h, *lookup; struct appctx *appctx; appctx = si_appctx(si); memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats)); appctx->st1 = appctx->st2 = 0; appctx->ctx.stats.st_code = STAT_STATUS_INIT; appctx->ctx.stats.flags |= STAT_FMT_HTML; /* assume HTML mode by default */ if ((msg->flags & HTTP_MSGF_VER_11) && (s->txn->meth != HTTP_METH_HEAD)) appctx->ctx.stats.flags |= STAT_CHUNKED; uri = ci_head(msg->chn) + msg->sl.rq.u; lookup = uri + uri_auth->uri_len; for (h = lookup; h <= uri + msg->sl.rq.u_l - 3; h++) { if (memcmp(h, ";up", 3) == 0) { appctx->ctx.stats.flags |= STAT_HIDE_DOWN; break; } } if (uri_auth->refresh) { for (h = lookup; h <= uri + msg->sl.rq.u_l - 10; h++) { if (memcmp(h, ";norefresh", 10) == 0) { appctx->ctx.stats.flags |= STAT_NO_REFRESH; break; } } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 4; h++) { if (memcmp(h, ";csv", 4) == 0) { appctx->ctx.stats.flags &= ~STAT_FMT_HTML; break; } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 6; h++) { if (memcmp(h, ";typed", 6) == 0) { appctx->ctx.stats.flags &= ~STAT_FMT_HTML; appctx->ctx.stats.flags |= STAT_FMT_TYPED; break; } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 8; h++) { if (memcmp(h, ";st=", 4) == 0) { int i; h += 4; appctx->ctx.stats.st_code = STAT_STATUS_UNKN; for (i = STAT_STATUS_INIT + 1; i < STAT_STATUS_SIZE; i++) { if (strncmp(stat_status_codes[i], h, 4) == 0) { appctx->ctx.stats.st_code = i; break; } } break; } } appctx->ctx.stats.scope_str = 0; appctx->ctx.stats.scope_len = 0; for (h = lookup; h <= uri + msg->sl.rq.u_l - 8; h++) { if (memcmp(h, STAT_SCOPE_INPUT_NAME "=", strlen(STAT_SCOPE_INPUT_NAME) + 1) == 0) { int itx = 0; const char *h2; char scope_txt[STAT_SCOPE_TXT_MAXLEN + 1]; const char *err; h += strlen(STAT_SCOPE_INPUT_NAME) + 1; h2 = h; appctx->ctx.stats.scope_str = h2 - ci_head(msg->chn); while (*h != ';' && *h != '\0' && *h != '&' && *h != ' ' && *h != '\n') { itx++; h++; } if (itx > STAT_SCOPE_TXT_MAXLEN) itx = STAT_SCOPE_TXT_MAXLEN; appctx->ctx.stats.scope_len = itx; /* scope_txt = search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */ memcpy(scope_txt, h2, itx); scope_txt[itx] = '\0'; err = invalid_char(scope_txt); if (err) { /* bad char in search text => clear scope */ appctx->ctx.stats.scope_str = 0; appctx->ctx.stats.scope_len = 0; } break; } } /* now check whether we have some admin rules for this request */ list_for_each_entry(stats_admin_rule, &uri_auth->admin_rules, list) { int ret = 1; if (stats_admin_rule->cond) { ret = acl_exec_cond(stats_admin_rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (stats_admin_rule->cond->pol == ACL_COND_UNLESS) ret = !ret; } if (ret) { /* no rule, or the rule matches */ appctx->ctx.stats.flags |= STAT_ADMIN; break; } } /* Was the status page requested with a POST ? */ if (unlikely(txn->meth == HTTP_METH_POST && txn->req.body_len > 0)) { if (appctx->ctx.stats.flags & STAT_ADMIN) { /* we'll need the request body, possibly after sending 100-continue */ if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) req->analysers |= AN_REQ_HTTP_BODY; appctx->st0 = STAT_HTTP_POST; } else { appctx->ctx.stats.st_code = STAT_STATUS_DENY; appctx->st0 = STAT_HTTP_LAST; } } else { /* So it was another method (GET/HEAD) */ appctx->st0 = STAT_HTTP_HEAD; } s->task->nice = -32; /* small boost for HTTP statistics */ return 1; } int http_transform_header_str(struct stream* s, struct http_msg *msg, const char* name, unsigned int name_len, const char *str, struct my_regex *re, int action) { struct hdr_idx *idx = &s->txn->hdr_idx; struct buffer *output = get_trash_chunk(); /* Choose the header browsing function. */ switch (action) { case ACT_HTTP_REPLACE_VAL: return http_legacy_replace_header(idx, msg, name, name_len, str, re, output); case ACT_HTTP_REPLACE_HDR: return http_legacy_replace_full_header(idx, msg, name, name_len, str, re, output); default: /* impossible */ return -1; } } static int http_transform_header(struct stream* s, struct http_msg *msg, const char* name, unsigned int name_len, struct list *fmt, struct my_regex *re, int action) { struct buffer *replace; int ret = -1; replace = alloc_trash_chunk(); if (!replace) goto leave; replace->data = build_logline(s, replace->area, replace->size, fmt); if (replace->data >= replace->size - 1) goto leave; ret = http_transform_header_str(s, msg, name, name_len, replace->area, re, action); leave: free_trash_chunk(replace); return ret; } /* * Build an HTTP Early Hint HTTP 103 response header with <name> as name and with a value * built according to <fmt> log line format. * If <early_hints> is NULL, it is allocated and the HTTP 103 response first * line is inserted before the header. If an error occurred <early_hints> is * released and NULL is returned. On success the updated buffer is returned. */ static struct buffer *http_apply_early_hint_rule(struct stream* s, struct buffer *early_hints, const char* name, unsigned int name_len, struct list *fmt) { if (!early_hints) { early_hints = alloc_trash_chunk(); if (!early_hints) goto fail; if (!chunk_memcat(early_hints, HTTP_103.ptr, HTTP_103.len)) goto fail; } if (!chunk_memcat(early_hints, name, name_len) || !chunk_memcat(early_hints, ": ", 2)) goto fail; early_hints->data += build_logline(s, b_tail(early_hints), b_room(early_hints), fmt); if (!chunk_memcat(early_hints, "\r\n", 2)) goto fail; return early_hints; fail: free_trash_chunk(early_hints); return NULL; } /* Sends an HTTP 103 response. Before sending it, the last CRLF finishing the * response is added. If an error occurred or if another response was already * sent, this function does nothing. */ static void http_send_early_hints(struct stream *s, struct buffer *early_hints) { struct channel *chn = s->txn->rsp.chn; char *cur_ptr = ci_head(chn); int ret; /* If a response was already sent, skip early hints */ if (s->txn->status > 0) return; if (!chunk_memcat(early_hints, "\r\n", 2)) return; ret = b_rep_blk(&chn->buf, cur_ptr, cur_ptr, b_head(early_hints), b_data(early_hints)); c_adv(chn, ret); chn->total += ret; } /* Executes the http-request rules <rules> for stream <s>, proxy <px> and * transaction <txn>. Returns the verdict of the first rule that prevents * further processing of the request (auth, deny, ...), and defaults to * HTTP_RULE_RES_STOP if it executed all rules or stopped on an allow, or * HTTP_RULE_RES_CONT if the last rule was reached. It may set the TX_CLTARPIT * on txn->flags if it encounters a tarpit rule. If <deny_status> is not NULL * and a deny/tarpit rule is matched, it will be filled with this rule's deny * status. */ enum rule_result http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct stream *s, int *deny_status) { struct session *sess = strm_sess(s); struct http_txn *txn = s->txn; struct act_rule *rule; struct hdr_ctx ctx; const char *auth_realm; struct buffer *early_hints = NULL; enum rule_result rule_ret = HTTP_RULE_RES_CONT; int act_flags = 0; int len; /* If "the current_rule_list" match the executed rule list, we are in * resume condition. If a resume is needed it is always in the action * and never in the ACL or converters. In this case, we initialise the * current rule, and go to the action execution point. */ if (s->current_rule) { rule = s->current_rule; s->current_rule = NULL; if (s->current_rule_list == rules) goto resume_execution; } s->current_rule_list = rules; list_for_each_entry(rule, rules, list) { /* check optional condition */ if (rule->cond) { int ret; ret = acl_exec_cond(rule->cond, px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (rule->cond->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) /* condition not matched */ continue; } act_flags |= ACT_FLAG_FIRST; resume_execution: switch (rule->action) { case ACT_ACTION_ALLOW: rule_ret = HTTP_RULE_RES_STOP; goto end; case ACT_ACTION_DENY: if (deny_status) *deny_status = rule->deny_status; rule_ret = HTTP_RULE_RES_DENY; goto end; case ACT_HTTP_REQ_TARPIT: txn->flags |= TX_CLTARPIT; if (deny_status) *deny_status = rule->deny_status; rule_ret = HTTP_RULE_RES_DENY; goto end; case ACT_HTTP_REQ_AUTH: /* Be sure to send any pending HTTP 103 response first */ if (early_hints) { http_send_early_hints(s, early_hints); free_trash_chunk(early_hints); early_hints = NULL; } /* Auth might be performed on regular http-req rules as well as on stats */ auth_realm = rule->arg.auth.realm; if (!auth_realm) { if (px->uri_auth && rules == &px->uri_auth->http_req_rules) auth_realm = STATS_DEFAULT_REALM; else auth_realm = px->id; } /* send 401/407 depending on whether we use a proxy or not. We still * count one error, because normal browsing won't significantly * increase the counter but brute force attempts will. */ chunk_printf(&trash, (txn->flags & TX_USE_PX_CONN) ? HTTP_407_fmt : HTTP_401_fmt, auth_realm); txn->status = (txn->flags & TX_USE_PX_CONN) ? 407 : 401; http_reply_and_close(s, txn->status, &trash); stream_inc_http_err_ctr(s); rule_ret = HTTP_RULE_RES_ABRT; goto end; case ACT_HTTP_REDIR: /* Be sure to send any pending HTTP 103 response first */ if (early_hints) { http_send_early_hints(s, early_hints); free_trash_chunk(early_hints); early_hints = NULL; } rule_ret = HTTP_RULE_RES_DONE; if (!http_apply_redirect_rule(rule->arg.redir, s, txn)) rule_ret = HTTP_RULE_RES_BADREQ; goto end; case ACT_HTTP_SET_NICE: s->task->nice = rule->arg.nice; break; case ACT_HTTP_SET_TOS: conn_set_tos(objt_conn(sess->origin), rule->arg.tos); break; case ACT_HTTP_SET_MARK: conn_set_mark(objt_conn(sess->origin), rule->arg.mark); break; case ACT_HTTP_SET_LOGL: s->logs.level = rule->arg.loglevel; break; case ACT_HTTP_REPLACE_HDR: case ACT_HTTP_REPLACE_VAL: if (http_transform_header(s, &txn->req, rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, &rule->arg.hdr_add.fmt, &rule->arg.hdr_add.re, rule->action)) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } break; case ACT_HTTP_DEL_HDR: ctx.idx = 0; /* remove all occurrences of the header */ while (http_find_header2(rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, ci_head(txn->req.chn), &txn->hdr_idx, &ctx)) { http_remove_header2(&txn->req, &txn->hdr_idx, &ctx); } break; case ACT_HTTP_SET_HDR: case ACT_HTTP_ADD_HDR: { /* The scope of the trash buffer must be limited to this function. The * build_logline() function can execute a lot of other function which * can use the trash buffer. So for limiting the scope of this global * buffer, we build first the header value using build_logline, and * after we store the header name. */ struct buffer *replace; replace = alloc_trash_chunk(); if (!replace) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } len = rule->arg.hdr_add.name_len + 2, len += build_logline(s, replace->area + len, replace->size - len, &rule->arg.hdr_add.fmt); memcpy(replace->area, rule->arg.hdr_add.name, rule->arg.hdr_add.name_len); replace->area[rule->arg.hdr_add.name_len] = ':'; replace->area[rule->arg.hdr_add.name_len + 1] = ' '; replace->data = len; if (rule->action == ACT_HTTP_SET_HDR) { /* remove all occurrences of the header */ ctx.idx = 0; while (http_find_header2(rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, ci_head(txn->req.chn), &txn->hdr_idx, &ctx)) { http_remove_header2(&txn->req, &txn->hdr_idx, &ctx); } } if (http_header_add_tail2(&txn->req, &txn->hdr_idx, replace->area, replace->data) < 0) { static unsigned char rate_limit = 0; if ((rate_limit++ & 255) == 0) { replace->area[rule->arg.hdr_add.name_len] = 0; send_log(px, LOG_WARNING, "Proxy %s failed to add or set the request header '%s' for request #%u. You might need to increase tune.maxrewrite.", px->id, replace->area, s->uniq_id); } HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_rewrites, 1); if (sess->fe != s->be) HA_ATOMIC_ADD(&s->be->be_counters.failed_rewrites, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_rewrites, 1); } free_trash_chunk(replace); break; } case ACT_HTTP_DEL_ACL: case ACT_HTTP_DEL_MAP: { struct pat_ref *ref; struct buffer *key; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* perform update */ /* returned code: 1=ok, 0=ko */ HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); pat_ref_delete(ref, key->area); HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); break; } case ACT_HTTP_ADD_ACL: { struct pat_ref *ref; struct buffer *key; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* perform update */ /* add entry only if it does not already exist */ HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) == NULL) pat_ref_add(ref, key->area, NULL, NULL); HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); break; } case ACT_HTTP_SET_MAP: { struct pat_ref *ref; struct buffer *key, *value; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* allocate value */ value = alloc_trash_chunk(); if (!value) { free_trash_chunk(key); rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* collect value */ value->data = build_logline(s, value->area, value->size, &rule->arg.map.value); value->area[value->data] = '\0'; /* perform update */ if (pat_ref_find_elt(ref, key->area) != NULL) /* update entry if it exists */ pat_ref_set(ref, key->area, value->area, NULL); else /* insert a new entry */ pat_ref_add(ref, key->area, value->area, NULL); free_trash_chunk(key); free_trash_chunk(value); break; } case ACT_HTTP_EARLY_HINT: if (!(txn->req.flags & HTTP_MSGF_VER_11)) break; early_hints = http_apply_early_hint_rule(s, early_hints, rule->arg.early_hint.name, rule->arg.early_hint.name_len, &rule->arg.early_hint.fmt); if (!early_hints) { rule_ret = HTTP_RULE_RES_DONE; goto end; } break; case ACT_CUSTOM: if ((s->req.flags & CF_READ_ERROR) || ((s->req.flags & (CF_SHUTR|CF_READ_NULL)) && !(s->si[0].flags & SI_FL_CLEAN_ABRT) && (px->options & PR_O_ABRT_CLOSE))) act_flags |= ACT_FLAG_FINAL; switch (rule->action_ptr(rule, px, s->sess, s, act_flags)) { case ACT_RET_ERR: case ACT_RET_CONT: break; case ACT_RET_STOP: rule_ret = HTTP_RULE_RES_DONE; goto end; case ACT_RET_YIELD: s->current_rule = rule; rule_ret = HTTP_RULE_RES_YIELD; goto end; } break; case ACT_ACTION_TRK_SC0 ... ACT_ACTION_TRK_SCMAX: /* Note: only the first valid tracking parameter of each * applies. */ if (stkctr_entry(&s->stkctr[trk_idx(rule->action)]) == NULL) { struct stktable *t; struct stksess *ts; struct stktable_key *key; void *ptr1, *ptr2; t = rule->arg.trk_ctr.table.t; key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL); if (key && (ts = stktable_get_entry(t, key))) { stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts); /* let's count a new HTTP request as it's the first time we do it */ ptr1 = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT); ptr2 = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_RATE); if (ptr1 || ptr2) { HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock); if (ptr1) stktable_data_cast(ptr1, http_req_cnt)++; if (ptr2) update_freq_ctr_period(&stktable_data_cast(ptr2, http_req_rate), t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock); /* If data was modified, we need to touch to re-schedule sync */ stktable_touch_local(t, ts, 0); } stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT); if (sess->fe != s->be) stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND); } } break; /* other flags exists, but normally, they never be matched. */ default: break; } } end: if (early_hints) { http_send_early_hints(s, early_hints); free_trash_chunk(early_hints); } /* we reached the end of the rules, nothing to report */ return rule_ret; } /* Executes the http-response rules <rules> for stream <s> and proxy <px>. It * returns one of 5 possible statuses: HTTP_RULE_RES_CONT, HTTP_RULE_RES_STOP, * HTTP_RULE_RES_DONE, HTTP_RULE_RES_YIELD, or HTTP_RULE_RES_BADREQ. If *CONT * is returned, the process can continue the evaluation of next rule list. If * *STOP or *DONE is returned, the process must stop the evaluation. If *BADREQ * is returned, it means the operation could not be processed and a server error * must be returned. It may set the TX_SVDENY on txn->flags if it encounters a * deny rule. If *YIELD is returned, the caller must call again the function * with the same context. */ enum rule_result http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct stream *s) { struct session *sess = strm_sess(s); struct http_txn *txn = s->txn; struct act_rule *rule; struct hdr_ctx ctx; enum rule_result rule_ret = HTTP_RULE_RES_CONT; int act_flags = 0; /* If "the current_rule_list" match the executed rule list, we are in * resume condition. If a resume is needed it is always in the action * and never in the ACL or converters. In this case, we initialise the * current rule, and go to the action execution point. */ if (s->current_rule) { rule = s->current_rule; s->current_rule = NULL; if (s->current_rule_list == rules) goto resume_execution; } s->current_rule_list = rules; list_for_each_entry(rule, rules, list) { /* check optional condition */ if (rule->cond) { int ret; ret = acl_exec_cond(rule->cond, px, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL); ret = acl_pass(ret); if (rule->cond->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) /* condition not matched */ continue; } act_flags |= ACT_FLAG_FIRST; resume_execution: switch (rule->action) { case ACT_ACTION_ALLOW: rule_ret = HTTP_RULE_RES_STOP; /* "allow" rules are OK */ goto end; case ACT_ACTION_DENY: txn->flags |= TX_SVDENY; rule_ret = HTTP_RULE_RES_STOP; goto end; case ACT_HTTP_SET_NICE: s->task->nice = rule->arg.nice; break; case ACT_HTTP_SET_TOS: conn_set_tos(objt_conn(sess->origin), rule->arg.tos); break; case ACT_HTTP_SET_MARK: conn_set_mark(objt_conn(sess->origin), rule->arg.mark); break; case ACT_HTTP_SET_LOGL: s->logs.level = rule->arg.loglevel; break; case ACT_HTTP_REPLACE_HDR: case ACT_HTTP_REPLACE_VAL: if (http_transform_header(s, &txn->rsp, rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, &rule->arg.hdr_add.fmt, &rule->arg.hdr_add.re, rule->action)) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } break; case ACT_HTTP_DEL_HDR: ctx.idx = 0; /* remove all occurrences of the header */ while (http_find_header2(rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, ci_head(txn->rsp.chn), &txn->hdr_idx, &ctx)) { http_remove_header2(&txn->rsp, &txn->hdr_idx, &ctx); } break; case ACT_HTTP_SET_HDR: case ACT_HTTP_ADD_HDR: { struct buffer *replace; replace = alloc_trash_chunk(); if (!replace) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } chunk_printf(replace, "%s: ", rule->arg.hdr_add.name); memcpy(replace->area, rule->arg.hdr_add.name, rule->arg.hdr_add.name_len); replace->data = rule->arg.hdr_add.name_len; replace->area[replace->data++] = ':'; replace->area[replace->data++] = ' '; replace->data += build_logline(s, replace->area + replace->data, replace->size - replace->data, &rule->arg.hdr_add.fmt); if (rule->action == ACT_HTTP_SET_HDR) { /* remove all occurrences of the header */ ctx.idx = 0; while (http_find_header2(rule->arg.hdr_add.name, rule->arg.hdr_add.name_len, ci_head(txn->rsp.chn), &txn->hdr_idx, &ctx)) { http_remove_header2(&txn->rsp, &txn->hdr_idx, &ctx); } } if (http_header_add_tail2(&txn->rsp, &txn->hdr_idx, replace->area, replace->data) < 0) { static unsigned char rate_limit = 0; if ((rate_limit++ & 255) == 0) { replace->area[rule->arg.hdr_add.name_len] = 0; send_log(px, LOG_WARNING, "Proxy %s failed to add or set the response header '%s' for request #%u. You might need to increase tune.maxrewrite.", px->id, replace->area, s->uniq_id); } HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_rewrites, 1); if (sess->fe != s->be) HA_ATOMIC_ADD(&s->be->be_counters.failed_rewrites, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_rewrites, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_rewrites, 1); } free_trash_chunk(replace); break; } case ACT_HTTP_DEL_ACL: case ACT_HTTP_DEL_MAP: { struct pat_ref *ref; struct buffer *key; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* perform update */ /* returned code: 1=ok, 0=ko */ HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); pat_ref_delete(ref, key->area); HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); break; } case ACT_HTTP_ADD_ACL: { struct pat_ref *ref; struct buffer *key; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* perform update */ /* check if the entry already exists */ if (pat_ref_find_elt(ref, key->area) == NULL) pat_ref_add(ref, key->area, NULL, NULL); free_trash_chunk(key); break; } case ACT_HTTP_SET_MAP: { struct pat_ref *ref; struct buffer *key, *value; /* collect reference */ ref = pat_ref_lookup(rule->arg.map.ref); if (!ref) continue; /* allocate key */ key = alloc_trash_chunk(); if (!key) { rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* allocate value */ value = alloc_trash_chunk(); if (!value) { free_trash_chunk(key); rule_ret = HTTP_RULE_RES_BADREQ; goto end; } /* collect key */ key->data = build_logline(s, key->area, key->size, &rule->arg.map.key); key->area[key->data] = '\0'; /* collect value */ value->data = build_logline(s, value->area, value->size, &rule->arg.map.value); value->area[value->data] = '\0'; /* perform update */ HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) != NULL) /* update entry if it exists */ pat_ref_set(ref, key->area, value->area, NULL); else /* insert a new entry */ pat_ref_add(ref, key->area, value->area, NULL); HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); free_trash_chunk(value); break; } case ACT_HTTP_REDIR: rule_ret = HTTP_RULE_RES_DONE; if (!http_apply_redirect_rule(rule->arg.redir, s, txn)) rule_ret = HTTP_RULE_RES_BADREQ; goto end; case ACT_ACTION_TRK_SC0 ... ACT_ACTION_TRK_SCMAX: /* Note: only the first valid tracking parameter of each * applies. */ if (stkctr_entry(&s->stkctr[trk_idx(rule->action)]) == NULL) { struct stktable *t; struct stksess *ts; struct stktable_key *key; void *ptr; t = rule->arg.trk_ctr.table.t; key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_RES | SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL); if (key && (ts = stktable_get_entry(t, key))) { stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts); HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock); /* let's count a new HTTP request as it's the first time we do it */ ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT); if (ptr) stktable_data_cast(ptr, http_req_cnt)++; ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_RATE); if (ptr) update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); /* When the client triggers a 4xx from the server, it's most often due * to a missing object or permission. These events should be tracked * because if they happen often, it may indicate a brute force or a * vulnerability scan. Normally this is done when receiving the response * but here we're tracking after this ought to have been done so we have * to do it on purpose. */ if ((unsigned)(txn->status - 400) < 100) { ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_ERR_CNT); if (ptr) stktable_data_cast(ptr, http_err_cnt)++; ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_ERR_RATE); if (ptr) update_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u, 1); } HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock); /* If data was modified, we need to touch to re-schedule sync */ stktable_touch_local(t, ts, 0); stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT); if (sess->fe != s->be) stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND); } } break; case ACT_CUSTOM: if ((s->req.flags & CF_READ_ERROR) || ((s->req.flags & (CF_SHUTR|CF_READ_NULL)) && !(s->si[0].flags & SI_FL_CLEAN_ABRT) && (px->options & PR_O_ABRT_CLOSE))) act_flags |= ACT_FLAG_FINAL; switch (rule->action_ptr(rule, px, s->sess, s, act_flags)) { case ACT_RET_ERR: case ACT_RET_CONT: break; case ACT_RET_STOP: rule_ret = HTTP_RULE_RES_STOP; goto end; case ACT_RET_YIELD: s->current_rule = rule; rule_ret = HTTP_RULE_RES_YIELD; goto end; } break; /* other flags exists, but normally, they never be matched. */ default: break; } } end: /* we reached the end of the rules, nothing to report */ return rule_ret; } /* Perform an HTTP redirect based on the information in <rule>. The function * returns non-zero on success, or zero in case of a, irrecoverable error such * as too large a request to build a valid response. */ int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn) { struct http_msg *req = &txn->req; struct http_msg *res = &txn->rsp; const char *msg_fmt; struct buffer *chunk; int ret = 0; if (IS_HTX_STRM(s)) return htx_apply_redirect_rule(rule, s, txn); chunk = alloc_trash_chunk(); if (!chunk) goto leave; /* build redirect message */ switch(rule->code) { case 308: msg_fmt = HTTP_308; break; case 307: msg_fmt = HTTP_307; break; case 303: msg_fmt = HTTP_303; break; case 301: msg_fmt = HTTP_301; break; case 302: default: msg_fmt = HTTP_302; break; } if (unlikely(!chunk_strcpy(chunk, msg_fmt))) goto leave; switch(rule->type) { case REDIRECT_TYPE_SCHEME: { const char *path; const char *host; struct hdr_ctx ctx; int pathlen; int hostlen; host = ""; hostlen = 0; ctx.idx = 0; if (http_find_header2("Host", 4, ci_head(req->chn), &txn->hdr_idx, &ctx)) { host = ctx.line + ctx.val; hostlen = ctx.vlen; } path = http_txn_get_path(txn); /* build message using path */ if (path) { pathlen = req->sl.rq.u_l + (ci_head(req->chn) + req->sl.rq.u) - path; if (rule->flags & REDIRECT_FLAG_DROP_QS) { int qs = 0; while (qs < pathlen) { if (path[qs] == '?') { pathlen = qs; break; } qs++; } } } else { path = "/"; pathlen = 1; } if (rule->rdr_str) { /* this is an old "redirect" rule */ /* check if we can add scheme + "://" + host + path */ if (chunk->data + rule->rdr_len + 3 + hostlen + pathlen > chunk->size - 4) goto leave; /* add scheme */ memcpy(chunk->area + chunk->data, rule->rdr_str, rule->rdr_len); chunk->data += rule->rdr_len; } else { /* add scheme with executing log format */ chunk->data += build_logline(s, chunk->area + chunk->data, chunk->size - chunk->data, &rule->rdr_fmt); /* check if we can add scheme + "://" + host + path */ if (chunk->data + 3 + hostlen + pathlen > chunk->size - 4) goto leave; } /* add "://" */ memcpy(chunk->area + chunk->data, "://", 3); chunk->data += 3; /* add host */ memcpy(chunk->area + chunk->data, host, hostlen); chunk->data += hostlen; /* add path */ memcpy(chunk->area + chunk->data, path, pathlen); chunk->data += pathlen; /* append a slash at the end of the location if needed and missing */ if (chunk->data && chunk->area[chunk->data - 1] != '/' && (rule->flags & REDIRECT_FLAG_APPEND_SLASH)) { if (chunk->data > chunk->size - 5) goto leave; chunk->area[chunk->data] = '/'; chunk->data++; } break; } case REDIRECT_TYPE_PREFIX: { const char *path; int pathlen; path = http_txn_get_path(txn); /* build message using path */ if (path) { pathlen = req->sl.rq.u_l + (ci_head(req->chn) + req->sl.rq.u) - path; if (rule->flags & REDIRECT_FLAG_DROP_QS) { int qs = 0; while (qs < pathlen) { if (path[qs] == '?') { pathlen = qs; break; } qs++; } } } else { path = "/"; pathlen = 1; } if (rule->rdr_str) { /* this is an old "redirect" rule */ if (chunk->data + rule->rdr_len + pathlen > chunk->size - 4) goto leave; /* add prefix. Note that if prefix == "/", we don't want to * add anything, otherwise it makes it hard for the user to * configure a self-redirection. */ if (rule->rdr_len != 1 || *rule->rdr_str != '/') { memcpy(chunk->area + chunk->data, rule->rdr_str, rule->rdr_len); chunk->data += rule->rdr_len; } } else { /* add prefix with executing log format */ chunk->data += build_logline(s, chunk->area + chunk->data, chunk->size - chunk->data, &rule->rdr_fmt); /* Check length */ if (chunk->data + pathlen > chunk->size - 4) goto leave; } /* add path */ memcpy(chunk->area + chunk->data, path, pathlen); chunk->data += pathlen; /* append a slash at the end of the location if needed and missing */ if (chunk->data && chunk->area[chunk->data - 1] != '/' && (rule->flags & REDIRECT_FLAG_APPEND_SLASH)) { if (chunk->data > chunk->size - 5) goto leave; chunk->area[chunk->data] = '/'; chunk->data++; } break; } case REDIRECT_TYPE_LOCATION: default: if (rule->rdr_str) { /* this is an old "redirect" rule */ if (chunk->data + rule->rdr_len > chunk->size - 4) goto leave; /* add location */ memcpy(chunk->area + chunk->data, rule->rdr_str, rule->rdr_len); chunk->data += rule->rdr_len; } else { /* add location with executing log format */ chunk->data += build_logline(s, chunk->area + chunk->data, chunk->size - chunk->data, &rule->rdr_fmt); /* Check left length */ if (chunk->data > chunk->size - 4) goto leave; } break; } if (rule->cookie_len) { memcpy(chunk->area + chunk->data, "\r\nSet-Cookie: ", 14); chunk->data += 14; memcpy(chunk->area + chunk->data, rule->cookie_str, rule->cookie_len); chunk->data += rule->cookie_len; } /* add end of headers and the keep-alive/close status. */ txn->status = rule->code; /* let's log the request time */ s->logs.tv_request = now; if (((!(req->flags & HTTP_MSGF_TE_CHNK) && !req->body_len) || (req->msg_state == HTTP_MSG_DONE)) && ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL)) { /* keep-alive possible */ if (!(req->flags & HTTP_MSGF_VER_11)) { if (unlikely(txn->flags & TX_USE_PX_CONN)) { memcpy(chunk->area + chunk->data, "\r\nProxy-Connection: keep-alive", 30); chunk->data += 30; } else { memcpy(chunk->area + chunk->data, "\r\nConnection: keep-alive", 24); chunk->data += 24; } } memcpy(chunk->area + chunk->data, "\r\n\r\n", 4); chunk->data += 4; FLT_STRM_CB(s, flt_http_reply(s, txn->status, chunk)); co_inject(res->chn, chunk->area, chunk->data); /* "eat" the request */ b_del(&req->chn->buf, req->sov); req->next -= req->sov; req->sov = 0; s->req.analysers = AN_REQ_HTTP_XFER_BODY | (s->req.analysers & AN_REQ_FLT_END); s->res.analysers = AN_RES_HTTP_XFER_BODY | (s->res.analysers & AN_RES_FLT_END); req->msg_state = HTTP_MSG_CLOSED; res->msg_state = HTTP_MSG_DONE; /* Trim any possible response */ b_set_data(&res->chn->buf, co_data(res->chn)); res->next = res->sov = 0; /* let the server side turn to SI_ST_CLO */ channel_shutw_now(req->chn); } else { /* keep-alive not possible */ if (unlikely(txn->flags & TX_USE_PX_CONN)) { memcpy(chunk->area + chunk->data, "\r\nProxy-Connection: close\r\n\r\n", 29); chunk->data += 29; } else { memcpy(chunk->area + chunk->data, "\r\nConnection: close\r\n\r\n", 23); chunk->data += 23; } http_reply_and_close(s, txn->status, chunk); req->chn->analysers &= AN_REQ_FLT_END; } if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_LOCAL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; ret = 1; leave: free_trash_chunk(chunk); return ret; } /* This stream analyser runs all HTTP request processing which is common to * frontends and backends, which means blocking ACLs, filters, connection-close, * reqadd, stats and redirects. This is performed for the designated proxy. * It returns 1 if the processing can continue on next analysers, or zero if it * either needs more data or wants to immediately abort the request (eg: deny, * error, ...). */ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->req; struct redirect_rule *rule; struct cond_wordlist *wl; enum rule_result verdict; int deny_status = HTTP_ERR_403; struct connection *conn = objt_conn(sess->origin); if (IS_HTX_STRM(s)) return htx_process_req_common(s, req, an_bit, px); if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* we need more data */ goto return_prx_yield; } DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, req, req->rex, req->wex, req->flags, ci_data(req), req->analysers); /* just in case we have some per-backend tracking */ stream_inc_be_http_req_ctr(s); /* evaluate http-request rules */ if (!LIST_ISEMPTY(&px->http_req_rules)) { verdict = http_req_get_intercept_rule(px, &px->http_req_rules, s, &deny_status); switch (verdict) { case HTTP_RULE_RES_YIELD: /* some data miss, call the function later. */ goto return_prx_yield; case HTTP_RULE_RES_CONT: case HTTP_RULE_RES_STOP: /* nothing to do */ break; case HTTP_RULE_RES_DENY: /* deny or tarpit */ if (txn->flags & TX_CLTARPIT) goto tarpit; goto deny; case HTTP_RULE_RES_ABRT: /* abort request, response already sent. Eg: auth */ goto return_prx_cond; case HTTP_RULE_RES_DONE: /* OK, but terminate request processing (eg: redirect) */ goto done; case HTTP_RULE_RES_BADREQ: /* failed with a bad request */ goto return_bad_req; } } if (conn && (conn->flags & CO_FL_EARLY_DATA) && (conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_HANDSHAKE))) { struct hdr_ctx ctx; ctx.idx = 0; if (!http_find_header2("Early-Data", strlen("Early-Data"), ci_head(&s->req), &txn->hdr_idx, &ctx)) { if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, "Early-Data: 1", strlen("Early-Data: 1")) < 0)) { goto return_bad_req; } } } /* OK at this stage, we know that the request was accepted according to * the http-request rules, we can check for the stats. Note that the * URI is detected *before* the req* rules in order not to be affected * by a possible reqrep, while they are processed *after* so that a * reqdeny can still block them. This clearly needs to change in 1.6! */ if (stats_check_uri(&s->si[1], txn, px)) { s->target = &http_stats_applet.obj_type; if (unlikely(!si_register_handler(&s->si[1], objt_applet(s->target)))) { txn->status = 500; s->logs.tv_request = now; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_RESOURCE; goto return_prx_cond; } /* parse the whole stats request and extract the relevant information */ http_handle_stats(s, req); verdict = http_req_get_intercept_rule(px, &px->uri_auth->http_req_rules, s, &deny_status); /* not all actions implemented: deny, allow, auth */ if (verdict == HTTP_RULE_RES_DENY) /* stats http-request deny */ goto deny; if (verdict == HTTP_RULE_RES_ABRT) /* stats auth / stats http-request auth */ goto return_prx_cond; } /* evaluate the req* rules except reqadd */ if (px->req_exp != NULL) { if (apply_filters_to_request(s, req, px) < 0) goto return_bad_req; if (txn->flags & TX_CLDENY) goto deny; if (txn->flags & TX_CLTARPIT) { deny_status = HTTP_ERR_500; goto tarpit; } } /* add request headers from the rule sets in the same order */ list_for_each_entry(wl, &px->req_add, list) { if (wl->cond) { int ret = acl_exec_cond(wl->cond, px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)wl->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, wl->s, strlen(wl->s)) < 0)) goto return_bad_req; } /* Proceed with the stats now. */ if (unlikely(objt_applet(s->target) == &http_stats_applet) || unlikely(objt_applet(s->target) == &http_cache_applet)) { /* process the stats request now */ if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */ HA_ATOMIC_ADD(&sess->fe->fe_counters.intercepted_req, 1); if (!(s->flags & SF_ERR_MASK)) // this is not really an error but it is s->flags |= SF_ERR_LOCAL; // to mark that it comes from the proxy if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; /* enable the minimally required analyzers to handle keep-alive and compression on the HTTP response */ req->analysers &= (AN_REQ_HTTP_BODY | AN_REQ_FLT_HTTP_HDRS | AN_REQ_FLT_END); req->analysers &= ~AN_REQ_FLT_XFER_DATA; req->analysers |= AN_REQ_HTTP_XFER_BODY; goto done; } /* check whether we have some ACLs set to redirect this request */ list_for_each_entry(rule, &px->redirect_rules, list) { if (rule->cond) { int ret; ret = acl_exec_cond(rule->cond, px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (rule->cond->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } if (!http_apply_redirect_rule(rule, s, txn)) goto return_bad_req; goto done; } /* POST requests may be accompanied with an "Expect: 100-Continue" header. * If this happens, then the data will not come immediately, so we must * send all what we have without waiting. Note that due to the small gain * in waiting for the body of the request, it's easier to simply put the * CF_SEND_DONTWAIT flag any time. It's a one-shot flag so it will remove * itself once used. */ req->flags |= CF_SEND_DONTWAIT; done: /* done with this analyser, continue with next ones that the calling * points will have set, if any. */ req->analyse_exp = TICK_ETERNITY; done_without_exp: /* done with this analyser, but dont reset the analyse_exp. */ req->analysers &= ~an_bit; return 1; tarpit: /* Allow cookie logging */ if (s->be->cookie_name || sess->fe->capture_name) manage_client_side_cookies(s, req); /* When a connection is tarpitted, we use the tarpit timeout, * which may be the same as the connect timeout if unspecified. * If unset, then set it to zero because we really want it to * eventually expire. We build the tarpit as an analyser. */ channel_erase(&s->req); /* wipe the request out so that we can drop the connection early * if the client closes first. */ channel_dont_connect(req); txn->status = http_err_codes[deny_status]; req->analysers &= AN_REQ_FLT_END; /* remove switching rules etc... */ req->analysers |= AN_REQ_HTTP_TARPIT; req->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.tarpit); if (!req->analyse_exp) req->analyse_exp = tick_add(now_ms, 0); stream_inc_http_err_ctr(s); HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_req, 1); if (sess->fe != s->be) HA_ATOMIC_ADD(&s->be->be_counters.denied_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->denied_req, 1); goto done_without_exp; deny: /* this request was blocked (denied) */ /* Allow cookie logging */ if (s->be->cookie_name || sess->fe->capture_name) manage_client_side_cookies(s, req); txn->flags |= TX_CLDENY; txn->status = http_err_codes[deny_status]; s->logs.tv_request = now; http_reply_and_close(s, txn->status, http_error_message(s)); stream_inc_http_err_ctr(s); HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_req, 1); if (sess->fe != s->be) HA_ATOMIC_ADD(&s->be->be_counters.denied_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->denied_req, 1); goto return_prx_cond; return_bad_req: /* We centralize bad requests processing here */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) { /* we detected a parsing error. We want to archive this request * in the dedicated proxy area for later troubleshooting. */ http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); } txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 400; http_reply_and_close(s, txn->status, http_error_message(s)); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); return_prx_cond: if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; req->analysers &= AN_REQ_FLT_END; req->analyse_exp = TICK_ETERNITY; return 0; return_prx_yield: channel_dont_connect(req); return 0; } /* This function performs all the processing enabled for the current request. * It returns 1 if the processing can continue on next analysers, or zero if it * needs more data, encounters an error, or wants to immediately abort the * request. It relies on buffers flags, and updates s->req.analysers. */ int http_process_request(struct stream *s, struct channel *req, int an_bit) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->req; struct connection *cli_conn = objt_conn(strm_sess(s)->origin); if (IS_HTX_STRM(s)) return htx_process_request(s, req, an_bit); if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* we need more data */ channel_dont_connect(req); return 0; } DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, req, req->rex, req->wex, req->flags, ci_data(req), req->analysers); /* * Right now, we know that we have processed the entire headers * and that unwanted requests have been filtered out. We can do * whatever we want with the remaining request. Also, now we * may have separate values for ->fe, ->be. */ /* * If HTTP PROXY is set we simply get remote server address parsing * incoming request. Note that this requires that a connection is * allocated on the server side. */ if ((s->be->options & PR_O_HTTP_PROXY) && !(s->flags & SF_ADDR_SET)) { struct connection *conn; char *path; /* Note that for now we don't reuse existing proxy connections */ if (unlikely((conn = cs_conn(si_alloc_cs(&s->si[1], NULL))) == NULL)) { txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 500; req->analysers &= AN_REQ_FLT_END; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_RESOURCE; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return 0; } path = http_txn_get_path(txn); if (url2sa(ci_head(req) + msg->sl.rq.u, path ? path - (ci_head(req) + msg->sl.rq.u) : msg->sl.rq.u_l, &conn->addr.to, NULL) == -1) goto return_bad_req; /* if the path was found, we have to remove everything between * ci_head(req) + msg->sl.rq.u and path (excluded). If it was not * found, we need to replace from ci_head(req) + msg->sl.rq.u for * u_l characters by a single "/". */ if (path) { char *cur_ptr = ci_head(req); char *cur_end = cur_ptr + txn->req.sl.rq.l; int delta; delta = b_rep_blk(&req->buf, cur_ptr + msg->sl.rq.u, path, NULL, 0); http_msg_move_end(&txn->req, delta); cur_end += delta; if (http_parse_reqline(&txn->req, HTTP_MSG_RQMETH, cur_ptr, cur_end + 1, NULL, NULL) == NULL) goto return_bad_req; } else { char *cur_ptr = ci_head(req); char *cur_end = cur_ptr + txn->req.sl.rq.l; int delta; delta = b_rep_blk(&req->buf, cur_ptr + msg->sl.rq.u, cur_ptr + msg->sl.rq.u + msg->sl.rq.u_l, "/", 1); http_msg_move_end(&txn->req, delta); cur_end += delta; if (http_parse_reqline(&txn->req, HTTP_MSG_RQMETH, cur_ptr, cur_end + 1, NULL, NULL) == NULL) goto return_bad_req; } } /* * 7: Now we can work with the cookies. * Note that doing so might move headers in the request, but * the fields will stay coherent and the URI will not move. * This should only be performed in the backend. */ if (s->be->cookie_name || sess->fe->capture_name) manage_client_side_cookies(s, req); /* add unique-id if "header-unique-id" is specified */ if (!LIST_ISEMPTY(&sess->fe->format_unique_id) && !s->unique_id) { if ((s->unique_id = pool_alloc(pool_head_uniqueid)) == NULL) goto return_bad_req; s->unique_id[0] = '\0'; build_logline(s, s->unique_id, UNIQUEID_LEN, &sess->fe->format_unique_id); } if (sess->fe->header_unique_id && s->unique_id) { if (chunk_printf(&trash, "%s: %s", sess->fe->header_unique_id, s->unique_id) < 0) goto return_bad_req; if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.area, trash.data) < 0)) goto return_bad_req; } /* * 9: add X-Forwarded-For if either the frontend or the backend * asks for it. */ if ((sess->fe->options | s->be->options) & PR_O_FWDFOR) { struct hdr_ctx ctx = { .idx = 0 }; if (!((sess->fe->options | s->be->options) & PR_O_FF_ALWAYS) && http_find_header2(s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_name : sess->fe->fwdfor_hdr_name, s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_len : sess->fe->fwdfor_hdr_len, ci_head(req), &txn->hdr_idx, &ctx)) { /* The header is set to be added only if none is present * and we found it, so don't do anything. */ } else if (cli_conn && cli_conn->addr.from.ss_family == AF_INET) { /* Add an X-Forwarded-For header unless the source IP is * in the 'except' network range. */ if ((!sess->fe->except_mask.s_addr || (((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & sess->fe->except_mask.s_addr) != sess->fe->except_net.s_addr) && (!s->be->except_mask.s_addr || (((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & s->be->except_mask.s_addr) != s->be->except_net.s_addr)) { int len; unsigned char *pn; pn = (unsigned char *)&((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr; /* Note: we rely on the backend to get the header name to be used for * x-forwarded-for, because the header is really meant for the backends. * However, if the backend did not specify any option, we have to rely * on the frontend's header name. */ if (s->be->fwdfor_hdr_len) { len = s->be->fwdfor_hdr_len; memcpy(trash.area, s->be->fwdfor_hdr_name, len); } else { len = sess->fe->fwdfor_hdr_len; memcpy(trash.area, sess->fe->fwdfor_hdr_name, len); } len += snprintf(trash.area + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.area, len) < 0)) goto return_bad_req; } } else if (cli_conn && cli_conn->addr.from.ss_family == AF_INET6) { /* FIXME: for the sake of completeness, we should also support * 'except' here, although it is mostly useless in this case. */ int len; char pn[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, (const void *)&((struct sockaddr_in6 *)(&cli_conn->addr.from))->sin6_addr, pn, sizeof(pn)); /* Note: we rely on the backend to get the header name to be used for * x-forwarded-for, because the header is really meant for the backends. * However, if the backend did not specify any option, we have to rely * on the frontend's header name. */ if (s->be->fwdfor_hdr_len) { len = s->be->fwdfor_hdr_len; memcpy(trash.area, s->be->fwdfor_hdr_name, len); } else { len = sess->fe->fwdfor_hdr_len; memcpy(trash.area, sess->fe->fwdfor_hdr_name, len); } len += snprintf(trash.area + len, trash.size - len, ": %s", pn); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.area, len) < 0)) goto return_bad_req; } } /* * 10: add X-Original-To if either the frontend or the backend * asks for it. */ if ((sess->fe->options | s->be->options) & PR_O_ORGTO) { /* FIXME: don't know if IPv6 can handle that case too. */ if (cli_conn && cli_conn->addr.from.ss_family == AF_INET) { /* Add an X-Original-To header unless the destination IP is * in the 'except' network range. */ conn_get_to_addr(cli_conn); if (cli_conn->addr.to.ss_family == AF_INET && ((!sess->fe->except_mask_to.s_addr || (((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & sess->fe->except_mask_to.s_addr) != sess->fe->except_to.s_addr) && (!s->be->except_mask_to.s_addr || (((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & s->be->except_mask_to.s_addr) != s->be->except_to.s_addr))) { int len; unsigned char *pn; pn = (unsigned char *)&((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr; /* Note: we rely on the backend to get the header name to be used for * x-original-to, because the header is really meant for the backends. * However, if the backend did not specify any option, we have to rely * on the frontend's header name. */ if (s->be->orgto_hdr_len) { len = s->be->orgto_hdr_len; memcpy(trash.area, s->be->orgto_hdr_name, len); } else { len = sess->fe->orgto_hdr_len; memcpy(trash.area, sess->fe->orgto_hdr_name, len); } len += snprintf(trash.area + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]); if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.area, len) < 0)) goto return_bad_req; } } } /* 11: add "Connection: close" or "Connection: keep-alive" if needed and not yet set. * If an "Upgrade" token is found, the header is left untouched in order not to have * to deal with some servers bugs : some of them fail an Upgrade if anything but * "Upgrade" is present in the Connection header. */ if (!(txn->flags & TX_HDR_CONN_UPG) && (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { unsigned int want_flags = 0; if (msg->flags & HTTP_MSGF_VER_11) { if ((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL && !((sess->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) want_flags |= TX_CON_CLO_SET; } else { if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || ((sess->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) want_flags |= TX_CON_KAL_SET; } if (want_flags != (txn->flags & (TX_CON_CLO_SET|TX_CON_KAL_SET))) http_change_connection_header(txn, msg, want_flags); } /* If we have no server assigned yet and we're balancing on url_param * with a POST request, we may be interested in checking the body for * that parameter. This will be done in another analyser. */ if (!(s->flags & (SF_ASSIGNED|SF_DIRECT)) && s->txn->meth == HTTP_METH_POST && s->be->url_param_name != NULL && (msg->flags & (HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK))) { channel_dont_connect(req); req->analysers |= AN_REQ_HTTP_BODY; } req->analysers &= ~AN_REQ_FLT_XFER_DATA; req->analysers |= AN_REQ_HTTP_XFER_BODY; /* We expect some data from the client. Unless we know for sure * we already have a full request, we have to re-enable quick-ack * in case we previously disabled it, otherwise we might cause * the client to delay further data. */ if ((sess->listener->options & LI_O_NOQUICKACK) && ((msg->flags & HTTP_MSGF_TE_CHNK) || (msg->body_len > ci_data(req) - txn->req.eoh - 2))) conn_set_quickack(cli_conn, 1); /************************************************************* * OK, that's finished for the headers. We have done what we * * could. Let's switch to the DATA state. * ************************************************************/ req->analyse_exp = TICK_ETERNITY; req->analysers &= ~an_bit; s->logs.tv_request = now; /* OK let's go on with the BODY now */ return 1; return_bad_req: /* let's centralize all bad requests */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) { /* we detected a parsing error. We want to archive this request * in the dedicated proxy area for later troubleshooting. */ http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe); } txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 400; req->analysers &= AN_REQ_FLT_END; http_reply_and_close(s, txn->status, http_error_message(s)); HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return 0; } /* This function is an analyser which processes the HTTP tarpit. It always * returns zero, at the beginning because it prevents any other processing * from occurring, and at the end because it terminates the request. */ int http_process_tarpit(struct stream *s, struct channel *req, int an_bit) { struct http_txn *txn = s->txn; if (IS_HTX_STRM(s)) return htx_process_tarpit(s, req, an_bit); /* This connection is being tarpitted. The CLIENT side has * already set the connect expiration date to the right * timeout. We just have to check that the client is still * there and that the timeout has not expired. */ channel_dont_connect(req); if ((req->flags & (CF_SHUTR|CF_READ_ERROR)) == 0 && !tick_is_expired(req->analyse_exp, now_ms)) return 0; /* We will set the queue timer to the time spent, just for * logging purposes. We fake a 500 server error, so that the * attacker will not suspect his connection has been tarpitted. * It will not cause trouble to the logs because we can exclude * the tarpitted connections by filtering on the 'PT' status flags. */ s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now); if (!(req->flags & CF_READ_ERROR)) http_reply_and_close(s, txn->status, http_error_message(s)); req->analysers &= AN_REQ_FLT_END; req->analyse_exp = TICK_ETERNITY; if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_T; return 0; } /* This function is an analyser which waits for the HTTP request body. It waits * for either the buffer to be full, or the full advertised contents to have * reached the buffer. It must only be called after the standard HTTP request * processing has occurred, because it expects the request to be parsed and will * look for the Expect header. It may send a 100-Continue interim response. It * takes in input any state starting from HTTP_MSG_BODY and leaves with one of * HTTP_MSG_CHK_SIZE, HTTP_MSG_DATA or HTTP_MSG_TRAILERS. It returns zero if it * needs to read more data, or 1 once it has completed its analysis. */ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &s->txn->req; if (IS_HTX_STRM(s)) return htx_wait_for_request_body(s, req, an_bit); /* We have to parse the HTTP request body to find any required data. * "balance url_param check_post" should have been the only way to get * into this. We were brought here after HTTP header analysis, so all * related structures are ready. */ if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) { /* This is the first call */ if (msg->msg_state < HTTP_MSG_BODY) goto missing_data; if (msg->msg_state < HTTP_MSG_100_SENT) { /* If we have HTTP/1.1 and Expect: 100-continue, then we must * send an HTTP/1.1 100 Continue intermediate response. */ if (msg->flags & HTTP_MSGF_VER_11) { struct hdr_ctx ctx; ctx.idx = 0; /* Expect is allowed in 1.1, look for it */ if (http_find_header2("Expect", 6, ci_head(req), &txn->hdr_idx, &ctx) && unlikely(ctx.vlen == 12 && strncasecmp(ctx.line+ctx.val, "100-continue", 12) == 0)) { co_inject(&s->res, HTTP_100.ptr, HTTP_100.len); http_remove_header2(&txn->req, &txn->hdr_idx, &ctx); } } msg->msg_state = HTTP_MSG_100_SENT; } /* we have msg->sov which points to the first byte of message body. * ci_head(req) still points to the beginning of the message. We * must save the body in msg->next because it survives buffer * re-alignments. */ msg->next = msg->sov; if (msg->flags & HTTP_MSGF_TE_CHNK) msg->msg_state = HTTP_MSG_CHUNK_SIZE; else msg->msg_state = HTTP_MSG_DATA; } if (!(msg->flags & HTTP_MSGF_TE_CHNK)) { /* We're in content-length mode, we just have to wait for enough data. */ if (http_body_bytes(msg) < msg->body_len) goto missing_data; /* OK we have everything we need now */ goto http_end; } /* OK here we're parsing a chunked-encoded message */ if (msg->msg_state == HTTP_MSG_CHUNK_SIZE) { /* read the chunk size and assign it to ->chunk_len, then * set ->sov and ->next to point to the body and switch to DATA or * TRAILERS state. */ unsigned int chunk; int ret = h1_parse_chunk_size(&req->buf, co_data(req) + msg->next, c_data(req), &chunk); if (!ret) goto missing_data; else if (ret < 0) { msg->err_pos = ci_data(req) + ret; if (msg->err_pos < 0) msg->err_pos += req->buf.size; stream_inc_http_err_ctr(s); goto return_bad_req; } msg->chunk_len = chunk; msg->body_len += chunk; msg->sol = ret; msg->next += ret; msg->msg_state = msg->chunk_len ? HTTP_MSG_DATA : HTTP_MSG_TRAILERS; } /* Now we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state. * We have the first data byte is in msg->sov + msg->sol. We're waiting * for at least a whole chunk or the whole content length bytes after * msg->sov + msg->sol. */ if (msg->msg_state == HTTP_MSG_TRAILERS) goto http_end; if (http_body_bytes(msg) >= msg->body_len) /* we have enough bytes now */ goto http_end; missing_data: /* we get here if we need to wait for more data. If the buffer is full, * we have the maximum we can expect. */ if (channel_full(req, global.tune.maxrewrite)) goto http_end; if ((req->flags & CF_READ_TIMEOUT) || tick_is_expired(req->analyse_exp, now_ms)) { txn->status = 408; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLITO; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_D; goto return_err_msg; } /* we get here if we need to wait for more data */ if (!(req->flags & (CF_SHUTR | CF_READ_ERROR))) { /* Not enough data. We'll re-use the http-request * timeout here. Ideally, we should set the timeout * relative to the accept() date. We just set the * request timeout once at the beginning of the * request. */ channel_dont_connect(req); if (!tick_isset(req->analyse_exp)) req->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.httpreq); return 0; } http_end: /* The situation will not evolve, so let's give up on the analysis. */ s->logs.tv_request = now; /* update the request timer to reflect full request */ req->analysers &= ~an_bit; req->analyse_exp = TICK_ETERNITY; return 1; return_bad_req: /* let's centralize all bad requests */ txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 400; http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_R; return_err_msg: req->analysers &= AN_REQ_FLT_END; HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); return 0; } /* send a server's name with an outgoing request over an established connection. * Note: this function is designed to be called once the request has been scheduled * for being forwarded. This is the reason why it rewinds the buffer before * proceeding. */ int http_send_name_header(struct stream *s, struct proxy* be, const char* srv_name) { struct hdr_ctx ctx; struct http_txn *txn = s->txn; char *hdr_name = be->server_id_hdr_name; int hdr_name_len = be->server_id_hdr_len; struct channel *chn = txn->req.chn; char *hdr_val; unsigned int old_o, old_i; if (IS_HTX_STRM(s)) return htx_send_name_header(s, be, srv_name); ctx.idx = 0; old_o = http_hdr_rewind(&txn->req); if (old_o) { /* The request was already skipped, let's restore it */ c_rew(chn, old_o); txn->req.next += old_o; txn->req.sov += old_o; } old_i = ci_data(chn); while (http_find_header2(hdr_name, hdr_name_len, ci_head(txn->req.chn), &txn->hdr_idx, &ctx)) { /* remove any existing values from the header */ http_remove_header2(&txn->req, &txn->hdr_idx, &ctx); } /* Add the new header requested with the server value */ hdr_val = trash.area; memcpy(hdr_val, hdr_name, hdr_name_len); hdr_val += hdr_name_len; *hdr_val++ = ':'; *hdr_val++ = ' '; hdr_val += strlcpy2(hdr_val, srv_name, trash.area + trash.size - hdr_val); http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.area, hdr_val - trash.area); if (old_o) { /* If this was a forwarded request, we must readjust the amount of * data to be forwarded in order to take into account the size * variations. Note that the current state is >= HTTP_MSG_BODY, * so we don't have to adjust ->sol. */ old_o += ci_data(chn) - old_i; c_adv(chn, old_o); txn->req.next -= old_o; txn->req.sov -= old_o; } return 0; } /* Terminate current transaction and prepare a new one. This is very tricky * right now but it works. */ void http_end_txn_clean_session(struct stream *s) { int prev_status = s->txn->status; struct proxy *fe = strm_fe(s); struct proxy *be = s->be; struct conn_stream *cs; struct connection *srv_conn; struct server *srv; unsigned int prev_flags = s->txn->flags; /* FIXME: We need a more portable way of releasing a backend's and a * server's connections. We need a safer way to reinitialize buffer * flags. We also need a more accurate method for computing per-request * data. */ cs = objt_cs(s->si[1].end); srv_conn = cs_conn(cs); /* unless we're doing keep-alive, we want to quickly close the connection * to the server. */ if (((s->txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) || !si_conn_ready(&s->si[1]) || !srv_conn->owner) { s->si[1].flags |= SI_FL_NOLINGER | SI_FL_NOHALF; si_shutr(&s->si[1]); si_shutw(&s->si[1]); } if (s->flags & SF_BE_ASSIGNED) { HA_ATOMIC_SUB(&be->beconn, 1); if (unlikely(s->srv_conn)) sess_change_server(s, NULL); } s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now); stream_process_counters(s); if (s->txn->status) { int n; n = s->txn->status / 100; if (n < 1 || n > 5) n = 0; if (fe->mode == PR_MODE_HTTP) { HA_ATOMIC_ADD(&fe->fe_counters.p.http.rsp[n], 1); } if ((s->flags & SF_BE_ASSIGNED) && (be->mode == PR_MODE_HTTP)) { HA_ATOMIC_ADD(&be->be_counters.p.http.rsp[n], 1); HA_ATOMIC_ADD(&be->be_counters.p.http.cum_req, 1); } } /* don't count other requests' data */ s->logs.bytes_in -= ci_data(&s->req); s->logs.bytes_out -= ci_data(&s->res); /* we may need to know the position in the queue */ pendconn_free(s); /* let's do a final log if we need it */ if (!LIST_ISEMPTY(&fe->logformat) && s->logs.logwait && !(s->flags & SF_MONITOR) && (!(fe->options & PR_O_NULLNOLOG) || s->req.total)) { s->do_log(s); } /* stop tracking content-based counters */ stream_stop_content_counters(s); stream_update_time_stats(s); /* reset the profiling counter */ s->task->calls = 0; s->task->cpu_time = 0; s->task->lat_time = 0; s->task->call_date = (profiling & HA_PROF_TASKS) ? now_mono_time() : 0; s->logs.accept_date = date; /* user-visible date for logging */ s->logs.tv_accept = now; /* corrected date for internal use */ s->logs.t_handshake = 0; /* There are no handshake in keep alive connection. */ s->logs.t_idle = -1; tv_zero(&s->logs.tv_request); s->logs.t_queue = -1; s->logs.t_connect = -1; s->logs.t_data = -1; s->logs.t_close = 0; s->logs.prx_queue_pos = 0; /* we get the number of pending conns before us */ s->logs.srv_queue_pos = 0; /* we will get this number soon */ s->logs.bytes_in = s->req.total = ci_data(&s->req); s->logs.bytes_out = s->res.total = ci_data(&s->res); if (objt_server(s->target)) { if (s->flags & SF_CURR_SESS) { s->flags &= ~SF_CURR_SESS; HA_ATOMIC_SUB(&__objt_server(s->target)->cur_sess, 1); } if (may_dequeue_tasks(objt_server(s->target), be)) process_srv_queue(objt_server(s->target)); } s->target = NULL; /* If we're doing keepalive, first call the mux detach() method * to let it know we want to detach without freing the connection. * We then can call si_release_endpoint() to destroy the conn_stream */ if (((s->txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) || !si_conn_ready(&s->si[1]) || (srv_conn && srv_conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) srv_conn = NULL; else if (!srv_conn->owner) { srv_conn->owner = s->sess; /* Add it unconditionally to the session list, it'll be removed * later if needed by session_check_idle_conn(), once we'll * have released the endpoint and know if it no longer has * attached streams, and so an idling connection */ if (!session_add_conn(s->sess, srv_conn, s->target)) { srv_conn->owner = NULL; /* Try to add the connection to the server idle list. * If it fails, as the connection no longer has an * owner, it will be destroy later by * si_release_endpoint(), anyway */ srv_add_to_idle_list(objt_server(srv_conn->target), srv_conn); srv_conn = NULL; } } si_release_endpoint(&s->si[1]); if (srv_conn && srv_conn->owner == s->sess) { if (session_check_idle_conn(s->sess, srv_conn) != 0) srv_conn = NULL; } s->si[1].state = s->si[1].prev_state = SI_ST_INI; s->si[1].err_type = SI_ET_NONE; s->si[1].conn_retries = 0; /* used for logging too */ s->si[1].exp = TICK_ETERNITY; s->si[1].flags &= SI_FL_ISBACK | SI_FL_DONT_WAKE; /* we're in the context of process_stream */ s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SF_DIRECT|SF_ASSIGNED|SF_ADDR_SET|SF_BE_ASSIGNED|SF_FORCE_PRST|SF_IGNORE_PRST); s->flags &= ~(SF_CURR_SESS|SF_REDIRECTABLE|SF_SRV_REUSED); s->flags &= ~(SF_ERR_MASK|SF_FINST_MASK|SF_REDISP); hlua_ctx_destroy(s->hlua); s->hlua = NULL; s->txn->meth = 0; http_reset_txn(s); s->txn->flags |= TX_NOT_FIRST | TX_WAIT_NEXT_RQ; if (prev_status == 401 || prev_status == 407) { /* In HTTP keep-alive mode, if we receive a 401, we still have * a chance of being able to send the visitor again to the same * server over the same connection. This is required by some * broken protocols such as NTLM, and anyway whenever there is * an opportunity for sending the challenge to the proper place, * it's better to do it (at least it helps with debugging), at * least for non-deterministic load balancing algorithms. */ s->txn->flags |= TX_PREFER_LAST; } /* Never ever allow to reuse a connection from a non-reuse backend */ if (srv_conn && (be->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) srv_conn->flags |= CO_FL_PRIVATE; if (fe->options2 & PR_O2_INDEPSTR) s->si[1].flags |= SI_FL_INDEP_STR; if (fe->options2 & PR_O2_NODELAY) { s->req.flags |= CF_NEVER_WAIT; s->res.flags |= CF_NEVER_WAIT; } /* we're removing the analysers, we MUST re-enable events detection. * We don't enable close on the response channel since it's either * already closed, or in keep-alive with an idle connection handler. */ channel_auto_read(&s->req); channel_auto_close(&s->req); channel_auto_read(&s->res); /* we're in keep-alive with an idle connection, monitor it if not already done */ if (srv_conn && LIST_ISEMPTY(&srv_conn->list)) { srv = objt_server(srv_conn->target); if (srv) { if (srv_conn->flags & CO_FL_PRIVATE) LIST_ADD(&srv->priv_conns[tid], &srv_conn->list); else if (prev_flags & TX_NOT_FIRST) /* note: we check the request, not the connection, but * this is valid for strategies SAFE and AGGR, and in * case of ALWS, we don't care anyway. */ LIST_ADD(&srv->safe_conns[tid], &srv_conn->list); else LIST_ADD(&srv->idle_conns[tid], &srv_conn->list); } } s->req.analysers = strm_li(s) ? strm_li(s)->analysers : 0; s->res.analysers = 0; } /* This function updates the request state machine according to the response * state machine and buffer flags. It returns 1 if it changes anything (flag * or state), otherwise zero. It ignores any state before HTTP_MSG_DONE, as * it is only used to find when a request/response couple is complete. Both * this function and its equivalent should loop until both return zero. It * can set its own state to DONE, CLOSING, CLOSED, TUNNEL, ERROR. */ int http_sync_req_state(struct stream *s) { struct channel *chn = &s->req; struct http_txn *txn = s->txn; unsigned int old_flags = chn->flags; unsigned int old_state = txn->req.msg_state; if (unlikely(txn->req.msg_state < HTTP_MSG_DONE)) return 0; if (txn->req.msg_state == HTTP_MSG_DONE) { /* No need to read anymore, the request was completely parsed. * We can shut the read side unless we want to abort_on_close, * or we have a POST request. The issue with POST requests is * that some browsers still send a CRLF after the request, and * this CRLF must be read so that it does not remain in the kernel * buffers, otherwise a close could cause an RST on some systems * (eg: Linux). * Note that if we're using keep-alive on the client side, we'd * rather poll now and keep the polling enabled for the whole * stream's life than enabling/disabling it between each * response and next request. */ if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_SCL) && ((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) && (!(s->be->options & PR_O_ABRT_CLOSE) || (s->si[0].flags & SI_FL_CLEAN_ABRT)) && txn->meth != HTTP_METH_POST) channel_dont_read(chn); /* if the server closes the connection, we want to immediately react * and close the socket to save packets and syscalls. */ s->si[1].flags |= SI_FL_NOHALF; /* In any case we've finished parsing the request so we must * disable Nagle when sending data because 1) we're not going * to shut this side, and 2) the server is waiting for us to * send pending data. */ chn->flags |= CF_NEVER_WAIT; if (txn->rsp.msg_state == HTTP_MSG_ERROR) goto wait_other_side; if (txn->rsp.msg_state < HTTP_MSG_DONE) { /* The server has not finished to respond, so we * don't want to move in order not to upset it. */ goto wait_other_side; } /* When we get here, it means that both the request and the * response have finished receiving. Depending on the connection * mode, we'll have to wait for the last bytes to leave in either * direction, and sometimes for a close to be effective. */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) { /* Server-close mode : queue a connection close to the server */ if (!(chn->flags & (CF_SHUTW|CF_SHUTW_NOW))) channel_shutw_now(chn); } else if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_CLO) { /* Option forceclose is set, or either side wants to close, * let's enforce it now that we're not expecting any new * data to come. The caller knows the stream is complete * once both states are CLOSED. * * However, there is an exception if the response * length is undefined. In this case, we need to wait * the close from the server. The response will be * switched in TUNNEL mode until the end. */ if (!(txn->rsp.flags & HTTP_MSGF_XFER_LEN) && txn->rsp.msg_state != HTTP_MSG_CLOSED) goto check_channel_flags; if (!(chn->flags & (CF_SHUTW|CF_SHUTW_NOW))) { channel_shutr_now(chn); channel_shutw_now(chn); } } else { /* The last possible modes are keep-alive and tunnel. Tunnel mode * will not have any analyser so it needs to poll for reads. */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_TUN) { channel_auto_read(chn); txn->req.msg_state = HTTP_MSG_TUNNEL; } } goto check_channel_flags; } if (txn->req.msg_state == HTTP_MSG_CLOSING) { http_msg_closing: /* nothing else to forward, just waiting for the output buffer * to be empty and for the shutw_now to take effect. */ if (channel_is_empty(chn)) { txn->req.msg_state = HTTP_MSG_CLOSED; goto http_msg_closed; } else if (chn->flags & CF_SHUTW) { txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; } goto wait_other_side; } if (txn->req.msg_state == HTTP_MSG_CLOSED) { http_msg_closed: /* if we don't know whether the server will close, we need to hard close */ if (txn->rsp.flags & HTTP_MSGF_XFER_LEN) s->si[1].flags |= SI_FL_NOLINGER; /* we want to close ASAP */ /* see above in MSG_DONE why we only do this in these states */ if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_SCL) && ((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) && (!(s->be->options & PR_O_ABRT_CLOSE) || (s->si[0].flags & SI_FL_CLEAN_ABRT))) channel_dont_read(chn); goto wait_other_side; } check_channel_flags: /* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */ if (chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) { /* if we've just closed an output, let's switch */ txn->req.msg_state = HTTP_MSG_CLOSING; goto http_msg_closing; } wait_other_side: return txn->req.msg_state != old_state || chn->flags != old_flags; } /* This function updates the response state machine according to the request * state machine and buffer flags. It returns 1 if it changes anything (flag * or state), otherwise zero. It ignores any state before HTTP_MSG_DONE, as * it is only used to find when a request/response couple is complete. Both * this function and its equivalent should loop until both return zero. It * can set its own state to DONE, CLOSING, CLOSED, TUNNEL, ERROR. */ int http_sync_res_state(struct stream *s) { struct channel *chn = &s->res; struct http_txn *txn = s->txn; unsigned int old_flags = chn->flags; unsigned int old_state = txn->rsp.msg_state; if (unlikely(txn->rsp.msg_state < HTTP_MSG_DONE)) return 0; if (txn->rsp.msg_state == HTTP_MSG_DONE) { /* In theory, we don't need to read anymore, but we must * still monitor the server connection for a possible close * while the request is being uploaded, so we don't disable * reading. */ /* channel_dont_read(chn); */ if (txn->req.msg_state == HTTP_MSG_ERROR) goto wait_other_side; if (txn->req.msg_state < HTTP_MSG_DONE) { /* The client seems to still be sending data, probably * because we got an error response during an upload. * We have the choice of either breaking the connection * or letting it pass through. Let's do the later. */ goto wait_other_side; } /* When we get here, it means that both the request and the * response have finished receiving. Depending on the connection * mode, we'll have to wait for the last bytes to leave in either * direction, and sometimes for a close to be effective. */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) { /* Server-close mode : shut read and wait for the request * side to close its output buffer. The caller will detect * when we're in DONE and the other is in CLOSED and will * catch that for the final cleanup. */ if (!(chn->flags & (CF_SHUTR|CF_SHUTR_NOW))) channel_shutr_now(chn); } else if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_CLO) { /* Option forceclose is set, or either side wants to close, * let's enforce it now that we're not expecting any new * data to come. The caller knows the stream is complete * once both states are CLOSED. */ if (!(chn->flags & (CF_SHUTW|CF_SHUTW_NOW))) { channel_shutr_now(chn); channel_shutw_now(chn); } } else { /* The last possible modes are keep-alive and tunnel. Tunnel will * need to forward remaining data. Keep-alive will need to monitor * for connection closing. */ channel_auto_read(chn); chn->flags |= CF_NEVER_WAIT; if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_TUN) txn->rsp.msg_state = HTTP_MSG_TUNNEL; } goto check_channel_flags; } if (txn->rsp.msg_state == HTTP_MSG_CLOSING) { http_msg_closing: /* nothing else to forward, just waiting for the output buffer * to be empty and for the shutw_now to take effect. */ if (channel_is_empty(chn)) { txn->rsp.msg_state = HTTP_MSG_CLOSED; goto http_msg_closed; } else if (chn->flags & CF_SHUTW) { txn->rsp.err_state = txn->rsp.msg_state; txn->rsp.msg_state = HTTP_MSG_ERROR; HA_ATOMIC_ADD(&s->be->be_counters.cli_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.cli_aborts, 1); } goto wait_other_side; } if (txn->rsp.msg_state == HTTP_MSG_CLOSED) { http_msg_closed: /* drop any pending data */ channel_truncate(chn); channel_auto_close(chn); channel_auto_read(chn); goto wait_other_side; } check_channel_flags: /* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */ if (chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) { /* if we've just closed an output, let's switch */ txn->rsp.msg_state = HTTP_MSG_CLOSING; goto http_msg_closing; } wait_other_side: /* We force the response to leave immediately if we're waiting for the * other side, since there is no pending shutdown to push it out. */ if (!channel_is_empty(chn)) chn->flags |= CF_SEND_DONTWAIT; return txn->rsp.msg_state != old_state || chn->flags != old_flags; } /* Resync the request and response state machines. */ void http_resync_states(struct stream *s) { struct http_txn *txn = s->txn; #ifdef DEBUG_FULL int old_req_state = txn->req.msg_state; int old_res_state = txn->rsp.msg_state; #endif http_sync_req_state(s); while (1) { if (!http_sync_res_state(s)) break; if (!http_sync_req_state(s)) break; } DPRINTF(stderr,"[%u] %s: stream=%p old=%s,%s cur=%s,%s " "req->analysers=0x%08x res->analysers=0x%08x\n", now_ms, __FUNCTION__, s, h1_msg_state_str(old_req_state), h1_msg_state_str(old_res_state), h1_msg_state_str(txn->req.msg_state), h1_msg_state_str(txn->rsp.msg_state), s->req.analysers, s->res.analysers); /* OK, both state machines agree on a compatible state. * There are a few cases we're interested in : * - HTTP_MSG_CLOSED on both sides means we've reached the end in both * directions, so let's simply disable both analysers. * - HTTP_MSG_CLOSED on the response only or HTTP_MSG_ERROR on either * means we must abort the request. * - HTTP_MSG_TUNNEL on either means we have to disable analyser on * corresponding channel. * - HTTP_MSG_DONE or HTTP_MSG_CLOSED on the request and HTTP_MSG_DONE * on the response with server-close mode means we've completed one * request and we must re-initialize the server connection. */ if (txn->req.msg_state == HTTP_MSG_CLOSED && txn->rsp.msg_state == HTTP_MSG_CLOSED) { s->req.analysers &= AN_REQ_FLT_END; channel_auto_close(&s->req); channel_auto_read(&s->req); s->res.analysers &= AN_RES_FLT_END; channel_auto_close(&s->res); channel_auto_read(&s->res); } else if (txn->rsp.msg_state == HTTP_MSG_CLOSED || txn->rsp.msg_state == HTTP_MSG_ERROR || txn->req.msg_state == HTTP_MSG_ERROR) { s->res.analysers &= AN_RES_FLT_END; channel_auto_close(&s->res); channel_auto_read(&s->res); s->req.analysers &= AN_REQ_FLT_END; channel_abort(&s->req); channel_auto_close(&s->req); channel_auto_read(&s->req); channel_truncate(&s->req); } else if (txn->req.msg_state == HTTP_MSG_TUNNEL || txn->rsp.msg_state == HTTP_MSG_TUNNEL) { if (txn->req.msg_state == HTTP_MSG_TUNNEL) { s->req.analysers &= AN_REQ_FLT_END; if (HAS_REQ_DATA_FILTERS(s)) s->req.analysers |= AN_REQ_FLT_XFER_DATA; } if (txn->rsp.msg_state == HTTP_MSG_TUNNEL) { s->res.analysers &= AN_RES_FLT_END; if (HAS_RSP_DATA_FILTERS(s)) s->res.analysers |= AN_RES_FLT_XFER_DATA; } channel_auto_close(&s->req); channel_auto_read(&s->req); channel_auto_close(&s->res); channel_auto_read(&s->res); } else if ((txn->req.msg_state == HTTP_MSG_DONE || txn->req.msg_state == HTTP_MSG_CLOSED) && txn->rsp.msg_state == HTTP_MSG_DONE && ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL)) { /* server-close/keep-alive: terminate this transaction, * possibly killing the server connection and reinitialize * a fresh-new transaction, but only once we're sure there's * enough room in the request and response buffer to process * another request. They must not hold any pending output data * and the response buffer must realigned * (realign is done is http_end_txn_clean_session). */ if (co_data(&s->req)) s->req.flags |= CF_WAKE_WRITE; else if (co_data(&s->res)) s->res.flags |= CF_WAKE_WRITE; else { s->req.analysers = AN_REQ_FLT_END; s->res.analysers = AN_RES_FLT_END; txn->flags |= TX_WAIT_CLEANUP; } } } /* This function is an analyser which forwards request body (including chunk * sizes if any). It is called as soon as we must forward, even if we forward * zero byte. The only situation where it must not be called is when we're in * tunnel mode and we want to forward till the close. It's used both to forward * remaining data and to resync after end of body. It expects the msg_state to * be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to * read more data, or 1 once we can go on with next request or end the stream. * When in MSG_DATA or MSG_TRAILERS, it will automatically forward chunk_len * bytes of pending data + the headers if not already done. */ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &s->txn->req; int ret; if (IS_HTX_STRM(s)) return htx_request_forward_body(s, req, an_bit); DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, req, req->rex, req->wex, req->flags, ci_data(req), req->analysers); if (unlikely(msg->msg_state < HTTP_MSG_BODY)) return 0; if ((req->flags & (CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) || ((req->flags & CF_SHUTW) && (req->to_forward || co_data(req)))) { /* Output closed while we were sending data. We must abort and * wake the other side up. */ msg->err_state = msg->msg_state; msg->msg_state = HTTP_MSG_ERROR; http_resync_states(s); return 1; } /* Note that we don't have to send 100-continue back because we don't * need the data to complete our job, and it's up to the server to * decide whether to return 100, 417 or anything else in return of * an "Expect: 100-continue" header. */ if (msg->msg_state == HTTP_MSG_BODY) { msg->msg_state = ((msg->flags & HTTP_MSGF_TE_CHNK) ? HTTP_MSG_CHUNK_SIZE : HTTP_MSG_DATA); /* TODO/filters: when http-buffer-request option is set or if a * rule on url_param exists, the first chunk size could be * already parsed. In that case, msg->next is after the chunk * size (including the CRLF after the size). So this case should * be handled to */ } /* Some post-connect processing might want us to refrain from starting to * forward data. Currently, the only reason for this is "balance url_param" * whichs need to parse/process the request after we've enabled forwarding. */ if (unlikely(msg->flags & HTTP_MSGF_WAIT_CONN)) { if (!(s->res.flags & CF_READ_ATTACHED)) { channel_auto_connect(req); req->flags |= CF_WAKE_CONNECT; channel_dont_close(req); /* don't fail on early shutr */ goto waiting; } msg->flags &= ~HTTP_MSGF_WAIT_CONN; } /* in most states, we should abort in case of early close */ channel_auto_close(req); if (req->to_forward) { /* We can't process the buffer's contents yet */ req->flags |= CF_WAKE_WRITE; goto missing_data_or_waiting; } if (msg->msg_state < HTTP_MSG_DONE) { ret = ((msg->flags & HTTP_MSGF_TE_CHNK) ? http_msg_forward_chunked_body(s, msg) : http_msg_forward_body(s, msg)); if (!ret) goto missing_data_or_waiting; if (ret < 0) goto return_bad_req; } /* other states, DONE...TUNNEL */ /* we don't want to forward closes on DONE except in tunnel mode. */ if ((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) channel_dont_close(req); http_resync_states(s); if (!(req->analysers & an_bit)) { if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { if (req->flags & CF_SHUTW) { /* request errors are most likely due to the * server aborting the transfer. */ goto aborted_xfer; } if (msg->err_pos >= 0) http_capture_bad_message(sess->fe, s, msg, msg->err_state, s->be); goto return_bad_req; } return 1; } /* If "option abortonclose" is set on the backend, we want to monitor * the client's connection and forward any shutdown notification to the * server, which will decide whether to close or to go on processing the * request. We only do that in tunnel mode, and not in other modes since * it can be abused to exhaust source ports. */ if ((s->be->options & PR_O_ABRT_CLOSE) && !(s->si[0].flags & SI_FL_CLEAN_ABRT)) { channel_auto_read(req); if ((req->flags & (CF_SHUTR|CF_READ_NULL)) && ((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN)) s->si[1].flags |= SI_FL_NOLINGER; channel_auto_close(req); } else if (s->txn->meth == HTTP_METH_POST) { /* POST requests may require to read extra CRLF sent by broken * browsers and which could cause an RST to be sent upon close * on some systems (eg: Linux). */ channel_auto_read(req); } return 0; missing_data_or_waiting: /* stop waiting for data if the input is closed before the end */ if (msg->msg_state < HTTP_MSG_ENDING && req->flags & CF_SHUTR) { if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (!(s->flags & SF_FINST_MASK)) { if (txn->rsp.msg_state < HTTP_MSG_ERROR) s->flags |= SF_FINST_H; else s->flags |= SF_FINST_D; } HA_ATOMIC_ADD(&sess->fe->fe_counters.cli_aborts, 1); HA_ATOMIC_ADD(&s->be->be_counters.cli_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.cli_aborts, 1); goto return_bad_req_stats_ok; } waiting: /* waiting for the last bits to leave the buffer */ if (req->flags & CF_SHUTW) goto aborted_xfer; /* When TE: chunked is used, we need to get there again to parse remaining * chunks even if the client has closed, so we don't want to set CF_DONTCLOSE. * And when content-length is used, we never want to let the possible * shutdown be forwarded to the other side, as the state machine will * take care of it once the client responds. It's also important to * prevent TIME_WAITs from accumulating on the backend side, and for * HTTP/2 where the last frame comes with a shutdown. */ if (msg->flags & (HTTP_MSGF_TE_CHNK|HTTP_MSGF_CNT_LEN)) channel_dont_close(req); /* We know that more data are expected, but we couldn't send more that * what we did. So we always set the CF_EXPECT_MORE flag so that the * system knows it must not set a PUSH on this first part. Interactive * modes are already handled by the stream sock layer. We must not do * this in content-length mode because it could present the MSG_MORE * flag with the last block of forwarded data, which would cause an * additional delay to be observed by the receiver. */ if (msg->flags & HTTP_MSGF_TE_CHNK) req->flags |= CF_EXPECT_MORE; return 0; return_bad_req: /* let's centralize all bad requests */ HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_req, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->failed_req, 1); return_bad_req_stats_ok: txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; if (txn->status) { /* Note: we don't send any error if some data were already sent */ http_reply_and_close(s, txn->status, NULL); } else { txn->status = 400; http_reply_and_close(s, txn->status, http_error_message(s)); } req->analysers &= AN_REQ_FLT_END; s->res.analysers &= AN_RES_FLT_END; /* we're in data phase, we want to abort both directions */ if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) { if (txn->rsp.msg_state < HTTP_MSG_ERROR) s->flags |= SF_FINST_H; else s->flags |= SF_FINST_D; } return 0; aborted_xfer: txn->req.err_state = txn->req.msg_state; txn->req.msg_state = HTTP_MSG_ERROR; if (txn->status) { /* Note: we don't send any error if some data were already sent */ http_reply_and_close(s, txn->status, NULL); } else { txn->status = 502; http_reply_and_close(s, txn->status, http_error_message(s)); } req->analysers &= AN_REQ_FLT_END; s->res.analysers &= AN_RES_FLT_END; /* we're in data phase, we want to abort both directions */ HA_ATOMIC_ADD(&sess->fe->fe_counters.srv_aborts, 1); HA_ATOMIC_ADD(&s->be->be_counters.srv_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.srv_aborts, 1); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_SRVCL; if (!(s->flags & SF_FINST_MASK)) { if (txn->rsp.msg_state < HTTP_MSG_ERROR) s->flags |= SF_FINST_H; else s->flags |= SF_FINST_D; } return 0; } /* This stream analyser waits for a complete HTTP response. It returns 1 if the * processing can continue on next analysers, or zero if it either needs more * data or wants to immediately abort the response (eg: timeout, error, ...). It * is tied to AN_RES_WAIT_HTTP and may may remove itself from s->res.analysers * when it has nothing left to do, and may remove any analyser when it wants to * abort. */ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->rsp; struct hdr_ctx ctx; struct connection *srv_conn; int use_close_only; int cur_idx; int n; srv_conn = cs_conn(objt_cs(s->si[1].end)); if (IS_HTX_STRM(s)) return htx_wait_for_response(s, rep, an_bit); DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, rep, rep->rex, rep->wex, rep->flags, ci_data(rep), rep->analysers); /* * Now parse the partial (or complete) lines. * We will check the response syntax, and also join multi-line * headers. An index of all the lines will be elaborated while * parsing. * * For the parsing, we use a 28 states FSM. * * Here is the information we currently have : * ci_head(rep) = beginning of response * ci_head(rep) + msg->eoh = end of processed headers / start of current one * ci_tail(rep) = end of input data * msg->eol = end of current header or line (LF or CRLF) * msg->next = first non-visited byte */ next_one: /* There's a protected area at the end of the buffer for rewriting * purposes. We don't want to start to parse the request if the * protected area is affected, because we may have to move processed * data later, which is much more complicated. */ if (c_data(rep) && msg->msg_state < HTTP_MSG_ERROR) { if (unlikely(!channel_is_rewritable(rep))) { /* some data has still not left the buffer, wake us once that's done */ if (rep->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) goto abort_response; channel_dont_close(rep); rep->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ rep->flags |= CF_WAKE_WRITE; return 0; } if (unlikely(ci_tail(rep) < c_ptr(rep, msg->next) || ci_tail(rep) > b_wrap(&rep->buf) - global.tune.maxrewrite)) channel_slow_realign(rep, trash.area); if (likely(msg->next < ci_data(rep))) http_msg_analyzer(msg, &txn->hdr_idx); } /* 1: we might have to print this header in debug mode */ if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && msg->msg_state >= HTTP_MSG_BODY)) { char *eol, *sol; sol = ci_head(rep); eol = sol + (msg->sl.st.l ? msg->sl.st.l : ci_data(rep)); debug_hdr("srvrep", s, sol, eol); sol += hdr_idx_first_pos(&txn->hdr_idx); cur_idx = hdr_idx_first_idx(&txn->hdr_idx); while (cur_idx) { eol = sol + txn->hdr_idx.v[cur_idx].len; debug_hdr("srvhdr", s, sol, eol); sol = eol + txn->hdr_idx.v[cur_idx].cr + 1; cur_idx = txn->hdr_idx.v[cur_idx].next; } } /* * Now we quickly check if we have found a full valid response. * If not so, we check the FD and buffer states before leaving. * A full response is indicated by the fact that we have seen * the double LF/CRLF, so the state is >= HTTP_MSG_BODY. Invalid * responses are checked first. * * Depending on whether the client is still there or not, we * may send an error response back or not. Note that normally * we should only check for HTTP status there, and check I/O * errors somewhere else. */ if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* Invalid response */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { /* we detected a parsing error. We want to archive this response * in the dedicated proxy area for later troubleshooting. */ hdr_response_bad: if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); } abort_response: channel_auto_close(rep); rep->analysers &= AN_RES_FLT_END; txn->status = 502; s->si[1].flags |= SI_FL_NOLINGER; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; return 0; } /* too large response does not fit in buffer. */ else if (channel_full(rep, global.tune.maxrewrite)) { if (msg->err_pos < 0) msg->err_pos = ci_data(rep); goto hdr_response_bad; } /* read error */ else if (rep->flags & CF_READ_ERROR) { if (msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); else if (txn->flags & TX_NOT_FIRST) goto abort_keep_alive; HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR); } channel_auto_close(rep); rep->analysers &= AN_RES_FLT_END; txn->status = 502; /* Check to see if the server refused the early data. * If so, just send a 425 */ if (objt_cs(s->si[1].end)) { struct connection *conn = objt_cs(s->si[1].end)->conn; if (conn->err_code == CO_ER_SSL_EARLY_FAILED) txn->status = 425; } s->si[1].flags |= SI_FL_NOLINGER; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_SRVCL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; return 0; } /* read timeout : return a 504 to the client. */ else if (rep->flags & CF_READ_TIMEOUT) { if (msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT); } channel_auto_close(rep); rep->analysers &= AN_RES_FLT_END; txn->status = 504; s->si[1].flags |= SI_FL_NOLINGER; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_SRVTO; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; return 0; } /* client abort with an abortonclose */ else if ((rep->flags & CF_SHUTR) && ((s->req.flags & (CF_SHUTR|CF_SHUTW)) == (CF_SHUTR|CF_SHUTW))) { HA_ATOMIC_ADD(&sess->fe->fe_counters.cli_aborts, 1); HA_ATOMIC_ADD(&s->be->be_counters.cli_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.cli_aborts, 1); rep->analysers &= AN_RES_FLT_END; channel_auto_close(rep); txn->status = 400; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; /* process_stream() will take care of the error */ return 0; } /* close from server, capture the response if the server has started to respond */ else if (rep->flags & CF_SHUTR) { if (msg->msg_state >= HTTP_MSG_RPVER || msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); else if (txn->flags & TX_NOT_FIRST) goto abort_keep_alive; HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE); } channel_auto_close(rep); rep->analysers &= AN_RES_FLT_END; txn->status = 502; s->si[1].flags |= SI_FL_NOLINGER; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_SRVCL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; return 0; } /* write error to client (we don't send any message then) */ else if (rep->flags & CF_WRITE_ERROR) { if (msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); else if (txn->flags & TX_NOT_FIRST) goto abort_keep_alive; HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); rep->analysers &= AN_RES_FLT_END; channel_auto_close(rep); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; /* process_stream() will take care of the error */ return 0; } channel_dont_close(rep); rep->flags |= CF_READ_DONTWAIT; /* try to get back here ASAP */ return 0; } /* More interesting part now : we know that we have a complete * response which at least looks like HTTP. We have an indicator * of each header's length, so we can parse them quickly. */ if (unlikely(msg->err_pos >= 0)) http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe); /* * 1: get the status code */ n = ci_head(rep)[msg->sl.st.c] - '0'; if (n < 1 || n > 5) n = 0; /* when the client triggers a 4xx from the server, it's most often due * to a missing object or permission. These events should be tracked * because if they happen often, it may indicate a brute force or a * vulnerability scan. */ if (n == 4) stream_inc_http_err_ctr(s); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.p.http.rsp[n], 1); /* RFC7230#2.6 has enforced the format of the HTTP version string to be * exactly one digit "." one digit. This check may be disabled using * option accept-invalid-http-response. */ if (!(s->be->options2 & PR_O2_RSPBUG_OK)) { if (msg->sl.st.v_l != 8) { msg->err_pos = 0; goto hdr_response_bad; } if (ci_head(rep)[4] != '/' || !isdigit((unsigned char)ci_head(rep)[5]) || ci_head(rep)[6] != '.' || !isdigit((unsigned char)ci_head(rep)[7])) { msg->err_pos = 4; goto hdr_response_bad; } } /* check if the response is HTTP/1.1 or above */ if ((msg->sl.st.v_l == 8) && ((ci_head(rep)[5] > '1') || ((ci_head(rep)[5] == '1') && (ci_head(rep)[7] >= '1')))) msg->flags |= HTTP_MSGF_VER_11; /* "connection" has not been parsed yet */ txn->flags &= ~(TX_HDR_CONN_PRS|TX_HDR_CONN_CLO|TX_HDR_CONN_KAL|TX_HDR_CONN_UPG|TX_CON_CLO_SET|TX_CON_KAL_SET); /* transfer length unknown*/ msg->flags &= ~HTTP_MSGF_XFER_LEN; txn->status = strl2ui(ci_head(rep) + msg->sl.st.c, msg->sl.st.c_l); /* Adjust server's health based on status code. Note: status codes 501 * and 505 are triggered on demand by client request, so we must not * count them as server failures. */ if (objt_server(s->target)) { if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505)) health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_OK); else health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_STS); } /* * We may be facing a 100-continue response, or any other informational * 1xx response which is non-final, in which case this is not the right * response, and we're waiting for the next one. Let's allow this response * to go to the client and wait for the next one. There's an exception for * 101 which is used later in the code to switch protocols. */ if (txn->status < 200 && (txn->status == 100 || txn->status >= 102)) { hdr_idx_init(&txn->hdr_idx); msg->next -= channel_forward(rep, msg->next); msg->msg_state = HTTP_MSG_RPBEFORE; txn->status = 0; s->logs.t_data = -1; /* was not a response yet */ FLT_STRM_CB(s, flt_http_reset(s, msg)); goto next_one; } /* * 2: check for cacheability. */ switch (txn->status) { case 200: case 203: case 204: case 206: case 300: case 301: case 404: case 405: case 410: case 414: case 501: break; default: /* RFC7231#6.1: * Responses with status codes that are defined as * cacheable by default (e.g., 200, 203, 204, 206, * 300, 301, 404, 405, 410, 414, and 501 in this * specification) can be reused by a cache with * heuristic expiration unless otherwise indicated * by the method definition or explicit cache * controls [RFC7234]; all other status codes are * not cacheable by default. */ txn->flags &= ~(TX_CACHEABLE | TX_CACHE_COOK); break; } /* * 3: we may need to capture headers */ s->logs.logwait &= ~LW_RESP; if (unlikely((s->logs.logwait & LW_RSPHDR) && s->res_cap)) http_capture_headers(ci_head(rep), &txn->hdr_idx, s->res_cap, sess->fe->rsp_cap); /* 4: determine the transfer-length according to RFC2616 #4.4, updated * by RFC7230#3.3.3 : * * The length of a message body is determined by one of the following * (in order of precedence): * * 1. Any 2xx (Successful) response to a CONNECT request implies that * the connection will become a tunnel immediately after the empty * line that concludes the header fields. A client MUST ignore * any Content-Length or Transfer-Encoding header fields received * in such a message. Any 101 response (Switching Protocols) is * managed in the same manner. * * 2. Any response to a HEAD request and any response with a 1xx * (Informational), 204 (No Content), or 304 (Not Modified) status * code is always terminated by the first empty line after the * header fields, regardless of the header fields present in the * message, and thus cannot contain a message body. * * 3. If a Transfer-Encoding header field is present and the chunked * transfer coding (Section 4.1) is the final encoding, the message * body length is determined by reading and decoding the chunked * data until the transfer coding indicates the data is complete. * * If a Transfer-Encoding header field is present in a response and * the chunked transfer coding is not the final encoding, the * message body length is determined by reading the connection until * it is closed by the server. If a Transfer-Encoding header field * is present in a request and the chunked transfer coding is not * the final encoding, the message body length cannot be determined * reliably; the server MUST respond with the 400 (Bad Request) * status code and then close the connection. * * If a message is received with both a Transfer-Encoding and a * Content-Length header field, the Transfer-Encoding overrides the * Content-Length. Such a message might indicate an attempt to * perform request smuggling (Section 9.5) or response splitting * (Section 9.4) and ought to be handled as an error. A sender MUST * remove the received Content-Length field prior to forwarding such * a message downstream. * * 4. If a message is received without Transfer-Encoding and with * either multiple Content-Length header fields having differing * field-values or a single Content-Length header field having an * invalid value, then the message framing is invalid and the * recipient MUST treat it as an unrecoverable error. If this is a * request message, the server MUST respond with a 400 (Bad Request) * status code and then close the connection. If this is a response * message received by a proxy, the proxy MUST close the connection * to the server, discard the received response, and send a 502 (Bad * Gateway) response to the client. If this is a response message * received by a user agent, the user agent MUST close the * connection to the server and discard the received response. * * 5. If a valid Content-Length header field is present without * Transfer-Encoding, its decimal value defines the expected message * body length in octets. If the sender closes the connection or * the recipient times out before the indicated number of octets are * received, the recipient MUST consider the message to be * incomplete and close the connection. * * 6. If this is a request message and none of the above are true, then * the message body length is zero (no message body is present). * * 7. Otherwise, this is a response message without a declared message * body length, so the message body length is determined by the * number of octets received prior to the server closing the * connection. */ /* Skip parsing if no content length is possible. The response flags * remain 0 as well as the chunk_len, which may or may not mirror * the real header value, and we note that we know the response's length. * FIXME: should we parse anyway and return an error on chunked encoding ? */ if (unlikely((txn->meth == HTTP_METH_CONNECT && txn->status == 200) || txn->status == 101)) { /* Either we've established an explicit tunnel, or we're * switching the protocol. In both cases, we're very unlikely * to understand the next protocols. We have to switch to tunnel * mode, so that we transfer the request and responses then let * this protocol pass unmodified. When we later implement specific * parsers for such protocols, we'll want to check the Upgrade * header which contains information about that protocol for * responses with status 101 (eg: see RFC2817 about TLS). */ txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_TUN; msg->flags |= HTTP_MSGF_XFER_LEN; goto end; } if (txn->meth == HTTP_METH_HEAD || (txn->status >= 100 && txn->status < 200) || txn->status == 204 || txn->status == 304) { msg->flags |= HTTP_MSGF_XFER_LEN; goto skip_content_length; } use_close_only = 0; ctx.idx = 0; while (http_find_header2("Transfer-Encoding", 17, ci_head(rep), &txn->hdr_idx, &ctx)) { if (ctx.vlen == 7 && strncasecmp(ctx.line + ctx.val, "chunked", 7) == 0) msg->flags |= (HTTP_MSGF_TE_CHNK | HTTP_MSGF_XFER_LEN); else if (msg->flags & HTTP_MSGF_TE_CHNK) { /* bad transfer-encoding (chunked followed by something else) */ use_close_only = 1; msg->flags &= ~(HTTP_MSGF_TE_CHNK | HTTP_MSGF_XFER_LEN); break; } } /* Chunked responses must have their content-length removed */ ctx.idx = 0; if (use_close_only || (msg->flags & HTTP_MSGF_TE_CHNK)) { while (http_find_header2("Content-Length", 14, ci_head(rep), &txn->hdr_idx, &ctx)) http_remove_header2(msg, &txn->hdr_idx, &ctx); } else while (http_find_header2("Content-Length", 14, ci_head(rep), &txn->hdr_idx, &ctx)) { signed long long cl; if (!ctx.vlen) { msg->err_pos = ctx.line + ctx.val - ci_head(rep); goto hdr_response_bad; } if (strl2llrc(ctx.line + ctx.val, ctx.vlen, &cl)) { msg->err_pos = ctx.line + ctx.val - ci_head(rep); goto hdr_response_bad; /* parse failure */ } if (cl < 0) { msg->err_pos = ctx.line + ctx.val - ci_head(rep); goto hdr_response_bad; } if ((msg->flags & HTTP_MSGF_CNT_LEN) && (msg->chunk_len != cl)) { msg->err_pos = ctx.line + ctx.val - ci_head(rep); goto hdr_response_bad; /* already specified, was different */ } msg->flags |= HTTP_MSGF_CNT_LEN | HTTP_MSGF_XFER_LEN; msg->body_len = msg->chunk_len = cl; } /* check for NTML authentication headers in 401 (WWW-Authenticate) and * 407 (Proxy-Authenticate) responses and set the connection to private */ if (srv_conn && txn->status == 401) { /* check for Negotiate/NTLM WWW-Authenticate headers */ ctx.idx = 0; while (http_find_header2("WWW-Authenticate", 16, ci_head(rep), &txn->hdr_idx, &ctx)) { if ((ctx.vlen >= 9 && word_match(ctx.line + ctx.val, ctx.vlen, "Negotiate", 9)) || (ctx.vlen >= 4 && word_match(ctx.line + ctx.val, ctx.vlen, "NTLM", 4))) srv_conn->flags |= CO_FL_PRIVATE; } } else if (srv_conn && txn->status == 407) { /* check for Negotiate/NTLM Proxy-Authenticate headers */ ctx.idx = 0; while (http_find_header2("Proxy-Authenticate", 18, ci_head(rep), &txn->hdr_idx, &ctx)) { if ((ctx.vlen >= 9 && word_match(ctx.line + ctx.val, ctx.vlen, "Negotiate", 9)) || (ctx.vlen >= 4 && word_match(ctx.line + ctx.val, ctx.vlen, "NTLM", 4))) srv_conn->flags |= CO_FL_PRIVATE; } } skip_content_length: /* Now we have to check if we need to modify the Connection header. * This is more difficult on the response than it is on the request, * because we can have two different HTTP versions and we don't know * how the client will interprete a response. For instance, let's say * that the client sends a keep-alive request in HTTP/1.0 and gets an * HTTP/1.1 response without any header. Maybe it will bound itself to * HTTP/1.0 because it only knows about it, and will consider the lack * of header as a close, or maybe it knows HTTP/1.1 and can consider * the lack of header as a keep-alive. Thus we will use two flags * indicating how a request MAY be understood by the client. In case * of multiple possibilities, we'll fix the header to be explicit. If * ambiguous cases such as both close and keepalive are seen, then we * will fall back to explicit close. Note that we won't take risks with * HTTP/1.0 clients which may not necessarily understand keep-alive. * See doc/internals/connection-header.txt for the complete matrix. */ if ((txn->status >= 200) && !(txn->flags & TX_HDR_CONN_PRS) && (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { int to_del = 0; /* on unknown transfer length, we must close */ if (!(msg->flags & HTTP_MSGF_XFER_LEN)) txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO; /* now adjust header transformations depending on current state */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_CLO) { to_del |= 2; /* remove "keep-alive" on any response */ if (!(msg->flags & HTTP_MSGF_VER_11)) to_del |= 1; /* remove "close" for HTTP/1.0 responses */ } else { /* SCL / KAL */ to_del |= 1; /* remove "close" on any response */ if (txn->req.flags & msg->flags & HTTP_MSGF_VER_11) to_del |= 2; /* remove "keep-alive" on pure 1.1 responses */ } /* Parse and remove some headers from the connection header */ http_parse_connection_header(txn, msg, to_del); /* Some keep-alive responses are converted to Server-close if * the server wants to close. */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL) { if ((txn->flags & TX_HDR_CONN_CLO) || (!(txn->flags & TX_HDR_CONN_KAL) && !(msg->flags & HTTP_MSGF_VER_11))) txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_SCL; } } end: /* we want to have the response time before we start processing it */ s->logs.t_data = tv_ms_elapsed(&s->logs.tv_accept, &now); /* end of job, return OK */ rep->analysers &= ~an_bit; rep->analyse_exp = TICK_ETERNITY; channel_auto_close(rep); return 1; abort_keep_alive: /* A keep-alive request to the server failed on a network error. * The client is required to retry. We need to close without returning * any other information so that the client retries. */ txn->status = 0; rep->analysers &= AN_RES_FLT_END; s->req.analysers &= AN_REQ_FLT_END; channel_auto_close(rep); s->logs.logwait = 0; s->logs.level = 0; s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */ channel_truncate(rep); http_reply_and_close(s, txn->status, NULL); return 0; } /* This function performs all the processing enabled for the current response. * It normally returns 1 unless it wants to break. It relies on buffers flags, * and updates s->res.analysers. It might make sense to explode it into several * other functions. It works like process_request (see indications above). */ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->rsp; struct proxy *cur_proxy; struct cond_wordlist *wl; enum rule_result ret = HTTP_RULE_RES_CONT; if (IS_HTX_STRM(s)) return htx_process_res_common(s, rep, an_bit, px); DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, rep, rep->rex, rep->wex, rep->flags, ci_data(rep), rep->analysers); if (unlikely(msg->msg_state < HTTP_MSG_BODY)) /* we need more data */ return 0; /* The stats applet needs to adjust the Connection header but we don't * apply any filter there. */ if (unlikely(objt_applet(s->target) == &http_stats_applet)) { rep->analysers &= ~an_bit; rep->analyse_exp = TICK_ETERNITY; goto skip_filters; } /* * We will have to evaluate the filters. * As opposed to version 1.2, now they will be evaluated in the * filters order and not in the header order. This means that * each filter has to be validated among all headers. * * Filters are tried with ->be first, then with ->fe if it is * different from ->be. * * Maybe we are in resume condiion. In this case I choose the * "struct proxy" which contains the rule list matching the resume * pointer. If none of theses "struct proxy" match, I initialise * the process with the first one. * * In fact, I check only correspondance betwwen the current list * pointer and the ->fe rule list. If it doesn't match, I initialize * the loop with the ->be. */ if (s->current_rule_list == &sess->fe->http_res_rules) cur_proxy = sess->fe; else cur_proxy = s->be; while (1) { struct proxy *rule_set = cur_proxy; /* evaluate http-response rules */ if (ret == HTTP_RULE_RES_CONT) { ret = http_res_get_intercept_rule(cur_proxy, &cur_proxy->http_res_rules, s); if (ret == HTTP_RULE_RES_BADREQ) goto return_srv_prx_502; if (ret == HTTP_RULE_RES_DONE) { rep->analysers &= ~an_bit; rep->analyse_exp = TICK_ETERNITY; return 1; } } /* we need to be called again. */ if (ret == HTTP_RULE_RES_YIELD) { channel_dont_close(rep); return 0; } /* try headers filters */ if (rule_set->rsp_exp != NULL) { if (apply_filters_to_response(s, rep, rule_set) < 0) { return_bad_resp: if (objt_server(s->target)) { HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP); } HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); return_srv_prx_502: rep->analysers &= AN_RES_FLT_END; txn->status = 502; s->logs.t_data = -1; /* was not a valid response */ s->si[1].flags |= SI_FL_NOLINGER; channel_truncate(rep); http_reply_and_close(s, txn->status, http_error_message(s)); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_H; return 0; } } /* has the response been denied ? */ if (txn->flags & TX_SVDENY) { if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_secu, 1); HA_ATOMIC_ADD(&s->be->be_counters.denied_resp, 1); HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_resp, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->denied_resp, 1); goto return_srv_prx_502; } /* add response headers from the rule sets in the same order */ list_for_each_entry(wl, &rule_set->rsp_add, list) { if (txn->status < 200 && txn->status != 101) break; if (wl->cond) { int ret = acl_exec_cond(wl->cond, px, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)wl->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } if (unlikely(http_header_add_tail2(&txn->rsp, &txn->hdr_idx, wl->s, strlen(wl->s)) < 0)) goto return_bad_resp; } /* check whether we're already working on the frontend */ if (cur_proxy == sess->fe) break; cur_proxy = sess->fe; } /* After this point, this anayzer can't return yield, so we can * remove the bit corresponding to this analyzer from the list. * * Note that the intermediate returns and goto found previously * reset the analyzers. */ rep->analysers &= ~an_bit; rep->analyse_exp = TICK_ETERNITY; /* OK that's all we can do for 1xx responses */ if (unlikely(txn->status < 200 && txn->status != 101)) goto skip_header_mangling; /* * Now check for a server cookie. */ if (s->be->cookie_name || sess->fe->capture_name || (s->be->options & PR_O_CHK_CACHE)) manage_server_side_cookies(s, rep); /* * Check for cache-control or pragma headers if required. */ if ((s->be->options & PR_O_CHK_CACHE) || (s->be->ck_opts & PR_CK_NOC)) check_response_for_cacheability(s, rep); /* * Add server cookie in the response if needed */ if (objt_server(s->target) && (s->be->ck_opts & PR_CK_INS) && !((txn->flags & TX_SCK_FOUND) && (s->be->ck_opts & PR_CK_PSV)) && (!(s->flags & SF_DIRECT) || ((s->be->cookie_maxidle || txn->cookie_last_date) && (!txn->cookie_last_date || (txn->cookie_last_date - date.tv_sec) < 0)) || (s->be->cookie_maxlife && !txn->cookie_first_date) || // set the first_date (!s->be->cookie_maxlife && txn->cookie_first_date)) && // remove the first_date (!(s->be->ck_opts & PR_CK_POST) || (txn->meth == HTTP_METH_POST)) && !(s->flags & SF_IGNORE_PRST)) { /* the server is known, it's not the one the client requested, or the * cookie's last seen date needs to be refreshed. We have to * insert a set-cookie here, except if we want to insert only on POST * requests and this one isn't. Note that servers which don't have cookies * (eg: some backup servers) will return a full cookie removal request. */ if (!objt_server(s->target)->cookie) { chunk_printf(&trash, "Set-Cookie: %s=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/", s->be->cookie_name); } else { chunk_printf(&trash, "Set-Cookie: %s=%s", s->be->cookie_name, objt_server(s->target)->cookie); if (s->be->cookie_maxidle || s->be->cookie_maxlife) { /* emit last_date, which is mandatory */ trash.area[trash.data++] = COOKIE_DELIM_DATE; s30tob64((date.tv_sec+3) >> 2, trash.area + trash.data); trash.data += 5; if (s->be->cookie_maxlife) { /* emit first_date, which is either the original one or * the current date. */ trash.area[trash.data++] = COOKIE_DELIM_DATE; s30tob64(txn->cookie_first_date ? txn->cookie_first_date >> 2 : (date.tv_sec+3) >> 2, trash.area + trash.data); trash.data += 5; } } chunk_appendf(&trash, "; path=/"); } if (s->be->cookie_domain) chunk_appendf(&trash, "; domain=%s", s->be->cookie_domain); if (s->be->ck_opts & PR_CK_HTTPONLY) chunk_appendf(&trash, "; HttpOnly"); if (s->be->ck_opts & PR_CK_SECURE) chunk_appendf(&trash, "; Secure"); if (unlikely(http_header_add_tail2(&txn->rsp, &txn->hdr_idx, trash.area, trash.data) < 0)) goto return_bad_resp; txn->flags &= ~TX_SCK_MASK; if (__objt_server(s->target)->cookie && (s->flags & SF_DIRECT)) /* the server did not change, only the date was updated */ txn->flags |= TX_SCK_UPDATED; else txn->flags |= TX_SCK_INSERTED; /* Here, we will tell an eventual cache on the client side that we don't * want it to cache this reply because HTTP/1.0 caches also cache cookies ! * Some caches understand the correct form: 'no-cache="set-cookie"', but * others don't (eg: apache <= 1.3.26). So we use 'private' instead. */ if ((s->be->ck_opts & PR_CK_NOC) && (txn->flags & TX_CACHEABLE)) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; if (unlikely(http_header_add_tail2(&txn->rsp, &txn->hdr_idx, "Cache-control: private", 22) < 0)) goto return_bad_resp; } } /* * Check if result will be cacheable with a cookie. * We'll block the response if security checks have caught * nasty things such as a cacheable cookie. */ if (((txn->flags & (TX_CACHEABLE | TX_CACHE_COOK | TX_SCK_PRESENT)) == (TX_CACHEABLE | TX_CACHE_COOK | TX_SCK_PRESENT)) && (s->be->options & PR_O_CHK_CACHE)) { /* we're in presence of a cacheable response containing * a set-cookie header. We'll block it as requested by * the 'checkcache' option, and send an alert. */ if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_secu, 1); HA_ATOMIC_ADD(&s->be->be_counters.denied_resp, 1); HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_resp, 1); if (sess->listener->counters) HA_ATOMIC_ADD(&sess->listener->counters->denied_resp, 1); ha_alert("Blocking cacheable cookie in response from instance %s, server %s.\n", s->be->id, objt_server(s->target) ? objt_server(s->target)->id : "<dispatch>"); send_log(s->be, LOG_ALERT, "Blocking cacheable cookie in response from instance %s, server %s.\n", s->be->id, objt_server(s->target) ? objt_server(s->target)->id : "<dispatch>"); goto return_srv_prx_502; } skip_filters: /* * Adjust "Connection: close" or "Connection: keep-alive" if needed. * If an "Upgrade" token is found, the header is left untouched in order * not to have to deal with some client bugs : some of them fail an upgrade * if anything but "Upgrade" is present in the Connection header. We don't * want to touch any 101 response either since it's switching to another * protocol. */ if ((txn->status != 101) && !(txn->flags & TX_HDR_CONN_UPG) && (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { unsigned int want_flags = 0; if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) { /* we want a keep-alive response here. Keep-alive header * required if either side is not 1.1. */ if (!(txn->req.flags & msg->flags & HTTP_MSGF_VER_11)) want_flags |= TX_CON_KAL_SET; } else { /* CLO */ /* we want a close response here. Close header required if * the server is 1.1, regardless of the client. */ if (msg->flags & HTTP_MSGF_VER_11) want_flags |= TX_CON_CLO_SET; } if (want_flags != (txn->flags & (TX_CON_CLO_SET|TX_CON_KAL_SET))) http_change_connection_header(txn, msg, want_flags); } skip_header_mangling: /* Always enter in the body analyzer */ rep->analysers &= ~AN_RES_FLT_XFER_DATA; rep->analysers |= AN_RES_HTTP_XFER_BODY; /* if the user wants to log as soon as possible, without counting * bytes from the server, then this is the right moment. We have * to temporarily assign bytes_out to log what we currently have. */ if (!LIST_ISEMPTY(&sess->fe->logformat) && !(s->logs.logwait & LW_BYTES)) { s->logs.t_close = s->logs.t_data; /* to get a valid end date */ s->logs.bytes_out = txn->rsp.eoh; s->do_log(s); s->logs.bytes_out = 0; } return 1; } /* This function is an analyser which forwards response body (including chunk * sizes if any). It is called as soon as we must forward, even if we forward * zero byte. The only situation where it must not be called is when we're in * tunnel mode and we want to forward till the close. It's used both to forward * remaining data and to resync after end of body. It expects the msg_state to * be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to * read more data, or 1 once we can go on with next request or end the stream. * * It is capable of compressing response data both in content-length mode and * in chunked mode. The state machines follows different flows depending on * whether content-length and chunked modes are used, since there are no * trailers in content-length : * * chk-mode cl-mode * ,----- BODY -----. * / \ * V size > 0 V chk-mode * .--> SIZE -------------> DATA -------------> CRLF * | | size == 0 | last byte | * | v final crlf v inspected | * | TRAILERS -----------> DONE | * | | * `----------------------------------------------' * * Compression only happens in the DATA state, and must be flushed in final * states (TRAILERS/DONE) or when leaving on missing data. Normal forwarding * is performed at once on final states for all bytes parsed, or when leaving * on missing data. */ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &s->txn->rsp; int ret; if (IS_HTX_STRM(s)) return htx_response_forward_body(s, res, an_bit); DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n", now_ms, __FUNCTION__, s, res, res->rex, res->wex, res->flags, ci_data(res), res->analysers); if (unlikely(msg->msg_state < HTTP_MSG_BODY)) return 0; if ((res->flags & (CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) || ((res->flags & CF_SHUTW) && (res->to_forward || co_data(res))) || !s->req.analysers) { /* Output closed while we were sending data. We must abort and * wake the other side up. */ msg->err_state = msg->msg_state; msg->msg_state = HTTP_MSG_ERROR; http_resync_states(s); return 1; } /* in most states, we should abort in case of early close */ channel_auto_close(res); if (msg->msg_state == HTTP_MSG_BODY) { msg->msg_state = ((msg->flags & HTTP_MSGF_TE_CHNK) ? HTTP_MSG_CHUNK_SIZE : HTTP_MSG_DATA); } if (res->to_forward) { /* We can't process the buffer's contents yet */ res->flags |= CF_WAKE_WRITE; goto missing_data_or_waiting; } if (msg->msg_state < HTTP_MSG_DONE) { ret = ((msg->flags & HTTP_MSGF_TE_CHNK) ? http_msg_forward_chunked_body(s, msg) : http_msg_forward_body(s, msg)); if (!ret) goto missing_data_or_waiting; if (ret < 0) goto return_bad_res; } /* other states, DONE...TUNNEL */ /* for keep-alive we don't want to forward closes on DONE */ if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) channel_dont_close(res); http_resync_states(s); if (!(res->analysers & an_bit)) { if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { if (res->flags & CF_SHUTW) { /* response errors are most likely due to the * client aborting the transfer. */ goto aborted_xfer; } if (msg->err_pos >= 0) http_capture_bad_message(s->be, s, msg, msg->err_state, strm_fe(s)); goto return_bad_res; } return 1; } return 0; missing_data_or_waiting: if (res->flags & CF_SHUTW) goto aborted_xfer; /* stop waiting for data if the input is closed before the end. If the * client side was already closed, it means that the client has aborted, * so we don't want to count this as a server abort. Otherwise it's a * server abort. */ if (msg->msg_state < HTTP_MSG_ENDING && res->flags & CF_SHUTR) { if ((s->req.flags & (CF_SHUTR|CF_SHUTW)) == (CF_SHUTR|CF_SHUTW)) goto aborted_xfer; /* If we have some pending data, we continue the processing */ if (!ci_data(res)) { if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_SRVCL; HA_ATOMIC_ADD(&s->be->be_counters.srv_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.srv_aborts, 1); goto return_bad_res_stats_ok; } } /* we need to obey the req analyser, so if it leaves, we must too */ if (!s->req.analysers) goto return_bad_res; /* When TE: chunked is used, we need to get there again to parse * remaining chunks even if the server has closed, so we don't want to * set CF_DONTCLOSE. Similarly, if keep-alive is set on the client side * or if there are filters registered on the stream, we don't want to * forward a close */ if ((msg->flags & HTTP_MSGF_TE_CHNK) || HAS_DATA_FILTERS(s, res) || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) channel_dont_close(res); /* We know that more data are expected, but we couldn't send more that * what we did. So we always set the CF_EXPECT_MORE flag so that the * system knows it must not set a PUSH on this first part. Interactive * modes are already handled by the stream sock layer. We must not do * this in content-length mode because it could present the MSG_MORE * flag with the last block of forwarded data, which would cause an * additional delay to be observed by the receiver. */ if ((msg->flags & HTTP_MSGF_TE_CHNK) || (msg->flags & HTTP_MSGF_COMPRESSING)) res->flags |= CF_EXPECT_MORE; /* the stream handler will take care of timeouts and errors */ return 0; return_bad_res: /* let's centralize all bad responses */ HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); return_bad_res_stats_ok: txn->rsp.err_state = txn->rsp.msg_state; txn->rsp.msg_state = HTTP_MSG_ERROR; /* don't send any error message as we're in the body */ http_reply_and_close(s, txn->status, NULL); res->analysers &= AN_RES_FLT_END; s->req.analysers &= AN_REQ_FLT_END; /* we're in data phase, we want to abort both directions */ if (objt_server(s->target)) health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_D; return 0; aborted_xfer: txn->rsp.err_state = txn->rsp.msg_state; txn->rsp.msg_state = HTTP_MSG_ERROR; /* don't send any error message as we're in the body */ http_reply_and_close(s, txn->status, NULL); res->analysers &= AN_RES_FLT_END; s->req.analysers &= AN_REQ_FLT_END; /* we're in data phase, we want to abort both directions */ HA_ATOMIC_ADD(&sess->fe->fe_counters.cli_aborts, 1); HA_ATOMIC_ADD(&s->be->be_counters.cli_aborts, 1); if (objt_server(s->target)) HA_ATOMIC_ADD(&objt_server(s->target)->counters.cli_aborts, 1); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_CLICL; if (!(s->flags & SF_FINST_MASK)) s->flags |= SF_FINST_D; return 0; } int http_msg_forward_body(struct stream *s, struct http_msg *msg) { struct channel *chn = msg->chn; int ret; /* Here we have the guarantee to be in HTTP_MSG_DATA or HTTP_MSG_ENDING state */ if (msg->msg_state == HTTP_MSG_ENDING) goto ending; /* Neither content-length, nor transfer-encoding was found, so we must * read the body until the server connection is closed. In that case, we * eat data as they come. Of course, this happens for response only. */ if (!(msg->flags & HTTP_MSGF_XFER_LEN)) { unsigned long long len = ci_data(chn) - msg->next; msg->chunk_len += len; msg->body_len += len; } ret = FLT_STRM_DATA_CB(s, chn, flt_http_data(s, msg), /* default_ret */ MIN(msg->chunk_len, ci_data(chn) - msg->next), /* on_error */ goto error); msg->next += ret; msg->chunk_len -= ret; if (msg->chunk_len) { /* input empty or output full */ if (ci_data(chn) > msg->next) chn->flags |= CF_WAKE_WRITE; goto missing_data_or_waiting; } /* This check can only be true for a response. HTTP_MSGF_XFER_LEN is * always set for a request. */ if (!(msg->flags & HTTP_MSGF_XFER_LEN)) { /* The server still sending data that should be filtered */ if (!(chn->flags & CF_SHUTR) && HAS_DATA_FILTERS(s, chn)) goto missing_data_or_waiting; msg->msg_state = HTTP_MSG_TUNNEL; goto ending; } msg->msg_state = HTTP_MSG_ENDING; ending: /* we may have some pending data starting at res->buf.p such as a last * chunk of data or trailers. */ ret = FLT_STRM_DATA_CB(s, chn, flt_http_forward_data(s, msg, msg->next), /* default_ret */ msg->next, /* on_error */ goto error); c_adv(chn, ret); msg->next -= ret; if (unlikely(!(chn->flags & CF_WROTE_DATA) || msg->sov > 0)) msg->sov -= ret; if (msg->next) goto waiting; FLT_STRM_DATA_CB(s, chn, flt_http_end(s, msg), /* default_ret */ 1, /* on_error */ goto error, /* on_wait */ goto waiting); if (msg->msg_state == HTTP_MSG_ENDING) msg->msg_state = HTTP_MSG_DONE; return 1; missing_data_or_waiting: /* we may have some pending data starting at chn->buf.p */ ret = FLT_STRM_DATA_CB(s, chn, flt_http_forward_data(s, msg, msg->next), /* default_ret */ msg->next, /* on_error */ goto error); c_adv(chn, ret); msg->next -= ret; if (!(chn->flags & CF_WROTE_DATA) || msg->sov > 0) msg->sov -= ret; if (!HAS_DATA_FILTERS(s, chn)) msg->chunk_len -= channel_forward(chn, msg->chunk_len); waiting: return 0; error: return -1; } int http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg) { struct channel *chn = msg->chn; unsigned int chunk; int ret; /* Here we have the guarantee to be in one of the following state: * HTTP_MSG_DATA, HTTP_MSG_CHUNK_SIZE, HTTP_MSG_CHUNK_CRLF, * HTTP_MSG_TRAILERS or HTTP_MSG_ENDING. */ if (msg->msg_state == HTTP_MSG_ENDING) goto ending; /* Don't parse chunks if there is no input data */ if (!ci_data(chn)) goto waiting; switch_states: switch (msg->msg_state) { case HTTP_MSG_DATA: ret = FLT_STRM_DATA_CB(s, chn, flt_http_data(s, msg), /* default_ret */ MIN(msg->chunk_len, ci_data(chn) - msg->next), /* on_error */ goto error); msg->next += ret; msg->chunk_len -= ret; if (msg->chunk_len) { /* input empty or output full */ if (ci_data(chn) > msg->next) chn->flags |= CF_WAKE_WRITE; goto missing_data_or_waiting; } /* nothing left to forward for this chunk*/ msg->msg_state = HTTP_MSG_CHUNK_CRLF; /* fall through for HTTP_MSG_CHUNK_CRLF */ case HTTP_MSG_CHUNK_CRLF: /* we want the CRLF after the data */ ret = h1_skip_chunk_crlf(&chn->buf, co_data(chn) + msg->next, c_data(chn)); if (ret == 0) goto missing_data_or_waiting; if (ret < 0) { msg->err_pos = ci_data(chn) + ret; if (msg->err_pos < 0) msg->err_pos += chn->buf.size; goto chunk_parsing_error; } msg->next += ret; msg->msg_state = HTTP_MSG_CHUNK_SIZE; /* fall through for HTTP_MSG_CHUNK_SIZE */ case HTTP_MSG_CHUNK_SIZE: /* read the chunk size and assign it to ->chunk_len, * then set ->next to point to the body and switch to * DATA or TRAILERS state. */ ret = h1_parse_chunk_size(&chn->buf, co_data(chn) + msg->next, c_data(chn), &chunk); if (ret == 0) goto missing_data_or_waiting; if (ret < 0) { msg->err_pos = ci_data(chn) + ret; if (msg->err_pos < 0) msg->err_pos += chn->buf.size; goto chunk_parsing_error; } msg->sol = ret; msg->next += ret; msg->chunk_len = chunk; msg->body_len += chunk; if (msg->chunk_len) { msg->msg_state = HTTP_MSG_DATA; goto switch_states; } msg->msg_state = HTTP_MSG_TRAILERS; /* fall through for HTTP_MSG_TRAILERS */ case HTTP_MSG_TRAILERS: ret = http_forward_trailers(msg); if (ret < 0) goto chunk_parsing_error; FLT_STRM_DATA_CB(s, chn, flt_http_chunk_trailers(s, msg), /* default_ret */ 1, /* on_error */ goto error); msg->next += msg->sol; if (!ret) goto missing_data_or_waiting; break; default: /* This should no happen in this function */ goto error; } msg->msg_state = HTTP_MSG_ENDING; ending: /* we may have some pending data starting at res->buf.p such as a last * chunk of data or trailers. */ ret = FLT_STRM_DATA_CB(s, chn, flt_http_forward_data(s, msg, msg->next), /* default_ret */ msg->next, /* on_error */ goto error); c_adv(chn, ret); msg->next -= ret; if (unlikely(!(chn->flags & CF_WROTE_DATA) || msg->sov > 0)) msg->sov -= ret; if (msg->next) goto waiting; FLT_STRM_DATA_CB(s, chn, flt_http_end(s, msg), /* default_ret */ 1, /* on_error */ goto error, /* on_wait */ goto waiting); msg->msg_state = HTTP_MSG_DONE; return 1; missing_data_or_waiting: /* we may have some pending data starting at chn->buf.p */ ret = FLT_STRM_DATA_CB(s, chn, flt_http_forward_data(s, msg, msg->next), /* default_ret */ msg->next, /* on_error */ goto error); c_adv(chn, ret); msg->next -= ret; if (!(chn->flags & CF_WROTE_DATA) || msg->sov > 0) msg->sov -= ret; if (!HAS_DATA_FILTERS(s, chn)) msg->chunk_len -= channel_forward(chn, msg->chunk_len); waiting: return 0; chunk_parsing_error: if (msg->err_pos >= 0) { if (chn->flags & CF_ISRESP) http_capture_bad_message(s->be, s, msg, msg->msg_state, strm_fe(s)); else http_capture_bad_message(strm_fe(s), s, msg, msg->msg_state, s->be); } error: return -1; } /* Iterate the same filter through all request headers. * Returns 1 if this filter can be stopped upon return, otherwise 0. * Since it can manage the switch to another backend, it updates the per-proxy * DENY stats. */ int apply_filter_to_req_headers(struct stream *s, struct channel *req, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = s->txn; struct hdr_idx_elem *cur_hdr; int delta, len; last_hdr = 0; cur_next = ci_head(req) + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch, 0)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_CLALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_CLDENY; last_hdr = 1; break; case ACT_TARPIT: txn->flags |= TX_CLTARPIT; last_hdr = 1; break; case ACT_REPLACE: len = exp_replace(trash.area, trash.size, cur_ptr, exp->replace, pmatch); if (len < 0) return -1; delta = b_rep_blk(&req->buf, cur_ptr, cur_end, trash.area, len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); break; case ACT_REMOVE: delta = b_rep_blk(&req->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->req, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; } /* Apply the filter to the request line. * Returns 0 if nothing has been done, 1 if the filter has been applied, * or -1 if a replacement resulted in an invalid request line. * Since it can manage the switch to another backend, it updates the per-proxy * DENY stats. */ int apply_filter_to_req_line(struct stream *s, struct channel *req, struct hdr_exp *exp) { char *cur_ptr, *cur_end; int done; struct http_txn *txn = s->txn; int delta, len; if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) return 0; else if (exp->action == ACT_REMOVE) return 0; done = 0; cur_ptr = ci_head(req); cur_end = cur_ptr + txn->req.sl.rq.l; /* Now we have the request line between cur_ptr and cur_end */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch, 0)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_CLALLOW; done = 1; break; case ACT_DENY: txn->flags |= TX_CLDENY; done = 1; break; case ACT_TARPIT: txn->flags |= TX_CLTARPIT; done = 1; break; case ACT_REPLACE: len = exp_replace(trash.area, trash.size, cur_ptr, exp->replace, pmatch); if (len < 0) return -1; delta = b_rep_blk(&req->buf, cur_ptr, cur_end, trash.area, len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ http_msg_move_end(&txn->req, delta); cur_end += delta; cur_end = (char *)http_parse_reqline(&txn->req, HTTP_MSG_RQMETH, cur_ptr, cur_end + 1, NULL, NULL); if (unlikely(!cur_end)) return -1; /* we have a full request and we know that we have either a CR * or an LF at <ptr>. */ txn->meth = find_http_meth(cur_ptr, txn->req.sl.rq.m_l); hdr_idx_set_start(&txn->hdr_idx, txn->req.sl.rq.l, *cur_end == '\r'); /* there is no point trying this regex on headers */ return 1; } } return done; } /* * Apply all the req filters of proxy <px> to all headers in buffer <req> of stream <s>. * Returns 0 if everything is alright, or -1 in case a replacement lead to an * unparsable request. Since it can manage the switch to another backend, it * updates the per-proxy DENY stats. */ int apply_filters_to_request(struct stream *s, struct channel *req, struct proxy *px) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct hdr_exp *exp; for (exp = px->req_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & (TX_CLDENY|TX_CLTARPIT)) break; if ((txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT || exp->action == ACT_PASS)) continue; /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the request line. */ ret = apply_filter_to_req_line(s, req, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the request, it can be * iterated through all headers. */ if (unlikely(apply_filter_to_req_headers(s, req, exp) < 0)) return -1; } } return 0; } /* Delete a value in a header between delimiters <from> and <next> in buffer * <buf>. The number of characters displaced is returned, and the pointer to * the first delimiter is updated if required. The function tries as much as * possible to respect the following principles : * - replace <from> delimiter by the <next> one unless <from> points to a * colon, in which case <next> is simply removed * - set exactly one space character after the new first delimiter, unless * there are not enough characters in the block being moved to do so. * - remove unneeded spaces before the previous delimiter and after the new * one. * * It is the caller's responsibility to ensure that : * - <from> points to a valid delimiter or the colon ; * - <next> points to a valid delimiter or the final CR/LF ; * - there are non-space chars before <from> ; * - there is a CR/LF at or after <next>. */ static int del_hdr_value(struct buffer *buf, char **from, char *next) { char *prev = *from; if (*prev == ':') { /* We're removing the first value, preserve the colon and add a * space if possible. */ if (!HTTP_IS_CRLF(*next)) next++; prev++; if (prev < next) *prev++ = ' '; while (HTTP_IS_SPHT(*next)) next++; } else { /* Remove useless spaces before the old delimiter. */ while (HTTP_IS_SPHT(*(prev-1))) prev--; *from = prev; /* copy the delimiter and if possible a space if we're * not at the end of the line. */ if (!HTTP_IS_CRLF(*next)) { *prev++ = *next++; if (prev + 1 < next) *prev++ = ' '; while (HTTP_IS_SPHT(*next)) next++; } } return b_rep_blk(buf, prev, next, NULL, 0); } /* * Manage client-side cookie. It can impact performance by about 2% so it is * desirable to call it only when needed. This code is quite complex because * of the multiple very crappy and ambiguous syntaxes we have to support. it * highly recommended not to touch this part without a good reason ! */ void manage_client_side_cookies(struct stream *s, struct channel *req) { struct http_txn *txn = s->txn; struct session *sess = s->sess; int preserve_hdr; int cur_idx, old_idx; char *hdr_beg, *hdr_end, *hdr_next, *del_from; char *prev, *att_beg, *att_end, *equal, *val_beg, *val_end, *next; /* Iterate through the headers, we start with the start line. */ old_idx = 0; hdr_next = ci_head(req) + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[old_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; hdr_beg = hdr_next; hdr_end = hdr_beg + cur_hdr->len; hdr_next = hdr_end + cur_hdr->cr + 1; /* We have one full header between hdr_beg and hdr_end, and the * next header starts at hdr_next. We're only interested in * "Cookie:" headers. */ val = http_header_match2(hdr_beg, hdr_end, "Cookie", 6); if (!val) { old_idx = cur_idx; continue; } del_from = NULL; /* nothing to be deleted */ preserve_hdr = 0; /* assume we may kill the whole header */ /* Now look for cookies. Conforming to RFC2109, we have to support * attributes whose name begin with a '$', and associate them with * the right cookie, if we want to delete this cookie. * So there are 3 cases for each cookie read : * 1) it's a special attribute, beginning with a '$' : ignore it. * 2) it's a server id cookie that we *MAY* want to delete : save * some pointers on it (last semi-colon, beginning of cookie...) * 3) it's an application cookie : we *MAY* have to delete a previous * "special" cookie. * At the end of loop, if a "special" cookie remains, we may have to * remove it. If no application cookie persists in the header, we * *MUST* delete it. * * Note: RFC2965 is unclear about the processing of spaces around * the equal sign in the ATTR=VALUE form. A careful inspection of * the RFC explicitly allows spaces before it, and not within the * tokens (attrs or values). An inspection of RFC2109 allows that * too but section 10.1.3 lets one think that spaces may be allowed * after the equal sign too, resulting in some (rare) buggy * implementations trying to do that. So let's do what servers do. * Latest ietf draft forbids spaces all around. Also, earlier RFCs * allowed quoted strings in values, with any possible character * after a backslash, including control chars and delimitors, which * causes parsing to become ambiguous. Browsers also allow spaces * within values even without quotes. * * We have to keep multiple pointers in order to support cookie * removal at the beginning, middle or end of header without * corrupting the header. All of these headers are valid : * * Cookie:NAME1=VALUE1;NAME2=VALUE2;NAME3=VALUE3\r\n * Cookie:NAME1=VALUE1;NAME2_ONLY ;NAME3=VALUE3\r\n * Cookie: NAME1 = VALUE 1 ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n * | | | | | | | | | * | | | | | | | | hdr_end <--+ * | | | | | | | +--> next * | | | | | | +----> val_end * | | | | | +-----------> val_beg * | | | | +--------------> equal * | | | +----------------> att_end * | | +---------------------> att_beg * | +--------------------------> prev * +--------------------------------> hdr_beg */ for (prev = hdr_beg + 6; prev < hdr_end; prev = next) { /* Iterate through all cookies on this line */ /* find att_beg */ att_beg = prev + 1; while (att_beg < hdr_end && HTTP_IS_SPHT(*att_beg)) att_beg++; /* find att_end : this is the first character after the last non * space before the equal. It may be equal to hdr_end. */ equal = att_end = att_beg; while (equal < hdr_end) { if (*equal == '=' || *equal == ',' || *equal == ';') break; if (HTTP_IS_SPHT(*equal++)) continue; att_end = equal; } /* here, <equal> points to '=', a delimitor or the end. <att_end> * is between <att_beg> and <equal>, both may be identical. */ /* look for end of cookie if there is an equal sign */ if (equal < hdr_end && *equal == '=') { /* look for the beginning of the value */ val_beg = equal + 1; while (val_beg < hdr_end && HTTP_IS_SPHT(*val_beg)) val_beg++; /* find the end of the value, respecting quotes */ next = http_find_cookie_value_end(val_beg, hdr_end); /* make val_end point to the first white space or delimitor after the value */ val_end = next; while (val_end > val_beg && HTTP_IS_SPHT(*(val_end - 1))) val_end--; } else { val_beg = val_end = next = equal; } /* We have nothing to do with attributes beginning with '$'. However, * they will automatically be removed if a header before them is removed, * since they're supposed to be linked together. */ if (*att_beg == '$') continue; /* Ignore cookies with no equal sign */ if (equal == next) { /* This is not our cookie, so we must preserve it. But if we already * scheduled another cookie for removal, we cannot remove the * complete header, but we can remove the previous block itself. */ preserve_hdr = 1; if (del_from != NULL) { int delta = del_hdr_value(&req->buf, &del_from, prev); val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); prev = del_from; del_from = NULL; } continue; } /* if there are spaces around the equal sign, we need to * strip them otherwise we'll get trouble for cookie captures, * or even for rewrites. Since this happens extremely rarely, * it does not hurt performance. */ if (unlikely(att_end != equal || val_beg > equal + 1)) { int stripped_before = 0; int stripped_after = 0; if (att_end != equal) { stripped_before = b_rep_blk(&req->buf, att_end, equal, NULL, 0); equal += stripped_before; val_beg += stripped_before; } if (val_beg > equal + 1) { stripped_after = b_rep_blk(&req->buf, equal + 1, val_beg, NULL, 0); val_beg += stripped_after; stripped_before += stripped_after; } val_end += stripped_before; next += stripped_before; hdr_end += stripped_before; hdr_next += stripped_before; cur_hdr->len += stripped_before; http_msg_move_end(&txn->req, stripped_before); } /* now everything is as on the diagram above */ /* First, let's see if we want to capture this cookie. We check * that we don't already have a client side cookie, because we * can only capture one. Also as an optimisation, we ignore * cookies shorter than the declared name. */ if (sess->fe->capture_name != NULL && txn->cli_cookie == NULL && (val_end - att_beg >= sess->fe->capture_namelen) && memcmp(att_beg, sess->fe->capture_name, sess->fe->capture_namelen) == 0) { int log_len = val_end - att_beg; if ((txn->cli_cookie = pool_alloc(pool_head_capture)) == NULL) { ha_alert("HTTP logging : out of memory.\n"); } else { if (log_len > sess->fe->capture_len) log_len = sess->fe->capture_len; memcpy(txn->cli_cookie, att_beg, log_len); txn->cli_cookie[log_len] = 0; } } /* Persistence cookies in passive, rewrite or insert mode have the * following form : * * Cookie: NAME=SRV[|<lastseen>[|<firstseen>]] * * For cookies in prefix mode, the form is : * * Cookie: NAME=SRV~VALUE */ if ((att_end - att_beg == s->be->cookie_len) && (s->be->cookie_name != NULL) && (memcmp(att_beg, s->be->cookie_name, att_end - att_beg) == 0)) { struct server *srv = s->be->srv; char *delim; /* if we're in cookie prefix mode, we'll search the delimitor so that we * have the server ID between val_beg and delim, and the original cookie between * delim+1 and val_end. Otherwise, delim==val_end : * * Cookie: NAME=SRV; # in all but prefix modes * Cookie: NAME=SRV~OPAQUE ; # in prefix mode * | || || | |+-> next * | || || | +--> val_end * | || || +---------> delim * | || |+------------> val_beg * | || +-------------> att_end = equal * | |+-----------------> att_beg * | +------------------> prev * +-------------------------> hdr_beg */ if (s->be->ck_opts & PR_CK_PFX) { for (delim = val_beg; delim < val_end; delim++) if (*delim == COOKIE_DELIM) break; } else { char *vbar1; delim = val_end; /* Now check if the cookie contains a date field, which would * appear after a vertical bar ('|') just after the server name * and before the delimiter. */ vbar1 = memchr(val_beg, COOKIE_DELIM_DATE, val_end - val_beg); if (vbar1) { /* OK, so left of the bar is the server's cookie and * right is the last seen date. It is a base64 encoded * 30-bit value representing the UNIX date since the * epoch in 4-second quantities. */ int val; delim = vbar1++; if (val_end - vbar1 >= 5) { val = b64tos30(vbar1); if (val > 0) txn->cookie_last_date = val << 2; } /* look for a second vertical bar */ vbar1 = memchr(vbar1, COOKIE_DELIM_DATE, val_end - vbar1); if (vbar1 && (val_end - vbar1 > 5)) { val = b64tos30(vbar1 + 1); if (val > 0) txn->cookie_first_date = val << 2; } } } /* if the cookie has an expiration date and the proxy wants to check * it, then we do that now. We first check if the cookie is too old, * then only if it has expired. We detect strict overflow because the * time resolution here is not great (4 seconds). Cookies with dates * in the future are ignored if their offset is beyond one day. This * allows an admin to fix timezone issues without expiring everyone * and at the same time avoids keeping unwanted side effects for too * long. */ if (txn->cookie_first_date && s->be->cookie_maxlife && (((signed)(date.tv_sec - txn->cookie_first_date) > (signed)s->be->cookie_maxlife) || ((signed)(txn->cookie_first_date - date.tv_sec) > 86400))) { txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_OLD; delim = val_beg; // let's pretend we have not found the cookie txn->cookie_first_date = 0; txn->cookie_last_date = 0; } else if (txn->cookie_last_date && s->be->cookie_maxidle && (((signed)(date.tv_sec - txn->cookie_last_date) > (signed)s->be->cookie_maxidle) || ((signed)(txn->cookie_last_date - date.tv_sec) > 86400))) { txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_EXPIRED; delim = val_beg; // let's pretend we have not found the cookie txn->cookie_first_date = 0; txn->cookie_last_date = 0; } /* Here, we'll look for the first running server which supports the cookie. * This allows to share a same cookie between several servers, for example * to dedicate backup servers to specific servers only. * However, to prevent clients from sticking to cookie-less backup server * when they have incidentely learned an empty cookie, we simply ignore * empty cookies and mark them as invalid. * The same behaviour is applied when persistence must be ignored. */ if ((delim == val_beg) || (s->flags & (SF_IGNORE_PRST | SF_ASSIGNED))) srv = NULL; while (srv) { if (srv->cookie && (srv->cklen == delim - val_beg) && !memcmp(val_beg, srv->cookie, delim - val_beg)) { if ((srv->cur_state != SRV_ST_STOPPED) || (s->be->options & PR_O_PERSIST) || (s->flags & SF_FORCE_PRST)) { /* we found the server and we can use it */ txn->flags &= ~TX_CK_MASK; txn->flags |= (srv->cur_state != SRV_ST_STOPPED) ? TX_CK_VALID : TX_CK_DOWN; s->flags |= SF_DIRECT | SF_ASSIGNED; s->target = &srv->obj_type; break; } else { /* we found a server, but it's down, * mark it as such and go on in case * another one is available. */ txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_DOWN; } } srv = srv->next; } if (!srv && !(txn->flags & (TX_CK_DOWN|TX_CK_EXPIRED|TX_CK_OLD))) { /* no server matched this cookie or we deliberately skipped it */ txn->flags &= ~TX_CK_MASK; if ((s->flags & (SF_IGNORE_PRST | SF_ASSIGNED))) txn->flags |= TX_CK_UNUSED; else txn->flags |= TX_CK_INVALID; } /* depending on the cookie mode, we may have to either : * - delete the complete cookie if we're in insert+indirect mode, so that * the server never sees it ; * - remove the server id from the cookie value, and tag the cookie as an * application cookie so that it does not get accidently removed later, * if we're in cookie prefix mode */ if ((s->be->ck_opts & PR_CK_PFX) && (delim != val_end)) { int delta; /* negative */ delta = b_rep_blk(&req->buf, val_beg, delim + 1, NULL, 0); val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); del_from = NULL; preserve_hdr = 1; /* we want to keep this cookie */ } else if (del_from == NULL && (s->be->ck_opts & (PR_CK_INS | PR_CK_IND)) == (PR_CK_INS | PR_CK_IND)) { del_from = prev; } } else { /* This is not our cookie, so we must preserve it. But if we already * scheduled another cookie for removal, we cannot remove the * complete header, but we can remove the previous block itself. */ preserve_hdr = 1; if (del_from != NULL) { int delta = del_hdr_value(&req->buf, &del_from, prev); if (att_beg >= del_from) att_beg += delta; if (att_end >= del_from) att_end += delta; val_beg += delta; val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); prev = del_from; del_from = NULL; } } /* continue with next cookie on this header line */ att_beg = next; } /* for each cookie */ /* There are no more cookies on this line. * We may still have one (or several) marked for deletion at the * end of the line. We must do this now in two ways : * - if some cookies must be preserved, we only delete from the * mark to the end of line ; * - if nothing needs to be preserved, simply delete the whole header */ if (del_from) { int delta; if (preserve_hdr) { delta = del_hdr_value(&req->buf, &del_from, hdr_end); hdr_end = del_from; cur_hdr->len += delta; } else { delta = b_rep_blk(&req->buf, hdr_beg, hdr_next, NULL, 0); /* FIXME: this should be a separate function */ txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_idx = old_idx; } hdr_next += delta; http_msg_move_end(&txn->req, delta); } /* check next header */ old_idx = cur_idx; } } /* Iterate the same filter through all response headers contained in <rtr>. * Returns 1 if this filter can be stopped upon return, otherwise 0. */ int apply_filter_to_resp_headers(struct stream *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = s->txn; struct hdr_idx_elem *cur_hdr; int delta, len; last_hdr = 0; cur_next = ci_head(rtr) + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch, 0)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; last_hdr = 1; break; case ACT_REPLACE: len = exp_replace(trash.area, trash.size, cur_ptr, exp->replace, pmatch); if (len < 0) return -1; delta = b_rep_blk(&rtr->buf, cur_ptr, cur_end, trash.area, len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); break; case ACT_REMOVE: delta = b_rep_blk(&rtr->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->rsp, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; } /* Apply the filter to the status line in the response buffer <rtr>. * Returns 0 if nothing has been done, 1 if the filter has been applied, * or -1 if a replacement resulted in an invalid status line. */ int apply_filter_to_sts_line(struct stream *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end; int done; struct http_txn *txn = s->txn; int delta, len; if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; else if (exp->action == ACT_REMOVE) return 0; done = 0; cur_ptr = ci_head(rtr); cur_end = cur_ptr + txn->rsp.sl.st.l; /* Now we have the status line between cur_ptr and cur_end */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch, 0)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; done = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; done = 1; break; case ACT_REPLACE: len = exp_replace(trash.area, trash.size, cur_ptr, exp->replace, pmatch); if (len < 0) return -1; delta = b_rep_blk(&rtr->buf, cur_ptr, cur_end, trash.area, len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ http_msg_move_end(&txn->rsp, delta); cur_end += delta; cur_end = (char *)http_parse_stsline(&txn->rsp, HTTP_MSG_RPVER, cur_ptr, cur_end + 1, NULL, NULL); if (unlikely(!cur_end)) return -1; /* we have a full respnse and we know that we have either a CR * or an LF at <ptr>. */ txn->status = strl2ui(ci_head(rtr) + txn->rsp.sl.st.c, txn->rsp.sl.st.c_l); hdr_idx_set_start(&txn->hdr_idx, txn->rsp.sl.st.l, *cur_end == '\r'); /* there is no point trying this regex on headers */ return 1; } } return done; } /* * Apply all the resp filters of proxy <px> to all headers in buffer <rtr> of stream <s>. * Returns 0 if everything is alright, or -1 in case a replacement lead to an * unparsable response. */ int apply_filters_to_response(struct stream *s, struct channel *rtr, struct proxy *px) { struct session *sess = s->sess; struct http_txn *txn = s->txn; struct hdr_exp *exp; for (exp = px->rsp_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & TX_SVDENY) break; if ((txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_PASS)) { exp = exp->next; continue; } /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the status line. */ ret = apply_filter_to_sts_line(s, rtr, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the response, it can be * iterated through all headers. */ if (unlikely(apply_filter_to_resp_headers(s, rtr, exp) < 0)) return -1; } } return 0; } /* * Manage server-side cookies. It can impact performance by about 2% so it is * desirable to call it only when needed. This function is also used when we * just need to know if there is a cookie (eg: for check-cache). */ void manage_server_side_cookies(struct stream *s, struct channel *res) { struct http_txn *txn = s->txn; struct session *sess = s->sess; struct server *srv; int is_cookie2; int cur_idx, old_idx, delta; char *hdr_beg, *hdr_end, *hdr_next; char *prev, *att_beg, *att_end, *equal, *val_beg, *val_end, *next; /* Iterate through the headers. * we start with the start line. */ old_idx = 0; hdr_next = ci_head(res) + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[old_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; hdr_beg = hdr_next; hdr_end = hdr_beg + cur_hdr->len; hdr_next = hdr_end + cur_hdr->cr + 1; /* We have one full header between hdr_beg and hdr_end, and the * next header starts at hdr_next. We're only interested in * "Set-Cookie" and "Set-Cookie2" headers. */ is_cookie2 = 0; prev = hdr_beg + 10; val = http_header_match2(hdr_beg, hdr_end, "Set-Cookie", 10); if (!val) { val = http_header_match2(hdr_beg, hdr_end, "Set-Cookie2", 11); if (!val) { old_idx = cur_idx; continue; } is_cookie2 = 1; prev = hdr_beg + 11; } /* OK, right now we know we have a Set-Cookie* at hdr_beg, and * <prev> points to the colon. */ txn->flags |= TX_SCK_PRESENT; /* Maybe we only wanted to see if there was a Set-Cookie (eg: * check-cache is enabled) and we are not interested in checking * them. Warning, the cookie capture is declared in the frontend. */ if (s->be->cookie_name == NULL && sess->fe->capture_name == NULL) return; /* OK so now we know we have to process this response cookie. * The format of the Set-Cookie header is slightly different * from the format of the Cookie header in that it does not * support the comma as a cookie delimiter (thus the header * cannot be folded) because the Expires attribute described in * the original Netscape's spec may contain an unquoted date * with a comma inside. We have to live with this because * many browsers don't support Max-Age and some browsers don't * support quoted strings. However the Set-Cookie2 header is * clean. * * We have to keep multiple pointers in order to support cookie * removal at the beginning, middle or end of header without * corrupting the header (in case of set-cookie2). A special * pointer, <scav> points to the beginning of the set-cookie-av * fields after the first semi-colon. The <next> pointer points * either to the end of line (set-cookie) or next unquoted comma * (set-cookie2). All of these headers are valid : * * Set-Cookie: NAME1 = VALUE 1 ; Secure; Path="/"\r\n * Set-Cookie:NAME=VALUE; Secure; Expires=Thu, 01-Jan-1970 00:00:01 GMT\r\n * Set-Cookie: NAME = VALUE ; Secure; Expires=Thu, 01-Jan-1970 00:00:01 GMT\r\n * Set-Cookie2: NAME1 = VALUE 1 ; Max-Age=0, NAME2=VALUE2; Discard\r\n * | | | | | | | | | | * | | | | | | | | +-> next hdr_end <--+ * | | | | | | | +------------> scav * | | | | | | +--------------> val_end * | | | | | +--------------------> val_beg * | | | | +----------------------> equal * | | | +------------------------> att_end * | | +----------------------------> att_beg * | +------------------------------> prev * +-----------------------------------------> hdr_beg */ for (; prev < hdr_end; prev = next) { /* Iterate through all cookies on this line */ /* find att_beg */ att_beg = prev + 1; while (att_beg < hdr_end && HTTP_IS_SPHT(*att_beg)) att_beg++; /* find att_end : this is the first character after the last non * space before the equal. It may be equal to hdr_end. */ equal = att_end = att_beg; while (equal < hdr_end) { if (*equal == '=' || *equal == ';' || (is_cookie2 && *equal == ',')) break; if (HTTP_IS_SPHT(*equal++)) continue; att_end = equal; } /* here, <equal> points to '=', a delimitor or the end. <att_end> * is between <att_beg> and <equal>, both may be identical. */ /* look for end of cookie if there is an equal sign */ if (equal < hdr_end && *equal == '=') { /* look for the beginning of the value */ val_beg = equal + 1; while (val_beg < hdr_end && HTTP_IS_SPHT(*val_beg)) val_beg++; /* find the end of the value, respecting quotes */ next = http_find_cookie_value_end(val_beg, hdr_end); /* make val_end point to the first white space or delimitor after the value */ val_end = next; while (val_end > val_beg && HTTP_IS_SPHT(*(val_end - 1))) val_end--; } else { /* <equal> points to next comma, semi-colon or EOL */ val_beg = val_end = next = equal; } if (next < hdr_end) { /* Set-Cookie2 supports multiple cookies, and <next> points to * a colon or semi-colon before the end. So skip all attr-value * pairs and look for the next comma. For Set-Cookie, since * commas are permitted in values, skip to the end. */ if (is_cookie2) next = http_find_hdr_value_end(next, hdr_end); else next = hdr_end; } /* Now everything is as on the diagram above */ /* Ignore cookies with no equal sign */ if (equal == val_end) continue; /* If there are spaces around the equal sign, we need to * strip them otherwise we'll get trouble for cookie captures, * or even for rewrites. Since this happens extremely rarely, * it does not hurt performance. */ if (unlikely(att_end != equal || val_beg > equal + 1)) { int stripped_before = 0; int stripped_after = 0; if (att_end != equal) { stripped_before = b_rep_blk(&res->buf, att_end, equal, NULL, 0); equal += stripped_before; val_beg += stripped_before; } if (val_beg > equal + 1) { stripped_after = b_rep_blk(&res->buf, equal + 1, val_beg, NULL, 0); val_beg += stripped_after; stripped_before += stripped_after; } val_end += stripped_before; next += stripped_before; hdr_end += stripped_before; hdr_next += stripped_before; cur_hdr->len += stripped_before; http_msg_move_end(&txn->rsp, stripped_before); } /* First, let's see if we want to capture this cookie. We check * that we don't already have a server side cookie, because we * can only capture one. Also as an optimisation, we ignore * cookies shorter than the declared name. */ if (sess->fe->capture_name != NULL && txn->srv_cookie == NULL && (val_end - att_beg >= sess->fe->capture_namelen) && memcmp(att_beg, sess->fe->capture_name, sess->fe->capture_namelen) == 0) { int log_len = val_end - att_beg; if ((txn->srv_cookie = pool_alloc(pool_head_capture)) == NULL) { ha_alert("HTTP logging : out of memory.\n"); } else { if (log_len > sess->fe->capture_len) log_len = sess->fe->capture_len; memcpy(txn->srv_cookie, att_beg, log_len); txn->srv_cookie[log_len] = 0; } } srv = objt_server(s->target); /* now check if we need to process it for persistence */ if (!(s->flags & SF_IGNORE_PRST) && (att_end - att_beg == s->be->cookie_len) && (s->be->cookie_name != NULL) && (memcmp(att_beg, s->be->cookie_name, att_end - att_beg) == 0)) { /* assume passive cookie by default */ txn->flags &= ~TX_SCK_MASK; txn->flags |= TX_SCK_FOUND; /* If the cookie is in insert mode on a known server, we'll delete * this occurrence because we'll insert another one later. * We'll delete it too if the "indirect" option is set and we're in * a direct access. */ if (s->be->ck_opts & PR_CK_PSV) { /* The "preserve" flag was set, we don't want to touch the * server's cookie. */ } else if ((srv && (s->be->ck_opts & PR_CK_INS)) || ((s->flags & SF_DIRECT) && (s->be->ck_opts & PR_CK_IND))) { /* this cookie must be deleted */ if (*prev == ':' && next == hdr_end) { /* whole header */ delta = b_rep_blk(&res->buf, hdr_beg, hdr_next, NULL, 0); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_idx = old_idx; hdr_next += delta; http_msg_move_end(&txn->rsp, delta); /* note: while both invalid now, <next> and <hdr_end> * are still equal, so the for() will stop as expected. */ } else { /* just remove the value */ int delta = del_hdr_value(&res->buf, &prev, next); next = prev; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); } txn->flags &= ~TX_SCK_MASK; txn->flags |= TX_SCK_DELETED; /* and go on with next cookie */ } else if (srv && srv->cookie && (s->be->ck_opts & PR_CK_RW)) { /* replace bytes val_beg->val_end with the cookie name associated * with this server since we know it. */ delta = b_rep_blk(&res->buf, val_beg, val_end, srv->cookie, srv->cklen); next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); txn->flags &= ~TX_SCK_MASK; txn->flags |= TX_SCK_REPLACED; } else if (srv && srv->cookie && (s->be->ck_opts & PR_CK_PFX)) { /* insert the cookie name associated with this server * before existing cookie, and insert a delimiter between them.. */ delta = b_rep_blk(&res->buf, val_beg, val_beg, srv->cookie, srv->cklen + 1); next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); val_beg[srv->cklen] = COOKIE_DELIM; txn->flags &= ~TX_SCK_MASK; txn->flags |= TX_SCK_REPLACED; } } /* that's done for this cookie, check the next one on the same * line when next != hdr_end (only if is_cookie2). */ } /* check next header */ old_idx = cur_idx; } } /* * Parses the Cache-Control and Pragma request header fields to determine if * the request may be served from the cache and/or if it is cacheable. Updates * s->txn->flags. */ void check_request_for_cacheability(struct stream *s, struct channel *chn) { struct http_txn *txn = s->txn; char *p1, *p2; char *cur_ptr, *cur_end, *cur_next; int pragma_found; int cc_found; int cur_idx; if (IS_HTX_STRM(s)) return htx_check_request_for_cacheability(s, chn); if ((txn->flags & (TX_CACHEABLE|TX_CACHE_IGNORE)) == TX_CACHE_IGNORE) return; /* nothing more to do here */ cur_idx = 0; pragma_found = cc_found = 0; cur_next = ci_head(chn) + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[cur_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* We have one full header between cur_ptr and cur_end, and the * next header starts at cur_next. */ val = http_header_match2(cur_ptr, cur_end, "Pragma", 6); if (val) { if ((cur_end - (cur_ptr + val) >= 8) && strncasecmp(cur_ptr + val, "no-cache", 8) == 0) { pragma_found = 1; continue; } } /* Don't use the cache and don't try to store if we found the * Authorization header */ val = http_header_match2(cur_ptr, cur_end, "Authorization", 13); if (val) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; txn->flags |= TX_CACHE_IGNORE; continue; } val = http_header_match2(cur_ptr, cur_end, "Cache-control", 13); if (!val) continue; /* OK, right now we know we have a cache-control header at cur_ptr */ cc_found = 1; p1 = cur_ptr + val; /* first non-space char after 'cache-control:' */ if (p1 >= cur_end) /* no more info */ continue; /* p1 is at the beginning of the value */ p2 = p1; while (p2 < cur_end && *p2 != '=' && *p2 != ',' && !isspace((unsigned char)*p2)) p2++; /* we have a complete value between p1 and p2. We don't check the * values after max-age, max-stale nor min-fresh, we simply don't * use the cache when they're specified. */ if (((p2 - p1 == 7) && strncasecmp(p1, "max-age", 7) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-cache", 8) == 0) || ((p2 - p1 == 9) && strncasecmp(p1, "max-stale", 9) == 0) || ((p2 - p1 == 9) && strncasecmp(p1, "min-fresh", 9) == 0)) { txn->flags |= TX_CACHE_IGNORE; continue; } if ((p2 - p1 == 8) && strncasecmp(p1, "no-store", 8) == 0) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; continue; } } /* RFC7234#5.4: * When the Cache-Control header field is also present and * understood in a request, Pragma is ignored. * When the Cache-Control header field is not present in a * request, caches MUST consider the no-cache request * pragma-directive as having the same effect as if * "Cache-Control: no-cache" were present. */ if (!cc_found && pragma_found) txn->flags |= TX_CACHE_IGNORE; } /* * Check if response is cacheable or not. Updates s->txn->flags. */ void check_response_for_cacheability(struct stream *s, struct channel *rtr) { struct http_txn *txn = s->txn; char *p1, *p2; char *cur_ptr, *cur_end, *cur_next; int cur_idx; if (IS_HTX_STRM(s)) return htx_check_response_for_cacheability(s, rtr); if (txn->status < 200) { /* do not try to cache interim responses! */ txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } /* Iterate through the headers. * we start with the start line. */ cur_idx = 0; cur_next = ci_head(rtr) + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[cur_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* We have one full header between cur_ptr and cur_end, and the * next header starts at cur_next. */ val = http_header_match2(cur_ptr, cur_end, "Pragma", 6); if (val) { if ((cur_end - (cur_ptr + val) >= 8) && strncasecmp(cur_ptr + val, "no-cache", 8) == 0) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } } val = http_header_match2(cur_ptr, cur_end, "Cache-control", 13); if (!val) continue; /* OK, right now we know we have a cache-control header at cur_ptr */ p1 = cur_ptr + val; /* first non-space char after 'cache-control:' */ if (p1 >= cur_end) /* no more info */ continue; /* p1 is at the beginning of the value */ p2 = p1; while (p2 < cur_end && *p2 != '=' && *p2 != ',' && !isspace((unsigned char)*p2)) p2++; /* we have a complete value between p1 and p2 */ if (p2 < cur_end && *p2 == '=') { if (((cur_end - p2) > 1 && (p2 - p1 == 7) && strncasecmp(p1, "max-age=0", 9) == 0) || ((cur_end - p2) > 1 && (p2 - p1 == 8) && strncasecmp(p1, "s-maxage=0", 10) == 0)) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; continue; } /* we have something of the form no-cache="set-cookie" */ if ((cur_end - p1 >= 21) && strncasecmp(p1, "no-cache=\"set-cookie", 20) == 0 && (p1[20] == '"' || p1[20] == ',')) txn->flags &= ~TX_CACHE_COOK; continue; } /* OK, so we know that either p2 points to the end of string or to a comma */ if (((p2 - p1 == 7) && strncasecmp(p1, "private", 7) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-cache", 8) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-store", 8) == 0)) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } if ((p2 - p1 == 6) && strncasecmp(p1, "public", 6) == 0) { txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; continue; } } } /* * In a GET, HEAD or POST request, check if the requested URI matches the stats uri * for the current backend. * * It is assumed that the request is either a HEAD, GET, or POST and that the * uri_auth field is valid. * * Returns 1 if stats should be provided, otherwise 0. */ int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend) { struct uri_auth *uri_auth = backend->uri_auth; struct http_msg *msg = &txn->req; const char *uri = ci_head(msg->chn)+ msg->sl.rq.u; if (!uri_auth) return 0; if (txn->meth != HTTP_METH_GET && txn->meth != HTTP_METH_HEAD && txn->meth != HTTP_METH_POST) return 0; /* check URI size */ if (uri_auth->uri_len > msg->sl.rq.u_l) return 0; if (memcmp(uri, uri_auth->uri_prefix, uri_auth->uri_len) != 0) return 0; return 1; } /* Append the description of what is present in error snapshot <es> into <out>. * The description must be small enough to always fit in a trash. The output * buffer may be the trash so the trash must not be used inside this function. */ void http_show_error_snapshot(struct buffer *out, const struct error_snapshot *es) { chunk_appendf(out, " stream #%d, stream flags 0x%08x, tx flags 0x%08x\n" " HTTP msg state %s(%d), msg flags 0x%08x\n" " HTTP chunk len %lld bytes, HTTP body len %lld bytes, channel flags 0x%08x :\n", es->ctx.http.sid, es->ctx.http.s_flags, es->ctx.http.t_flags, h1_msg_state_str(es->ctx.http.state), es->ctx.http.state, es->ctx.http.m_flags, es->ctx.http.m_clen, es->ctx.http.m_blen, es->ctx.http.b_flags); } /* * Capture a bad request or response and archive it in the proxy's structure. * By default it tries to report the error position as msg->err_pos. However if * this one is not set, it will then report msg->next, which is the last known * parsing point. The function is able to deal with wrapping buffers. It always * displays buffers as a contiguous area starting at buf->p. The direction is * determined thanks to the channel's flags. */ void http_capture_bad_message(struct proxy *proxy, struct stream *s, struct http_msg *msg, enum h1_state state, struct proxy *other_end) { union error_snapshot_ctx ctx; long ofs; /* http-specific part now */ ctx.http.sid = s->uniq_id; ctx.http.state = state; ctx.http.b_flags = msg->chn->flags; ctx.http.s_flags = s->flags; ctx.http.t_flags = s->txn->flags; ctx.http.m_flags = msg->flags; ctx.http.m_clen = msg->chunk_len; ctx.http.m_blen = msg->body_len; ofs = msg->chn->total - ci_data(msg->chn); if (ofs < 0) ofs = 0; proxy_capture_error(proxy, !!(msg->chn->flags & CF_ISRESP), other_end, s->target, strm_sess(s), &msg->chn->buf, ofs, co_data(msg->chn), (msg->err_pos >= 0) ? msg->err_pos : msg->next, &ctx, http_show_error_snapshot); } /* * Print a debug line with a header. Always stop at the first CR or LF char, * so it is safe to pass it a full buffer if needed. If <err> is not NULL, an * arrow is printed after the line which contains the pointer. */ void debug_hdr(const char *dir, struct stream *s, const char *start, const char *end) { struct session *sess = strm_sess(s); int max; chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", s->uniq_id, s->be->id, dir, objt_conn(sess->origin) ? (unsigned short)objt_conn(sess->origin)->handle.fd : -1, objt_cs(s->si[1].end) ? (unsigned short)objt_cs(s->si[1].end)->conn->handle.fd : -1); for (max = 0; start + max < end; max++) if (start[max] == '\r' || start[max] == '\n') break; UBOUND(max, trash.size - trash.data - 3); trash.data += strlcpy2(trash.area + trash.data, start, max + 1); trash.area[trash.data++] = '\n'; shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); } /* Allocate a new HTTP transaction for stream <s> unless there is one already. * The hdr_idx is allocated as well. In case of allocation failure, everything * allocated is freed and NULL is returned. Otherwise the new transaction is * assigned to the stream and returned. */ struct http_txn *http_alloc_txn(struct stream *s) { struct http_txn *txn = s->txn; if (txn) return txn; txn = pool_alloc(pool_head_http_txn); if (!txn) return txn; txn->hdr_idx.size = global.tune.max_http_hdr; txn->hdr_idx.v = pool_alloc(pool_head_hdr_idx); if (!txn->hdr_idx.v) { pool_free(pool_head_http_txn, txn); return NULL; } s->txn = txn; return txn; } void http_txn_reset_req(struct http_txn *txn) { txn->req.flags = 0; txn->req.sol = txn->req.eol = txn->req.eoh = 0; /* relative to the buffer */ txn->req.next = 0; txn->req.chunk_len = 0LL; txn->req.body_len = 0LL; txn->req.msg_state = HTTP_MSG_RQBEFORE; /* at the very beginning of the request */ } void http_txn_reset_res(struct http_txn *txn) { txn->rsp.flags = 0; txn->rsp.sol = txn->rsp.eol = txn->rsp.eoh = 0; /* relative to the buffer */ txn->rsp.next = 0; txn->rsp.chunk_len = 0LL; txn->rsp.body_len = 0LL; txn->rsp.msg_state = HTTP_MSG_RPBEFORE; /* at the very beginning of the response */ } /* * Initialize a new HTTP transaction for stream <s>. It is assumed that all * the required fields are properly allocated and that we only need to (re)init * them. This should be used before processing any new request. */ void http_init_txn(struct stream *s) { struct http_txn *txn = s->txn; struct proxy *fe = strm_fe(s); struct conn_stream *cs = objt_cs(s->si[0].end); txn->flags = ((cs && cs->flags & CS_FL_NOT_FIRST) ? (TX_NOT_FIRST|TX_WAIT_NEXT_RQ) : 0); txn->status = -1; txn->cookie_first_date = 0; txn->cookie_last_date = 0; txn->srv_cookie = NULL; txn->cli_cookie = NULL; txn->uri = NULL; http_txn_reset_req(txn); http_txn_reset_res(txn); txn->req.chn = &s->req; txn->rsp.chn = &s->res; txn->auth.method = HTTP_AUTH_UNKNOWN; txn->req.err_pos = txn->rsp.err_pos = -2; /* block buggy requests/responses */ if (fe->options2 & PR_O2_REQBUG_OK) txn->req.err_pos = -1; /* let buggy requests pass */ if (txn->hdr_idx.v) hdr_idx_init(&txn->hdr_idx); vars_init(&s->vars_txn, SCOPE_TXN); vars_init(&s->vars_reqres, SCOPE_REQ); } /* to be used at the end of a transaction */ void http_end_txn(struct stream *s) { struct http_txn *txn = s->txn; struct proxy *fe = strm_fe(s); /* these ones will have been dynamically allocated */ pool_free(pool_head_requri, txn->uri); pool_free(pool_head_capture, txn->cli_cookie); pool_free(pool_head_capture, txn->srv_cookie); pool_free(pool_head_uniqueid, s->unique_id); s->unique_id = NULL; txn->uri = NULL; txn->srv_cookie = NULL; txn->cli_cookie = NULL; if (s->req_cap) { struct cap_hdr *h; for (h = fe->req_cap; h; h = h->next) pool_free(h->pool, s->req_cap[h->index]); memset(s->req_cap, 0, fe->nb_req_cap * sizeof(void *)); } if (s->res_cap) { struct cap_hdr *h; for (h = fe->rsp_cap; h; h = h->next) pool_free(h->pool, s->res_cap[h->index]); memset(s->res_cap, 0, fe->nb_rsp_cap * sizeof(void *)); } if (!LIST_ISEMPTY(&s->vars_txn.head)) vars_prune(&s->vars_txn, s->sess, s); if (!LIST_ISEMPTY(&s->vars_reqres.head)) vars_prune(&s->vars_reqres, s->sess, s); } /* to be used at the end of a transaction to prepare a new one */ void http_reset_txn(struct stream *s) { http_end_txn(s); http_init_txn(s); /* reinitialise the current rule list pointer to NULL. We are sure that * any rulelist match the NULL pointer. */ s->current_rule_list = NULL; s->be = strm_fe(s); s->logs.logwait = strm_fe(s)->to_log; s->logs.level = 0; stream_del_srv_conn(s); s->target = NULL; /* re-init store persistence */ s->store_count = 0; s->uniq_id = HA_ATOMIC_XADD(&global.req_count, 1); s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */ /* We must trim any excess data from the response buffer, because we * may have blocked an invalid response from a server that we don't * want to accidently forward once we disable the analysers, nor do * we want those data to come along with next response. A typical * example of such data would be from a buggy server responding to * a HEAD with some data, or sending more than the advertised * content-length. */ if (unlikely(ci_data(&s->res))) b_set_data(&s->res.buf, co_data(&s->res)); /* Now we can realign the response buffer */ c_realign_if_empty(&s->res); s->req.rto = strm_fe(s)->timeout.client; s->req.wto = TICK_ETERNITY; s->res.rto = TICK_ETERNITY; s->res.wto = strm_fe(s)->timeout.client; s->req.rex = TICK_ETERNITY; s->req.wex = TICK_ETERNITY; s->req.analyse_exp = TICK_ETERNITY; s->res.rex = TICK_ETERNITY; s->res.wex = TICK_ETERNITY; s->res.analyse_exp = TICK_ETERNITY; s->si[1].hcto = TICK_ETERNITY; } /* This function executes one of the set-{method,path,query,uri} actions. It * takes the string from the variable 'replace' with length 'len', then modifies * the relevant part of the request line accordingly. Then it updates various * pointers to the next elements which were moved, and the total buffer length. * It finds the action to be performed in p[2], previously filled by function * parse_set_req_line(). It returns 0 in case of success, -1 in case of internal * error, though this can be revisited when this code is finally exploited. * * 'action' can be '0' to replace method, '1' to replace path, '2' to replace * query string and 3 to replace uri. * * In query string case, the mark question '?' must be set at the start of the * string by the caller, event if the replacement query string is empty. */ int http_replace_req_line(int action, const char *replace, int len, struct proxy *px, struct stream *s) { struct http_txn *txn = s->txn; char *cur_ptr, *cur_end; int offset = 0; int delta; if (IS_HTX_STRM(s)) return htx_req_replace_stline(action, replace, len, px, s); switch (action) { case 0: // method cur_ptr = ci_head(&s->req); cur_end = cur_ptr + txn->req.sl.rq.m_l; /* adjust req line offsets and lengths */ delta = len - offset - (cur_end - cur_ptr); txn->req.sl.rq.m_l += delta; txn->req.sl.rq.u += delta; txn->req.sl.rq.v += delta; break; case 1: // path cur_ptr = http_txn_get_path(txn); if (!cur_ptr) cur_ptr = ci_head(&s->req) + txn->req.sl.rq.u; cur_end = cur_ptr; while (cur_end < ci_head(&s->req) + txn->req.sl.rq.u + txn->req.sl.rq.u_l && *cur_end != '?') cur_end++; /* adjust req line offsets and lengths */ delta = len - offset - (cur_end - cur_ptr); txn->req.sl.rq.u_l += delta; txn->req.sl.rq.v += delta; break; case 2: // query offset = 1; cur_ptr = ci_head(&s->req) + txn->req.sl.rq.u; cur_end = cur_ptr + txn->req.sl.rq.u_l; while (cur_ptr < cur_end && *cur_ptr != '?') cur_ptr++; /* skip the question mark or indicate that we must insert it * (but only if the format string is not empty then). */ if (cur_ptr < cur_end) cur_ptr++; else if (len > 1) offset = 0; /* adjust req line offsets and lengths */ delta = len - offset - (cur_end - cur_ptr); txn->req.sl.rq.u_l += delta; txn->req.sl.rq.v += delta; break; case 3: // uri cur_ptr = ci_head(&s->req) + txn->req.sl.rq.u; cur_end = cur_ptr + txn->req.sl.rq.u_l; /* adjust req line offsets and lengths */ delta = len - offset - (cur_end - cur_ptr); txn->req.sl.rq.u_l += delta; txn->req.sl.rq.v += delta; break; default: return -1; } /* commit changes and adjust end of message */ delta = b_rep_blk(&s->req.buf, cur_ptr, cur_end, replace + offset, len - offset); txn->req.sl.rq.l += delta; txn->hdr_idx.v[0].len += delta; http_msg_move_end(&txn->req, delta); return 0; } /* This function replace the HTTP status code and the associated message. The * variable <status> contains the new status code. This function never fails. */ void http_set_status(unsigned int status, const char *reason, struct stream *s) { struct http_txn *txn = s->txn; char *cur_ptr, *cur_end; int delta; char *res; int c_l; const char *msg = reason; int msg_len; if (IS_HTX_STRM(s)) return htx_res_set_status(status, reason, s); chunk_reset(&trash); res = ultoa_o(status, trash.area, trash.size); c_l = res - trash.area; trash.area[c_l] = ' '; trash.data = c_l + 1; /* Do we have a custom reason format string? */ if (msg == NULL) msg = http_get_reason(status); msg_len = strlen(msg); strncpy(&trash.area[trash.data], msg, trash.size - trash.data); trash.data += msg_len; cur_ptr = ci_head(&s->res) + txn->rsp.sl.st.c; cur_end = ci_head(&s->res) + txn->rsp.sl.st.r + txn->rsp.sl.st.r_l; /* commit changes and adjust message */ delta = b_rep_blk(&s->res.buf, cur_ptr, cur_end, trash.area, trash.data); /* adjust res line offsets and lengths */ txn->rsp.sl.st.r += c_l - txn->rsp.sl.st.c_l; txn->rsp.sl.st.c_l = c_l; txn->rsp.sl.st.r_l = msg_len; delta = trash.data - (cur_end - cur_ptr); txn->rsp.sl.st.l += delta; txn->hdr_idx.v[0].len += delta; http_msg_move_end(&txn->rsp, delta); } /* * Local variables: * c-indent-level: 8 * c-basic-offset: 8 * End: */
32.550467
161
0.656046
[ "object" ]
bf6f0a1677a34f66d4374e0c6ede35b3308adc5b
41,898
c
C
gnome/src/rbgnome-app-helper.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
2
2016-05-08T20:57:12.000Z
2017-07-28T21:00:42.000Z
gnome/src/rbgnome-app-helper.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
null
null
null
gnome/src/rbgnome-app-helper.c
pkorenev/ruby-gnome2
08011d8535529a3866f877817f29361b1b0703d7
[ "Ruby" ]
2
2016-07-23T09:53:08.000Z
2021-07-13T07:21:05.000Z
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /* $Id: rbgnome-app-helper.c,v 1.18 2007/07/13 16:07:28 ggc Exp $ */ /* based on libgnomeui/gnome-app-helper.h */ /* Gnome::UIInfo module for Ruby/GNOME2 * Copyright (C) 2002-2003 Ruby-GNOME2 Project Team * Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org> * Copyright (C) 2001 Neil Conway <neilconway@rogers.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "rbgnome.h" static ID id_call; #define _SELF(self) GNOME_APP(RVAL2GOBJ(self)) #define CSTR2SYM(str) ID2SYM(rb_intern(str)) static VALUE uiinfo_separator(self) VALUE self; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_SEPARATOR)); /* type */ rb_ary_push(ary, Qnil); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, Qnil); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_item(self, label, tooltip, callback, xpm_data) VALUE self, label, tooltip, callback, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_item_stock(self, label, tooltip, callback, stock_id) VALUE self, label, tooltip, callback, stock_id; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_STOCK)); /* pixmap_type */ rb_ary_push(ary, stock_id); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_item_none(self, label, tooltip, callback) VALUE self, label, tooltip, callback; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_NONE)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_item_data(self, label, tooltip, callback, user_data, xpm_data) VALUE self, label, tooltip, callback, user_data, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, user_data); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_toggleitem(self, label, tooltip, callback, xpm_data) VALUE self, label, tooltip, callback, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_TOGGLEITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_toggleitem_data(self, label, tooltip, callback, user_data, xpm_data) VALUE self, label, tooltip, callback, user_data, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_TOGGLEITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, user_data); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_help(self, app_name) VALUE self, app_name; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_HELP)); /* type */ rb_ary_push(ary, Qnil); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, app_name); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_subtree(self, label, tree) VALUE self, label, tree; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_SUBTREE)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, tree); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_subtree_hint(self, label, hint, tree) VALUE self, label, hint, tree; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_SUBTREE)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, hint); /* hint */ rb_ary_push(ary, tree); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_subtree_stock(self, label, tree, stock_id) VALUE self, label, tree, stock_id; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_SUBTREE)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, tree); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_STOCK)); /* pixmap_type */ rb_ary_push(ary, stock_id); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_include(self, tree) VALUE self, tree; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_INCLUDE)); /* type */ rb_ary_push(ary, Qnil); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, tree); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_radiolist(self, list) VALUE self, list; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_RADIOITEMS)); /* type */ rb_ary_push(ary, Qnil); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, list); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(0)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_radioitem(self, label, tooltip, callback, xpm_data) VALUE self, label, tooltip, callback, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_radioitem_data(self, label, tooltip, callback, user_data, xpm_data) VALUE self, label, tooltip, callback, user_data, xpm_data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tooltip); /* hint */ rb_ary_push(ary, callback); /* moreinfo */ rb_ary_push(ary, user_data); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_DATA)); /* pixmap_type */ rb_ary_push(ary, xpm_data); /* pixmap_info */ rb_ary_push(ary, INT2FIX(0)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_menu_new_item(self, label, tip, cb, data) VALUE self, label, tip, cb, data; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_ITEM_CONFIGURABLE)); /* type */ rb_ary_push(ary, label); /* label */ rb_ary_push(ary, tip); /* hint */ rb_ary_push(ary, cb); /* moreinfo */ rb_ary_push(ary, data); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_NONE)); /* pixmap_type */ rb_ary_push(ary, Qnil); /* pixmap_info */ rb_ary_push(ary, INT2FIX(GNOME_APP_CONFIGURABLE_ITEM_NEW)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(0)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } static VALUE uiinfo_menu_new_subtree(self, tree) VALUE self, tree; { VALUE ary; ary = rb_ary_new2(10); rb_ary_push(ary, INT2FIX(GNOME_APP_UI_SUBTREE_STOCK)); /* type */ rb_ary_push(ary, rb_str_new2(N_("_New"))); /* label */ rb_ary_push(ary, Qnil); /* hint */ rb_ary_push(ary, tree); /* moreinfo */ rb_ary_push(ary, Qnil); /* user_data */ rb_ary_push(ary, INT2FIX(GNOME_APP_PIXMAP_STOCK)); /* pixmap_type */ rb_ary_push(ary, CSTR2SYM(GTK_STOCK_NEW)); /* pixmap_info */ rb_ary_push(ary, INT2FIX(GNOME_KEY_NAME_NEW)); /* accelerator_key */ rb_ary_push(ary, INT2FIX(GNOME_KEY_MOD_NEW)); /* ac_mods */ rb_ary_push(ary, Qnil); /* widget */ return ary; } #define DEF_UIINFO_CONF(func_name, type) \ static VALUE \ func_name(self, cb, data) \ VALUE self, cb, data; \ { \ return rb_ary_new3(10, \ INT2FIX(GNOME_APP_UI_ITEM_CONFIGURABLE), /* type */ \ Qnil, /* label */ \ Qnil, /* hint */ \ (cb), /* moreinfo */ \ (data), /* user_data */ \ INT2FIX(GNOME_APP_PIXMAP_NONE), /* pixmap_type */ \ Qnil, /* pixmap_info */ \ INT2FIX(type), /* accelerator_key */ \ INT2FIX(0), /* ac_mods */ \ Qnil /* widget */ ); \ } DEF_UIINFO_CONF(uiinfo_menu_open_item, GNOME_APP_CONFIGURABLE_ITEM_OPEN); DEF_UIINFO_CONF(uiinfo_menu_save_item, GNOME_APP_CONFIGURABLE_ITEM_SAVE); DEF_UIINFO_CONF(uiinfo_menu_save_as_item, GNOME_APP_CONFIGURABLE_ITEM_SAVE_AS); DEF_UIINFO_CONF(uiinfo_menu_revert_item, GNOME_APP_CONFIGURABLE_ITEM_REVERT); DEF_UIINFO_CONF(uiinfo_menu_print_item, GNOME_APP_CONFIGURABLE_ITEM_PRINT); DEF_UIINFO_CONF(uiinfo_menu_print_setup_item, GNOME_APP_CONFIGURABLE_ITEM_PRINT_SETUP); DEF_UIINFO_CONF(uiinfo_menu_close_item, GNOME_APP_CONFIGURABLE_ITEM_CLOSE); DEF_UIINFO_CONF(uiinfo_menu_quit_item, GNOME_APP_CONFIGURABLE_ITEM_QUIT); DEF_UIINFO_CONF(uiinfo_menu_cut_item, GNOME_APP_CONFIGURABLE_ITEM_CUT); DEF_UIINFO_CONF(uiinfo_menu_copy_item, GNOME_APP_CONFIGURABLE_ITEM_COPY); DEF_UIINFO_CONF(uiinfo_menu_paste_item, GNOME_APP_CONFIGURABLE_ITEM_PASTE); DEF_UIINFO_CONF(uiinfo_menu_select_all_item, GNOME_APP_CONFIGURABLE_ITEM_SELECT_ALL); DEF_UIINFO_CONF(uiinfo_menu_clear_item, GNOME_APP_CONFIGURABLE_ITEM_CLEAR); DEF_UIINFO_CONF(uiinfo_menu_undo_item, GNOME_APP_CONFIGURABLE_ITEM_UNDO); DEF_UIINFO_CONF(uiinfo_menu_redo_item, GNOME_APP_CONFIGURABLE_ITEM_REDO); DEF_UIINFO_CONF(uiinfo_menu_find_item, GNOME_APP_CONFIGURABLE_ITEM_FIND); DEF_UIINFO_CONF(uiinfo_menu_find_again_item, GNOME_APP_CONFIGURABLE_ITEM_FIND_AGAIN); DEF_UIINFO_CONF(uiinfo_menu_replace_item, GNOME_APP_CONFIGURABLE_ITEM_REPLACE); DEF_UIINFO_CONF(uiinfo_menu_properties_item, GNOME_APP_CONFIGURABLE_ITEM_PROPERTIES); DEF_UIINFO_CONF(uiinfo_menu_preferences_item, GNOME_APP_CONFIGURABLE_ITEM_PREFERENCES); DEF_UIINFO_CONF(uiinfo_menu_new_window_item, GNOME_APP_CONFIGURABLE_ITEM_NEW_WINDOW); DEF_UIINFO_CONF(uiinfo_menu_close_window_item, GNOME_APP_CONFIGURABLE_ITEM_CLOSE_WINDOW); DEF_UIINFO_CONF(uiinfo_menu_about_item, GNOME_APP_CONFIGURABLE_ITEM_ABOUT); DEF_UIINFO_CONF(uiinfo_menu_new_game_item, GNOME_APP_CONFIGURABLE_ITEM_NEW_GAME); DEF_UIINFO_CONF(uiinfo_menu_pause_game_item, GNOME_APP_CONFIGURABLE_ITEM_PAUSE_GAME); DEF_UIINFO_CONF(uiinfo_menu_restart_game_item, GNOME_APP_CONFIGURABLE_ITEM_RESTART_GAME); DEF_UIINFO_CONF(uiinfo_menu_undo_move_item, GNOME_APP_CONFIGURABLE_ITEM_UNDO_MOVE); DEF_UIINFO_CONF(uiinfo_menu_redo_move_item, GNOME_APP_CONFIGURABLE_ITEM_REDO_MOVE); DEF_UIINFO_CONF(uiinfo_menu_hint_item, GNOME_APP_CONFIGURABLE_ITEM_HINT); DEF_UIINFO_CONF(uiinfo_menu_scores_item, GNOME_APP_CONFIGURABLE_ITEM_SCORES); DEF_UIINFO_CONF(uiinfo_menu_end_game_item, GNOME_APP_CONFIGURABLE_ITEM_END_GAME); #define DEF_UIINFO_TREE(func_name, label) \ static VALUE \ func_name(self, tree) \ VALUE self, tree; \ { \ return rb_ary_new3(10, \ INT2FIX(GNOME_APP_UI_SUBTREE_STOCK), /* type */ \ rb_str_new2(N_(label)), /* label */ \ Qnil, /* hint */ \ (tree), /* moreinfo */ \ Qnil, /* user_data */ \ INT2FIX(0), /* pixmap_type */ \ Qnil, /* pixmap_info */ \ INT2FIX(0), /* accelerator_key */ \ INT2FIX(0), /* ac_mods */ \ Qnil /* widget */ ); \ } DEF_UIINFO_TREE(uiinfo_menu_file_tree, "_File"); DEF_UIINFO_TREE(uiinfo_menu_edit_tree, "_Edit"); DEF_UIINFO_TREE(uiinfo_menu_view_tree, "_View"); DEF_UIINFO_TREE(uiinfo_menu_settings_tree, "_Settings"); DEF_UIINFO_TREE(uiinfo_menu_files_tree, "Fi_les"); DEF_UIINFO_TREE(uiinfo_menu_windows_tree, "_Windows"); DEF_UIINFO_TREE(uiinfo_menu_help_tree, "_Help"); DEF_UIINFO_TREE(uiinfo_menu_game_tree, "_Game"); static void menu_item_callback(GtkWidget *widget, gpointer data, GtkWidget *for_widget) { VALUE proc = (VALUE)g_object_get_data(G_OBJECT(widget), GNOMEUIINFO_KEY_UIDATA); rb_funcall(proc, id_call, 3, GOBJ2RVAL(widget), (VALUE)data, for_widget ? GOBJ2RVAL(for_widget) : Qnil); } static void do_ui_signal_connect(uiinfo, signal_name, uibdata) GnomeUIInfo *uiinfo; gchar *signal_name; GnomeUIBuilderData *uibdata; { VALUE proc = (VALUE)uiinfo->moreinfo; VALUE args; GClosure* rclosure; if (NIL_P(proc)) return; args = rb_ary_new3(1, (VALUE)uiinfo->user_data); rclosure = g_rclosure_new(proc, args, NULL); /* FIX ME: GOBJ2RVAL(uiinfo->widget) will be GCed. This is same problem as the following: Gtk::Window.new.show_all.signal_connect("destroy") {p :destroyed} In the above sample, callback can't be invoked when the object made by "Gtk::Window.new" is GCed. */ g_rclosure_attach(rclosure, GOBJ2RVAL(uiinfo->widget)); g_signal_connect_closure(G_OBJECT(uiinfo->widget), signal_name, rclosure, FALSE); } static GnomeUIBuilderData RbGnome_UIBuilder = { do_ui_signal_connect, 0, 0, 0, 0 }; static void fill_ui_info(uiinfo, ary, uitype) GnomeUIInfo *uiinfo; VALUE ary; enum RBUIInfoType uitype; { GnomeUIInfoType type; GnomeUIInfo *sub; VALUE item, moreinfo, pixmap_info; char **xpm_data; int i, j; /* ary is T_ARRAY. */ for (i = 0; i < RARRAY_LEN(ary); i++) { item = RARRAY_PTR(ary)[i]; /* set temporal terminator for free_ui_info. */ uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; uiinfo[i].moreinfo = NULL; uiinfo[i].pixmap_type = GNOME_APP_PIXMAP_NONE; uiinfo[i].pixmap_info = NULL; if (TYPE(item) != T_ARRAY) rb_raise(rb_eArgError, "invalid data type for UIInfo entry (%s for Array)", rb_class2name(CLASS_OF(item))); if (RARRAY_LEN(item) != 10) rb_raise(rb_eArgError, "wrong array size for UIInfo entry (%ld for 10)", RARRAY_LEN(item));; type = RVAL2GENUM(RARRAY_PTR(item)[0], GNOME_TYPE_UI_INFO_TYPE); uiinfo[i].label = NIL_P(RARRAY_PTR(item)[1])?0:RVAL2CSTR(RARRAY_PTR(item)[1]); uiinfo[i].hint = NIL_P(RARRAY_PTR(item)[2])?0:RVAL2CSTR(RARRAY_PTR(item)[2]); moreinfo = RARRAY_PTR(item)[3]; uiinfo[i].user_data = (gpointer)RARRAY_PTR(item)[4]; uiinfo[i].unused_data = NULL; uiinfo[i].pixmap_type = RVAL2GENUM(RARRAY_PTR(item)[5], GNOME_TYPE_UI_PIXMAP_TYPE); pixmap_info = RARRAY_PTR(item)[6]; uiinfo[i].accelerator_key = NUM2INT(RARRAY_PTR(item)[7]); uiinfo[i].ac_mods = RVAL2GFLAGS(RARRAY_PTR(item)[8], GDK_TYPE_MODIFIER_TYPE); uiinfo[i].widget = NIL_P(RARRAY_PTR(item)[9])?0:GTK_WIDGET(RVAL2GOBJ((RARRAY_PTR(item)[9]))); switch (uitype) { case RBUI_MENUS: case RBUI_MENU_HINTS: case RBUI_POPUP_MENU: break; case RBUI_TOOLBAR: switch (type) { case GNOME_APP_UI_INCLUDE: case GNOME_APP_UI_RADIOITEMS: case GNOME_APP_UI_SEPARATOR: case GNOME_APP_UI_ITEM: case GNOME_APP_UI_TOGGLEITEM: break; default: rb_raise(rb_eArgError, "Invalid type for toolbar"); } break; } switch (type) { case GNOME_APP_UI_ITEM: case GNOME_APP_UI_TOGGLEITEM: case GNOME_APP_UI_ITEM_CONFIGURABLE: break; default: if (NIL_P(uiinfo[i].user_data)) uiinfo[i].user_data = NULL; } #define RAISE_TYPE_MISMATCH(pos, obj, expect) \ rb_raise(rb_eArgError, \ "wrong data type for %s (%s for %s)", \ pos, rb_class2name(CLASS_OF(obj)), expect) /* set moreinfo */ switch (type) { case GNOME_APP_UI_ENDOFINFO: case GNOME_APP_UI_SEPARATOR: /* expect nil */ if (!NIL_P(moreinfo)) RAISE_TYPE_MISMATCH("moreinfo", moreinfo, "nil"); uiinfo[i].moreinfo = NULL; uiinfo[i].type = type; break; case GNOME_APP_UI_ITEM: case GNOME_APP_UI_TOGGLEITEM: case GNOME_APP_UI_ITEM_CONFIGURABLE: /* expect Proc */ if (!rb_obj_is_kind_of(moreinfo, rb_cProc)) RAISE_TYPE_MISMATCH("moreinfo", moreinfo, "Proc"); if (uitype == RBUI_POPUP_MENU) { uiinfo[i].moreinfo = (gpointer)menu_item_callback; uiinfo[i].user_data = (gpointer)moreinfo; } else { uiinfo[i].moreinfo = (gpointer)moreinfo; } uiinfo[i].type = type; break; case GNOME_APP_UI_RADIOITEMS: case GNOME_APP_UI_SUBTREE: case GNOME_APP_UI_SUBTREE_STOCK: case GNOME_APP_UI_INCLUDE: /* expect subarray */ if (TYPE(moreinfo) != T_ARRAY) RAISE_TYPE_MISMATCH("moreinfo", moreinfo, "Array"); sub = g_new(GnomeUIInfo, RARRAY_LEN(moreinfo) + 1); sub[0].type = GNOME_APP_UI_ENDOFINFO; uiinfo[i].moreinfo = sub; uiinfo[i].type = type; fill_ui_info(sub, moreinfo, uitype); break; case GNOME_APP_UI_HELP: /* expect string */ if (TYPE(moreinfo) != T_STRING) RAISE_TYPE_MISMATCH("moreinfo", moreinfo, "String"); uiinfo[i].moreinfo = RVAL2CSTR(moreinfo); uiinfo[i].type = type; break; case GNOME_APP_UI_BUILDER_DATA: default: rb_raise(rb_eArgError, "wrong type (%d for Gnome::App::UI_*)", type); } /* set pixmap_info */ switch (uiinfo[i].pixmap_type) { case GNOME_APP_PIXMAP_NONE: if (!NIL_P(pixmap_info)) rb_raise(rb_eArgError, "wrong pixmap data for Gnome::App::PIXMAP_NONE (%s for nil)", rb_class2name(CLASS_OF(pixmap_info))); break; case GNOME_APP_PIXMAP_STOCK: if (NIL_P(pixmap_info)) break; if (!SYMBOL_P(pixmap_info)) rb_raise(rb_eArgError, "wrong pixmap data for Gnome::App::PIXMAP_STOCK (%s for Symbol)", rb_class2name(CLASS_OF(pixmap_info))); uiinfo[i].pixmap_info = rb_id2name(SYM2ID(pixmap_info)); break; case GNOME_APP_PIXMAP_DATA: if (NIL_P(pixmap_info)) break; if (TYPE(pixmap_info) != T_ARRAY) rb_raise(rb_eArgError, "wrong pixmap data for Gnome::App::PIXMAP_DATA (%s for Array)", rb_class2name(CLASS_OF(pixmap_info))); xpm_data = g_new(char *, RARRAY_LEN(pixmap_info) + 1); uiinfo[i].pixmap_info = xpm_data; for (j = 0; j < RARRAY_LEN(pixmap_info); j++) { xpm_data[j] = RVAL2CSTR(RARRAY_PTR(pixmap_info)[j]); } xpm_data[j] = NULL; break; case GNOME_APP_PIXMAP_FILENAME: if (NIL_P(pixmap_info)) break; if (TYPE(pixmap_info) != T_STRING) rb_raise(rb_eArgError, "wrong pixmap data for Gnome::App::PIXMAP_FILENAME (%s for String)", rb_class2name(CLASS_OF(pixmap_info))); uiinfo[i].pixmap_info = RVAL2CSTR(pixmap_info); break; default: rb_raise(rb_eArgError, "wrong pixmap type (%d for Gnome::App::PIXMAP_*)", uiinfo[i].pixmap_type); } } uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; } static void free_ui_info(uiinfo) GnomeUIInfo *uiinfo; { GnomeUIInfo *inf; for (inf = uiinfo; inf->type != GNOME_APP_UI_ENDOFINFO; inf++) { /* free moreinfo */ switch (inf->type) { case GNOME_APP_UI_RADIOITEMS: case GNOME_APP_UI_SUBTREE: case GNOME_APP_UI_SUBTREE_STOCK: case GNOME_APP_UI_INCLUDE: free_ui_info(inf->moreinfo); break; default: break; } /* free pixmap_info */ switch (inf->pixmap_type) { case GNOME_APP_PIXMAP_DATA: if (inf->pixmap_info) g_free((gpointer)inf->pixmap_info); break; default: break; } } g_free(uiinfo); } /* * Don't use returned value after 'ary' is GCed. * This is only for short time lifetime. */ VALUE rbgno_ary_to_ui_info(ary, uitype) VALUE ary; enum RBUIInfoType uitype; { GnomeUIInfo *uiinfo; VALUE obj; Check_Type(ary, T_ARRAY); uiinfo = g_new(GnomeUIInfo, RARRAY_LEN(ary) + 1); /* set terminator for free_ui_info. */ uiinfo[0].type = GNOME_APP_UI_ENDOFINFO; obj = Data_Wrap_Struct(rb_cData, NULL, free_ui_info, uiinfo); /* uiinfo will be freed, even if any exception occurs in the following function.*/ fill_ui_info(uiinfo, ary, uitype); return obj; } static VALUE ui_info_to_ary(uiinfo) GnomeUIInfo *uiinfo; { VALUE ary, item, xpm_data; char **xpm; ary = rb_ary_new(); for (; uiinfo->type != GNOME_APP_UI_ENDOFINFO; uiinfo++) { item = rb_ary_new(); rb_ary_push(item, INT2FIX(uiinfo->type)); /* 0 */ rb_ary_push(item, uiinfo->label ? rb_str_new2(uiinfo->label) : Qnil); /* 1 */ rb_ary_push(item, uiinfo->hint ? rb_str_new2(uiinfo->hint) : Qnil); /* 2 */ switch (uiinfo->type) { /* 3 */ case GNOME_APP_UI_ENDOFINFO: case GNOME_APP_UI_SEPARATOR: rb_ary_push(item, Qnil); break; case GNOME_APP_UI_ITEM: case GNOME_APP_UI_TOGGLEITEM: case GNOME_APP_UI_ITEM_CONFIGURABLE: rb_ary_push(item, (VALUE)uiinfo->moreinfo); break; case GNOME_APP_UI_RADIOITEMS: case GNOME_APP_UI_SUBTREE: case GNOME_APP_UI_SUBTREE_STOCK: case GNOME_APP_UI_INCLUDE: rb_ary_push(item, ui_info_to_ary(uiinfo->moreinfo)); break; case GNOME_APP_UI_HELP: rb_ary_push(item, rb_str_new2(uiinfo->moreinfo)); break; case GNOME_APP_UI_BUILDER_DATA: /* ignore this entry */ continue; } rb_ary_push(item, (VALUE)uiinfo->user_data); /* 4 */ rb_ary_push(item, INT2FIX(uiinfo->pixmap_type)); /* 5 */ switch (uiinfo->pixmap_type) { /* 6 */ case GNOME_APP_PIXMAP_NONE: rb_ary_push(item, Qnil); break; case GNOME_APP_PIXMAP_STOCK: rb_ary_push(item, CSTR2SYM(uiinfo->pixmap_info)); break; case GNOME_APP_PIXMAP_FILENAME: rb_ary_push(item, rb_str_new2(uiinfo->pixmap_info)); break; case GNOME_APP_PIXMAP_DATA: if (uiinfo->pixmap_info == NULL) { xpm_data = Qnil; } else { xpm_data = rb_ary_new(); for (xpm = (char **)uiinfo->pixmap_info; *xpm != NULL; xpm++) { rb_ary_push(xpm_data, rb_str_new2(*xpm)); } rb_ary_push(item, xpm_data); } break; } rb_ary_push(item, INT2FIX(uiinfo->accelerator_key)); /* 7 */ rb_ary_push(item, INT2FIX(uiinfo->ac_mods)); /* 8 */ rb_ary_push(item, uiinfo->widget ? GOBJ2RVAL(uiinfo->widget) : Qnil); /* 9 */ rb_ary_push(ary, item); } return ary; } static VALUE app_fill_menus(self, menuinfo, accel_group, uline_accels, pos) VALUE self, menuinfo, accel_group; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENUS); gnome_app_fill_menu_custom(GTK_MENU_SHELL(RVAL2GOBJ(self)), DATA_PTR(uiinfo), &RbGnome_UIBuilder, GTK_ACCEL_GROUP(RVAL2GOBJ(accel_group)), RVAL2CBOOL(uline_accels), NUM2INT(pos)); return ui_info_to_ary(DATA_PTR(uiinfo)); } static VALUE gno_s_accelerators_sync(self) VALUE self; { gnome_accelerators_sync(); return self; } /* How can I implement this? void gnome_app_ui_configure_configurable (GnomeUIInfo *uiinfo); */ static VALUE app_create_menus(self, menuinfo) VALUE self, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENUS); gnome_app_create_menus_custom(GNOME_APP(RVAL2GOBJ(self)), DATA_PTR(uiinfo), &RbGnome_UIBuilder); return ui_info_to_ary(DATA_PTR(uiinfo)); } static VALUE app_fill_toolbar(self, menuinfo, accel_group) VALUE self, menuinfo, accel_group; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_TOOLBAR); gnome_app_fill_toolbar_custom(GTK_TOOLBAR(RVAL2GOBJ(self)), DATA_PTR(uiinfo), &RbGnome_UIBuilder, GTK_ACCEL_GROUP(RVAL2GOBJ(accel_group))); return ui_info_to_ary(DATA_PTR(uiinfo)); } static VALUE app_create_toolbar(self, menuinfo) VALUE self, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_TOOLBAR); gnome_app_create_toolbar_custom(_SELF(self), DATA_PTR(uiinfo), &RbGnome_UIBuilder); return ui_info_to_ary(DATA_PTR(uiinfo)); } static VALUE app_find_menu_pos(self, path) VALUE self, path; { GtkWidget *item; gint pos; item = gnome_app_find_menu_pos(GTK_WIDGET(RVAL2GOBJ(self)), RVAL2CSTR(path), &pos); return item ? rb_ary_new3(2, GOBJ2RVAL(item), INT2NUM(pos)) : Qnil; } static VALUE app_remove_menus(self, path, items) VALUE self, path, items; { gnome_app_remove_menus(_SELF(self), RVAL2CSTR(path), NUM2INT(items)); return self; } static VALUE app_remove_menu_range(self, path, start, items) VALUE self, path, start, items; { gnome_app_remove_menu_range(_SELF(self), RVAL2CSTR(path), NUM2INT(start), NUM2INT(items)); return self; } static VALUE app_insert_menus(self, path, menuinfo) VALUE self, path, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENUS); gnome_app_insert_menus_custom(_SELF(self), RVAL2CSTR(path), DATA_PTR(uiinfo), &RbGnome_UIBuilder); return ui_info_to_ary(DATA_PTR(uiinfo)); } static VALUE app_install_appbar_menu_hints(self, menuinfo) VALUE self, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENU_HINTS); gnome_app_install_appbar_menu_hints(GNOME_APPBAR(RVAL2GOBJ(self)), DATA_PTR(uiinfo)); return self; } static VALUE app_install_statusbar_menu_hints(self, menuinfo) VALUE self, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENU_HINTS); gnome_app_install_statusbar_menu_hints(GTK_STATUSBAR(RVAL2GOBJ(self)), DATA_PTR(uiinfo)); return self; } static VALUE app_install_menu_hints(self, menuinfo) VALUE self, menuinfo; { VALUE uiinfo = rbgno_ary_to_ui_info(menuinfo, RBUI_MENU_HINTS); gnome_app_install_menu_hints(GNOME_APP(RVAL2GOBJ(self)), DATA_PTR(uiinfo)); return self; } static VALUE app_setup_toolbar(self, dock_item) VALUE self, dock_item; { gnome_app_setup_toolbar(GTK_TOOLBAR(RVAL2GOBJ(self)), BONOBO_DOCK_ITEM(RVAL2GOBJ(dock_item))); return self; } void Init_gnome_app_helper(mGnome) VALUE mGnome; { VALUE mGnomeUIInfo = rb_define_module_under(mGnome, "UIInfo"); VALUE gnoApp = GTYPE2CLASS(GNOME_TYPE_APP); VALUE gnoAppBar = GTYPE2CLASS(GNOME_TYPE_APPBAR); VALUE gtkMenuShell = GTYPE2CLASS(GTK_TYPE_MENU_SHELL); VALUE gtkStatusBar = GTYPE2CLASS(GTK_TYPE_STATUSBAR); VALUE gtkToolBar = GTYPE2CLASS(GTK_TYPE_TOOLBAR); id_call = rb_intern("call"); /* GnomeUIInfoType */ G_DEF_CLASS(GNOME_TYPE_UI_INFO_TYPE, "UIInfoType", gnoApp); G_DEF_CONSTANTS(gnoApp, GNOME_TYPE_UI_INFO_TYPE, "GNOME_APP_"); /* GnomeUIInfoConfigurableTypes */ G_DEF_CLASS(GNOME_TYPE_UI_INFO_CONFIGURABLE_TYPES, "UIInfoConfigurableTypes", gnoApp); G_DEF_CONSTANTS(gnoApp, GNOME_TYPE_UI_INFO_CONFIGURABLE_TYPES, "GNOME_APP_"); /* GnomeUIPixmapType */ G_DEF_CLASS(GNOME_TYPE_UI_PIXMAP_TYPE, "UIPixmapType", gnoApp); G_DEF_CONSTANTS(gnoApp, GNOME_TYPE_UI_PIXMAP_TYPE, "GNOME_APP_"); /* */ rb_define_module_function(mGnomeUIInfo, "separator", uiinfo_separator, 0); rb_define_module_function(mGnomeUIInfo, "item", uiinfo_item, 4); rb_define_module_function(mGnomeUIInfo, "item_stock", uiinfo_item_stock, 4); rb_define_module_function(mGnomeUIInfo, "item_none", uiinfo_item_none, 3); rb_define_module_function(mGnomeUIInfo, "item_data", uiinfo_item_data, 5); rb_define_module_function(mGnomeUIInfo, "toggleitem", uiinfo_toggleitem, 4); rb_define_module_function(mGnomeUIInfo, "toggleitem_data", uiinfo_toggleitem_data, 5); rb_define_module_function(mGnomeUIInfo, "help", uiinfo_help, 1); rb_define_module_function(mGnomeUIInfo, "subtree", uiinfo_subtree, 2); rb_define_module_function(mGnomeUIInfo, "subtree_hint", uiinfo_subtree_hint, 3); rb_define_module_function(mGnomeUIInfo, "subtree_stock", uiinfo_subtree_stock, 3); rb_define_module_function(mGnomeUIInfo, "include", uiinfo_include, 1); rb_define_module_function(mGnomeUIInfo, "radiolist", uiinfo_radiolist, 1); rb_define_module_function(mGnomeUIInfo, "radioitem", uiinfo_radioitem, 4); rb_define_module_function(mGnomeUIInfo, "radioitem_data", uiinfo_radioitem_data, 5); /* The 'File' menu */ rb_define_module_function(mGnomeUIInfo, "menu_new_item", uiinfo_menu_new_item, 4); rb_define_module_function(mGnomeUIInfo, "menu_new_subtree", uiinfo_menu_new_subtree, 1); rb_define_module_function(mGnomeUIInfo, "menu_open_item", uiinfo_menu_open_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_save_item", uiinfo_menu_save_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_save_as_item", uiinfo_menu_save_as_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_revert_item", uiinfo_menu_revert_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_print_item", uiinfo_menu_print_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_print_setup_item", uiinfo_menu_print_setup_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_close_item", uiinfo_menu_close_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_quit_item", uiinfo_menu_quit_item, 2); /* The "Edit" menu */ rb_define_module_function(mGnomeUIInfo, "menu_cut_item", uiinfo_menu_cut_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_copy_item", uiinfo_menu_copy_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_paste_item", uiinfo_menu_paste_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_select_all_item", uiinfo_menu_select_all_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_clear_item", uiinfo_menu_clear_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_undo_item", uiinfo_menu_undo_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_redo_item", uiinfo_menu_redo_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_find_item", uiinfo_menu_find_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_find_again_item", uiinfo_menu_find_again_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_replace_item", uiinfo_menu_replace_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_properties_item", uiinfo_menu_properties_item, 2); /* The Settings menu */ rb_define_module_function(mGnomeUIInfo, "menu_preferences_item", uiinfo_menu_preferences_item, 2); /* The Windows menu */ rb_define_module_function(mGnomeUIInfo, "menu_new_window_item", uiinfo_menu_new_window_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_close_window_item", uiinfo_menu_close_window_item, 2); /* The "Help" menu */ rb_define_module_function(mGnomeUIInfo, "menu_about_item", uiinfo_menu_about_item, 2); /* The "Game" menu */ rb_define_module_function(mGnomeUIInfo, "menu_new_game_item", uiinfo_menu_new_game_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_pause_game_item", uiinfo_menu_pause_game_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_restart_game_item", uiinfo_menu_restart_game_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_undo_move_item", uiinfo_menu_undo_move_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_redo_move_item", uiinfo_menu_redo_move_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_hint_item", uiinfo_menu_hint_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_scores_item", uiinfo_menu_scores_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_end_game_item", uiinfo_menu_end_game_item, 2); rb_define_module_function(mGnomeUIInfo, "menu_file_tree", uiinfo_menu_file_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_edit_tree", uiinfo_menu_edit_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_view_tree", uiinfo_menu_view_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_settings_tree", uiinfo_menu_settings_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_files_tree", uiinfo_menu_files_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_windows_tree", uiinfo_menu_windows_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_help_tree", uiinfo_menu_help_tree, 1); rb_define_module_function(mGnomeUIInfo, "menu_game_tree", uiinfo_menu_game_tree, 1); /* Misc methods */ rb_define_module_function(mGnome, "accelerators_sync", gno_s_accelerators_sync, 0); rb_define_method(gtkMenuShell, "fill_menus", app_fill_menus, 4); rb_define_method(gnoApp, "create_menus", app_create_menus, 1); rb_define_method(gtkToolBar, "fill_toolbar", app_fill_toolbar, 2); rb_define_method(gnoApp, "create_toolbar", app_create_toolbar, 1); rb_define_method(gtkMenuShell, "find_menu_pos", app_find_menu_pos, 1); rb_define_method(gnoApp, "remove_menus", app_remove_menus, 2); rb_define_method(gnoApp, "remove_menu_range", app_remove_menu_range, 3); rb_define_method(gnoApp, "insert_menus", app_insert_menus, 2); rb_define_method(gnoAppBar, "install_menu_hints", app_install_appbar_menu_hints, 1); rb_define_method(gtkStatusBar, "install_menu_hints", app_install_statusbar_menu_hints, 1); rb_define_method(gnoApp, "install_menu_hints", app_install_menu_hints, 1); rb_define_method(gtkToolBar, "setup_toolbar", app_setup_toolbar, 1); }
40.836257
108
0.635567
[ "object" ]
bf72652299b3ba4e978924e0b57df688e1ef58d4
3,052
h
C
ZLScanModule/Frameworks/opencv2.framework/Versions/A/Headers/QRCodeEncoder.h
RichieZhl/ZLScanModule
cd058847b145114240f814030aae4cc0069c1abc
[ "MIT" ]
null
null
null
ZLScanModule/Frameworks/opencv2.framework/Versions/A/Headers/QRCodeEncoder.h
RichieZhl/ZLScanModule
cd058847b145114240f814030aae4cc0069c1abc
[ "MIT" ]
null
null
null
ZLScanModule/Frameworks/opencv2.framework/Versions/A/Headers/QRCodeEncoder.h
RichieZhl/ZLScanModule
cd058847b145114240f814030aae4cc0069c1abc
[ "MIT" ]
null
null
null
// // This file is auto-generated. Please don't modify it! // #pragma once #ifdef __cplusplus //#import "opencv.hpp" #import "opencv2/objdetect.hpp" #else #define CV_EXPORTS #endif #import <Foundation/Foundation.h> @class Mat; @class QRCodeEncoderParams; // C++: enum CorrectionLevel (cv.QRCodeEncoder.CorrectionLevel) typedef NS_ENUM(int, CorrectionLevel) { CORRECT_LEVEL_L = 0, CORRECT_LEVEL_M = 1, CORRECT_LEVEL_Q = 2, CORRECT_LEVEL_H = 3 }; // C++: enum ECIEncodings (cv.QRCodeEncoder.ECIEncodings) typedef NS_ENUM(int, ECIEncodings) { ECI_UTF8 = 26 }; // C++: enum EncodeMode (cv.QRCodeEncoder.EncodeMode) typedef NS_ENUM(int, EncodeMode) { MODE_AUTO = -1, MODE_NUMERIC = 1, MODE_ALPHANUMERIC = 2, MODE_BYTE = 4, MODE_ECI = 7, MODE_KANJI = 8, MODE_STRUCTURED_APPEND = 3 }; NS_ASSUME_NONNULL_BEGIN // C++: class QRCodeEncoder /** * Groups the object candidate rectangles. * rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.) * weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.) * groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. * eps Relative difference between sides of the rectangles to merge them into a group. * * Member of `Objdetect` */ CV_EXPORTS @interface QRCodeEncoder : NSObject #ifdef __cplusplus @property(readonly)cv::Ptr<cv::QRCodeEncoder> nativePtr; #endif #ifdef __cplusplus - (instancetype)initWithNativePtr:(cv::Ptr<cv::QRCodeEncoder>)nativePtr; + (instancetype)fromNative:(cv::Ptr<cv::QRCodeEncoder>)nativePtr; #endif #pragma mark - Methods // // static Ptr_QRCodeEncoder cv::QRCodeEncoder::create(QRCodeEncoder_Params parameters = QRCodeEncoder::Params()) // /** * Constructor * @param parameters QR code encoder parameters QRCodeEncoder::Params */ + (QRCodeEncoder*)create:(QRCodeEncoderParams*)parameters NS_SWIFT_NAME(create(parameters:)); /** * Constructor */ + (QRCodeEncoder*)create NS_SWIFT_NAME(create()); // // void cv::QRCodeEncoder::encode(String encoded_info, Mat& qrcode) // /** * Generates QR code from input string. * @param encoded_info Input string to encode. * @param qrcode Generated QR code. */ - (void)encode:(NSString*)encoded_info qrcode:(Mat*)qrcode NS_SWIFT_NAME(encode(encoded_info:qrcode:)); // // void cv::QRCodeEncoder::encodeStructuredAppend(String encoded_info, vector_Mat& qrcodes) // /** * Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. * @param encoded_info Input string to encode. * @param qrcodes Vector of generated QR codes. */ - (void)encodeStructuredAppend:(NSString*)encoded_info qrcodes:(NSMutableArray<Mat*>*)qrcodes NS_SWIFT_NAME(encodeStructuredAppend(encoded_info:qrcodes:)); @end NS_ASSUME_NONNULL_END
25.647059
171
0.742464
[ "object", "vector" ]
bf799efd12ab83421996f2beea638d74c22c2342
21,915
h
C
NN/RL.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
NN/RL.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
NN/RL.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
#pragma once #include <utils/utils.h> #include <utils/fileutils.h> #include <utils/queue.h> #include "DLNet.h" #include <list> #include <vector> namespace RL { // presentation class that can do Reinforcment Learning template<typename _State> interface ILearn { // start new episode on learning virtual void start_new_episode() = 0; // get best next state virtual void get_best_state(_State& _best) = 0; // get next rand state virtual void get_rand_state(_State& _best) = 0; // next state virtual void find_next_train_state(_State& _best) = 0; // remember state virtual void fix_state(const _State& _state) = 0; // set stimulation for remebered state virtual void set_stimulation(double _stimulation) = 0; // id methods virtual void fix_state_with_id(size_t _id,const _State& _state) = 0; virtual void set_stimulation_with_id(size_t _id,double _stimulation) = 0; virtual void clear_states_before_id(size_t _id) = 0; };//interface ILearn // need for presentation of class that can set/get stimulation template<typename _State> interface IStateStimulation { // get stimulation virtual double get_value(const _State& _state) = 0; // set stimulation virtual void set_value(const _State& _state,double _value) = 0; // return true if stimulation is zero virtual bool is_zero_value(double _value) const = 0; };//interface IStimulation struct ValueBounds { protected: double value_min; double value_max; public: ValueBounds(double _value_min = 0 ,double _value_max = 1 ) :value_min(_value_min) ,value_max(_value_max) { } double normalize(double _natural_value) const { double d = (value_max-value_min); if(eql(d,0)) return (_natural_value - value_min); else return (_natural_value - value_min)/d; } double naturalize(double _normalized_value) const { return _normalized_value*(value_max-value_min)+value_min; } };//struct ValueMinMax namespace Private { struct Stimulation { protected: double value; public: Stimulation() :value(0) {} void set(double _val,const ValueBounds& _bounds = ValueBounds()) { value = clamp<double>(_bounds.normalize(_val),0,1); } double get(const ValueBounds& _bounds = ValueBounds()) { return _bounds.naturalize(value); } void to_vec(std::vector<double>& _vec,long& _idx) const { VERIFY_VEC_SIZE(); _vec[_idx++] = clamp(value-0.5,-0.5,0.5); } void to_vec(std::vector<double>& _vec) const { long idx = 0; to_vec(_vec,idx); } void from_vec(const std::vector<double>& _vec,long& _idx) { VERIFY_VEC_SIZE(); value = _vec[_idx++]+0.5;//clamp<double>(_vec[_idx++]+0.5,0,1); } void from_vec(const std::vector<double>& _vec) { long idx = 0; from_vec(_vec,idx); } static size_t size() { return 1; } }; };//namespace Private template<typename _State,class _Consts> struct SimpleSearchBest { void get(_State& _best,IStateStimulation<_State>* _stimulation) const { VERIFY_EXIT(NOT_NULL(_stimulation)); size_t i = 0; _State best_state = _best; best_state.rand(); double max_stimulation = _stimulation->get_value(best_state); for(i=0;i<_Consts::get().RL_SimpleSearchBest_search_depth;i++) { _State state = _best; state.rand(); double stimulation = _stimulation->get_value(state); if(stimulation>max_stimulation) { best_state = state; max_stimulation = stimulation; } } _best = best_state; } };//template<> struct SimpleSearchBest namespace GA { namespace Private { template<typename _State> struct Item { _State state; double stimulation; bool new_item_flag; Item() :stimulation(0) ,new_item_flag(true) { } bool operator == (const Item<_State>& _state) const { return stimulation == _state.stimulation; } bool operator < (const Item<_State>& _state) const { return stimulation < _state.stimulation; } }; template<typename _State> struct ItemPtr { Item<_State>* ptr; ItemPtr() :ptr(NULL) { } bool operator==(const ItemPtr<_State>& _ga_item_ptr) const { if(ptr!=_ga_item_ptr.ptr)return false; if(IS_NULL(ptr)) return true; return *ptr==*(_ga_item_ptr.ptr); } bool operator<(const ItemPtr<_State>& _ga_item_ptr) const { if(IS_NULL(ptr) && NOT_NULL(_ga_item_ptr.ptr)) return true; if(IS_NULL(ptr) || IS_NULL(_ga_item_ptr.ptr)) return false; return *ptr<*(_ga_item_ptr.ptr); } bool operator > (const ItemPtr<_State>& _ga_item_ptr) const { return _ga_item_ptr < *this; } }; template<typename _State> struct Items { typedef std::list<Item<_State> > ItemsLst; typedef std::vector<ItemPtr<_State> > Sorted; ItemsLst items; Sorted sorted; double stimulation_sum; _State& from; Items(_State& _from) :from(_from) ,stimulation_sum(0) { } void rand(size_t _idx) { ItemPtr<_State> item = get_item(_idx); VERIFY_EXIT(NOT_NULL(item.ptr)); item.ptr->state.rand(); item.ptr->new_item_flag = true; } void create(size_t _idx) { ItemPtr<_State> item = get_item(_idx); VERIFY_EXIT(NOT_NULL(item.ptr)); } void process(IStateStimulation<_State>* _stimulation) { VERIFY_EXIT(NOT_NULL(_stimulation)); ItemsLst::iterator it = items.begin() ,ite = items.end() ; stimulation_sum = 0; for(;it!=ite;++it) { if(it->new_item_flag) { it->stimulation = _stimulation->get_value(it->state); } if(it->stimulation>0) stimulation_sum += it->stimulation; } } void sort() { VERIFY_EXIT(sorted.size()==items.size()); std::sort(sorted.begin(),sorted.end(),std::greater<ItemPtr<_State> >()); } void crossover(Items<_State>& _crossover_items,size_t _crossover_idx) { ItemPtr<_State> item = _crossover_items.get_item(_crossover_idx); VERIFY_EXIT(NOT_NULL(item.ptr)); item.ptr->state.crossover(get_rand_state(),get_rand_state()); } void copy(Items<_State>& _crossover_items,size_t _crossover_idx,size_t _idx) { ItemPtr<_State> item_crossover = _crossover_items.get_item(_crossover_idx); VERIFY_EXIT(NOT_NULL(item_crossover.ptr)); ItemPtr<_State> item = get_item(_idx); VERIFY_EXIT(NOT_NULL(item.ptr)); item.ptr->state = item_crossover.ptr->state; item.ptr->new_item_flag = true; } void mutate(size_t _idx) { ItemPtr<_State> item = get_item(_idx); VERIFY_EXIT(NOT_NULL(item.ptr)); item.ptr->state.mutate(); item.ptr->new_item_flag = true; } const _State& get_best() const { VERIFY_EXIT1(!sorted.empty() && NOT_NULL(sorted[0].ptr),Fish<_State>::get()); return sorted[0].ptr->state; } protected: ItemPtr<_State> get_item(size_t _idx) { VERIFY_EXIT1(_idx<=items.size() && items.size()==sorted.size(),ItemPtr<_State>()); if(_idx==items.size()) { items.push_back(GA::Private::Item<_State>()); sorted.push_back(GA::Private::ItemPtr<_State>()); items.back().state = from; sorted.back().ptr = &items.back(); return sorted.back(); } return sorted[_idx]; } const _State& get_rand_state() { VERIFY_EXIT1(sorted.size()==items.size(),Fish<_State>::get()); double v = ::rand(stimulation_sum); Sorted::iterator it = sorted.begin() ,ite = sorted.end() ; double sum = 0; for(;it!=ite;++it) { if(v<=sum) return it->ptr->state; if(it->ptr->stimulation>0) sum += it->ptr->stimulation; } --ite; return ite->ptr->state; } }; };//namespace Private template<typename _State,class _Consts> struct SearchBest { void get(_State& _best,IStateStimulation<_State>* _stimulation) const { VERIFY_EXIT(NOT_NULL(_stimulation)); size_t i=0; Private::Items<_State> items(_best); Private::Items<_State> crossover_items(_best); for(i=0;i<_Consts::get().RL_GASearchBest_Items;i++) items.rand(i); for(i=0;i<_Consts::get().RL_GASearchBest_CrossoverItems_per_cycle;i++) crossover_items.create(i); for(i=0;;i++) { items.process(_stimulation); items.sort(); if(i>=_Consts::get().RL_GASearchBest_Cycles) break; long j = 0,k = 0; for(k=0,j=(long)_Consts::get().RL_GASearchBest_Items-1 ;j>=0 && k<(long)_Consts::get().RL_GASearchBest_CrossoverItems_per_cycle ;k++,j-- ) { items.crossover(crossover_items,(size_t)k); } for(k=0,j=(long)_Consts::get().RL_GASearchBest_Items-1 ;j>=0 && k<(long)_Consts::get().RL_GASearchBest_CrossoverItems_per_cycle ;k++,j-- ) { items.copy(crossover_items,(size_t)k,(size_t)j); } for(k=0 ;j>=0 && k<(long)_Consts::get().RL_GASearchBest_MutateItems_per_cycle ;k++,j-- ) { items.mutate((size_t)j); } for(k=0 ;j>=0 && k<(long)_Consts::get().RL_GASearchBest_RandItems_per_cycle ;k++,j-- ) { items.rand((size_t)j); } } _best = items.get_best(); } }; };//namespace GA template<class _State,class _Consts> struct MonteCarlo { protected: Queue<_State> states; IStateStimulation<_State>* istimulation; public: enum {optimization_tip_need_best = false}; MonteCarlo(IStateStimulation<_State>* _istimulation) :istimulation(_istimulation) { states.resize(_Consts::get().RL_LearnNet_queue_min_size); } void start_new_episode() { states.clear(); } void fix_current_state(const _State& _state) { states.push(_state); } void fix_current_state(size_t _id,const _State& _state) { } void fix_best_state(const _State& _best_state) { _best_state; } void set_stimulation(double _stimulation_value) { VERIFY_EXIT(NOT_NULL(istimulation)); size_t i=0; for(i=0;i<states.size();i++) { istimulation->set_value(states.get(i),_stimulation_value); } } void set_stimulation(size_t _id,double _stimulation) { } void clear_states_before_id(size_t _id) { } };//template<> struct MonteCarlo template<class _State,class _Consts> struct TD1 { protected: _State current_state; _State best_state; double stimulation; IStateStimulation<_State>* istimulation; public: enum {optimization_tip_need_best = true}; TD1(IStateStimulation<_State>* _istimulation) :istimulation(_istimulation) ,stimulation(0) { } void start_new_episode() { stimulation = 0; } void fix_current_state(const _State& _state) { current_state = _state; } void fix_current_state(size_t _id,const _State& _state) { } void fix_best_state(const _State& _best_state) { best_state = _best_state; VERIFY_EXIT(NOT_NULL(istimulation)); double Vtcur = istimulation->get_value(best_state); double Vtprev = stimulation + _Consts::get().RL_TD1_ro*Vtcur; istimulation->set_value(current_state,Vtprev); } void set_stimulation(double _stimulation_value) { stimulation = _stimulation_value; } void set_stimulation(size_t _id,double _stimulation) { } void clear_states_before_id(size_t _id) { } }; template<class _State> struct StatesPair { size_t id; _State from; _State to; double stimulation; StatesPair(size_t _id = -1,const _State& _from = _State(),const _State& _to = _State(),double _stimulation = 0) :id(_id) ,from(_from) ,to(_to) ,stimulation(_stimulation) { } }; template<class _State,class _Consts> struct TD1WithHistory { protected: _State current_state; _State best_state; double stimulation; IStateStimulation<_State>* istimulation; Queue<StatesPair<_State> > queue; //typedef std::pair<_State,_State> StatePair; //typedef std::map<size_t,StatePair> HistoryMap; //HistoryMap history; size_t last_id; _State from_state; bool need_to_set_best_state; public: enum {optimization_tip_need_best = true}; TD1WithHistory(IStateStimulation<_State>* _istimulation) :istimulation(_istimulation) ,stimulation(0) ,last_id(0) ,need_to_set_best_state(false) { queue.resize(8); } void start_new_episode() { stimulation = 0; } void fix_current_state(const _State& _state) { current_state = _state; } void fix_current_state(size_t _id,const _State& _state) { last_id = _id; from_state = _state; need_to_set_best_state = true; } void fix_best_state(const _State& _best_state) { best_state = _best_state; if(need_to_set_best_state) { if(queue.size()<_Consts::get().RL_LearnNet_max_queue_size) queue.push(StatesPair<_State>(last_id,from_state,_best_state,stimulation)); else { size_t idx = ::rand()%queue.size(); queue.set(idx,StatesPair<_State>(last_id,from_state,_best_state,stimulation)); } need_to_set_best_state = false; } if(queue.size()>=_Consts::get().RL_LearnNet_min_queue_size) { VERIFY_EXIT(NOT_NULL(istimulation)); size_t i = 0; for(i=0;i<_Consts::get().RL_LearnNet_batch_size;i++) { size_t idx = ::rand()%queue.size(); const StatesPair<_State>& sp = queue.get(idx); double Vtcur = istimulation->get_value(sp.to); double Vtprev = stimulation + _Consts::get().RL_TD1_ro*Vtcur; istimulation->set_value(sp.from,Vtprev); } } } void set_stimulation(double _stimulation_value) { stimulation = _stimulation_value; } void set_stimulation(size_t _id,double _stimulation) { size_t i = 0; for(i=0;i<queue.size();i++) { if(queue.get(i).id==_id) { queue.get(i).stimulation = _stimulation; break; } } } void clear_states_before_id(size_t _id) { } }; template<typename _State> struct StateTraits { typedef RL::Private::Stimulation Rewards; static double get_value(const _State& _state,Net& _net,const ValueBounds& _stimulation_bounds) { _state.to_vec(_net.get_input().w); _net.forward(); Rewards stim; stim.from_vec(_net.get_result().w); return stim.get(_stimulation_bounds); } template<typename _Consts> static void set_value(const _State& _state,double _value,Net& _net,SGDTrainer& _trainer,double& _loss,const ValueBounds& _stimulation_bounds,const _Consts& _consts) { Rewards stim; stim.set(_value,_stimulation_bounds); _state.to_vec(_net.get_input().w); stim.to_vec(_net.get_target().w); DWORD fwd_time = 0,bwd_time = 0; double l2_decay_loss = 0,l1_decay_loss = 0,cost_loss = 0,loss1 = 0; _trainer.train(fwd_time,bwd_time,l2_decay_loss,l1_decay_loss,cost_loss,loss1); _loss += (cost_loss - _loss)*_Consts::get().RL_LearnNet_loss_avg_coef; } }; template< class _State ,class _SearchBest = SimpleSearchBest<_State,Consts> ,class _RLAlg = MonteCarlo<_State,Consts> ,class _Consts = Consts > struct LearnNet :ILearn<_State> ,IStateStimulation<_State> { protected: _SearchBest search_best_functor; _RLAlg rl_alg_functor; Net net; SGDTrainer trainer; Net get_net; double loss; size_t train_idx; public: ValueBounds stimulation_bounds; public: LearnNet() :trainer(net) ,loss(0) #pragma warning(push) #pragma warning(disable: 4355) ,rl_alg_functor(this) #pragma warning(pop) ,train_idx(0) { init_net(); } ~LearnNet() { free(); } void free() { net.free(); } double get_loss() const {return loss;} //interface ILearn //{ virtual void start_new_episode() { rl_alg_functor.start_new_episode(); } virtual void get_best_state(_State& _best) { search_best_functor.get(_best,this); } virtual void get_rand_state(_State& _best) { _best.rand(); } virtual void find_next_train_state(_State& _state) { if(rl_alg_functor.optimization_tip_need_best) { get_best_state(_state); rl_alg_functor.fix_best_state(_state); } if(::rand(1.0)<_Consts::get().RL_LearnNet_search_coef) get_rand_state(_state); else if(!rl_alg_functor.optimization_tip_need_best) get_best_state(_state); } virtual void fix_state(const _State& _state) { rl_alg_functor.fix_current_state(_state); } virtual void set_stimulation(double _stimulation) { rl_alg_functor.set_stimulation(_stimulation); } virtual void fix_state_with_id(size_t _id,const _State& _state) { rl_alg_functor.fix_current_state(_id,_state); } virtual void set_stimulation_with_id(size_t _id,double _stimulation) { rl_alg_functor.set_stimulation(_id,_stimulation); } virtual void clear_states_before_id(size_t _id) { rl_alg_functor.clear_states_before_id(_id); } //};//interface ILearn //interface IStateStimulation //{ virtual double get_value(const _State& _state) { return StateTraits<_State>::get_value(_state,get_net,stimulation_bounds); } virtual void set_value(const _State& _state,double _value) { StateTraits<_State>::set_value(_state,_value,net,trainer,loss,stimulation_bounds,_Consts::get()); train_idx++; if(train_idx>_Consts::get().RL_LearnNet_train_cycles_to_switch_net) { train_idx = 0; get_net.copy_from(net); } } virtual bool is_zero_value(double _value) const { return eql(stimulation_bounds.normalize(_value),0); } //};//interface IStateStimulation template<typename _Stream> void save(_Stream& _out) const { net.save(_out); } template<typename _Stream> void load(_Stream& _in) { net.load(_in); get_net.copy_from(net); } void save(LPCTSTR _file_name) const { std::tofstream out; out.open(_file_name); save(out); } void load(LPCTSTR _file_name) { if(!FileUtils::IsFileExist(_file_name)) return; std::tifstream inp; inp.open(_file_name); load(inp); } void save(const CString& _file_name) const { save((LPCTSTR)_file_name); } void load(const CString& _file_name) { load((LPCTSTR)_file_name); } protected: void init_net() { TrainerOptions to; to.learning_rate = _Consts::get().RL_LearnNet_learning_rate; to.momentum = _Consts::get().RL_LearnNet_momentum; to.l2_decay = _Consts::get().RL_LearnNet_l2_decay; to.batch_size = _Consts::get().RL_LearnNet_batch_size; trainer.set_options(to); LayerOptsLst layer_defs; { LayerOpts opt; InputLayer::init(opt); opt.type = layertype_input; opt.out_sx = 1; opt.out_sy = 1; opt.out_depth = _State::size(); layer_defs.push_back(opt); } { LayerOpts opt; FullyConnLayer::init(opt); //ReluLayer::init(opt); init_layer_options(_Consts::get().RL_LearnNet_net_hidden_layers_type,opt); opt.type = layertype_fc; opt.activation = _Consts::get().RL_LearnNet_net_hidden_layers_type;//layertype_relu; opt.num_neurons = _Consts::get().RL_LearnNet_net_hidden_layers_size; size_t i=0; for(i=0;i<_Consts::get().RL_LearnNet_net_hidden_layers_count;i++) { layer_defs.push_back(opt); } } { LayerOpts opt; RegressionLayer::init(opt); opt.type = layertype_regression; opt.num_neurons = StateTraits<_State>::Rewards::size(); layer_defs.push_back(opt); } net.makeLayers(layer_defs); get_net.makeLayers(layer_defs); } };//template<> struct LearnNet };//namespace RL /* struct Consts // RL consts template { public: size_t RL_SimpleSearchBest_search_depth; size_t RL_GASearchBest_Items; size_t RL_GASearchBest_Cycles; size_t RL_GASearchBest_CrossoverItems_per_cycle; size_t RL_GASearchBest_MutateItems_per_cycle; size_t RL_GASearchBest_RandItems_per_cycle; size_t RL_LearnNet_queue_min_size; double RL_TD1_ro; double RL_LearnNet_loss_avg_coef; double RL_LearnNet_search_coef; double RL_LearnNet_learning_rate; double RL_LearnNet_momentum; double RL_LearnNet_l2_decay; size_t RL_LearnNet_batch_size; LayerTypeEn RL_LearnNet_net_hidden_layers_type; size_t RL_LearnNet_net_hidden_layers_size; size_t RL_LearnNet_net_hidden_layers_count; protected: Consts() { RL_SimpleSearchBest_search_depth = 100; RL_GASearchBest_Items = 30; RL_GASearchBest_Cycles = 100; RL_GASearchBest_CrossoverItems_per_cycle = 10; RL_GASearchBest_MutateItems_per_cycle = 3; RL_GASearchBest_RandItems_per_cycle = 3; RL_LearnNet_queue_min_size = 16; RL_TD1_ro = 1.0; RL_LearnNet_loss_avg_coef = 1e-3; RL_LearnNet_search_coef = 0.3; RL_LearnNet_learning_rate = 0.1; RL_LearnNet_momentum = 0.9; RL_LearnNet_l2_decay = 0; RL_LearnNet_batch_size = 1; RL_LearnNet_net_hidden_layers_type = layertype_relu; RL_LearnNet_net_hidden_layers_size = 20; RL_LearnNet_net_hidden_layers_count = 6; } static Consts& get_instance() { static Consts _; return _; } public: static const Consts& get() { return get_instance(); } template<typename _Stream> void print(_Stream& _out) const { OUT_VALUE(_out,RL_SimpleSearchBest_search_depth); OUT_VALUE(_out,RL_GASearchBest_Items); OUT_VALUE(_out,RL_GASearchBest_Cycles); OUT_VALUE(_out,RL_GASearchBest_CrossoverItems_per_cycle); OUT_VALUE(_out,RL_GASearchBest_MutateItems_per_cycle); OUT_VALUE(_out,RL_GASearchBest_RandItems_per_cycle); OUT_VALUE(_out,RL_LearnNet_queue_min_size); OUT_VALUE(_out,RL_TD1_ro); OUT_VALUE(_out,RL_LearnNet_loss_avg_coef); OUT_VALUE(_out,RL_LearnNet_search_coef); OUT_VALUE(_out,RL_LearnNet_learning_rate); OUT_VALUE(_out,RL_LearnNet_momentum); OUT_VALUE(_out,RL_LearnNet_l2_decay); OUT_VALUE(_out,RL_LearnNet_batch_size); OUT_VALUE_CONV(_out,RL_LearnNet_net_hidden_layers_type); OUT_VALUE(_out,RL_LearnNet_net_hidden_layers_size); OUT_VALUE(_out,RL_LearnNet_net_hidden_layers_count); } void print_to_file(const CString& _file_name) const { std::tofstream out; out.open(_file_name); print(out); } }; */
23.068421
166
0.687566
[ "vector" ]
ba7fe5e839148371f0a2a6b40c2ee9ca1a3c2456
260
h
C
module/settings.h
Neboer/ipgw_linux_c
77df9c27e4608c7a97b4d0b87fbc93115a970729
[ "MIT" ]
3
2019-06-01T08:12:57.000Z
2020-10-10T16:47:35.000Z
module/settings.h
Neboer/mini_ipgw
77df9c27e4608c7a97b4d0b87fbc93115a970729
[ "MIT" ]
3
2019-05-23T08:41:28.000Z
2020-10-15T08:24:35.000Z
module/settings.h
Neboer/mini_ipgw
77df9c27e4608c7a97b4d0b87fbc93115a970729
[ "MIT" ]
1
2019-05-13T12:23:08.000Z
2019-05-13T12:23:08.000Z
//The file aimed at make and parse settings.json file #ifndef IPGW_SETTINGS_H #define IPGW_SETTINGS_H #include <cjson/cJSON.h> void *getSettingsObject(int argc, ...);// powerful function. Get data and return the deep data in object. #endif //IPGW_SETTINGS_H
28.888889
105
0.773077
[ "object" ]
ba82264977b39fd5ce7a73c037be984f109e6619
504
h
C
Reflection/Objects/LessObjectPointer.h
dnv-opensource/Reflection
27effb850e9f0cc6acc2d48630ee6aa5d75fa000
[ "BSL-1.0" ]
null
null
null
Reflection/Objects/LessObjectPointer.h
dnv-opensource/Reflection
27effb850e9f0cc6acc2d48630ee6aa5d75fa000
[ "BSL-1.0" ]
null
null
null
Reflection/Objects/LessObjectPointer.h
dnv-opensource/Reflection
27effb850e9f0cc6acc2d48630ee6aa5d75fa000
[ "BSL-1.0" ]
null
null
null
#pragma once // Copyright (c) 2021 DNV AS // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include "Object.h" namespace DNVS {namespace MoFa {namespace Reflection {namespace Objects { struct LessObjectPointer { bool operator()(const Object& lhs, const Object& rhs) const { return lhs.GetVariant().GetData() < rhs.GetVariant().GetData(); } }; }}}}
31.5
75
0.666667
[ "object" ]
ba861ae70bd466923d1321404d9179ae92ad7303
27,094
h
C
indra/llcommon/lltreeiterators.h
SaladDais/LSO2-VM-Performance
d7ec9ad9daa9a2c9e48c5f06cd768606e3e50638
[ "ISC" ]
1
2022-01-29T07:10:03.000Z
2022-01-29T07:10:03.000Z
indra/llcommon/lltreeiterators.h
SaladDais/LSO2-VM-Performance
d7ec9ad9daa9a2c9e48c5f06cd768606e3e50638
[ "ISC" ]
null
null
null
indra/llcommon/lltreeiterators.h
SaladDais/LSO2-VM-Performance
d7ec9ad9daa9a2c9e48c5f06cd768606e3e50638
[ "ISC" ]
1
2021-10-01T22:22:27.000Z
2021-10-01T22:22:27.000Z
/** * @file lltreeiterators.h * @author Nat Goodspeed * @date 2008-08-19 * @brief This file defines iterators useful for traversing arbitrary node * classes, potentially polymorphic, linked into strict tree * structures. * * Dereferencing any one of these iterators actually yields a @em * pointer to the node in question. For example, given an * LLLinkedIter<MyNode> <tt>li</tt>, <tt>*li</tt> gets you a pointer * to MyNode, and <tt>**li</tt> gets you the MyNode instance itself. * More commonly, instead of writing <tt>li->member</tt>, you write * <tt>(*li)->member</tt> -- as you would if you were traversing an * STL container of MyNode pointers. * * It would certainly be possible to build these iterators so that * <tt>*iterator</tt> would return a reference to the node itself * rather than a pointer to the node, and for many purposes it would * even be more convenient. However, that would be insufficiently * flexible. If you want to use an iterator range to (e.g.) initialize * a std::vector collecting results -- you rarely want to actually @em * copy the nodes in question. You're much more likely to want to copy * <i>pointers to</i> the traversed nodes. Hence these iterators * produce pointers. * * Though you specify the actual NODE class as the template parameter, * these iterators internally use LLPtrTo<> to discover whether to * store and return an LLPointer<NODE> or a simple NODE*. * * By strict tree structures, we mean that each child must have * exactly one parent. This forbids a child claiming any ancestor as a * child of its own. Child nodes with multiple parents will be visited * once for each parent. Cycles in the graph will result in either an * infinite loop or an out-of-memory crash. You Have Been Warned. * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #if ! defined(LL_LLTREEITERATORS_H) #define LL_LLTREEITERATORS_H #include "llptrto.h" #include <vector> #include <deque> #include <boost/iterator/iterator_facade.hpp> #include <boost/function.hpp> #include <boost/static_assert.hpp> namespace LLTreeIter { /// Discriminator between LLTreeUpIter and LLTreeDownIter enum RootIter { UP, DOWN }; /// Discriminator between LLTreeDFSIter, LLTreeDFSPostIter and LLTreeBFSIter enum WalkIter { DFS_PRE, DFS_POST, BFS }; } /** * LLBaseIter defines some machinery common to all these iterators. We use * boost::iterator_facade to define the iterator boilerplate: the conventional * operators and methods necessary to implement a standards-conforming * iterator. That allows us to specify the actual iterator semantics in terms * of equal(), dereference() and increment() methods. */ template <class SELFTYPE, class NODE> class LLBaseIter: public boost::iterator_facade<SELFTYPE, // use pointer type as the // reference type typename LLPtrTo<NODE>::type, boost::forward_traversal_tag> { protected: /// LLPtrTo<NODE>::type is either NODE* or LLPointer<NODE>, as appropriate typedef typename LLPtrTo<NODE>::type ptr_type; /// function that advances from this node to next accepts a node pointer /// and returns another typedef boost::function<ptr_type(const ptr_type&)> func_type; typedef SELFTYPE self_type; }; /// Functor returning NULL, suitable for an end-iterator's 'next' functor template <class NODE> typename LLPtrTo<NODE>::type LLNullNextFunctor(const typename LLPtrTo<NODE>::type&) { return typename LLPtrTo<NODE>::type(); } /** * LLLinkedIter is an iterator over an intrusive singly-linked list. The * beginning of the list is represented by LLLinkedIter(list head); the end is * represented by LLLinkedIter(). * * The begin LLLinkedIter must be instantiated with a functor to extract the * 'next' pointer from the current node. Supposing that the link pointer is @c * public, something like: * * @code * NODE* mNext; * @endcode * * you can use (e.g.) <tt>boost::bind(&NODE::mNext, _1)</tt> for the purpose. * Alternatively, you can bind whatever accessor method is normally used to * advance to the next node, e.g. for: * * @code * NODE* next() const; * @endcode * * you can use <tt>boost::bind(&NODE::next, _1)</tt>. */ template <class NODE> class LLLinkedIter: public LLBaseIter<LLLinkedIter<NODE>, NODE> { typedef LLBaseIter<LLLinkedIter<NODE>, NODE> super; protected: /// some methods need to return a reference to self typedef typename super::self_type self_type; typedef typename super::ptr_type ptr_type; typedef typename super::func_type func_type; public: /// Instantiate an LLLinkedIter to start a range, or to end a range before /// a particular list entry. Pass a functor to extract the 'next' pointer /// from the current node. LLLinkedIter(const ptr_type& entry, const func_type& nextfunc): mCurrent(entry), mNextFunc(nextfunc) {} /// Instantiate an LLLinkedIter to end a range at the end of the list LLLinkedIter(): mCurrent(), mNextFunc(LLNullNextFunctor<NODE>) {} private: /// leverage boost::iterator_facade friend class boost::iterator_core_access; /// advance void increment() { mCurrent = mNextFunc(mCurrent); } /// equality bool equal(const self_type& that) const { return this->mCurrent == that.mCurrent; } /// dereference ptr_type& dereference() const { return const_cast<ptr_type&>(mCurrent); } ptr_type mCurrent; func_type mNextFunc; }; /** * LLTreeUpIter walks from the node in hand to the root of the tree. The term * "up" is applied to a tree visualized with the root at the top. * * LLTreeUpIter is an alias for LLLinkedIter, since any linked tree that you * can navigate that way at all contains parent pointers. */ template <class NODE> class LLTreeUpIter: public LLLinkedIter<NODE> { typedef LLLinkedIter<NODE> super; public: /// Instantiate an LLTreeUpIter to start from a particular tree node, or /// to end a parent traversal before reaching a particular ancestor. Pass /// a functor to extract the 'parent' pointer from the current node. LLTreeUpIter(const typename super::ptr_type& node, const typename super::func_type& parentfunc): super(node, parentfunc) {} /// Instantiate an LLTreeUpIter to end a range at the root of the tree LLTreeUpIter(): super() {} }; /** * LLTreeDownIter walks from the root of the tree to the node in hand. The * term "down" is applied to a tree visualized with the root at the top. * * Though you instantiate the begin() LLTreeDownIter with a pointer to some * node at an arbitrary location in the tree, the root will be the first node * you dereference and the passed node will be the last node you dereference. * * On construction, LLTreeDownIter walks from the current node to the root, * capturing the path. Then in use, it replays that walk in reverse. As with * all traversals of interesting data structures, it is actively dangerous to * modify the tree during an LLTreeDownIter walk. */ template <class NODE> class LLTreeDownIter: public LLBaseIter<LLTreeDownIter<NODE>, NODE> { typedef LLBaseIter<LLTreeDownIter<NODE>, NODE> super; typedef typename super::self_type self_type; protected: typedef typename super::ptr_type ptr_type; typedef typename super::func_type func_type; private: typedef std::vector<ptr_type> list_type; public: /// Instantiate an LLTreeDownIter to end at a particular tree node. Pass a /// functor to extract the 'parent' pointer from the current node. LLTreeDownIter(const ptr_type& node, const func_type& parentfunc) { for (ptr_type n = node; n; n = parentfunc(n)) mParents.push_back(n); } /// Instantiate an LLTreeDownIter representing "here", the end of the loop LLTreeDownIter() {} private: /// leverage boost::iterator_facade friend class boost::iterator_core_access; /// advance void increment() { mParents.pop_back(); } /// equality bool equal(const self_type& that) const { return this->mParents == that.mParents; } /// implement dereference/indirection operators ptr_type& dereference() const { return const_cast<ptr_type&>(mParents.back()); } list_type mParents; }; /** * When you want to select between LLTreeUpIter and LLTreeDownIter with a * compile-time discriminator, use LLTreeRootIter with an LLTreeIter::RootIter * template arg. */ template <LLTreeIter::RootIter DISCRIM, class NODE> class LLTreeRootIter { enum { use_a_valid_LLTreeIter_RootIter_value = false }; public: /// Bogus constructors for default (unrecognized discriminator) case template <typename TYPE1, typename TYPE2> LLTreeRootIter(TYPE1, TYPE2) { BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_RootIter_value); } LLTreeRootIter() { BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_RootIter_value); } }; /// Specialize for LLTreeIter::UP template <class NODE> class LLTreeRootIter<LLTreeIter::UP, NODE>: public LLTreeUpIter<NODE> { typedef LLTreeUpIter<NODE> super; public: /// forward begin ctor LLTreeRootIter(const typename super::ptr_type& node, const typename super::func_type& parentfunc): super(node, parentfunc) {} /// forward end ctor LLTreeRootIter(): super() {} }; /// Specialize for LLTreeIter::DOWN template <class NODE> class LLTreeRootIter<LLTreeIter::DOWN, NODE>: public LLTreeDownIter<NODE> { typedef LLTreeDownIter<NODE> super; public: /// forward begin ctor LLTreeRootIter(const typename super::ptr_type& node, const typename super::func_type& parentfunc): super(node, parentfunc) {} /// forward end ctor LLTreeRootIter(): super() {} }; /** * Instantiated with a tree node, typically the root, LLTreeDFSIter "flattens" * a depth-first tree walk through that node and all its descendants. * * The begin() LLTreeDFSIter must be instantiated with functors to obtain from * a given node begin() and end() iterators for that node's children. For this * reason, you must specify the type of the node's child iterator as an * additional template parameter. * * Specifically, the begin functor must return an iterator whose dereferenced * value is a @em pointer to a child tree node. For instance, if each node * tracks its children in an STL container of node* pointers, you can simply * return that container's begin() iterator. * * Alternatively, if a node tracks its children with a classic linked list, * write a functor returning LLLinkedIter<NODE>. * * The end() LLTreeDFSIter must, of course, match the begin() iterator's * template parameters, but is constructed without runtime parameters. */ template <class NODE, typename CHILDITER> class LLTreeDFSIter: public LLBaseIter<LLTreeDFSIter<NODE, CHILDITER>, NODE> { typedef LLBaseIter<LLTreeDFSIter<NODE, CHILDITER>, NODE> super; typedef typename super::self_type self_type; protected: typedef typename super::ptr_type ptr_type; // The func_type is different for this: from a NODE pointer, we must // obtain a CHILDITER. typedef boost::function<CHILDITER(const ptr_type&)> func_type; private: typedef std::vector<ptr_type> list_type; public: /// Instantiate an LLTreeDFSIter to start a depth-first walk. Pass /// functors to extract the 'child begin' and 'child end' iterators from /// each node. LLTreeDFSIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc) : mBeginFunc(beginfunc), mEndFunc(endfunc), mSkipChildren(false) { // Only push back this node if it's non-NULL! if (node) mPending.push_back(node); } /// Instantiate an LLTreeDFSIter to mark the end of the walk LLTreeDFSIter() : mSkipChildren(false) {} /// flags iterator logic to skip traversing children of current node on next increment void skipDescendants(bool skip = true) { mSkipChildren = skip; } private: /// leverage boost::iterator_facade friend class boost::iterator_core_access; /// advance /// This implementation is due to http://en.wikipedia.org/wiki/Depth-first_search void increment() { // Capture the node we were just looking at ptr_type current = mPending.back(); // Remove it from mPending so we don't process it again later mPending.pop_back(); if (!mSkipChildren) { // Add all its children to mPending addChildren(current); } // reset flag after each step mSkipChildren = false; } /// equality bool equal(const self_type& that) const { return this->mPending == that.mPending; } /// implement dereference/indirection operators ptr_type& dereference() const { return const_cast<ptr_type&>(mPending.back()); } /// Add the direct children of the specified node to mPending void addChildren(const ptr_type& node) { // If we just use push_back() for each child in turn, we'll end up // processing children in reverse order. We don't want to assume // CHILDITER is reversible: some of the linked trees we'll be // processing manage their children using singly-linked lists. So // figure out how many children there are, grow mPending by that size // and reverse-copy the children into the new space. CHILDITER chi = mBeginFunc(node), chend = mEndFunc(node); // grow mPending by the number of children mPending.resize(mPending.size() + std::distance(chi, chend)); // reverse-copy the children into the newly-expanded space std::copy(chi, chend, mPending.rbegin()); } /// list of the nodes yet to be processed list_type mPending; /// functor to extract begin() child iterator func_type mBeginFunc; /// functor to extract end() child iterator func_type mEndFunc; /// flag which controls traversal of children (skip children of current node if true) bool mSkipChildren; }; /** * Instantiated with a tree node, typically the root, LLTreeDFSPostIter * "flattens" a depth-first tree walk through that node and all its * descendants. Whereas LLTreeDFSIter visits each node before visiting any of * its children, LLTreeDFSPostIter visits all of a node's children before * visiting the node itself. * * The begin() LLTreeDFSPostIter must be instantiated with functors to obtain * from a given node begin() and end() iterators for that node's children. For * this reason, you must specify the type of the node's child iterator as an * additional template parameter. * * Specifically, the begin functor must return an iterator whose dereferenced * value is a @em pointer to a child tree node. For instance, if each node * tracks its children in an STL container of node* pointers, you can simply * return that container's begin() iterator. * * Alternatively, if a node tracks its children with a classic linked list, * write a functor returning LLLinkedIter<NODE>. * * The end() LLTreeDFSPostIter must, of course, match the begin() iterator's * template parameters, but is constructed without runtime parameters. */ template <class NODE, typename CHILDITER> class LLTreeDFSPostIter: public LLBaseIter<LLTreeDFSPostIter<NODE, CHILDITER>, NODE> { typedef LLBaseIter<LLTreeDFSPostIter<NODE, CHILDITER>, NODE> super; typedef typename super::self_type self_type; protected: typedef typename super::ptr_type ptr_type; // The func_type is different for this: from a NODE pointer, we must // obtain a CHILDITER. typedef boost::function<CHILDITER(const ptr_type&)> func_type; private: // Upon reaching a given node in our pending list, we need to know whether // we've already pushed that node's children, so we must associate a bool // with each node pointer. typedef std::vector< std::pair<ptr_type, bool> > list_type; public: /// Instantiate an LLTreeDFSPostIter to start a depth-first walk. Pass /// functors to extract the 'child begin' and 'child end' iterators from /// each node. LLTreeDFSPostIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc) : mBeginFunc(beginfunc), mEndFunc(endfunc), mSkipAncestors(false) { if (! node) return; mPending.push_back(typename list_type::value_type(node, false)); makeCurrent(); } /// Instantiate an LLTreeDFSPostIter to mark the end of the walk LLTreeDFSPostIter() : mSkipAncestors(false) {} /// flags iterator logic to skip traversing ancestors of current node on next increment void skipAncestors(bool skip = true) { mSkipAncestors = skip; } private: /// leverage boost::iterator_facade friend class boost::iterator_core_access; /// advance /// This implementation is due to http://en.wikipedia.org/wiki/Depth-first_search void increment() { // Pop the previous current node mPending.pop_back(); makeCurrent(); } /// equality bool equal(const self_type& that) const { return this->mPending == that.mPending; } /// implement dereference/indirection operators ptr_type& dereference() const { return const_cast<ptr_type&>(mPending.back().first); } struct isOpen { bool operator()(const typename list_type::value_type& item) { return item.second; } }; /// Call this each time we change mPending.back() -- that is, every time /// we're about to change the value returned by dereference(). If we /// haven't yet pushed the new node's children, do so now. void makeCurrent() { if (mSkipAncestors) { mPending.erase(std::remove_if(mPending.begin(), mPending.end(), isOpen()), mPending.end()); mSkipAncestors = false; } // Once we've popped the last node, this becomes a no-op. if (mPending.empty()) return; // Here mPending.back() holds the node pointer we're proposing to // dereference next. Have we pushed that node's children yet? if (mPending.back().second) return; // if so, it's okay to visit this node now // We haven't yet pushed this node's children. Do so now. Remember // that we did -- while the node in question is still back(). mPending.back().second = true; addChildren(mPending.back().first); // Now, because we've just changed mPending.back(), make that new node // current. makeCurrent(); } /// Add the direct children of the specified node to mPending void addChildren(const ptr_type& node) { // If we just use push_back() for each child in turn, we'll end up // processing children in reverse order. We don't want to assume // CHILDITER is reversible: some of the linked trees we'll be // processing manage their children using singly-linked lists. So // figure out how many children there are, grow mPending by that size // and reverse-copy the children into the new space. CHILDITER chi = mBeginFunc(node), chend = mEndFunc(node); // grow mPending by the number of children mPending.resize(mPending.size() + std::distance(chi, chend)); // Reverse-copy the children into the newly-expanded space. We can't // just use std::copy() because the source is a ptr_type, whereas the // dest is a pair of (ptr_type, bool). for (typename list_type::reverse_iterator pi = mPending.rbegin(); chi != chend; ++chi, ++pi) { pi->first = *chi; // copy the child pointer pi->second = false; // we haven't yet pushed this child's chldren } } /// list of the nodes yet to be processed list_type mPending; /// functor to extract begin() child iterator func_type mBeginFunc; /// functor to extract end() child iterator func_type mEndFunc; /// flags logic to skip traversal of ancestors of current node bool mSkipAncestors; }; /** * Instantiated with a tree node, typically the root, LLTreeBFSIter "flattens" * a breadth-first tree walk through that node and all its descendants. * * The begin() LLTreeBFSIter must be instantiated with functors to obtain from * a given node the begin() and end() iterators of that node's children. For * this reason, you must specify the type of the node's child iterator as an * additional template parameter. * * Specifically, the begin functor must return an iterator whose dereferenced * value is a @em pointer to a child tree node. For instance, if each node * tracks its children in an STL container of node* pointers, you can simply * return that container's begin() iterator. * * Alternatively, if a node tracks its children with a classic linked list, * write a functor returning LLLinkedIter<NODE>. * * The end() LLTreeBFSIter must, of course, match the begin() iterator's * template parameters, but is constructed without runtime parameters. */ template <class NODE, typename CHILDITER> class LLTreeBFSIter: public LLBaseIter<LLTreeBFSIter<NODE, CHILDITER>, NODE> { typedef LLBaseIter<LLTreeBFSIter<NODE, CHILDITER>, NODE> super; typedef typename super::self_type self_type; protected: typedef typename super::ptr_type ptr_type; // The func_type is different for this: from a NODE pointer, we must // obtain a CHILDITER. typedef boost::function<CHILDITER(const ptr_type&)> func_type; private: // We need a FIFO queue rather than a LIFO stack. Use a deque rather than // a vector, since vector can't implement pop_front() efficiently. typedef std::deque<ptr_type> list_type; public: /// Instantiate an LLTreeBFSIter to start a depth-first walk. Pass /// functors to extract the 'child begin' and 'child end' iterators from /// each node. LLTreeBFSIter(const ptr_type& node, const func_type& beginfunc, const func_type& endfunc): mBeginFunc(beginfunc), mEndFunc(endfunc) { if (node) mPending.push_back(node); } /// Instantiate an LLTreeBFSIter to mark the end of the walk LLTreeBFSIter() {} private: /// leverage boost::iterator_facade friend class boost::iterator_core_access; /// advance /// This implementation is due to http://en.wikipedia.org/wiki/Breadth-first_search void increment() { // Capture the node we were just looking at ptr_type current = mPending.front(); // Remove it from mPending so we don't process it again later mPending.pop_front(); // Add all its children to mPending CHILDITER chend = mEndFunc(current); for (CHILDITER chi = mBeginFunc(current); chi != chend; ++chi) mPending.push_back(*chi); } /// equality bool equal(const self_type& that) const { return this->mPending == that.mPending; } /// implement dereference/indirection operators ptr_type& dereference() const { return const_cast<ptr_type&>(mPending.front()); } /// list of the nodes yet to be processed list_type mPending; /// functor to extract begin() child iterator func_type mBeginFunc; /// functor to extract end() child iterator func_type mEndFunc; }; /** * When you want to select between LLTreeDFSIter, LLTreeDFSPostIter and * LLTreeBFSIter with a compile-time discriminator, use LLTreeWalkIter with an * LLTreeIter::WalkIter template arg. */ template <LLTreeIter::WalkIter DISCRIM, class NODE, typename CHILDITER> class LLTreeWalkIter { enum { use_a_valid_LLTreeIter_WalkIter_value = false }; public: /// Bogus constructors for default (unrecognized discriminator) case template <typename TYPE1, typename TYPE2> LLTreeWalkIter(TYPE1, TYPE2) { BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_WalkIter_value); } LLTreeWalkIter() { BOOST_STATIC_ASSERT(use_a_valid_LLTreeIter_WalkIter_value); } }; /// Specialize for LLTreeIter::DFS_PRE template <class NODE, typename CHILDITER> class LLTreeWalkIter<LLTreeIter::DFS_PRE, NODE, CHILDITER>: public LLTreeDFSIter<NODE, CHILDITER> { typedef LLTreeDFSIter<NODE, CHILDITER> super; public: /// forward begin ctor LLTreeWalkIter(const typename super::ptr_type& node, const typename super::func_type& beginfunc, const typename super::func_type& endfunc): super(node, beginfunc, endfunc) {} /// forward end ctor LLTreeWalkIter(): super() {} }; /// Specialize for LLTreeIter::DFS_POST template <class NODE, typename CHILDITER> class LLTreeWalkIter<LLTreeIter::DFS_POST, NODE, CHILDITER>: public LLTreeDFSPostIter<NODE, CHILDITER> { typedef LLTreeDFSPostIter<NODE, CHILDITER> super; public: /// forward begin ctor LLTreeWalkIter(const typename super::ptr_type& node, const typename super::func_type& beginfunc, const typename super::func_type& endfunc): super(node, beginfunc, endfunc) {} /// forward end ctor LLTreeWalkIter(): super() {} }; /// Specialize for LLTreeIter::BFS template <class NODE, typename CHILDITER> class LLTreeWalkIter<LLTreeIter::BFS, NODE, CHILDITER>: public LLTreeBFSIter<NODE, CHILDITER> { typedef LLTreeBFSIter<NODE, CHILDITER> super; public: /// forward begin ctor LLTreeWalkIter(const typename super::ptr_type& node, const typename super::func_type& beginfunc, const typename super::func_type& endfunc): super(node, beginfunc, endfunc) {} /// forward end ctor LLTreeWalkIter(): super() {} }; #endif /* ! defined(LL_LLTREEITERATORS_H) */
38.376771
100
0.690079
[ "vector" ]
ba8c45930954f08c6db0f775b5918ed356735780
11,890
h
C
Blindmode/CPP/Targets/MapLib/Shared/include/MultiFileDBufRequester.h
wayfinder/Wayfinder-S60-Navigator
14d1b729b2cea52f726874687e78f17492949585
[ "BSD-3-Clause" ]
6
2015-12-01T01:12:33.000Z
2021-07-24T09:02:34.000Z
Blindmode/CPP/Targets/MapLib/Shared/include/MultiFileDBufRequester.h
wayfinder/Wayfinder-S60-Navigator
14d1b729b2cea52f726874687e78f17492949585
[ "BSD-3-Clause" ]
null
null
null
Blindmode/CPP/Targets/MapLib/Shared/include/MultiFileDBufRequester.h
wayfinder/Wayfinder-S60-Navigator
14d1b729b2cea52f726874687e78f17492949585
[ "BSD-3-Clause" ]
2
2017-02-02T19:31:29.000Z
2018-12-17T21:00:45.000Z
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. 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 Vodafone Group Services Ltd 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. */ #ifndef MULTIFILEDBUFREQUESTER_H #define MULTIFILEDBUFREQUESTER_H #include "config.h" #include "DBufRequester.h" #include "MC2SimpleString.h" #include "FileHandler.h" #include "MemTracker.h" #include "LangTypes.h" #include <list> #include <vector> #include <set> class MemoryDBufRequester; class MFileDBufReqIdxHandler; class BitBuffer; class SharedBuffer; struct ParamsNotice; // -- ReadOnly requester is further down. class MultiFileDBufRequester : public DBufRequester, public FileHandlerListener, public MemEater { public: /** * Creates a new MultiFileDBufRequester that saves files * in the specified path and uses the specified number of * files. * @param parent The usual parent parameter. * @param basepath The directory to put the cache into. * @param memTracker Shared object, that keep track of how much * memory that may be used for caching index * files etc. * @param maxSize Maximum size of the cache before deleting old files. * @param nbrFiles The number of wanted data files. * @param nbrHash The number of index files per data file. * @param readOnly True if the cache should not write anything. */ MultiFileDBufRequester( DBufRequester* parent, const char* basepath, MemTracker* memTracker, uint32 maxSize, int nbrFiles = -1, int nbrHash = -1, int readOnly = false ); /// Deletes the requester virtual ~MultiFileDBufRequester(); /** * Sets a buffer to use when xor:ing. * Call this function before starting to use the * MultiFileDBufRequester, because otherwise it may * not recognize the files. */ void setXorBuffer( const SharedBuffer* xorBuffer ); /** * Returns zero if ok. Currently returns the number of * needed files that were not possible to open. */ int status() const; /// Does the initialization. bool init(); // -- DBufRequester void request( const MC2SimpleString& desc, DBufRequestListener* client, request_t whereFrom); BitBuffer* requestCached( const MC2SimpleString& desc); void release( const MC2SimpleString& desc, BitBuffer* buffer ); void cancelAll(); // -- FileHandlerListener void readDone( int nbrRead ); void writeDone( int nbrWritten ); /// Sets maximum storage size. void setMaxSize(uint32 size); /// Clears cache void clearCache(); /// Called by the MFileDBufReqIdxHandler when done searching void findComplete( const MC2SimpleString& desc, int fileNo, int startOffset, int size ); /// Called by the MFileDBufReqIdxHandler when index is written. void indexWritten( const MC2SimpleString& desc ); /// Called by the MFileDBufReqIdxHandler when it has removed void removeComplete( const MC2SimpleString& desc ); /** * Method that will be called when the MemTracker thinks that too * much memory are used for the cache. Will clean up the * cached index tables. */ void cleanUpMemUsage(); protected: /** * Creates a filehandler siutable for the current platform. * @param fileName The file name. * @param createIfNotExists If to create the file. * @param initNow If the file will be opened immediately * or only when needed. May not be * supported for all subclasses. */ virtual FileHandler* createFileHandler(const char* fileName, bool createIfNotExists, bool initNow = true ) = 0; /** * Returns the path separator for the current platform. */ virtual const char* getPathSeparator() const = 0; /** * Returns true if the buffer is ok to write even if it already * exists. */ bool okToWriteEvenIfItExists( const MC2SimpleString& descr ); private: /// Enum of states enum state_t { /// The MultiFileDBufRequester does not have anything to do. IDLE, /// We are looking for a map. LOOKING_FOR_MAP, /// We are reading a map from a file READING_MAP, /// We are checking where the map is WRITING_LOOKING_FOR_MAP, /// We are adding the map to a data file WRITING_MAP_DATA, /// We are adding the map to an index file. WRITING_INDEX, /// We are removing a map from the index. REMOVING_MAP, } m_state; MC2SimpleString updateParamLang( const MC2SimpleString param ) const; void startFinding(); void startWorking(); void startWriting(); void startRemoving(); void setState( state_t newState ); /// Decreases index. Wraps if necessary int decIndex(int oldIndex) const; /// Increases index. Wraps if necessary int incIndex(int oldIndex) const; /// Clears the oldest not empty file. @return The amount of deleted mem uint32 clearOldestNotEmptyFile(); /// Returns the amount of avaliable space on the drive of the first index. uint32 getAvailableSpace() const; /// Returns the total cache size int32 getTotalCacheSize() const; /// Calculates max size of the cache uint32 calcMaxAllowedCacheSize( uint32 wantedSize ) const; /// Write remainding maps to a dump file. void writeRemainders(); /// Read remainding maps from dump file. void readRemainders(FileHandler* dumpFile); /// Clears a file and its index. void clearFileAndIndex( int fileNbr ); /// Internal remove call from DBufRequester void internalRemove( const MC2SimpleString& desc ); /// Returns true if the desc is currently being removed. int isBeingRemoved( const MC2SimpleString& desc ); inline uint32 getFileSize( int index ); /// Read the read only cache info file. void readCacheInfoFile( FileHandler* cacheInfoFile ); /// True if the desc may be in the cache. False if definitely not. bool maybeInCache( const MC2SimpleString& desc ); /// True if the cache is read only const int m_readOnly; /// Maximum size of the files uint32 m_maxSize; /// Max size for one file. uint32 m_maxSizePerFile; /// Number of files to use. int m_nbrFiles; /// Nbr hashes for each index file. int m_nbrHash; /// Base path MC2SimpleString m_basePath; /// Map of fileHandlers for the map files. std::vector<FileHandler*> m_dataFiles; /// Map of fileHandlers for the index files. std::vector<FileHandler*> m_indexFiles; /// Set of maps to be removed from the index. std::set<MC2SimpleString> m_buffersToRemove; /// Maps that are waiting to be written do disk. MemoryDBufRequester* m_writeQueue; /// Currently removing descr MC2SimpleString m_currentlyRemoving; /// Buffer about to be written std::pair<MC2SimpleString, BitBuffer*> m_currentlyWriting; int m_startWritePos; struct readJob_t { /// Default constructor seems to be needed by the stlport readJob_t() { second = NULL; whereFrom = DBufRequester::cacheOrInternet; } readJob_t( const MC2SimpleString& descr, DBufRequestListener* listener, request_t pWhereFrom ) { first = descr; second = listener; whereFrom = pWhereFrom; } int operator==( const readJob_t& other ) const { return other.first == first && other.second == second && other.whereFrom == other.whereFrom; } /// The requested databuffer. Called first since this was a pair MC2SimpleString first; /// The request listener. Called second since this was a pair. DBufRequestListener* second; /// True if it is only allowed to request from cache. request_t whereFrom; }; //typedef pair<MC2SimpleString, DBufRequestListener*> readJob_t; /// Queue of jobs to read. std::list<readJob_t> m_readQueue; /// Pair of map description and listener that we currently are reading. readJob_t m_currentlyReading; MC2SimpleString m_currentlyCorrectLang; /// Last written fil int m_lastWrittenFileNbr; /// The index handler MFileDBufReqIdxHandler* m_indexHandler; /// The current read buffer. BitBuffer* m_readBuffer; /// BitBuffer used when dumping (10k constantly allocated) BitBuffer* m_dumpBuffer; /// Counts the number of writes to disk. uint32 m_nbrWrites; /// Counts number of readonly cache misses. uint32 m_readOnlyMisses; /// The dump file. FileHandler* m_dumpFile; /// Size of cache to set next time the handles is idle uint32 m_newSize; /// True if we are shutting down bool m_shuttingDown; /// Count if we are in startWriting int m_inStartWriting; /// Count if we are in startFinding. int m_inStartFinding; /// Count if we are in startRemoving. int m_inStartRemoving; /// The number of needed files with errors. int m_nbrErrorFiles; /// Pointer to the buffer we will use for the xor:ing. const SharedBuffer* m_xorBuffer; /// The languages present available in the readonly cache. std::vector<LangTypes::language_t> m_readOnlyLangs; /// first is layerid and second is detaillevel. typedef std::pair<int,int> layerAndDetail_t; /** * Table used for the readonly cache to quickly check if inside * the available tiles. */ std::map<layerAndDetail_t, ParamsNotice> m_paramsByLayerAndDetail; /// The memory tracker. MemTracker* m_memTracker; /// If the cache contains bitmaps. bool m_containsBitmaps; }; /// Same same. typedef MultiFileDBufRequester MFDBufReq; // --- Inlines --- inline uint32 MultiFileDBufRequester::getFileSize( int index ) { uint32 size = m_dataFiles[ index ]->getFileSize(); for ( int i = 0; i < m_nbrHash; ++i ) { size += m_indexFiles[ index * m_nbrHash + i ]->getFileSize(); } return size; } #endif
33.212291
757
0.665433
[ "object", "vector" ]
ba91e04fd61e2cd074104e39a9854e4bd6b6768b
1,736
h
C
src/io/SymbolicTrajPrinter.h
takafumihoriuchi/HyLaGI
26b9f32a84611ee62d9cbbd903773d224088c959
[ "BSL-1.0" ]
1
2019-03-15T07:11:09.000Z
2019-03-15T07:11:09.000Z
src/io/SymbolicTrajPrinter.h
takafumihoriuchi/HyLaGI
26b9f32a84611ee62d9cbbd903773d224088c959
[ "BSL-1.0" ]
null
null
null
src/io/SymbolicTrajPrinter.h
takafumihoriuchi/HyLaGI
26b9f32a84611ee62d9cbbd903773d224088c959
[ "BSL-1.0" ]
null
null
null
#pragma once #include "TrajPrinter.h" #include "LTLNode.h" #include "PropertyNode.h" namespace hydla{ namespace io{ class SymbolicTrajPrinter: public TrajPrinter { public: SymbolicTrajPrinter(simulator::backend_sptr_t b, std::ostream& ostream = std::cout, bool numerize_par = false); void output_result_tree(const phase_result_const_sptr_t&) const; void output_one_phase(const phase_result_const_sptr_t&, const std::string& prefix = "") const; std::string get_state_output(const phase_result_t& result) const; void output_parameter_map(const parameter_map_t& pm) const; void output_variable_map(std::ostream &stream, const phase_result_t& result) const; void output_result_node(const phase_result_const_sptr_t &node, std::vector<std::string> &result, int &case_num, int &phase_num) const; void output_property_automaton(simulator::PropertyNode* node); void dump_property_automaton(simulator::PropertyNode* node); void output_ltl_node(simulator::LTLNode* node); void dump_ltl_node(simulator::LTLNode* node); virtual void set_epsilon_mode(simulator::backend_sptr_t back, bool flag); void output_limit_of_time(std::ostream &stream, backend::Backend* backend_, const phase_result_t& result) const; void output_limits_of_variable_map(std::ostream &stream, backend::Backend* backend_, const phase_result_t& result, const variable_map_t& vm) const; private: void output_asks(std::ostream &stream, const phase_result_t &phase) const; void output_inconsistent_constraints(std::ostream &stream, const phase_result_t &phase) const; std::ostream& ostream; simulator::backend_sptr_t backend; bool numerize_parameter; bool epsilon_mode_flag = false; }; } // namespace io } // namespace hydla
35.428571
149
0.785714
[ "vector" ]
ba9b19aca60d0b65259e3d12c44ed968e2615541
839
h
C
Asteroide.h
darcusfenix/lsdl2
992ca07163811390ac8395ef41876bf6ff7e46ff
[ "MIT" ]
null
null
null
Asteroide.h
darcusfenix/lsdl2
992ca07163811390ac8395ef41876bf6ff7e46ff
[ "MIT" ]
null
null
null
Asteroide.h
darcusfenix/lsdl2
992ca07163811390ac8395ef41876bf6ff7e46ff
[ "MIT" ]
null
null
null
#ifndef ASTEROIDE_H_ #define ASTEROIDE_H_ #include "Poligonoirreg.h" #include "Vector2D.h" #include <vector> #include <SDL2/SDL.h> class Asteroide : public Poligonoirreg { public: Asteroide(int); ~Asteroide(); SDL_Point* getPoints(); void updatePosition(float, float); void erase(); void addVertice(Vector2D, int); void setPoints(SDL_Point*); int getNumeroVertices(); int getDiametro(); int getTipoDireccion(); int getMasa(); bool estaDentro(); void setDiametro(int); void setTipoDireccion(int); void setVelocidad(long double); void setMasa(int); void setDentro(bool); long double getVelocidad(); private: std::vector <Vector2D> vertices; int numVertices; long double angle; SDL_Point* points; int diametro; int tipo_direccion; long double velocidad; int masa; bool dentro; }; #endif
21.512821
38
0.721097
[ "vector" ]
ba9fc7aef50d243b3b1bb5946e2e667023c0a9e8
246,019
c
C
c/file-stream.c
blakemcbride/eclipse-lisp
8bdaaa71289cbc2e2ca8de52ded3d09dcf3f1f06
[ "BSD-2-Clause" ]
101
2015-04-03T02:07:13.000Z
2022-03-19T12:21:34.000Z
c/file-stream.c
blakemcbride/eclipse-lisp
8bdaaa71289cbc2e2ca8de52ded3d09dcf3f1f06
[ "BSD-2-Clause" ]
2
2015-04-15T17:19:06.000Z
2018-10-15T20:51:50.000Z
c/file-stream.c
blakemcbride/eclipse-lisp
8bdaaa71289cbc2e2ca8de52ded3d09dcf3f1f06
[ "BSD-2-Clause" ]
11
2015-04-07T07:04:19.000Z
2022-02-21T01:16:45.000Z
/* Generated by Eclipse Common Lisp 1.1-HOSTED on cad0. Wednesday the sixth of May, 1998, 12:39:46 am CDT. */ #include <eclipse.h> clObject clMINUS_FUNC(clProto), cl1PLUS_FUNC(clProto), clApply(clProto), clCanonicalizeSpecializer(clProto), clCar(clProto), clCdr(clProto), clCharpSimpleBaseString __P((clCharp)), clClassOf(clProto), clClearOutput(clProto), clCons(clProto), clDeleteFile(clProto), clDrain __P((clObject)), clEndp(clProto), clEnsureClass(clProto), clEnsureGenericFunction(clProto), clEnsureMethod(clProto), clEq(clProto), clExpungeFile(clProto), clExtraArgs(clProto), clFastFindSlot __P((clObject, clObject)), clFileDescriptorClose __P((clObject)), cl_SETF_FillPointer(clProto), clFillPointer(clProto), clFindClass(clProto), clFinishOutput(clProto), clFlushInput __P((clObject)), clFlushOutput __P((clObject)), clGetSimpleVector(clProto), clInitializeSlotP(clProto), clKeyArg(clProto), clLength(clProto), clList(clProto), clMakeArray(clProto), clMakeBuffer(clProto), clMakeKeyword(clProto), clMissingArgs(clProto), clNot(clProto), clNull(clProto), clOutputStream(clProto), clPlusp(clProto), clPoll __P((clObject)), clPosition(clProto), clPrinc(clProto), clPrintUnreadableObjectHeader(clProto), clPrintUnreadableObjectTrailer(clProto), clReadAscii __P((clObject, clObject, clObject, clObject)), clReadBes16 __P((clObject, clObject, clObject, clObject)), clReadBes32 __P((clObject, clObject, clObject, clObject)), clReadBes8 __P((clObject, clObject, clObject, clObject)), clReadBeu16 __P((clObject, clObject, clObject, clObject)), clReadBeu32 __P((clObject, clObject, clObject, clObject)), clReadBeu8 __P((clObject, clObject, clObject, clObject)), clReadLes16 __P((clObject, clObject, clObject, clObject)), clReadLes32 __P((clObject, clObject, clObject, clObject)), clReadLes8 __P((clObject, clObject, clObject, clObject)), clReadLeu16 __P((clObject, clObject, clObject, clObject)), clReadLeu32 __P((clObject, clObject, clObject, clObject)), clReadLeu8 __P((clObject, clObject, clObject, clObject)), clReadMb __P((clObject, clObject, clObject, clObject, clObject)), clReadUcs2 __P((clObject, clObject, clObject, clObject)), clReadUcs4 __P((clObject, clObject, clObject, clObject)), clRenameFile(clProto), clRest(clProto), cl_SETF_SlotValue(clProto), clWriteAscii __P((clObject, clObject, clObject, clObject)), clWriteBes16 __P((clObject, clObject, clObject, clObject)), clWriteBes32 __P((clObject, clObject, clObject, clObject)), clWriteBes8 __P((clObject, clObject, clObject, clObject)), clWriteBeu16 __P((clObject, clObject, clObject, clObject)), clWriteBeu32 __P((clObject, clObject, clObject, clObject)), clWriteBeu8 __P((clObject, clObject, clObject, clObject)), clWriteLes16 __P((clObject, clObject, clObject, clObject)), clWriteLes32 __P((clObject, clObject, clObject, clObject)), clWriteLes8 __P((clObject, clObject, clObject, clObject)), clWriteLeu16 __P((clObject, clObject, clObject, clObject)), clWriteLeu32 __P((clObject, clObject, clObject, clObject)), clWriteLeu8 __P((clObject, clObject, clObject, clObject)), clWriteMb __P((clObject, clObject, clObject, clObject)), clWriteUcs2 __P((clObject, clObject, clObject, clObject)), clWriteUcs4 __P((clObject, clObject, clObject, clObject)); extern clObject clampersandKEY, clampersandOPTIONAL, clampersandREST, clBASE_CHAR, clIF, clIGNORE, clQUOTE, clSIGNED_BYTE, clUNSIGNED_BYTE, clstarDEFAULT_BUFFER_SIZEstar, clstarFEATURESstar, clABORT, clADD, clARRAY_DIMENSION, clASCII_FILE_BIDIRECTIONAL_STREAM, clASCII_FILE_INPUT_STREAM, clASCII_FILE_OUTPUT_STREAM, clASCII_FILE_STREAM, clAUX, clBES16_FILE_BIDIRECTIONAL_STREAM, clBES16_FILE_INPUT_STREAM, clBES16_FILE_OUTPUT_STREAM, clBES16_FILE_STREAM, clBES32_FILE_BIDIRECTIONAL_STREAM, clBES32_FILE_INPUT_STREAM, clBES32_FILE_OUTPUT_STREAM, clBES32_FILE_STREAM, clBES8_FILE_BIDIRECTIONAL_STREAM, clBES8_FILE_INPUT_STREAM, clBES8_FILE_OUTPUT_STREAM, clBES8_FILE_STREAM, clBEU16_FILE_BIDIRECTIONAL_STREAM, clBEU16_FILE_INPUT_STREAM, clBEU16_FILE_OUTPUT_STREAM, clBEU16_FILE_STREAM, clBEU32_FILE_BIDIRECTIONAL_STREAM, clBEU32_FILE_INPUT_STREAM, clBEU32_FILE_OUTPUT_STREAM, clBEU32_FILE_STREAM, clBEU8_FILE_BIDIRECTIONAL_STREAM, clBEU8_FILE_INPUT_STREAM, clBEU8_FILE_OUTPUT_STREAM, clBEU8_FILE_STREAM, clBIDIRECTIONAL_STREAM, clBUFFER_LINE_COLUMN, clBUFFERED_BINARY_FILE_INPUT_STREAM, clBUFFERED_BINARY_FILE_OUTPUT_STREAM, clBUFFERED_BINARY_INPUT_STREAM, clBUFFERED_BINARY_OUTPUT_STREAM, clBUFFERED_CHARACTER_FILE_BIDIRECTIONAL_STREAM, clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM, clBUFFERED_CHARACTER_INPUT_STREAM, clBUFFERED_CHARACTER_OUTPUT_STREAM, clBUFFERED_EXTERNAL_BINARY_INPUT_STREAM, clBUFFERED_EXTERNAL_BINARY_OUTPUT_STREAM, clBUFFERED_EXTERNAL_CHARACTER_INPUT_STREAM, clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clBUFFERED_EXTERNAL_INPUT_STREAM, clBUFFERED_EXTERNAL_OUTPUT_STREAM, clBUFFERED_FILE_BIDIRECTIONAL_STREAM, clBUFFERED_FILE_INPUT_STREAM, clBUFFERED_FILE_OUTPUT_STREAM, clBUFFERED_FILE_STREAM, clBUFFERED_INPUT_STREAM, clBUFFERED_OUTPUT_STREAM, clCHAR, clCHECK_BUFFER_SIZE, clCLASS_PROTOTYPE, clCLEANUP, clCLOSE, clELEMENT_TYPE, clEND, clEXTERNAL_FORMAT, clEXTERNAL_STREAM, clFILE_INPUT_STREAM, clFILE_OUTPUT_STREAM, clFILE_STREAM, clFILE_STREAM_DESCRIPTOR, clFILLABLE_CHARACTER_INPUT_STREAM, clFILLABLE_INPUT_STREAM, clFUNDAMENTAL_CHARACTER_STREAM, clFUNDAMENTAL_STREAM, clGE, clINPUT_BUFFER, clINPUT_FD, clINPUT_STREAM, clINTERACTIVE_STREAM_P, clLES16_FILE_BIDIRECTIONAL_STREAM, clLES16_FILE_INPUT_STREAM, clLES16_FILE_OUTPUT_STREAM, clLES16_FILE_STREAM, clLES32_FILE_BIDIRECTIONAL_STREAM, clLES32_FILE_INPUT_STREAM, clLES32_FILE_OUTPUT_STREAM, clLES32_FILE_STREAM, clLES8_FILE_BIDIRECTIONAL_STREAM, clLES8_FILE_INPUT_STREAM, clLES8_FILE_OUTPUT_STREAM, clLES8_FILE_STREAM, clLEU16_FILE_BIDIRECTIONAL_STREAM, clLEU16_FILE_INPUT_STREAM, clLEU16_FILE_OUTPUT_STREAM, clLEU16_FILE_STREAM, clLEU32_FILE_BIDIRECTIONAL_STREAM, clLEU32_FILE_INPUT_STREAM, clLEU32_FILE_OUTPUT_STREAM, clLEU32_FILE_STREAM, clLEU8_FILE_BIDIRECTIONAL_STREAM, clLEU8_FILE_INPUT_STREAM, clLEU8_FILE_OUTPUT_STREAM, clLEU8_FILE_STREAM, clLIST, clMAKE_ARRAY, clMB_FILE_BIDIRECTIONAL_STREAM, clMB_FILE_INPUT_STREAM, clMB_FILE_OUTPUT_STREAM, clMB_FILE_STREAM, clMEMBER, clMETHOD_FUNCTION, clN, clN_ADDITIONAL_ITEMS, clNO_NEXT_METHOD, clOBJECT, clOFFSET, clORIGINAL_INPUT_BUFFER, clOUTPUT_BUFFER, clOUTPUT_FD, clOUTPUT_STREAM, clPATHNAME, clPOSITION, clPRINT_OBJECT, clRENAMED, clREPLACE, clS, clSETF, clSHARED_INITIALIZE, clSLOT_VALUE_USING_CLASS, clSLOTS, clSTANDARD_METHOD, clSTART_LINE_P, clSTREAM, clSTREAM_CLEAR_INPUT, clSTREAM_CLEAR_OUTPUT, clSTREAM_ELEMENT_TYPE, clSTREAM_EXTERNAL_FORMAT, clSTREAM_FILL_INPUT, clSTREAM_FINISH_OUTPUT, clSTREAM_FORCE_OUTPUT, clSTREAM_LINE_COLUMN, clSTREAM_PATHNAME, clSTREAM_PEEK_CHAR, clSTREAM_READ, clSTREAM_READ_CHAR, clSTREAM_READ_CHAR_NO_HANG, clSTREAM_START_LINE_P, clSTREAM_TERPRI, clSTREAM_TRUENAME, clSTREAM_WRITE, clSUBT, clTRUENAME, clUCS_2_CHAR, clUCS_2_FILE_BIDIRECTIONAL_STREAM, clUCS_2_FILE_INPUT_STREAM, clUCS_2_FILE_OUTPUT_STREAM, clUCS_2_FILE_STREAM, clUCS_4_FILE_BIDIRECTIONAL_STREAM, clUCS_4_FILE_INPUT_STREAM, clUCS_4_FILE_OUTPUT_STREAM, clUCS_4_FILE_STREAM, clUNICODE_CHAR, clWAIT; static clObject C_Newline, CONS_0, CONS_1, CONS_10, CONS_100, CONS_101, CONS_102, CONS_103, CONS_104, CONS_105, CONS_106, CONS_107, CONS_108, CONS_109, CONS_11, CONS_110, CONS_111, CONS_112, CONS_113, CONS_114, CONS_115, CONS_116, CONS_117, CONS_118, CONS_119, CONS_12, CONS_120, CONS_121, CONS_122, CONS_123, CONS_124, CONS_125, CONS_126, CONS_127, CONS_128, CONS_129, CONS_13, CONS_130, CONS_131, CONS_132, CONS_133, CONS_134, CONS_135, CONS_136, CONS_137, CONS_138, CONS_139, CONS_14, CONS_140, CONS_141, CONS_142, CONS_143, CONS_144, CONS_145, CONS_146, CONS_147, CONS_148, CONS_149, CONS_15, CONS_150, CONS_151, CONS_152, CONS_153, CONS_154, CONS_155, CONS_156, CONS_157, CONS_158, CONS_159, CONS_16, CONS_160, CONS_161, CONS_162, CONS_163, CONS_164, CONS_165, CONS_166, CONS_167, CONS_168, CONS_169, CONS_17, CONS_170, CONS_171, CONS_172, CONS_173, CONS_174, CONS_175, CONS_176, CONS_177, CONS_178, CONS_179, CONS_18, CONS_180, CONS_181, CONS_182, CONS_183, CONS_184, CONS_185, CONS_186, CONS_187, CONS_188, CONS_189, CONS_19, CONS_190, CONS_191, CONS_192, CONS_193, CONS_194, CONS_195, CONS_196, CONS_197, CONS_198, CONS_2, CONS_20, CONS_21, CONS_22, CONS_23, CONS_24, CONS_25, CONS_26, CONS_27, CONS_28, CONS_29, CONS_3, CONS_30, CONS_31, CONS_32, CONS_33, CONS_34, CONS_35, CONS_36, CONS_37, CONS_38, CONS_39, CONS_4, CONS_40, CONS_41, CONS_42, CONS_43, CONS_44, CONS_45, CONS_46, CONS_47, CONS_48, CONS_49, CONS_5, CONS_50, CONS_51, CONS_52, CONS_53, CONS_54, CONS_55, CONS_56, CONS_57, CONS_58, CONS_59, CONS_6, CONS_60, CONS_61, CONS_62, CONS_63, CONS_64, CONS_65, CONS_66, CONS_67, CONS_68, CONS_69, CONS_7, CONS_70, CONS_71, CONS_72, CONS_73, CONS_74, CONS_75, CONS_76, CONS_77, CONS_78, CONS_79, CONS_8, CONS_80, CONS_81, CONS_82, CONS_83, CONS_84, CONS_85, CONS_86, CONS_87, CONS_88, CONS_89, CONS_9, CONS_90, CONS_91, CONS_92, CONS_93, CONS_94, CONS_95, CONS_96, CONS_97, CONS_98, CONS_99, I_0, I_1, I_16, I_2, I_32, I_6, I_8, keyABORT, keyAFTER, keyASCII, keyBEFORE, keyBIG_ENDIAN, keyCLEANUP, keyDECLARATIONS, keyDEFAULT, keyDELETE, keyDIRECT_SLOTS, keyDIRECT_SUPERCLASSES, keyDOCUMENTATION, keyELEMENT_TYPE, keyEND, keyEOF, keyEXPUNGE, keyEXTERNAL_FORMAT, keyFILL_POINTER, keyFROM_END, keyFUNCTION, keyINITARGS, keyINITFORM, keyINITFUNCTION, keyINPUT_FD, keyLAMBDA_LIST, keyLITTLE_ENDIAN, keyMULTI_BYTE, keyNAME, keyOUTPUT_FD, keyPATHNAME, keyQUALIFIERS, keyREADERS, keyRENAMED, keySPECIALIZERS, keySTART2, keyTRUENAME, keyUCS, keyUCS_4_IO, keyWRITERS, STR_ABORT__27, STR_AFTER__10, STR_ASCII__32, STR_BEFORE__17, STR_BIG_ENDIAN__37, STR_CLEANUP__26, STR_DECLARATIONS__15, STR_DEFAULT__4, STR_DELETE__29, STR_DIRECT_SLOTS__1, STR_DIRECT_SUPERCLASSES__0, STR_DOCUMENTATION__16, STR_ELEMENT_TYPE__14, STR_END__19, STR_EOF__31, STR_EXPUNGE__28, STR_EXTERNAL_FORMAT__6, STR_FILL_POINTER__36, STR_FROM_END__20, STR_FUNCTION__13, STR_INITARGS__5, STR_INITFORM__7, STR_INITFUNCTION__3, STR_INPUT_FD__23, STR_LAMBDA_LIST__11, STR_LITTLE_ENDIAN__38, STR_MULTI_BYTE__34, STR_NAME__2, STR_OUTPUT_FD__24, STR_PATHNAME__21, STR_QUALIFIERS__9, STR_READERS__8, STR_RENAMED__25, STR_SPECIALIZERS__12, STR_START2__30, STR_TRUENAME__22, STR_UCS_4_IO__35, STR_UCS__33, STR_WRITERS__18; static clObject clLambda clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyDEFAULT)); } clObject clSharedInitialize_keyAFTER_clBUFFERED_EXTERNAL_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args395 = clMakeBinding(), *L_methods396 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args395, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods396, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form400, stream, slots, ignore; clSetq(L_form400, *L_args395); if (clTrue(L_form400)) { clObject L_top401; clSetq(L_top401, clCar(L_form400, clEOA)); { clObject L_0; clSetq(L_0, L_form400); clSetq(L_form400, clCdr(L_0, clEOA)); } clSetq(stream, L_top401); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form400)) { clObject L_top402; { clObject L_0; clSetq(L_0, L_form400); clSetq(L_top402, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form400); clSetq(L_form400, clCdr(L_0, clEOA)); } clSetq(slots, L_top402); } else clSetq(slots, clMissingArgs(I_2, clEOA)); clSetq(ignore, L_form400); { clObject L_test; { clObject L_2, L_0; clSetq(L_0, stream); clSetq(L_2, slots); clSetq(L_test, clInitializeSlotP(L_0, clINPUT_BUFFER, L_2, clEOA)); } if (clTrue(L_test)) { clObject buffer; { clObject L_2, L_0; clSetq(L_0, clSymbolValue(clstarDEFAULT_BUFFER_SIZEstar, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSTREAM_ELEMENT_TYPE), L_0__R1, clEOA)); } clSetq(buffer, clMakeArray(L_0, keyELEMENT_TYPE, L_2, clEOA)); } { clObject L_arg404; clSetq(L_arg404, stream); cl_SETF_SlotValue(buffer, L_arg404, clORIGINAL_INPUT_BUFFER, clEOA); } { clObject L_arg407; clSetq(L_arg407, stream); return(cl_SETF_SlotValue(I_0, L_arg407, clEND, clEOA)); } } else return(clValues1(clNIL)); } } } clObject clSharedInitialize_keyAFTER_clBUFFERED_EXTERNAL_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args409 = clMakeBinding(), *L_methods410 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args409, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods410, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form412, stream, slots, ignore; clSetq(L_form412, *L_args409); if (clTrue(L_form412)) { clObject L_top413; clSetq(L_top413, clCar(L_form412, clEOA)); { clObject L_0; clSetq(L_0, L_form412); clSetq(L_form412, clCdr(L_0, clEOA)); } clSetq(stream, L_top413); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form412)) { clObject L_top414; { clObject L_0; clSetq(L_0, L_form412); clSetq(L_top414, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form412); clSetq(L_form412, clCdr(L_0, clEOA)); } clSetq(slots, L_top414); } else clSetq(slots, clMissingArgs(I_2, clEOA)); clSetq(ignore, L_form412); { clObject L_test; { clObject L_2, L_0; clSetq(L_0, stream); clSetq(L_2, slots); clSetq(L_test, clInitializeSlotP(L_0, clOUTPUT_BUFFER, L_2, clEOA)); } if (clTrue(L_test)) { clObject L_arg416, L_value415; clSetq(L_arg416, stream); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSTREAM_ELEMENT_TYPE), L_0__R1, clEOA)); } clSetq(L_value415, clMakeBuffer(L_0, clEOA)); } return(cl_SETF_SlotValue(L_value415, L_arg416, clOUTPUT_BUFFER, clEOA)); } else return(clValues1(clNIL)); } } } clObject clCheckBufferSize_clBUFFERED_EXTERNAL_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args418 = clMakeBinding(), *L_methods419 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args418, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods419, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form421, stream, n_additional_items; clSetq(L_form421, *L_args418); if (clTrue(L_form421)) { clObject L_top422; clSetq(L_top422, clCar(L_form421, clEOA)); { clObject L_0; clSetq(L_0, L_form421); clSetq(L_form421, clCdr(L_0, clEOA)); } clSetq(stream, L_top422); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form421)) { clObject L_top423; { clObject L_0; clSetq(L_0, L_form421); clSetq(L_top423, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form421); clSetq(L_form421, clCdr(L_0, clEOA)); } clSetq(n_additional_items, L_top423); } else clSetq(n_additional_items, clMissingArgs(I_2, clEOA)); if (clTrue(L_form421)) { clObject L_0; clSetq(L_0, L_form421); clExtraArgs(L_0, clEOA); } { clObject L_instance424, L_class425, L_output_buffer426; clSetq(L_instance424, stream); clSetq(L_class425, clClassOf(L_instance424, clEOA)); clSetq(L_output_buffer426, clFastFindSlot(L_class425, clOUTPUT_BUFFER)); { clObject buf, current, pos, needed; clSetq(buf, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class425, L_instance424, L_output_buffer426, clEOA)); clSetq(current, clFuncallFunction(clSymbolFunctionValue(clARRAY_DIMENSION), buf, I_0, clEOA)); clSetq(pos, clFillPointer(buf, clEOA)); { clObject needed__R1; clSetq(needed__R1, clNIL); clLabel(NEXT_LOOP); { clObject L_1; clSetq(L_1, n_additional_items); clSetq(needed__R1, clFuncallFunction(clSymbolFunctionValue(clADD), pos, L_1, clEOA)); } { clObject L_test; { clObject L_1; clSetq(L_1, needed__R1); clSetq(L_test, clFuncallFunction(clSymbolFunctionValue(clGE), current, L_1, clEOA)); } if (clTrue(L_test)) goto END_LOOP; } { clObject L_0; clSetq(L_0, stream); clFuncallFunction(clSymbolFunctionValue(clSTREAM_FORCE_OUTPUT), L_0, clEOA); } clSetq(pos, clFillPointer(buf, clEOA)); goto NEXT_LOOP; clLabel(END_LOOP); clSetq(needed, needed__R1); clLocalReturn(NIL); clSetq(needed, clNIL); clBlockEnd(NIL); } { clObject L_value428; clSetq(L_value428, needed); cl_SETF_FillPointer(L_value428, buf, clEOA); } return(clValues1(pos)); } } } } clObject clStreamFinishOutput_keyBEFORE_clBUFFERED_EXTERNAL_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args430 = clMakeBinding(), *L_methods431 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args430, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods431, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form433, stream; clSetq(L_form433, *L_args430); if (clTrue(L_form433)) { clObject L_top434; clSetq(L_top434, clCar(L_form433, clEOA)); { clObject L_0; clSetq(L_0, L_form433); clSetq(L_form433, clCdr(L_0, clEOA)); } clSetq(stream, L_top434); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form433)) { clObject L_0; clSetq(L_0, L_form433); clExtraArgs(L_0, clEOA); } { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clSTREAM_FORCE_OUTPUT), L_0, clEOA)); } } } static clObject clLambda_r1 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(I_0)); } clObject clStreamTerpri_keyAFTER_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args435 = clMakeBinding(), *L_methods436 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args435, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods436, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form438, stream; clSetq(L_form438, *L_args435); if (clTrue(L_form438)) { clObject L_top439; clSetq(L_top439, clCar(L_form438, clEOA)); { clObject L_0; clSetq(L_0, L_form438); clSetq(L_form438, clCdr(L_0, clEOA)); } clSetq(stream, L_top439); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form438)) { clObject L_0; clSetq(L_0, L_form438); clExtraArgs(L_0, clEOA); } { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clSTREAM_FORCE_OUTPUT), L_0, clEOA)); } } } clObject clStreamLineColumn_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args440 = clMakeBinding(), *L_methods441 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args440, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods441, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form443, stream; clSetq(L_form443, *L_args440); if (clTrue(L_form443)) { clObject L_top444; clSetq(L_top444, clCar(L_form443, clEOA)); { clObject L_0; clSetq(L_0, L_form443); clSetq(L_form443, clCdr(L_0, clEOA)); } clSetq(stream, L_top444); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form443)) { clObject L_0; clSetq(L_0, L_form443); clExtraArgs(L_0, clEOA); } { clObject string, pos, start; { clObject L_0; clSetq(L_0, stream); clSetq(string, clFuncallFunction(clSymbolFunctionValue(clOUTPUT_BUFFER), L_0, clEOA)); } clSetq(pos, clFillPointer(string, clEOA)); clSetq(start, clPosition(C_Newline, string, keyEND, pos, keyFROM_END, clT, clEOA)); if (clTrue(start)) return(clMINUS_FUNC(pos, start, I_1, clEOA)); else { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clBUFFER_LINE_COLUMN), L_0__R1, clEOA)); } return(clFuncallFunction(clSymbolFunctionValue(clADD), L_0, pos, clEOA)); } } } } clObject cl_SETF_StreamStartLineP_clT_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args445 = clMakeBinding(), *L_methods446 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args445, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods446, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form448, start_line_p, stream; clSetq(L_form448, *L_args445); if (clTrue(L_form448)) { clObject L_top449; clSetq(L_top449, clCar(L_form448, clEOA)); { clObject L_0; clSetq(L_0, L_form448); clSetq(L_form448, clCdr(L_0, clEOA)); } clSetq(start_line_p, L_top449); } else clSetq(start_line_p, clMissingArgs(I_1, clEOA)); if (clTrue(L_form448)) { clObject L_top450; { clObject L_0; clSetq(L_0, L_form448); clSetq(L_top450, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form448); clSetq(L_form448, clCdr(L_0, clEOA)); } clSetq(stream, L_top450); } else clSetq(stream, clMissingArgs(I_2, clEOA)); if (clTrue(L_form448)) { clObject L_0; clSetq(L_0, L_form448); clExtraArgs(L_0, clEOA); } if (clTrue(start_line_p)) { { clObject L_arg452; clSetq(L_arg452, stream); clFuncallFunction(clFdefinition(CONS_29, clEOA), I_0, L_arg452, clEOA); } return(clValues1(start_line_p)); } else return(clValues1(clNIL)); } } static clObject clLambda_r2 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(clNIL)); } static clObject clLambda_r3 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(clNIL)); } clObject clPrintObject_clFILE_STREAM_clT clVdecl(_ap) { clObject *L_args453 = clMakeBinding(), *L_methods454 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args453, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods454, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form456, object, s; clSetq(L_form456, *L_args453); if (clTrue(L_form456)) { clObject L_top457; clSetq(L_top457, clCar(L_form456, clEOA)); { clObject L_0; clSetq(L_0, L_form456); clSetq(L_form456, clCdr(L_0, clEOA)); } clSetq(object, L_top457); } else clSetq(object, clMissingArgs(I_1, clEOA)); if (clTrue(L_form456)) { clObject L_top458; { clObject L_0; clSetq(L_0, L_form456); clSetq(L_top458, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form456); clSetq(L_form456, clCdr(L_0, clEOA)); } clSetq(s, L_top458); } else clSetq(s, clMissingArgs(I_2, clEOA)); if (clTrue(L_form456)) { clObject L_0; clSetq(L_0, L_form456); clExtraArgs(L_0, clEOA); } { clObject L_object459, L_stream460; clSetq(L_object459, object); { clObject L_0; clSetq(L_0, s); clSetq(L_stream460, clOutputStream(L_0, clEOA)); } clPrintUnreadableObjectHeader(L_object459, L_stream460, clT, clT, clT, clEOA); { clObject L_1, L_0; { clObject L_0__R1; clSetq(L_0__R1, object); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clPATHNAME), L_0__R1, clEOA)); } clSetq(L_1, s); clPrinc(L_0, L_1, clEOA); } return(clPrintUnreadableObjectTrailer(L_object459, L_stream460, clT, clT, clEOA)); } } } clObject clFileStreamDescriptor_clFILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args463 = clMakeBinding(), *L_methods464 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args463, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods464, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form466, stream; clSetq(L_form466, *L_args463); if (clTrue(L_form466)) { clObject L_top467; clSetq(L_top467, clCar(L_form466, clEOA)); { clObject L_0; clSetq(L_0, L_form466); clSetq(L_form466, clCdr(L_0, clEOA)); } clSetq(stream, L_top467); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form466)) { clObject L_0; clSetq(L_0, L_form466); clExtraArgs(L_0, clEOA); } { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clINPUT_FD), L_0, clEOA)); } } } clObject clFileStreamDescriptor_clFILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args468 = clMakeBinding(), *L_methods469 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args468, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods469, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form471, stream; clSetq(L_form471, *L_args468); if (clTrue(L_form471)) { clObject L_top472; clSetq(L_top472, clCar(L_form471, clEOA)); { clObject L_0; clSetq(L_0, L_form471); clSetq(L_form471, clCdr(L_0, clEOA)); } clSetq(stream, L_top472); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form471)) { clObject L_0; clSetq(L_0, L_form471); clExtraArgs(L_0, clEOA); } { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clOUTPUT_FD), L_0, clEOA)); } } } clObject clClose_keyBEFORE_clFILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args473 = clMakeBinding(), *L_methods474 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args473, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods474, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form476, L_form476__R1, stream, L_keys, abort; clSetq(L_form476, *L_args473); if (clTrue(L_form476)) { clObject L_top477; clSetq(L_top477, clCar(L_form476, clEOA)); { clObject L_0; clSetq(L_0, L_form476); clSetq(L_form476, clCdr(L_0, clEOA)); } clSetq(stream, L_top477); } else clSetq(stream, clMissingArgs(I_1, clEOA)); clSetq(L_keys, L_form476); if (clTrue(clSetq(L_form476__R1, clKeyArg(keyABORT, L_keys, clEOA)))) { clObject L_0; clSetq(L_0, L_form476__R1); clSetq(abort, clCar(L_0, clEOA)); } else clSetq(abort, clNIL); if (clTrue(abort)) { clObject L_0; clSetq(L_0, stream); return(clClearOutput(L_0, clEOA)); } else { clObject L_0; clSetq(L_0, stream); return(clFinishOutput(L_0, clEOA)); } } } clObject clClose_keyAFTER_clFILE_STREAM clVdecl(_ap) { clObject *L_args478 = clMakeBinding(), *L_methods479 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args478, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods479, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form481, L_form481__R1, stream, L_keys, abort; clSetq(L_form481, *L_args478); if (clTrue(L_form481)) { clObject L_top482; clSetq(L_top482, clCar(L_form481, clEOA)); { clObject L_0; clSetq(L_0, L_form481); clSetq(L_form481, clCdr(L_0, clEOA)); } clSetq(stream, L_top482); } else clSetq(stream, clMissingArgs(I_1, clEOA)); clSetq(L_keys, L_form481); if (clTrue(clSetq(L_form481__R1, clKeyArg(keyABORT, L_keys, clEOA)))) { clObject L_0; clSetq(L_0, L_form481__R1); clSetq(abort, clCar(L_0, clEOA)); } else clSetq(abort, clNIL); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clFILE_STREAM_DESCRIPTOR), L_0__R1, clEOA)); } return(clValues1(clFileDescriptorClose(L_0))); } } } clObject clClose_keyAFTER_clFILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args483 = clMakeBinding(), *L_methods484 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args483, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods484, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form486, L_form486__R1, stream, L_keys, abort; clSetq(L_form486, *L_args483); if (clTrue(L_form486)) { clObject L_top487; clSetq(L_top487, clCar(L_form486, clEOA)); { clObject L_0; clSetq(L_0, L_form486); clSetq(L_form486, clCdr(L_0, clEOA)); } clSetq(stream, L_top487); } else clSetq(stream, clMissingArgs(I_1, clEOA)); clSetq(L_keys, L_form486); if (clTrue(clSetq(L_form486__R1, clKeyArg(keyABORT, L_keys, clEOA)))) { clObject L_0; clSetq(L_0, L_form486__R1); clSetq(abort, clCar(L_0, clEOA)); } else clSetq(abort, clNIL); { clObject L_instance488, L_class489, L_cleanup492, L_renamed491, L_truename490; clSetq(L_instance488, stream); clSetq(L_class489, clClassOf(L_instance488, clEOA)); clSetq(L_cleanup492, clFastFindSlot(L_class489, clCLEANUP)); clSetq(L_renamed491, clFastFindSlot(L_class489, clRENAMED)); clSetq(L_truename490, clFastFindSlot(L_class489, clTRUENAME)); if (clTrue(abort)) { clDeleteFile(clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_truename490, clEOA), clEOA); if (clTrue(clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_renamed491, clEOA))) { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_renamed491, clEOA)); return(clRenameFile(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_truename490, clEOA), clEOA)); } else return(clValues1(clNIL)); } else { clObject L_key493; clSetq(L_key493, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_cleanup492, clEOA)); if (_clEq(L_key493, keyEXPUNGE)) return(clExpungeFile(clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_renamed491, clEOA), clEOA)); else if (_clEq(L_key493, keyDELETE)) return(clDeleteFile(clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class489, L_instance488, L_renamed491, clEOA), clEOA)); else return(clValues1(clNIL)); } } } } clObject clStreamClearInput_keyBEFORE_clFILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args494 = clMakeBinding(), *L_methods495 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args494, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods495, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form497, stream; clSetq(L_form497, *L_args494); if (clTrue(L_form497)) { clObject L_top498; clSetq(L_top498, clCar(L_form497, clEOA)); { clObject L_0; clSetq(L_0, L_form497); clSetq(L_form497, clCdr(L_0, clEOA)); } clSetq(stream, L_top498); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form497)) { clObject L_0; clSetq(L_0, L_form497); clExtraArgs(L_0, clEOA); } { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clINPUT_FD), L_0__R1, clEOA)); } return(clValues1(clFlushInput(L_0))); } } } clObject clStreamClearOutput_keyBEFORE_clFILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args499 = clMakeBinding(), *L_methods500 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args499, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods500, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form502, stream; clSetq(L_form502, *L_args499); if (clTrue(L_form502)) { clObject L_top503; clSetq(L_top503, clCar(L_form502, clEOA)); { clObject L_0; clSetq(L_0, L_form502); clSetq(L_form502, clCdr(L_0, clEOA)); } clSetq(stream, L_top503); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form502)) { clObject L_0; clSetq(L_0, L_form502); clExtraArgs(L_0, clEOA); } { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clOUTPUT_FD), L_0__R1, clEOA)); } return(clValues1(clFlushOutput(L_0))); } } } clObject clStreamFinishOutput_clFILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args504 = clMakeBinding(), *L_methods505 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args504, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods505, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form507, stream; clSetq(L_form507, *L_args504); if (clTrue(L_form507)) { clObject L_top508; clSetq(L_top508, clCar(L_form507, clEOA)); { clObject L_0; clSetq(L_0, L_form507); clSetq(L_form507, clCdr(L_0, clEOA)); } clSetq(stream, L_top508); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form507)) { clObject L_0; clSetq(L_0, L_form507); clExtraArgs(L_0, clEOA); } { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, stream); clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clOUTPUT_FD), L_0__R1, clEOA)); } clDrain(L_0); } return(clValues1(clNIL)); } } clObject clStreamForceOutput_clBUFFERED_FILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args509 = clMakeBinding(), *L_methods510 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args509, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods510, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form512, stream; clSetq(L_form512, *L_args509); if (clTrue(L_form512)) { clObject L_top513; clSetq(L_top513, clCar(L_form512, clEOA)); { clObject L_0; clSetq(L_0, L_form512); clSetq(L_form512, clCdr(L_0, clEOA)); } clSetq(stream, L_top513); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form512)) { clObject L_0; clSetq(L_0, L_form512); clExtraArgs(L_0, clEOA); } { clObject L_instance514, L_class515, L_output_buffer516; clSetq(L_instance514, stream); clSetq(L_class515, clClassOf(L_instance514, clEOA)); clSetq(L_output_buffer516, clFastFindSlot(L_class515, clOUTPUT_BUFFER)); { clObject buffer, n; clSetq(buffer, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class515, L_instance514, L_output_buffer516, clEOA)); { clObject L_0; clSetq(L_0, stream); clSetq(n, clFuncallFunction(clSymbolFunctionValue(clSTREAM_WRITE), L_0, clLength(buffer, clEOA), clEOA)); } clFuncallFunction(clSymbolFunctionValue(clREPLACE), buffer, buffer, keySTART2, n, clEOA); { clObject L_value517; { clObject L_0; clSetq(L_0, clFillPointer(buffer, clEOA)); clSetq(L_value517, clFuncallFunction(clSymbolFunctionValue(clSUBT), L_0, n, clEOA)); } cl_SETF_FillPointer(L_value517, buffer, clEOA); } return(clValues1(clNIL)); } } } } clObject clStreamFillInput_clBUFFERED_FILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args519 = clMakeBinding(), *L_methods520 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args519, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods520, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form522, stream, wait; clSetq(L_form522, *L_args519); if (clTrue(L_form522)) { clObject L_top523; clSetq(L_top523, clCar(L_form522, clEOA)); { clObject L_0; clSetq(L_0, L_form522); clSetq(L_form522, clCdr(L_0, clEOA)); } clSetq(stream, L_top523); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form522)) { clObject L_top524; { clObject L_0; clSetq(L_0, L_form522); clSetq(L_top524, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form522); clSetq(L_form522, clCdr(L_0, clEOA)); } clSetq(wait, L_top524); } else clSetq(wait, clT); if (clTrue(L_form522)) { clObject L_0; clSetq(L_0, L_form522); clExtraArgs(L_0, clEOA); } { clObject L_test; { clObject L_test__R1; { clObject L_0; clSetq(L_0, wait); clSetq(L_test__R1, clNot(L_0, clEOA)); } if (clTrue(L_test__R1)) { clObject L_test__R2; { clObject L_0; clSetq(L_0, stream); clSetq(L_test__R2, clFuncallFunction(clSymbolFunctionValue(clINTERACTIVE_STREAM_P), L_0, clEOA)); } if (clTrue(L_test__R2)) { clObject L_0; { clObject L_0__R1; { clObject L_0__R2; clSetq(L_0__R2, stream); clSetq(L_0__R1, clFuncallFunction(clSymbolFunctionValue(clINPUT_FD), L_0__R2, clEOA)); } clSetq(L_0, clPoll(L_0__R1)); } clSetq(L_test, clNot(L_0, clEOA)); } else clSetq(L_test, clNIL); } else clSetq(L_test, clNIL); } if (clTrue(L_test)) return(clValues1(I_0)); } { clObject L_instance525, L_class526, L_offset530, L_end529, L_position528, L_input_buffer527; clSetq(L_instance525, stream); clSetq(L_class526, clClassOf(L_instance525, clEOA)); clSetq(L_offset530, clFastFindSlot(L_class526, clOFFSET)); clSetq(L_end529, clFastFindSlot(L_class526, clEND)); clSetq(L_position528, clFastFindSlot(L_class526, clPOSITION)); clSetq(L_input_buffer527, clFastFindSlot(L_class526, clINPUT_BUFFER)); { clObject n; { clObject L_0; clSetq(L_0, stream); clSetq(n, clFuncallFunction(clSymbolFunctionValue(clSTREAM_READ), L_0, clLength(clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class526, L_instance525, L_input_buffer527, clEOA), clEOA), clEOA)); } if (clTrue(clPlusp(n, clEOA))) { { clObject L_value531; clSetq(L_value531, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class526, L_instance525, L_offset530, clEOA)); clFuncallFunction(clFdefinition(CONS_72, clEOA), L_value531, L_class526, L_instance525, L_position528, clEOA); } { clObject L_value535; { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class526, L_instance525, L_offset530, clEOA)); clSetq(L_value535, clFuncallFunction(clSymbolFunctionValue(clADD), L_0, n, clEOA)); } clFuncallFunction(clFdefinition(CONS_72, clEOA), L_value535, L_class526, L_instance525, L_end529, clEOA); } return(clValues1(n)); } else return(clValues1(clNIL)); } } } } clObject clStreamReadChar_keyBEFORE_clBUFFERED_CHARACTER_FILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args539 = clMakeBinding(), *L_methods540 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args539, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods540, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form542, stream; clSetq(L_form542, *L_args539); if (clTrue(L_form542)) { clObject L_top543; clSetq(L_top543, clCar(L_form542, clEOA)); { clObject L_0; clSetq(L_0, L_form542); clSetq(L_form542, clCdr(L_0, clEOA)); } clSetq(stream, L_top543); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form542)) { clObject L_0; clSetq(L_0, L_form542); clExtraArgs(L_0, clEOA); } { clObject L_instance544, L_class545, L_end547, L_position546; clSetq(L_instance544, stream); clSetq(L_class545, clClassOf(L_instance544, clEOA)); clSetq(L_end547, clFastFindSlot(L_class545, clEND)); clSetq(L_position546, clFastFindSlot(L_class545, clPOSITION)); { clObject L_test; { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class545, L_instance544, L_position546, clEOA)); clSetq(L_test, clFuncallFunction(clSymbolFunctionValue(clGE), L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class545, L_instance544, L_end547, clEOA), clEOA)); } if (clTrue(L_test)) { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clSTREAM_FILL_INPUT), L_0, clEOA)); } else return(clValues1(clNIL)); } } } } clObject clStreamPeekChar_keyBEFORE_clBUFFERED_CHARACTER_FILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args548 = clMakeBinding(), *L_methods549 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args548, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods549, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form551, stream; clSetq(L_form551, *L_args548); if (clTrue(L_form551)) { clObject L_top552; clSetq(L_top552, clCar(L_form551, clEOA)); { clObject L_0; clSetq(L_0, L_form551); clSetq(L_form551, clCdr(L_0, clEOA)); } clSetq(stream, L_top552); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form551)) { clObject L_0; clSetq(L_0, L_form551); clExtraArgs(L_0, clEOA); } { clObject L_instance553, L_class554, L_end556, L_position555; clSetq(L_instance553, stream); clSetq(L_class554, clClassOf(L_instance553, clEOA)); clSetq(L_end556, clFastFindSlot(L_class554, clEND)); clSetq(L_position555, clFastFindSlot(L_class554, clPOSITION)); { clObject L_test; { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class554, L_instance553, L_position555, clEOA)); clSetq(L_test, clFuncallFunction(clSymbolFunctionValue(clGE), L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class554, L_instance553, L_end556, clEOA), clEOA)); } if (clTrue(L_test)) { clObject L_0; clSetq(L_0, stream); return(clFuncallFunction(clSymbolFunctionValue(clSTREAM_FILL_INPUT), L_0, clEOA)); } else return(clValues1(clNIL)); } } } } clObject clStreamReadCharNoHang_clBUFFERED_CHARACTER_FILE_INPUT_STREAM clVdecl(_ap) { clObject *L_args557 = clMakeBinding(), *L_methods558 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args557, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods558, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form560, stream; clSetq(L_form560, *L_args557); if (clTrue(L_form560)) { clObject L_top561; clSetq(L_top561, clCar(L_form560, clEOA)); { clObject L_0; clSetq(L_0, L_form560); clSetq(L_form560, clCdr(L_0, clEOA)); } clSetq(stream, L_top561); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form560)) { clObject L_0; clSetq(L_0, L_form560); clExtraArgs(L_0, clEOA); } { clObject L_instance562, L_class563, L_end566, L_position565, L_input_buffer564; clSetq(L_instance562, stream); clSetq(L_class563, clClassOf(L_instance562, clEOA)); clSetq(L_end566, clFastFindSlot(L_class563, clEND)); clSetq(L_position565, clFastFindSlot(L_class563, clPOSITION)); clSetq(L_input_buffer564, clFastFindSlot(L_class563, clINPUT_BUFFER)); { clObject pos; clSetq(pos, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class563, L_instance562, L_position565, clEOA)); if (clTrue(clFuncallFunction(clSymbolFunctionValue(clGE), pos, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class563, L_instance562, L_end566, clEOA), clEOA))) { clObject L_key567; { clObject L_0; clSetq(L_0, stream); clSetq(L_key567, clFuncallFunction(clSymbolFunctionValue(clSTREAM_FILL_INPUT), L_0, clNIL, clEOA)); } if (_clEq(L_key567, clNIL)) return(clValues1(keyEOF)); else if (_clEq(L_key567, I_0)) return(clValues1(clNIL)); else clSetq(pos, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class563, L_instance562, L_position565, clEOA)); } { clObject L_value568; { clObject L_0; clSetq(L_0, pos); clSetq(L_value568, cl1PLUS_FUNC(L_0, clEOA)); } clFuncallFunction(clFdefinition(CONS_72, clEOA), L_value568, L_class563, L_instance562, L_position565, clEOA); } { clObject L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class563, L_instance562, L_input_buffer564, clEOA)); clSetq(L_1, pos); return(clFuncallFunction(clSymbolFunctionValue(clCHAR), L_0, L_1, clEOA)); } } } } } clObject clStreamForceOutput_clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM clVdecl(_ap) { clObject *L_args572 = clMakeBinding(), *L_methods573 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args572, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods573, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form575, stream; clSetq(L_form575, *L_args572); if (clTrue(L_form575)) { clObject L_top576; clSetq(L_top576, clCar(L_form575, clEOA)); { clObject L_0; clSetq(L_0, L_form575); clSetq(L_form575, clCdr(L_0, clEOA)); } clSetq(stream, L_top576); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form575)) { clObject L_0; clSetq(L_0, L_form575); clExtraArgs(L_0, clEOA); } { clObject L_instance577, L_class578, L_buffer_line_column580, L_output_buffer579; clSetq(L_instance577, stream); clSetq(L_class578, clClassOf(L_instance577, clEOA)); clSetq(L_buffer_line_column580, clFastFindSlot(L_class578, clBUFFER_LINE_COLUMN)); clSetq(L_output_buffer579, clFastFindSlot(L_class578, clOUTPUT_BUFFER)); { clObject buffer, n, pos; clSetq(buffer, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class578, L_instance577, L_output_buffer579, clEOA)); { clObject L_0; clSetq(L_0, stream); clSetq(n, clFuncallFunction(clSymbolFunctionValue(clSTREAM_WRITE), L_0, clLength(buffer, clEOA), clEOA)); } clSetq(pos, clPosition(C_Newline, buffer, keyEND, n, keyFROM_END, clT, clEOA)); { clObject L_value581; if (clTrue(pos)) clSetq(L_value581, clMINUS_FUNC(n, pos, I_1, clEOA)); else { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class578, L_instance577, L_buffer_line_column580, clEOA)); clSetq(L_value581, clFuncallFunction(clSymbolFunctionValue(clADD), L_0, n, clEOA)); } { clObject L_0; clSetq(L_0, L_value581); clFuncallFunction(clFdefinition(CONS_72, clEOA), L_0, L_class578, L_instance577, L_buffer_line_column580, clEOA); } } clFuncallFunction(clSymbolFunctionValue(clREPLACE), buffer, buffer, keySTART2, n, clEOA); { clObject L_value585; { clObject L_0; clSetq(L_0, clFillPointer(buffer, clEOA)); clSetq(L_value585, clFuncallFunction(clSymbolFunctionValue(clSUBT), L_0, n, clEOA)); } cl_SETF_FillPointer(L_value585, buffer, clEOA); } return(clValues1(clNIL)); } } } } static clObject clLambda_r4 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyASCII)); } static clObject clLambda_r5 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(clBASE_CHAR)); } static clObject clLambda_r6 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyUCS)); } static clObject clLambda_r7 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(clUCS_2_CHAR)); } static clObject clLambda_r8 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyUCS)); } static clObject clLambda_r9 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(clUNICODE_CHAR)); } static clObject clLambda_r10 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyMULTI_BYTE)); } static clObject clLambda_r11 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_test; { clObject L_sub607; clSetq(L_sub607, clSymbolValue(clstarFEATURESstar, clEOA)); clLabel(l_ITERATE610); if (clTrue(clEndp(L_sub607, clEOA))) { clSetq(L_test, clNIL); clLocalReturn(NIL); } if (_clEq(keyUCS_4_IO, clCar(L_sub607, clEOA))) { clSetq(L_test, L_sub607); clLocalReturn(l_MEMBER609); } { clObject L_value611; clSetq(L_value611, clCdr(L_sub607, clEOA)); clSetq(L_sub607, L_value611); } goto l_ITERATE610; } clBlockEnd(NIL); clBlockEnd(l_MEMBER609); if (clTrue(L_test)) return(clValues1(clUNICODE_CHAR)); else return(clValues1(clUCS_2_CHAR)); } } static clObject clLambda_r12 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clMakeArray(I_6, keyELEMENT_TYPE, clBASE_CHAR, keyFILL_POINTER, I_0, clEOA)); } static clObject clLambda_r13 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r14 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_128)); } static clObject clLambda_r15 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r16 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_136)); } static clObject clLambda_r17 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r18 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_144)); } static clObject clLambda_r19 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r20 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_152)); } static clObject clLambda_r21 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r22 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_159)); } static clObject clLambda_r23 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyBIG_ENDIAN)); } static clObject clLambda_r24 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_166)); } static clObject clLambda_r25 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r26 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_128)); } static clObject clLambda_r27 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r28 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_136)); } static clObject clLambda_r29 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r30 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_144)); } static clObject clLambda_r31 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r32 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_152)); } static clObject clLambda_r33 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r34 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_159)); } static clObject clLambda_r35 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(keyLITTLE_ENDIAN)); } static clObject clLambda_r36 clVdecl(_ap) { { clBeginParse(_ap); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } return(clValues1(CONS_166)); } clObject clStreamRead_clASCII_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args676 = clMakeBinding(), *L_methods677 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args676, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods677, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form679, stream, n; clSetq(L_form679, *L_args676); if (clTrue(L_form679)) { clObject L_top680; clSetq(L_top680, clCar(L_form679, clEOA)); { clObject L_0; clSetq(L_0, L_form679); clSetq(L_form679, clCdr(L_0, clEOA)); } clSetq(stream, L_top680); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form679)) { clObject L_top681; { clObject L_0; clSetq(L_0, L_form679); clSetq(L_top681, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form679); clSetq(L_form679, clCdr(L_0, clEOA)); } clSetq(n, L_top681); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form679)) { clObject L_0; clSetq(L_0, L_form679); clExtraArgs(L_0, clEOA); } { clObject L_instance682, L_class683, L_offset686, L_input_buffer685, L_input_fd684; clSetq(L_instance682, stream); clSetq(L_class683, clClassOf(L_instance682, clEOA)); clSetq(L_offset686, clFastFindSlot(L_class683, clOFFSET)); clSetq(L_input_buffer685, clFastFindSlot(L_class683, clINPUT_BUFFER)); clSetq(L_input_fd684, clFastFindSlot(L_class683, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class683, L_instance682, L_input_fd684, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class683, L_instance682, L_input_buffer685, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class683, L_instance682, L_offset686, clEOA)); clSetq(L_3, n); return(clValues1(clReadAscii(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clUCS_2_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args691 = clMakeBinding(), *L_methods692 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args691, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods692, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form694, stream, n; clSetq(L_form694, *L_args691); if (clTrue(L_form694)) { clObject L_top695; clSetq(L_top695, clCar(L_form694, clEOA)); { clObject L_0; clSetq(L_0, L_form694); clSetq(L_form694, clCdr(L_0, clEOA)); } clSetq(stream, L_top695); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form694)) { clObject L_top696; { clObject L_0; clSetq(L_0, L_form694); clSetq(L_top696, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form694); clSetq(L_form694, clCdr(L_0, clEOA)); } clSetq(n, L_top696); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form694)) { clObject L_0; clSetq(L_0, L_form694); clExtraArgs(L_0, clEOA); } { clObject L_instance697, L_class698, L_offset701, L_input_buffer700, L_input_fd699; clSetq(L_instance697, stream); clSetq(L_class698, clClassOf(L_instance697, clEOA)); clSetq(L_offset701, clFastFindSlot(L_class698, clOFFSET)); clSetq(L_input_buffer700, clFastFindSlot(L_class698, clINPUT_BUFFER)); clSetq(L_input_fd699, clFastFindSlot(L_class698, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class698, L_instance697, L_input_fd699, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class698, L_instance697, L_input_buffer700, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class698, L_instance697, L_offset701, clEOA)); clSetq(L_3, n); return(clValues1(clReadUcs2(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clUCS_4_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args706 = clMakeBinding(), *L_methods707 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args706, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods707, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form709, stream, n; clSetq(L_form709, *L_args706); if (clTrue(L_form709)) { clObject L_top710; clSetq(L_top710, clCar(L_form709, clEOA)); { clObject L_0; clSetq(L_0, L_form709); clSetq(L_form709, clCdr(L_0, clEOA)); } clSetq(stream, L_top710); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form709)) { clObject L_top711; { clObject L_0; clSetq(L_0, L_form709); clSetq(L_top711, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form709); clSetq(L_form709, clCdr(L_0, clEOA)); } clSetq(n, L_top711); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form709)) { clObject L_0; clSetq(L_0, L_form709); clExtraArgs(L_0, clEOA); } { clObject L_instance712, L_class713, L_offset716, L_input_buffer715, L_input_fd714; clSetq(L_instance712, stream); clSetq(L_class713, clClassOf(L_instance712, clEOA)); clSetq(L_offset716, clFastFindSlot(L_class713, clOFFSET)); clSetq(L_input_buffer715, clFastFindSlot(L_class713, clINPUT_BUFFER)); clSetq(L_input_fd714, clFastFindSlot(L_class713, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class713, L_instance712, L_input_fd714, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class713, L_instance712, L_input_buffer715, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class713, L_instance712, L_offset716, clEOA)); clSetq(L_3, n); return(clValues1(clReadUcs4(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clMB_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args721 = clMakeBinding(), *L_methods722 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args721, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods722, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form724, stream, n; clSetq(L_form724, *L_args721); if (clTrue(L_form724)) { clObject L_top725; clSetq(L_top725, clCar(L_form724, clEOA)); { clObject L_0; clSetq(L_0, L_form724); clSetq(L_form724, clCdr(L_0, clEOA)); } clSetq(stream, L_top725); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form724)) { clObject L_top726; { clObject L_0; clSetq(L_0, L_form724); clSetq(L_top726, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form724); clSetq(L_form724, clCdr(L_0, clEOA)); } clSetq(n, L_top726); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form724)) { clObject L_0; clSetq(L_0, L_form724); clExtraArgs(L_0, clEOA); } { clObject L_instance727, L_class728, L_aux732, L_offset731, L_input_buffer730, L_input_fd729; clSetq(L_instance727, stream); clSetq(L_class728, clClassOf(L_instance727, clEOA)); clSetq(L_aux732, clFastFindSlot(L_class728, clAUX)); clSetq(L_offset731, clFastFindSlot(L_class728, clOFFSET)); clSetq(L_input_buffer730, clFastFindSlot(L_class728, clINPUT_BUFFER)); clSetq(L_input_fd729, clFastFindSlot(L_class728, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class728, L_instance727, L_input_fd729, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class728, L_instance727, L_input_buffer730, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class728, L_instance727, L_offset731, clEOA)); clSetq(L_3, n); return(clValues1(clReadMb(L_0, L_1, L_2, L_3, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class728, L_instance727, L_aux732, clEOA)))); } } } } clObject clStreamRead_clBEU8_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args737 = clMakeBinding(), *L_methods738 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args737, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods738, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form740, stream, n; clSetq(L_form740, *L_args737); if (clTrue(L_form740)) { clObject L_top741; clSetq(L_top741, clCar(L_form740, clEOA)); { clObject L_0; clSetq(L_0, L_form740); clSetq(L_form740, clCdr(L_0, clEOA)); } clSetq(stream, L_top741); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form740)) { clObject L_top742; { clObject L_0; clSetq(L_0, L_form740); clSetq(L_top742, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form740); clSetq(L_form740, clCdr(L_0, clEOA)); } clSetq(n, L_top742); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form740)) { clObject L_0; clSetq(L_0, L_form740); clExtraArgs(L_0, clEOA); } { clObject L_instance743, L_class744, L_offset747, L_input_buffer746, L_input_fd745; clSetq(L_instance743, stream); clSetq(L_class744, clClassOf(L_instance743, clEOA)); clSetq(L_offset747, clFastFindSlot(L_class744, clOFFSET)); clSetq(L_input_buffer746, clFastFindSlot(L_class744, clINPUT_BUFFER)); clSetq(L_input_fd745, clFastFindSlot(L_class744, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class744, L_instance743, L_input_fd745, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class744, L_instance743, L_input_buffer746, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class744, L_instance743, L_offset747, clEOA)); clSetq(L_3, n); return(clValues1(clReadBeu8(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clBEU16_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args752 = clMakeBinding(), *L_methods753 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args752, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods753, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form755, stream, n; clSetq(L_form755, *L_args752); if (clTrue(L_form755)) { clObject L_top756; clSetq(L_top756, clCar(L_form755, clEOA)); { clObject L_0; clSetq(L_0, L_form755); clSetq(L_form755, clCdr(L_0, clEOA)); } clSetq(stream, L_top756); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form755)) { clObject L_top757; { clObject L_0; clSetq(L_0, L_form755); clSetq(L_top757, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form755); clSetq(L_form755, clCdr(L_0, clEOA)); } clSetq(n, L_top757); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form755)) { clObject L_0; clSetq(L_0, L_form755); clExtraArgs(L_0, clEOA); } { clObject L_instance758, L_class759, L_offset762, L_input_buffer761, L_input_fd760; clSetq(L_instance758, stream); clSetq(L_class759, clClassOf(L_instance758, clEOA)); clSetq(L_offset762, clFastFindSlot(L_class759, clOFFSET)); clSetq(L_input_buffer761, clFastFindSlot(L_class759, clINPUT_BUFFER)); clSetq(L_input_fd760, clFastFindSlot(L_class759, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class759, L_instance758, L_input_fd760, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class759, L_instance758, L_input_buffer761, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class759, L_instance758, L_offset762, clEOA)); clSetq(L_3, n); return(clValues1(clReadBeu16(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clBEU32_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args767 = clMakeBinding(), *L_methods768 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args767, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods768, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form770, stream, n; clSetq(L_form770, *L_args767); if (clTrue(L_form770)) { clObject L_top771; clSetq(L_top771, clCar(L_form770, clEOA)); { clObject L_0; clSetq(L_0, L_form770); clSetq(L_form770, clCdr(L_0, clEOA)); } clSetq(stream, L_top771); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form770)) { clObject L_top772; { clObject L_0; clSetq(L_0, L_form770); clSetq(L_top772, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form770); clSetq(L_form770, clCdr(L_0, clEOA)); } clSetq(n, L_top772); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form770)) { clObject L_0; clSetq(L_0, L_form770); clExtraArgs(L_0, clEOA); } { clObject L_instance773, L_class774, L_offset777, L_input_buffer776, L_input_fd775; clSetq(L_instance773, stream); clSetq(L_class774, clClassOf(L_instance773, clEOA)); clSetq(L_offset777, clFastFindSlot(L_class774, clOFFSET)); clSetq(L_input_buffer776, clFastFindSlot(L_class774, clINPUT_BUFFER)); clSetq(L_input_fd775, clFastFindSlot(L_class774, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class774, L_instance773, L_input_fd775, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class774, L_instance773, L_input_buffer776, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class774, L_instance773, L_offset777, clEOA)); clSetq(L_3, n); return(clValues1(clReadBeu32(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLEU8_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args782 = clMakeBinding(), *L_methods783 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args782, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods783, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form785, stream, n; clSetq(L_form785, *L_args782); if (clTrue(L_form785)) { clObject L_top786; clSetq(L_top786, clCar(L_form785, clEOA)); { clObject L_0; clSetq(L_0, L_form785); clSetq(L_form785, clCdr(L_0, clEOA)); } clSetq(stream, L_top786); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form785)) { clObject L_top787; { clObject L_0; clSetq(L_0, L_form785); clSetq(L_top787, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form785); clSetq(L_form785, clCdr(L_0, clEOA)); } clSetq(n, L_top787); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form785)) { clObject L_0; clSetq(L_0, L_form785); clExtraArgs(L_0, clEOA); } { clObject L_instance788, L_class789, L_offset792, L_input_buffer791, L_input_fd790; clSetq(L_instance788, stream); clSetq(L_class789, clClassOf(L_instance788, clEOA)); clSetq(L_offset792, clFastFindSlot(L_class789, clOFFSET)); clSetq(L_input_buffer791, clFastFindSlot(L_class789, clINPUT_BUFFER)); clSetq(L_input_fd790, clFastFindSlot(L_class789, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class789, L_instance788, L_input_fd790, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class789, L_instance788, L_input_buffer791, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class789, L_instance788, L_offset792, clEOA)); clSetq(L_3, n); return(clValues1(clReadLeu8(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLEU16_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args797 = clMakeBinding(), *L_methods798 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args797, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods798, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form800, stream, n; clSetq(L_form800, *L_args797); if (clTrue(L_form800)) { clObject L_top801; clSetq(L_top801, clCar(L_form800, clEOA)); { clObject L_0; clSetq(L_0, L_form800); clSetq(L_form800, clCdr(L_0, clEOA)); } clSetq(stream, L_top801); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form800)) { clObject L_top802; { clObject L_0; clSetq(L_0, L_form800); clSetq(L_top802, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form800); clSetq(L_form800, clCdr(L_0, clEOA)); } clSetq(n, L_top802); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form800)) { clObject L_0; clSetq(L_0, L_form800); clExtraArgs(L_0, clEOA); } { clObject L_instance803, L_class804, L_offset807, L_input_buffer806, L_input_fd805; clSetq(L_instance803, stream); clSetq(L_class804, clClassOf(L_instance803, clEOA)); clSetq(L_offset807, clFastFindSlot(L_class804, clOFFSET)); clSetq(L_input_buffer806, clFastFindSlot(L_class804, clINPUT_BUFFER)); clSetq(L_input_fd805, clFastFindSlot(L_class804, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class804, L_instance803, L_input_fd805, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class804, L_instance803, L_input_buffer806, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class804, L_instance803, L_offset807, clEOA)); clSetq(L_3, n); return(clValues1(clReadLeu16(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLEU32_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args812 = clMakeBinding(), *L_methods813 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args812, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods813, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form815, stream, n; clSetq(L_form815, *L_args812); if (clTrue(L_form815)) { clObject L_top816; clSetq(L_top816, clCar(L_form815, clEOA)); { clObject L_0; clSetq(L_0, L_form815); clSetq(L_form815, clCdr(L_0, clEOA)); } clSetq(stream, L_top816); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form815)) { clObject L_top817; { clObject L_0; clSetq(L_0, L_form815); clSetq(L_top817, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form815); clSetq(L_form815, clCdr(L_0, clEOA)); } clSetq(n, L_top817); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form815)) { clObject L_0; clSetq(L_0, L_form815); clExtraArgs(L_0, clEOA); } { clObject L_instance818, L_class819, L_offset822, L_input_buffer821, L_input_fd820; clSetq(L_instance818, stream); clSetq(L_class819, clClassOf(L_instance818, clEOA)); clSetq(L_offset822, clFastFindSlot(L_class819, clOFFSET)); clSetq(L_input_buffer821, clFastFindSlot(L_class819, clINPUT_BUFFER)); clSetq(L_input_fd820, clFastFindSlot(L_class819, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class819, L_instance818, L_input_fd820, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class819, L_instance818, L_input_buffer821, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class819, L_instance818, L_offset822, clEOA)); clSetq(L_3, n); return(clValues1(clReadLeu32(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clBES8_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args827 = clMakeBinding(), *L_methods828 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args827, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods828, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form830, stream, n; clSetq(L_form830, *L_args827); if (clTrue(L_form830)) { clObject L_top831; clSetq(L_top831, clCar(L_form830, clEOA)); { clObject L_0; clSetq(L_0, L_form830); clSetq(L_form830, clCdr(L_0, clEOA)); } clSetq(stream, L_top831); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form830)) { clObject L_top832; { clObject L_0; clSetq(L_0, L_form830); clSetq(L_top832, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form830); clSetq(L_form830, clCdr(L_0, clEOA)); } clSetq(n, L_top832); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form830)) { clObject L_0; clSetq(L_0, L_form830); clExtraArgs(L_0, clEOA); } { clObject L_instance833, L_class834, L_offset837, L_input_buffer836, L_input_fd835; clSetq(L_instance833, stream); clSetq(L_class834, clClassOf(L_instance833, clEOA)); clSetq(L_offset837, clFastFindSlot(L_class834, clOFFSET)); clSetq(L_input_buffer836, clFastFindSlot(L_class834, clINPUT_BUFFER)); clSetq(L_input_fd835, clFastFindSlot(L_class834, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class834, L_instance833, L_input_fd835, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class834, L_instance833, L_input_buffer836, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class834, L_instance833, L_offset837, clEOA)); clSetq(L_3, n); return(clValues1(clReadBes8(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clBES16_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args842 = clMakeBinding(), *L_methods843 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args842, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods843, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form845, stream, n; clSetq(L_form845, *L_args842); if (clTrue(L_form845)) { clObject L_top846; clSetq(L_top846, clCar(L_form845, clEOA)); { clObject L_0; clSetq(L_0, L_form845); clSetq(L_form845, clCdr(L_0, clEOA)); } clSetq(stream, L_top846); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form845)) { clObject L_top847; { clObject L_0; clSetq(L_0, L_form845); clSetq(L_top847, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form845); clSetq(L_form845, clCdr(L_0, clEOA)); } clSetq(n, L_top847); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form845)) { clObject L_0; clSetq(L_0, L_form845); clExtraArgs(L_0, clEOA); } { clObject L_instance848, L_class849, L_offset852, L_input_buffer851, L_input_fd850; clSetq(L_instance848, stream); clSetq(L_class849, clClassOf(L_instance848, clEOA)); clSetq(L_offset852, clFastFindSlot(L_class849, clOFFSET)); clSetq(L_input_buffer851, clFastFindSlot(L_class849, clINPUT_BUFFER)); clSetq(L_input_fd850, clFastFindSlot(L_class849, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class849, L_instance848, L_input_fd850, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class849, L_instance848, L_input_buffer851, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class849, L_instance848, L_offset852, clEOA)); clSetq(L_3, n); return(clValues1(clReadBes16(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clBES32_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args857 = clMakeBinding(), *L_methods858 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args857, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods858, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form860, stream, n; clSetq(L_form860, *L_args857); if (clTrue(L_form860)) { clObject L_top861; clSetq(L_top861, clCar(L_form860, clEOA)); { clObject L_0; clSetq(L_0, L_form860); clSetq(L_form860, clCdr(L_0, clEOA)); } clSetq(stream, L_top861); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form860)) { clObject L_top862; { clObject L_0; clSetq(L_0, L_form860); clSetq(L_top862, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form860); clSetq(L_form860, clCdr(L_0, clEOA)); } clSetq(n, L_top862); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form860)) { clObject L_0; clSetq(L_0, L_form860); clExtraArgs(L_0, clEOA); } { clObject L_instance863, L_class864, L_offset867, L_input_buffer866, L_input_fd865; clSetq(L_instance863, stream); clSetq(L_class864, clClassOf(L_instance863, clEOA)); clSetq(L_offset867, clFastFindSlot(L_class864, clOFFSET)); clSetq(L_input_buffer866, clFastFindSlot(L_class864, clINPUT_BUFFER)); clSetq(L_input_fd865, clFastFindSlot(L_class864, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class864, L_instance863, L_input_fd865, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class864, L_instance863, L_input_buffer866, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class864, L_instance863, L_offset867, clEOA)); clSetq(L_3, n); return(clValues1(clReadBes32(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLES8_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args872 = clMakeBinding(), *L_methods873 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args872, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods873, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form875, stream, n; clSetq(L_form875, *L_args872); if (clTrue(L_form875)) { clObject L_top876; clSetq(L_top876, clCar(L_form875, clEOA)); { clObject L_0; clSetq(L_0, L_form875); clSetq(L_form875, clCdr(L_0, clEOA)); } clSetq(stream, L_top876); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form875)) { clObject L_top877; { clObject L_0; clSetq(L_0, L_form875); clSetq(L_top877, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form875); clSetq(L_form875, clCdr(L_0, clEOA)); } clSetq(n, L_top877); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form875)) { clObject L_0; clSetq(L_0, L_form875); clExtraArgs(L_0, clEOA); } { clObject L_instance878, L_class879, L_offset882, L_input_buffer881, L_input_fd880; clSetq(L_instance878, stream); clSetq(L_class879, clClassOf(L_instance878, clEOA)); clSetq(L_offset882, clFastFindSlot(L_class879, clOFFSET)); clSetq(L_input_buffer881, clFastFindSlot(L_class879, clINPUT_BUFFER)); clSetq(L_input_fd880, clFastFindSlot(L_class879, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class879, L_instance878, L_input_fd880, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class879, L_instance878, L_input_buffer881, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class879, L_instance878, L_offset882, clEOA)); clSetq(L_3, n); return(clValues1(clReadLes8(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLES16_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args887 = clMakeBinding(), *L_methods888 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args887, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods888, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form890, stream, n; clSetq(L_form890, *L_args887); if (clTrue(L_form890)) { clObject L_top891; clSetq(L_top891, clCar(L_form890, clEOA)); { clObject L_0; clSetq(L_0, L_form890); clSetq(L_form890, clCdr(L_0, clEOA)); } clSetq(stream, L_top891); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form890)) { clObject L_top892; { clObject L_0; clSetq(L_0, L_form890); clSetq(L_top892, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form890); clSetq(L_form890, clCdr(L_0, clEOA)); } clSetq(n, L_top892); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form890)) { clObject L_0; clSetq(L_0, L_form890); clExtraArgs(L_0, clEOA); } { clObject L_instance893, L_class894, L_offset897, L_input_buffer896, L_input_fd895; clSetq(L_instance893, stream); clSetq(L_class894, clClassOf(L_instance893, clEOA)); clSetq(L_offset897, clFastFindSlot(L_class894, clOFFSET)); clSetq(L_input_buffer896, clFastFindSlot(L_class894, clINPUT_BUFFER)); clSetq(L_input_fd895, clFastFindSlot(L_class894, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class894, L_instance893, L_input_fd895, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class894, L_instance893, L_input_buffer896, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class894, L_instance893, L_offset897, clEOA)); clSetq(L_3, n); return(clValues1(clReadLes16(L_0, L_1, L_2, L_3))); } } } } clObject clStreamRead_clLES32_FILE_INPUT_STREAM_clT clVdecl(_ap) { clObject *L_args902 = clMakeBinding(), *L_methods903 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args902, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods903, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form905, stream, n; clSetq(L_form905, *L_args902); if (clTrue(L_form905)) { clObject L_top906; clSetq(L_top906, clCar(L_form905, clEOA)); { clObject L_0; clSetq(L_0, L_form905); clSetq(L_form905, clCdr(L_0, clEOA)); } clSetq(stream, L_top906); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form905)) { clObject L_top907; { clObject L_0; clSetq(L_0, L_form905); clSetq(L_top907, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form905); clSetq(L_form905, clCdr(L_0, clEOA)); } clSetq(n, L_top907); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form905)) { clObject L_0; clSetq(L_0, L_form905); clExtraArgs(L_0, clEOA); } { clObject L_instance908, L_class909, L_offset912, L_input_buffer911, L_input_fd910; clSetq(L_instance908, stream); clSetq(L_class909, clClassOf(L_instance908, clEOA)); clSetq(L_offset912, clFastFindSlot(L_class909, clOFFSET)); clSetq(L_input_buffer911, clFastFindSlot(L_class909, clINPUT_BUFFER)); clSetq(L_input_fd910, clFastFindSlot(L_class909, clINPUT_FD)); { clObject L_3, L_2, L_1, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class909, L_instance908, L_input_fd910, clEOA)); clSetq(L_1, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class909, L_instance908, L_input_buffer911, clEOA)); clSetq(L_2, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class909, L_instance908, L_offset912, clEOA)); clSetq(L_3, n); return(clValues1(clReadLes32(L_0, L_1, L_2, L_3))); } } } } clObject clStreamWrite_clASCII_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args917 = clMakeBinding(), *L_methods918 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args917, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods918, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form920, stream, n; clSetq(L_form920, *L_args917); if (clTrue(L_form920)) { clObject L_top921; clSetq(L_top921, clCar(L_form920, clEOA)); { clObject L_0; clSetq(L_0, L_form920); clSetq(L_form920, clCdr(L_0, clEOA)); } clSetq(stream, L_top921); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form920)) { clObject L_top922; { clObject L_0; clSetq(L_0, L_form920); clSetq(L_top922, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form920); clSetq(L_form920, clCdr(L_0, clEOA)); } clSetq(n, L_top922); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form920)) { clObject L_0; clSetq(L_0, L_form920); clExtraArgs(L_0, clEOA); } { clObject L_instance923, L_class924, L_output_buffer926, L_output_fd925; clSetq(L_instance923, stream); clSetq(L_class924, clClassOf(L_instance923, clEOA)); clSetq(L_output_buffer926, clFastFindSlot(L_class924, clOUTPUT_BUFFER)); clSetq(L_output_fd925, clFastFindSlot(L_class924, clOUTPUT_FD)); { clObject L_values927, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class924, L_instance923, L_output_buffer926, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values927, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values927, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values927); clSetq(L_0, clSetq(L_values927, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class924, L_instance923, L_output_fd925, clEOA)); clSetq(L_3, n); return(clValues1(clWriteAscii(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clUCS_2_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args932 = clMakeBinding(), *L_methods933 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args932, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods933, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form935, stream, n; clSetq(L_form935, *L_args932); if (clTrue(L_form935)) { clObject L_top936; clSetq(L_top936, clCar(L_form935, clEOA)); { clObject L_0; clSetq(L_0, L_form935); clSetq(L_form935, clCdr(L_0, clEOA)); } clSetq(stream, L_top936); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form935)) { clObject L_top937; { clObject L_0; clSetq(L_0, L_form935); clSetq(L_top937, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form935); clSetq(L_form935, clCdr(L_0, clEOA)); } clSetq(n, L_top937); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form935)) { clObject L_0; clSetq(L_0, L_form935); clExtraArgs(L_0, clEOA); } { clObject L_instance938, L_class939, L_output_buffer941, L_output_fd940; clSetq(L_instance938, stream); clSetq(L_class939, clClassOf(L_instance938, clEOA)); clSetq(L_output_buffer941, clFastFindSlot(L_class939, clOUTPUT_BUFFER)); clSetq(L_output_fd940, clFastFindSlot(L_class939, clOUTPUT_FD)); { clObject L_values942, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class939, L_instance938, L_output_buffer941, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values942, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values942, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values942); clSetq(L_0, clSetq(L_values942, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class939, L_instance938, L_output_fd940, clEOA)); clSetq(L_3, n); return(clValues1(clWriteUcs2(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clUCS_4_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args947 = clMakeBinding(), *L_methods948 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args947, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods948, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form950, stream, n; clSetq(L_form950, *L_args947); if (clTrue(L_form950)) { clObject L_top951; clSetq(L_top951, clCar(L_form950, clEOA)); { clObject L_0; clSetq(L_0, L_form950); clSetq(L_form950, clCdr(L_0, clEOA)); } clSetq(stream, L_top951); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form950)) { clObject L_top952; { clObject L_0; clSetq(L_0, L_form950); clSetq(L_top952, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form950); clSetq(L_form950, clCdr(L_0, clEOA)); } clSetq(n, L_top952); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form950)) { clObject L_0; clSetq(L_0, L_form950); clExtraArgs(L_0, clEOA); } { clObject L_instance953, L_class954, L_output_buffer956, L_output_fd955; clSetq(L_instance953, stream); clSetq(L_class954, clClassOf(L_instance953, clEOA)); clSetq(L_output_buffer956, clFastFindSlot(L_class954, clOUTPUT_BUFFER)); clSetq(L_output_fd955, clFastFindSlot(L_class954, clOUTPUT_FD)); { clObject L_values957, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class954, L_instance953, L_output_buffer956, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values957, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values957, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values957); clSetq(L_0, clSetq(L_values957, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class954, L_instance953, L_output_fd955, clEOA)); clSetq(L_3, n); return(clValues1(clWriteUcs4(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clMB_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args962 = clMakeBinding(), *L_methods963 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args962, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods963, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form965, stream, n; clSetq(L_form965, *L_args962); if (clTrue(L_form965)) { clObject L_top966; clSetq(L_top966, clCar(L_form965, clEOA)); { clObject L_0; clSetq(L_0, L_form965); clSetq(L_form965, clCdr(L_0, clEOA)); } clSetq(stream, L_top966); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form965)) { clObject L_top967; { clObject L_0; clSetq(L_0, L_form965); clSetq(L_top967, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form965); clSetq(L_form965, clCdr(L_0, clEOA)); } clSetq(n, L_top967); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form965)) { clObject L_0; clSetq(L_0, L_form965); clExtraArgs(L_0, clEOA); } { clObject L_instance968, L_class969, L_output_buffer971, L_output_fd970; clSetq(L_instance968, stream); clSetq(L_class969, clClassOf(L_instance968, clEOA)); clSetq(L_output_buffer971, clFastFindSlot(L_class969, clOUTPUT_BUFFER)); clSetq(L_output_fd970, clFastFindSlot(L_class969, clOUTPUT_FD)); { clObject L_values972, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class969, L_instance968, L_output_buffer971, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values972, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values972, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values972); clSetq(L_0, clSetq(L_values972, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class969, L_instance968, L_output_fd970, clEOA)); clSetq(L_3, n); return(clValues1(clWriteMb(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBEU8_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args977 = clMakeBinding(), *L_methods978 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args977, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods978, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form980, stream, n; clSetq(L_form980, *L_args977); if (clTrue(L_form980)) { clObject L_top981; clSetq(L_top981, clCar(L_form980, clEOA)); { clObject L_0; clSetq(L_0, L_form980); clSetq(L_form980, clCdr(L_0, clEOA)); } clSetq(stream, L_top981); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form980)) { clObject L_top982; { clObject L_0; clSetq(L_0, L_form980); clSetq(L_top982, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form980); clSetq(L_form980, clCdr(L_0, clEOA)); } clSetq(n, L_top982); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form980)) { clObject L_0; clSetq(L_0, L_form980); clExtraArgs(L_0, clEOA); } { clObject L_instance983, L_class984, L_output_buffer986, L_output_fd985; clSetq(L_instance983, stream); clSetq(L_class984, clClassOf(L_instance983, clEOA)); clSetq(L_output_buffer986, clFastFindSlot(L_class984, clOUTPUT_BUFFER)); clSetq(L_output_fd985, clFastFindSlot(L_class984, clOUTPUT_FD)); { clObject L_values987, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class984, L_instance983, L_output_buffer986, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values987, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values987, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values987); clSetq(L_0, clSetq(L_values987, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class984, L_instance983, L_output_fd985, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBeu8(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBEU16_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args992 = clMakeBinding(), *L_methods993 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args992, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods993, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form995, stream, n; clSetq(L_form995, *L_args992); if (clTrue(L_form995)) { clObject L_top996; clSetq(L_top996, clCar(L_form995, clEOA)); { clObject L_0; clSetq(L_0, L_form995); clSetq(L_form995, clCdr(L_0, clEOA)); } clSetq(stream, L_top996); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form995)) { clObject L_top997; { clObject L_0; clSetq(L_0, L_form995); clSetq(L_top997, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form995); clSetq(L_form995, clCdr(L_0, clEOA)); } clSetq(n, L_top997); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form995)) { clObject L_0; clSetq(L_0, L_form995); clExtraArgs(L_0, clEOA); } { clObject L_instance998, L_class999, L_output_buffer1001, L_output_fd1000; clSetq(L_instance998, stream); clSetq(L_class999, clClassOf(L_instance998, clEOA)); clSetq(L_output_buffer1001, clFastFindSlot(L_class999, clOUTPUT_BUFFER)); clSetq(L_output_fd1000, clFastFindSlot(L_class999, clOUTPUT_FD)); { clObject L_values1002, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class999, L_instance998, L_output_buffer1001, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1002, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1002, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1002); clSetq(L_0, clSetq(L_values1002, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class999, L_instance998, L_output_fd1000, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBeu16(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBEU32_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1007 = clMakeBinding(), *L_methods1008 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1007, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1008, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1010, stream, n; clSetq(L_form1010, *L_args1007); if (clTrue(L_form1010)) { clObject L_top1011; clSetq(L_top1011, clCar(L_form1010, clEOA)); { clObject L_0; clSetq(L_0, L_form1010); clSetq(L_form1010, clCdr(L_0, clEOA)); } clSetq(stream, L_top1011); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1010)) { clObject L_top1012; { clObject L_0; clSetq(L_0, L_form1010); clSetq(L_top1012, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1010); clSetq(L_form1010, clCdr(L_0, clEOA)); } clSetq(n, L_top1012); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1010)) { clObject L_0; clSetq(L_0, L_form1010); clExtraArgs(L_0, clEOA); } { clObject L_instance1013, L_class1014, L_output_buffer1016, L_output_fd1015; clSetq(L_instance1013, stream); clSetq(L_class1014, clClassOf(L_instance1013, clEOA)); clSetq(L_output_buffer1016, clFastFindSlot(L_class1014, clOUTPUT_BUFFER)); clSetq(L_output_fd1015, clFastFindSlot(L_class1014, clOUTPUT_FD)); { clObject L_values1017, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1014, L_instance1013, L_output_buffer1016, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1017, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1017, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1017); clSetq(L_0, clSetq(L_values1017, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1014, L_instance1013, L_output_fd1015, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBeu32(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLEU8_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1022 = clMakeBinding(), *L_methods1023 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1022, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1023, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1025, stream, n; clSetq(L_form1025, *L_args1022); if (clTrue(L_form1025)) { clObject L_top1026; clSetq(L_top1026, clCar(L_form1025, clEOA)); { clObject L_0; clSetq(L_0, L_form1025); clSetq(L_form1025, clCdr(L_0, clEOA)); } clSetq(stream, L_top1026); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1025)) { clObject L_top1027; { clObject L_0; clSetq(L_0, L_form1025); clSetq(L_top1027, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1025); clSetq(L_form1025, clCdr(L_0, clEOA)); } clSetq(n, L_top1027); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1025)) { clObject L_0; clSetq(L_0, L_form1025); clExtraArgs(L_0, clEOA); } { clObject L_instance1028, L_class1029, L_output_buffer1031, L_output_fd1030; clSetq(L_instance1028, stream); clSetq(L_class1029, clClassOf(L_instance1028, clEOA)); clSetq(L_output_buffer1031, clFastFindSlot(L_class1029, clOUTPUT_BUFFER)); clSetq(L_output_fd1030, clFastFindSlot(L_class1029, clOUTPUT_FD)); { clObject L_values1032, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1029, L_instance1028, L_output_buffer1031, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1032, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1032, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1032); clSetq(L_0, clSetq(L_values1032, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1029, L_instance1028, L_output_fd1030, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLeu8(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLEU16_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1037 = clMakeBinding(), *L_methods1038 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1037, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1038, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1040, stream, n; clSetq(L_form1040, *L_args1037); if (clTrue(L_form1040)) { clObject L_top1041; clSetq(L_top1041, clCar(L_form1040, clEOA)); { clObject L_0; clSetq(L_0, L_form1040); clSetq(L_form1040, clCdr(L_0, clEOA)); } clSetq(stream, L_top1041); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1040)) { clObject L_top1042; { clObject L_0; clSetq(L_0, L_form1040); clSetq(L_top1042, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1040); clSetq(L_form1040, clCdr(L_0, clEOA)); } clSetq(n, L_top1042); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1040)) { clObject L_0; clSetq(L_0, L_form1040); clExtraArgs(L_0, clEOA); } { clObject L_instance1043, L_class1044, L_output_buffer1046, L_output_fd1045; clSetq(L_instance1043, stream); clSetq(L_class1044, clClassOf(L_instance1043, clEOA)); clSetq(L_output_buffer1046, clFastFindSlot(L_class1044, clOUTPUT_BUFFER)); clSetq(L_output_fd1045, clFastFindSlot(L_class1044, clOUTPUT_FD)); { clObject L_values1047, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1044, L_instance1043, L_output_buffer1046, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1047, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1047, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1047); clSetq(L_0, clSetq(L_values1047, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1044, L_instance1043, L_output_fd1045, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLeu16(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLEU32_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1052 = clMakeBinding(), *L_methods1053 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1052, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1053, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1055, stream, n; clSetq(L_form1055, *L_args1052); if (clTrue(L_form1055)) { clObject L_top1056; clSetq(L_top1056, clCar(L_form1055, clEOA)); { clObject L_0; clSetq(L_0, L_form1055); clSetq(L_form1055, clCdr(L_0, clEOA)); } clSetq(stream, L_top1056); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1055)) { clObject L_top1057; { clObject L_0; clSetq(L_0, L_form1055); clSetq(L_top1057, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1055); clSetq(L_form1055, clCdr(L_0, clEOA)); } clSetq(n, L_top1057); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1055)) { clObject L_0; clSetq(L_0, L_form1055); clExtraArgs(L_0, clEOA); } { clObject L_instance1058, L_class1059, L_output_buffer1061, L_output_fd1060; clSetq(L_instance1058, stream); clSetq(L_class1059, clClassOf(L_instance1058, clEOA)); clSetq(L_output_buffer1061, clFastFindSlot(L_class1059, clOUTPUT_BUFFER)); clSetq(L_output_fd1060, clFastFindSlot(L_class1059, clOUTPUT_FD)); { clObject L_values1062, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1059, L_instance1058, L_output_buffer1061, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1062, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1062, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1062); clSetq(L_0, clSetq(L_values1062, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1059, L_instance1058, L_output_fd1060, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLeu32(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBES8_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1067 = clMakeBinding(), *L_methods1068 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1067, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1068, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1070, stream, n; clSetq(L_form1070, *L_args1067); if (clTrue(L_form1070)) { clObject L_top1071; clSetq(L_top1071, clCar(L_form1070, clEOA)); { clObject L_0; clSetq(L_0, L_form1070); clSetq(L_form1070, clCdr(L_0, clEOA)); } clSetq(stream, L_top1071); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1070)) { clObject L_top1072; { clObject L_0; clSetq(L_0, L_form1070); clSetq(L_top1072, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1070); clSetq(L_form1070, clCdr(L_0, clEOA)); } clSetq(n, L_top1072); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1070)) { clObject L_0; clSetq(L_0, L_form1070); clExtraArgs(L_0, clEOA); } { clObject L_instance1073, L_class1074, L_output_buffer1076, L_output_fd1075; clSetq(L_instance1073, stream); clSetq(L_class1074, clClassOf(L_instance1073, clEOA)); clSetq(L_output_buffer1076, clFastFindSlot(L_class1074, clOUTPUT_BUFFER)); clSetq(L_output_fd1075, clFastFindSlot(L_class1074, clOUTPUT_FD)); { clObject L_values1077, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1074, L_instance1073, L_output_buffer1076, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1077, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1077, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1077); clSetq(L_0, clSetq(L_values1077, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1074, L_instance1073, L_output_fd1075, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBes8(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBES16_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1082 = clMakeBinding(), *L_methods1083 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1082, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1083, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1085, stream, n; clSetq(L_form1085, *L_args1082); if (clTrue(L_form1085)) { clObject L_top1086; clSetq(L_top1086, clCar(L_form1085, clEOA)); { clObject L_0; clSetq(L_0, L_form1085); clSetq(L_form1085, clCdr(L_0, clEOA)); } clSetq(stream, L_top1086); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1085)) { clObject L_top1087; { clObject L_0; clSetq(L_0, L_form1085); clSetq(L_top1087, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1085); clSetq(L_form1085, clCdr(L_0, clEOA)); } clSetq(n, L_top1087); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1085)) { clObject L_0; clSetq(L_0, L_form1085); clExtraArgs(L_0, clEOA); } { clObject L_instance1088, L_class1089, L_output_buffer1091, L_output_fd1090; clSetq(L_instance1088, stream); clSetq(L_class1089, clClassOf(L_instance1088, clEOA)); clSetq(L_output_buffer1091, clFastFindSlot(L_class1089, clOUTPUT_BUFFER)); clSetq(L_output_fd1090, clFastFindSlot(L_class1089, clOUTPUT_FD)); { clObject L_values1092, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1089, L_instance1088, L_output_buffer1091, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1092, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1092, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1092); clSetq(L_0, clSetq(L_values1092, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1089, L_instance1088, L_output_fd1090, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBes16(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clBES32_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1097 = clMakeBinding(), *L_methods1098 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1097, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1098, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1100, stream, n; clSetq(L_form1100, *L_args1097); if (clTrue(L_form1100)) { clObject L_top1101; clSetq(L_top1101, clCar(L_form1100, clEOA)); { clObject L_0; clSetq(L_0, L_form1100); clSetq(L_form1100, clCdr(L_0, clEOA)); } clSetq(stream, L_top1101); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1100)) { clObject L_top1102; { clObject L_0; clSetq(L_0, L_form1100); clSetq(L_top1102, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1100); clSetq(L_form1100, clCdr(L_0, clEOA)); } clSetq(n, L_top1102); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1100)) { clObject L_0; clSetq(L_0, L_form1100); clExtraArgs(L_0, clEOA); } { clObject L_instance1103, L_class1104, L_output_buffer1106, L_output_fd1105; clSetq(L_instance1103, stream); clSetq(L_class1104, clClassOf(L_instance1103, clEOA)); clSetq(L_output_buffer1106, clFastFindSlot(L_class1104, clOUTPUT_BUFFER)); clSetq(L_output_fd1105, clFastFindSlot(L_class1104, clOUTPUT_FD)); { clObject L_values1107, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1104, L_instance1103, L_output_buffer1106, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1107, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1107, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1107); clSetq(L_0, clSetq(L_values1107, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1104, L_instance1103, L_output_fd1105, clEOA)); clSetq(L_3, n); return(clValues1(clWriteBes32(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLES8_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1112 = clMakeBinding(), *L_methods1113 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1112, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1113, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1115, stream, n; clSetq(L_form1115, *L_args1112); if (clTrue(L_form1115)) { clObject L_top1116; clSetq(L_top1116, clCar(L_form1115, clEOA)); { clObject L_0; clSetq(L_0, L_form1115); clSetq(L_form1115, clCdr(L_0, clEOA)); } clSetq(stream, L_top1116); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1115)) { clObject L_top1117; { clObject L_0; clSetq(L_0, L_form1115); clSetq(L_top1117, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1115); clSetq(L_form1115, clCdr(L_0, clEOA)); } clSetq(n, L_top1117); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1115)) { clObject L_0; clSetq(L_0, L_form1115); clExtraArgs(L_0, clEOA); } { clObject L_instance1118, L_class1119, L_output_buffer1121, L_output_fd1120; clSetq(L_instance1118, stream); clSetq(L_class1119, clClassOf(L_instance1118, clEOA)); clSetq(L_output_buffer1121, clFastFindSlot(L_class1119, clOUTPUT_BUFFER)); clSetq(L_output_fd1120, clFastFindSlot(L_class1119, clOUTPUT_FD)); { clObject L_values1122, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1119, L_instance1118, L_output_buffer1121, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1122, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1122, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1122); clSetq(L_0, clSetq(L_values1122, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1119, L_instance1118, L_output_fd1120, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLes8(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLES16_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1127 = clMakeBinding(), *L_methods1128 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1127, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1128, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1130, stream, n; clSetq(L_form1130, *L_args1127); if (clTrue(L_form1130)) { clObject L_top1131; clSetq(L_top1131, clCar(L_form1130, clEOA)); { clObject L_0; clSetq(L_0, L_form1130); clSetq(L_form1130, clCdr(L_0, clEOA)); } clSetq(stream, L_top1131); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1130)) { clObject L_top1132; { clObject L_0; clSetq(L_0, L_form1130); clSetq(L_top1132, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1130); clSetq(L_form1130, clCdr(L_0, clEOA)); } clSetq(n, L_top1132); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1130)) { clObject L_0; clSetq(L_0, L_form1130); clExtraArgs(L_0, clEOA); } { clObject L_instance1133, L_class1134, L_output_buffer1136, L_output_fd1135; clSetq(L_instance1133, stream); clSetq(L_class1134, clClassOf(L_instance1133, clEOA)); clSetq(L_output_buffer1136, clFastFindSlot(L_class1134, clOUTPUT_BUFFER)); clSetq(L_output_fd1135, clFastFindSlot(L_class1134, clOUTPUT_FD)); { clObject L_values1137, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1134, L_instance1133, L_output_buffer1136, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1137, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1137, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1137); clSetq(L_0, clSetq(L_values1137, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1134, L_instance1133, L_output_fd1135, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLes16(L_0, vector, offset, L_3))); } } } } } clObject clStreamWrite_clLES32_FILE_OUTPUT_STREAM_clT clVdecl(_ap) { clObject *L_args1142 = clMakeBinding(), *L_methods1143 = clMakeBinding(); { clBeginParse(_ap); clSetq(*L_args1142, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_1, clEOA))); clSetq(*L_methods1143, (_clVp(_ap) ? clVpop(_ap) : clMissingArgs(I_2, clEOA))); if (_clVp(_ap)) clExtraArgs(clVargs(_ap), clEOA); clEndParse(_ap); } { clObject L_form1145, stream, n; clSetq(L_form1145, *L_args1142); if (clTrue(L_form1145)) { clObject L_top1146; clSetq(L_top1146, clCar(L_form1145, clEOA)); { clObject L_0; clSetq(L_0, L_form1145); clSetq(L_form1145, clCdr(L_0, clEOA)); } clSetq(stream, L_top1146); } else clSetq(stream, clMissingArgs(I_1, clEOA)); if (clTrue(L_form1145)) { clObject L_top1147; { clObject L_0; clSetq(L_0, L_form1145); clSetq(L_top1147, clCar(L_0, clEOA)); } { clObject L_0; clSetq(L_0, L_form1145); clSetq(L_form1145, clCdr(L_0, clEOA)); } clSetq(n, L_top1147); } else clSetq(n, clMissingArgs(I_2, clEOA)); if (clTrue(L_form1145)) { clObject L_0; clSetq(L_0, L_form1145); clExtraArgs(L_0, clEOA); } { clObject L_instance1148, L_class1149, L_output_buffer1151, L_output_fd1150; clSetq(L_instance1148, stream); clSetq(L_class1149, clClassOf(L_instance1148, clEOA)); clSetq(L_output_buffer1151, clFastFindSlot(L_class1149, clOUTPUT_BUFFER)); clSetq(L_output_fd1150, clFastFindSlot(L_class1149, clOUTPUT_FD)); { clObject L_values1152, vector, offset; { clMultipleValueCall(MVC); clSetq(MVC, clSymbolFunctionValue(clLIST)); { clObject L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1149, L_instance1148, L_output_buffer1151, clEOA)); clGetSimpleVector(L_0, I_0, clEOA); } clAccumulateValues(MVC); clSetq(L_values1152, clMultipleValueFuncall(MVC)); } clSetq(vector, clCar(L_values1152, clEOA)); { clObject L_0; { clObject L_0__R1; clSetq(L_0__R1, L_values1152); clSetq(L_0, clSetq(L_values1152, clCdr(L_0__R1, clEOA))); } clSetq(offset, clCar(L_0, clEOA)); } { clObject L_3, L_0; clSetq(L_0, clFuncallFunction(clSymbolFunctionValue(clSLOT_VALUE_USING_CLASS), L_class1149, L_instance1148, L_output_fd1150, clEOA)); clSetq(L_3, n); return(clValues1(clWriteLes32(L_0, vector, offset, L_3))); } } } } } void clInitFileStream __P((void)) { clDbind(clstarPACKAGEstar); clDbind(clstarREADTABLEstar); clDbind(clstarLOAD_TRUENAMEstar); clDbind(clstarLOAD_PATHNAMEstar); clSetq(STR_DIRECT_SUPERCLASSES__0, clCharpSimpleBaseString("DIRECT-SUPERCLASSES")); clSetq(keyDIRECT_SUPERCLASSES, clMakeKeyword(STR_DIRECT_SUPERCLASSES__0, clEOA)); clSetq(CONS_0, clCons(clFUNDAMENTAL_STREAM, clNIL, clEOA)); clSetq(STR_DIRECT_SLOTS__1, clCharpSimpleBaseString("DIRECT-SLOTS")); clSetq(keyDIRECT_SLOTS, clMakeKeyword(STR_DIRECT_SLOTS__1, clEOA)); clSetq(STR_NAME__2, clCharpSimpleBaseString("NAME")); clSetq(keyNAME, clMakeKeyword(STR_NAME__2, clEOA)); clSetq(STR_INITFUNCTION__3, clCharpSimpleBaseString("INITFUNCTION")); clSetq(keyINITFUNCTION, clMakeKeyword(STR_INITFUNCTION__3, clEOA)); clSetq(STR_DEFAULT__4, clCharpSimpleBaseString("DEFAULT")); clSetq(keyDEFAULT, clMakeKeyword(STR_DEFAULT__4, clEOA)); clSetq(STR_INITARGS__5, clCharpSimpleBaseString("INITARGS")); clSetq(keyINITARGS, clMakeKeyword(STR_INITARGS__5, clEOA)); clSetq(STR_EXTERNAL_FORMAT__6, clCharpSimpleBaseString("EXTERNAL-FORMAT")); clSetq(keyEXTERNAL_FORMAT, clMakeKeyword(STR_EXTERNAL_FORMAT__6, clEOA)); clSetq(CONS_1, clCons(keyEXTERNAL_FORMAT, clNIL, clEOA)); clSetq(STR_INITFORM__7, clCharpSimpleBaseString("INITFORM")); clSetq(keyINITFORM, clMakeKeyword(STR_INITFORM__7, clEOA)); clSetq(STR_READERS__8, clCharpSimpleBaseString("READERS")); clSetq(keyREADERS, clMakeKeyword(STR_READERS__8, clEOA)); clSetq(CONS_2, clCons(clSTREAM_EXTERNAL_FORMAT, clNIL, clEOA)); clSetq(CONS_4, clCons(clEXTERNAL_STREAM, clNIL, clEOA)); clSetq(CONS_3, clCons(clBUFFERED_INPUT_STREAM, CONS_4, clEOA)); clSetq(CONS_5, clCons(clBUFFERED_OUTPUT_STREAM, CONS_4, clEOA)); clSetq(STR_QUALIFIERS__9, clCharpSimpleBaseString("QUALIFIERS")); clSetq(keyQUALIFIERS, clMakeKeyword(STR_QUALIFIERS__9, clEOA)); clSetq(STR_AFTER__10, clCharpSimpleBaseString("AFTER")); clSetq(keyAFTER, clMakeKeyword(STR_AFTER__10, clEOA)); clSetq(CONS_6, clCons(keyAFTER, clNIL, clEOA)); clSetq(STR_LAMBDA_LIST__11, clCharpSimpleBaseString("LAMBDA-LIST")); clSetq(keyLAMBDA_LIST, clMakeKeyword(STR_LAMBDA_LIST__11, clEOA)); clSetq(CONS_10, clCons(clIGNORE, clNIL, clEOA)); clSetq(CONS_9, clCons(clampersandREST, CONS_10, clEOA)); clSetq(CONS_8, clCons(clSLOTS, CONS_9, clEOA)); clSetq(CONS_7, clCons(clSTREAM, CONS_8, clEOA)); clSetq(STR_SPECIALIZERS__12, clCharpSimpleBaseString("SPECIALIZERS")); clSetq(keySPECIALIZERS, clMakeKeyword(STR_SPECIALIZERS__12, clEOA)); clSetq(STR_FUNCTION__13, clCharpSimpleBaseString("FUNCTION")); clSetq(keyFUNCTION, clMakeKeyword(STR_FUNCTION__13, clEOA)); clSetq(I_1, clIntFixnum(1)); clSetq(I_2, clIntFixnum(2)); clSetq(STR_ELEMENT_TYPE__14, clCharpSimpleBaseString("ELEMENT-TYPE")); clSetq(keyELEMENT_TYPE, clMakeKeyword(STR_ELEMENT_TYPE__14, clEOA)); clSetq(I_0, clIntFixnum(0)); clSetq(STR_DECLARATIONS__15, clCharpSimpleBaseString("DECLARATIONS")); clSetq(keyDECLARATIONS, clMakeKeyword(STR_DECLARATIONS__15, clEOA)); clSetq(CONS_12, clCons(clIGNORE, CONS_10, clEOA)); clSetq(CONS_11, clCons(CONS_12, clNIL, clEOA)); clSetq(STR_DOCUMENTATION__16, clCharpSimpleBaseString("DOCUMENTATION")); clSetq(keyDOCUMENTATION, clMakeKeyword(STR_DOCUMENTATION__16, clEOA)); clSetq(CONS_14, clCons(clN_ADDITIONAL_ITEMS, clNIL, clEOA)); clSetq(CONS_13, clCons(clSTREAM, CONS_14, clEOA)); clSetq(STR_BEFORE__17, clCharpSimpleBaseString("BEFORE")); clSetq(keyBEFORE, clMakeKeyword(STR_BEFORE__17, clEOA)); clSetq(CONS_15, clCons(keyBEFORE, clNIL, clEOA)); clSetq(CONS_16, clCons(clSTREAM, clNIL, clEOA)); clSetq(CONS_18, clCons(clBUFFERED_EXTERNAL_INPUT_STREAM, clNIL, clEOA)); clSetq(CONS_17, clCons(clBUFFERED_CHARACTER_INPUT_STREAM, CONS_18, clEOA)); clSetq(CONS_20, clCons(clBUFFERED_EXTERNAL_OUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_19, clCons(clBUFFERED_CHARACTER_OUTPUT_STREAM, CONS_20, clEOA)); clSetq(CONS_21, clCons(clBUFFER_LINE_COLUMN, clNIL, clEOA)); clSetq(STR_WRITERS__18, clCharpSimpleBaseString("WRITERS")); clSetq(keyWRITERS, clMakeKeyword(STR_WRITERS__18, clEOA)); clSetq(CONS_23, clCons(clSETF, CONS_21, clEOA)); clSetq(CONS_22, clCons(CONS_23, clNIL, clEOA)); clSetq(CONS_24, clCons(clBUFFERED_BINARY_INPUT_STREAM, CONS_18, clEOA)); clSetq(CONS_25, clCons(clBUFFERED_BINARY_OUTPUT_STREAM, CONS_20, clEOA)); clSetq(C_Newline, clIntCharacter('\n')); clSetq(STR_END__19, clCharpSimpleBaseString("END")); clSetq(keyEND, clMakeKeyword(STR_END__19, clEOA)); clSetq(STR_FROM_END__20, clCharpSimpleBaseString("FROM-END")); clSetq(keyFROM_END, clMakeKeyword(STR_FROM_END__20, clEOA)); clSetq(CONS_27, clCons(clSTREAM_START_LINE_P, clNIL, clEOA)); clSetq(CONS_26, clCons(clSETF, CONS_27, clEOA)); clSetq(CONS_28, clCons(clSTART_LINE_P, CONS_16, clEOA)); clSetq(CONS_29, clCons(clSETF, CONS_21, clEOA)); clSetq(STR_PATHNAME__21, clCharpSimpleBaseString("PATHNAME")); clSetq(keyPATHNAME, clMakeKeyword(STR_PATHNAME__21, clEOA)); clSetq(CONS_30, clCons(keyPATHNAME, clNIL, clEOA)); clSetq(CONS_32, clCons(clSTREAM_PATHNAME, clNIL, clEOA)); clSetq(CONS_31, clCons(clPATHNAME, CONS_32, clEOA)); clSetq(STR_TRUENAME__22, clCharpSimpleBaseString("TRUENAME")); clSetq(keyTRUENAME, clMakeKeyword(STR_TRUENAME__22, clEOA)); clSetq(CONS_33, clCons(keyTRUENAME, clNIL, clEOA)); clSetq(CONS_34, clCons(clSTREAM_TRUENAME, clNIL, clEOA)); clSetq(CONS_36, clCons(clINPUT_STREAM, clNIL, clEOA)); clSetq(CONS_35, clCons(clFILE_STREAM, CONS_36, clEOA)); clSetq(STR_INPUT_FD__23, clCharpSimpleBaseString("INPUT-FD")); clSetq(keyINPUT_FD, clMakeKeyword(STR_INPUT_FD__23, clEOA)); clSetq(CONS_37, clCons(keyINPUT_FD, clNIL, clEOA)); clSetq(CONS_38, clCons(clINPUT_FD, clNIL, clEOA)); clSetq(CONS_40, clCons(clOUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_39, clCons(clFILE_STREAM, CONS_40, clEOA)); clSetq(STR_OUTPUT_FD__24, clCharpSimpleBaseString("OUTPUT-FD")); clSetq(keyOUTPUT_FD, clMakeKeyword(STR_OUTPUT_FD__24, clEOA)); clSetq(CONS_41, clCons(keyOUTPUT_FD, clNIL, clEOA)); clSetq(CONS_42, clCons(clOUTPUT_FD, clNIL, clEOA)); clSetq(STR_RENAMED__25, clCharpSimpleBaseString("RENAMED")); clSetq(keyRENAMED, clMakeKeyword(STR_RENAMED__25, clEOA)); clSetq(CONS_43, clCons(keyRENAMED, clNIL, clEOA)); clSetq(STR_CLEANUP__26, clCharpSimpleBaseString("CLEANUP")); clSetq(keyCLEANUP, clMakeKeyword(STR_CLEANUP__26, clEOA)); clSetq(CONS_44, clCons(keyCLEANUP, clNIL, clEOA)); clSetq(CONS_46, clCons(clS, clNIL, clEOA)); clSetq(CONS_45, clCons(clOBJECT, CONS_46, clEOA)); clSetq(CONS_49, clCons(clABORT, clNIL, clEOA)); clSetq(CONS_48, clCons(clampersandKEY, CONS_49, clEOA)); clSetq(CONS_47, clCons(clSTREAM, CONS_48, clEOA)); clSetq(STR_ABORT__27, clCharpSimpleBaseString("ABORT")); clSetq(keyABORT, clMakeKeyword(STR_ABORT__27, clEOA)); clSetq(CONS_51, clCons(clIGNORE, CONS_49, clEOA)); clSetq(CONS_50, clCons(CONS_51, clNIL, clEOA)); clSetq(STR_EXPUNGE__28, clCharpSimpleBaseString("EXPUNGE")); clSetq(keyEXPUNGE, clMakeKeyword(STR_EXPUNGE__28, clEOA)); clSetq(STR_DELETE__29, clCharpSimpleBaseString("DELETE")); clSetq(keyDELETE, clMakeKeyword(STR_DELETE__29, clEOA)); clSetq(CONS_52, clCons(clFILE_STREAM, clNIL, clEOA)); clSetq(CONS_56, clCons(clFILE_INPUT_STREAM, clNIL, clEOA)); clSetq(CONS_55, clCons(clBUFFERED_EXTERNAL_INPUT_STREAM, CONS_56, clEOA)); clSetq(CONS_54, clCons(clFILLABLE_INPUT_STREAM, CONS_55, clEOA)); clSetq(CONS_53, clCons(clBUFFERED_FILE_STREAM, CONS_54, clEOA)); clSetq(CONS_59, clCons(clFILE_OUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_58, clCons(clBUFFERED_EXTERNAL_OUTPUT_STREAM, CONS_59, clEOA)); clSetq(CONS_57, clCons(clBUFFERED_FILE_STREAM, CONS_58, clEOA)); clSetq(CONS_66, clCons(clBIDIRECTIONAL_STREAM, clNIL, clEOA)); clSetq(CONS_65, clCons(clFILE_OUTPUT_STREAM, CONS_66, clEOA)); clSetq(CONS_64, clCons(clFILE_INPUT_STREAM, CONS_65, clEOA)); clSetq(CONS_63, clCons(clBUFFERED_EXTERNAL_OUTPUT_STREAM, CONS_64, clEOA)); clSetq(CONS_62, clCons(clBUFFERED_EXTERNAL_INPUT_STREAM, CONS_63, clEOA)); clSetq(CONS_61, clCons(clFILLABLE_INPUT_STREAM, CONS_62, clEOA)); clSetq(CONS_60, clCons(clBUFFERED_FILE_STREAM, CONS_61, clEOA)); clSetq(STR_START2__30, clCharpSimpleBaseString("START2")); clSetq(keySTART2, clMakeKeyword(STR_START2__30, clEOA)); clSetq(CONS_71, clCons(clT, clNIL, clEOA)); clSetq(CONS_70, clCons(clWAIT, CONS_71, clEOA)); clSetq(CONS_69, clCons(CONS_70, clNIL, clEOA)); clSetq(CONS_68, clCons(clampersandOPTIONAL, CONS_69, clEOA)); clSetq(CONS_67, clCons(clSTREAM, CONS_68, clEOA)); clSetq(CONS_73, clCons(clSLOT_VALUE_USING_CLASS, clNIL, clEOA)); clSetq(CONS_72, clCons(clSETF, CONS_73, clEOA)); clSetq(CONS_76, clCons(clBUFFERED_EXTERNAL_CHARACTER_INPUT_STREAM, clNIL, clEOA)); clSetq(CONS_75, clCons(clBUFFERED_FILE_INPUT_STREAM, CONS_76, clEOA)); clSetq(CONS_74, clCons(clFILLABLE_CHARACTER_INPUT_STREAM, CONS_75, clEOA)); clSetq(CONS_78, clCons(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_77, clCons(clBUFFERED_FILE_OUTPUT_STREAM, CONS_78, clEOA)); clSetq(CONS_84, clCons(clBUFFERED_FILE_BIDIRECTIONAL_STREAM, clNIL, clEOA)); clSetq(CONS_83, clCons(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, CONS_84, clEOA)); clSetq(CONS_82, clCons(clBUFFERED_EXTERNAL_CHARACTER_INPUT_STREAM, CONS_83, clEOA)); clSetq(CONS_81, clCons(clBUFFERED_FILE_OUTPUT_STREAM, CONS_82, clEOA)); clSetq(CONS_80, clCons(clBUFFERED_FILE_INPUT_STREAM, CONS_81, clEOA)); clSetq(CONS_79, clCons(clFILLABLE_CHARACTER_INPUT_STREAM, CONS_80, clEOA)); clSetq(CONS_86, clCons(clBUFFERED_EXTERNAL_BINARY_INPUT_STREAM, clNIL, clEOA)); clSetq(CONS_85, clCons(clBUFFERED_FILE_INPUT_STREAM, CONS_86, clEOA)); clSetq(CONS_88, clCons(clBUFFERED_EXTERNAL_BINARY_OUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_87, clCons(clBUFFERED_FILE_OUTPUT_STREAM, CONS_88, clEOA)); clSetq(STR_EOF__31, clCharpSimpleBaseString("EOF")); clSetq(keyEOF, clMakeKeyword(STR_EOF__31, clEOA)); clSetq(CONS_89, clCons(clFUNDAMENTAL_CHARACTER_STREAM, clNIL, clEOA)); clSetq(STR_ASCII__32, clCharpSimpleBaseString("ASCII")); clSetq(keyASCII, clMakeKeyword(STR_ASCII__32, clEOA)); clSetq(CONS_91, clCons(clBASE_CHAR, clNIL, clEOA)); clSetq(CONS_90, clCons(clQUOTE, CONS_91, clEOA)); clSetq(CONS_93, clCons(clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clNIL, clEOA)); clSetq(CONS_92, clCons(clASCII_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_95, clCons(clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM, clNIL, clEOA)); clSetq(CONS_94, clCons(clASCII_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_98, clCons(clBUFFERED_CHARACTER_FILE_BIDIRECTIONAL_STREAM, clNIL, clEOA)); clSetq(CONS_97, clCons(clASCII_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_96, clCons(clASCII_FILE_INPUT_STREAM, CONS_97, clEOA)); clSetq(STR_UCS__33, clCharpSimpleBaseString("UCS")); clSetq(keyUCS, clMakeKeyword(STR_UCS__33, clEOA)); clSetq(CONS_100, clCons(clUCS_2_CHAR, clNIL, clEOA)); clSetq(CONS_99, clCons(clQUOTE, CONS_100, clEOA)); clSetq(CONS_101, clCons(clUCS_2_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_102, clCons(clUCS_2_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_104, clCons(clUCS_2_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_103, clCons(clUCS_2_FILE_INPUT_STREAM, CONS_104, clEOA)); clSetq(CONS_106, clCons(clUNICODE_CHAR, clNIL, clEOA)); clSetq(CONS_105, clCons(clQUOTE, CONS_106, clEOA)); clSetq(CONS_107, clCons(clUCS_4_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_108, clCons(clUCS_4_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_110, clCons(clUCS_4_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_109, clCons(clUCS_4_FILE_INPUT_STREAM, CONS_110, clEOA)); clSetq(STR_MULTI_BYTE__34, clCharpSimpleBaseString("MULTI-BYTE")); clSetq(keyMULTI_BYTE, clMakeKeyword(STR_MULTI_BYTE__34, clEOA)); clSetq(STR_UCS_4_IO__35, clCharpSimpleBaseString("UCS-4-IO")); clSetq(keyUCS_4_IO, clMakeKeyword(STR_UCS_4_IO__35, clEOA)); clSetq(CONS_115, clCons(clstarFEATURESstar, clNIL, clEOA)); clSetq(CONS_114, clCons(keyUCS_4_IO, CONS_115, clEOA)); clSetq(CONS_113, clCons(clMEMBER, CONS_114, clEOA)); clSetq(CONS_117, clCons(CONS_99, clNIL, clEOA)); clSetq(CONS_116, clCons(CONS_105, CONS_117, clEOA)); clSetq(CONS_112, clCons(CONS_113, CONS_116, clEOA)); clSetq(CONS_111, clCons(clIF, CONS_112, clEOA)); clSetq(CONS_118, clCons(clMB_FILE_STREAM, CONS_93, clEOA)); clSetq(I_6, clIntFixnum(6)); clSetq(STR_FILL_POINTER__36, clCharpSimpleBaseString("FILL-POINTER")); clSetq(keyFILL_POINTER, clMakeKeyword(STR_FILL_POINTER__36, clEOA)); clSetq(CONS_124, clCons(I_0, clNIL, clEOA)); clSetq(CONS_123, clCons(keyFILL_POINTER, CONS_124, clEOA)); clSetq(CONS_122, clCons(CONS_90, CONS_123, clEOA)); clSetq(CONS_121, clCons(keyELEMENT_TYPE, CONS_122, clEOA)); clSetq(CONS_120, clCons(I_6, CONS_121, clEOA)); clSetq(CONS_119, clCons(clMAKE_ARRAY, CONS_120, clEOA)); clSetq(CONS_125, clCons(clMB_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_127, clCons(clMB_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_126, clCons(clMB_FILE_INPUT_STREAM, CONS_127, clEOA)); clSetq(STR_BIG_ENDIAN__37, clCharpSimpleBaseString("BIG-ENDIAN")); clSetq(keyBIG_ENDIAN, clMakeKeyword(STR_BIG_ENDIAN__37, clEOA)); clSetq(I_8, clIntFixnum(8)); clSetq(CONS_129, clCons(I_8, clNIL, clEOA)); clSetq(CONS_128, clCons(clUNSIGNED_BYTE, CONS_129, clEOA)); clSetq(CONS_131, clCons(CONS_128, clNIL, clEOA)); clSetq(CONS_130, clCons(clQUOTE, CONS_131, clEOA)); clSetq(CONS_132, clCons(clBEU8_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_133, clCons(clBEU8_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_135, clCons(clBEU8_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_134, clCons(clBEU8_FILE_INPUT_STREAM, CONS_135, clEOA)); clSetq(I_16, clIntFixnum(16)); clSetq(CONS_137, clCons(I_16, clNIL, clEOA)); clSetq(CONS_136, clCons(clUNSIGNED_BYTE, CONS_137, clEOA)); clSetq(CONS_139, clCons(CONS_136, clNIL, clEOA)); clSetq(CONS_138, clCons(clQUOTE, CONS_139, clEOA)); clSetq(CONS_140, clCons(clBEU16_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_141, clCons(clBEU16_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_143, clCons(clBEU16_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_142, clCons(clBEU16_FILE_INPUT_STREAM, CONS_143, clEOA)); clSetq(I_32, clIntFixnum(32)); clSetq(CONS_145, clCons(I_32, clNIL, clEOA)); clSetq(CONS_144, clCons(clUNSIGNED_BYTE, CONS_145, clEOA)); clSetq(CONS_147, clCons(CONS_144, clNIL, clEOA)); clSetq(CONS_146, clCons(clQUOTE, CONS_147, clEOA)); clSetq(CONS_148, clCons(clBEU32_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_149, clCons(clBEU32_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_151, clCons(clBEU32_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_150, clCons(clBEU32_FILE_INPUT_STREAM, CONS_151, clEOA)); clSetq(CONS_152, clCons(clSIGNED_BYTE, CONS_129, clEOA)); clSetq(CONS_154, clCons(CONS_152, clNIL, clEOA)); clSetq(CONS_153, clCons(clQUOTE, CONS_154, clEOA)); clSetq(CONS_155, clCons(clBES8_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_156, clCons(clBES8_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_158, clCons(clBES8_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_157, clCons(clBES8_FILE_INPUT_STREAM, CONS_158, clEOA)); clSetq(CONS_159, clCons(clSIGNED_BYTE, CONS_137, clEOA)); clSetq(CONS_161, clCons(CONS_159, clNIL, clEOA)); clSetq(CONS_160, clCons(clQUOTE, CONS_161, clEOA)); clSetq(CONS_162, clCons(clBES16_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_163, clCons(clBES16_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_165, clCons(clBES16_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_164, clCons(clBES16_FILE_INPUT_STREAM, CONS_165, clEOA)); clSetq(CONS_166, clCons(clSIGNED_BYTE, CONS_145, clEOA)); clSetq(CONS_168, clCons(CONS_166, clNIL, clEOA)); clSetq(CONS_167, clCons(clQUOTE, CONS_168, clEOA)); clSetq(CONS_169, clCons(clBES32_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_170, clCons(clBES32_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_172, clCons(clBES32_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_171, clCons(clBES32_FILE_INPUT_STREAM, CONS_172, clEOA)); clSetq(STR_LITTLE_ENDIAN__38, clCharpSimpleBaseString("LITTLE-ENDIAN")); clSetq(keyLITTLE_ENDIAN, clMakeKeyword(STR_LITTLE_ENDIAN__38, clEOA)); clSetq(CONS_173, clCons(clLEU8_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_174, clCons(clLEU8_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_176, clCons(clLEU8_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_175, clCons(clLEU8_FILE_INPUT_STREAM, CONS_176, clEOA)); clSetq(CONS_177, clCons(clLEU16_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_178, clCons(clLEU16_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_180, clCons(clLEU16_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_179, clCons(clLEU16_FILE_INPUT_STREAM, CONS_180, clEOA)); clSetq(CONS_181, clCons(clLEU32_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_182, clCons(clLEU32_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_184, clCons(clLEU32_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_183, clCons(clLEU32_FILE_INPUT_STREAM, CONS_184, clEOA)); clSetq(CONS_185, clCons(clLES8_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_186, clCons(clLES8_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_188, clCons(clLES8_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_187, clCons(clLES8_FILE_INPUT_STREAM, CONS_188, clEOA)); clSetq(CONS_189, clCons(clLES16_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_190, clCons(clLES16_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_192, clCons(clLES16_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_191, clCons(clLES16_FILE_INPUT_STREAM, CONS_192, clEOA)); clSetq(CONS_193, clCons(clLES32_FILE_STREAM, CONS_93, clEOA)); clSetq(CONS_194, clCons(clLES32_FILE_STREAM, CONS_95, clEOA)); clSetq(CONS_196, clCons(clLES32_FILE_OUTPUT_STREAM, CONS_98, clEOA)); clSetq(CONS_195, clCons(clLES32_FILE_INPUT_STREAM, CONS_196, clEOA)); clSetq(CONS_198, clCons(clN, clNIL, clEOA)); clSetq(CONS_197, clCons(clSTREAM, CONS_198, clEOA)); { clObject L_4; { clObject L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITARGS, CONS_1, keyINITFORM, keyDEFAULT, keyREADERS, CONS_2, clEOA)); } clSetq(L_4, clList(L_0__R1, clEOA)); } clEnsureClass(clEXTERNAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_0, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBUFFERED_EXTERNAL_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_3, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_EXTERNAL_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_5, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSHARED_INITIALIZE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clSharedInitialize_keyAFTER_clBUFFERED_EXTERNAL_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_6, keyLAMBDA_LIST, CONS_7, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, CONS_11, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSHARED_INITIALIZE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clSharedInitialize_keyAFTER_clBUFFERED_EXTERNAL_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_6, keyLAMBDA_LIST, CONS_7, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, CONS_11, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clCHECK_BUFFER_SIZE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clCheckBufferSize_clBUFFERED_EXTERNAL_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_13, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_FINISH_OUTPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamFinishOutput_keyBEFORE_clBUFFERED_EXTERNAL_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } clEnsureClass(clBUFFERED_EXTERNAL_CHARACTER_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_17, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r1, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clBUFFER_LINE_COLUMN, keyINITFUNCTION, L_3__R1, keyINITFORM, I_0, keyREADERS, CONS_21, keyWRITERS, CONS_22, clEOA)); } clSetq(L_4, clList(L_0__R1, clEOA)); } clEnsureClass(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_19, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBUFFERED_EXTERNAL_BINARY_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_24, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_EXTERNAL_BINARY_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_25, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_TERPRI, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamTerpri_keyAFTER_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_6, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_LINE_COLUMN, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamLineColumn_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(CONS_26, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clT, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, cl_SETF_StreamStartLineP_clT_clBUFFERED_EXTERNAL_CHARACTER_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_28, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_4; { clObject L_0__R1; clSetq(L_0__R1, clList(keyNAME, clPATHNAME, keyINITARGS, CONS_30, keyREADERS, CONS_31, clEOA)); clSetq(L_4, clList(L_0__R1, clList(keyNAME, clTRUENAME, keyINITARGS, CONS_33, keyREADERS, CONS_34, clEOA), clEOA)); } clEnsureClass(clFILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_4, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clFILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_35, keyDIRECT_SLOTS, clList(clList(keyNAME, clINPUT_FD, keyINITARGS, CONS_37, keyREADERS, CONS_38, clEOA), clEOA), clEOA); { clObject L_4; { clObject L_2__R1, L_1__R1, L_0__R1; clSetq(L_0__R1, clList(keyNAME, clOUTPUT_FD, keyINITARGS, CONS_41, keyREADERS, CONS_42, clEOA)); { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r2, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clRENAMED, keyINITFUNCTION, L_3__R1, keyINITARGS, CONS_43, keyINITFORM, clNIL, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r3, clNULL_HOOK)); clSetq(L_2__R1, clList(keyNAME, clCLEANUP, keyINITFUNCTION, L_3__R1, keyINITARGS, CONS_44, keyINITFORM, clNIL, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, L_2__R1, clEOA)); } clEnsureClass(clFILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_39, keyDIRECT_SLOTS, L_4, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clPRINT_OBJECT, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clFILE_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clPrintObject_clFILE_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_45, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clFILE_STREAM_DESCRIPTOR, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clFileStreamDescriptor_clFILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clFILE_STREAM_DESCRIPTOR, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clFileStreamDescriptor_clFILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clCLOSE, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clClose_keyBEFORE_clFILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_47, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clCLOSE, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clClose_keyAFTER_clFILE_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_6, keyLAMBDA_LIST, CONS_47, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, CONS_50, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clCLOSE, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clClose_keyAFTER_clFILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_6, keyLAMBDA_LIST, CONS_47, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_CLEAR_INPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamClearInput_keyBEFORE_clFILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_CLEAR_OUTPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamClearOutput_keyBEFORE_clFILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_FINISH_OUTPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clFILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamFinishOutput_clFILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } clEnsureClass(clBUFFERED_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_52, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_53, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_57, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_60, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_FORCE_OUTPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_FILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamForceOutput_clBUFFERED_FILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_FILL_INPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_FILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamFillInput_clBUFFERED_FILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_67, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } clEnsureClass(clBUFFERED_CHARACTER_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_74, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_77, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_CHARACTER_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_79, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_BINARY_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_85, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBUFFERED_BINARY_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_87, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ_CHAR, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamReadChar_keyBEFORE_clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_PEEK_CHAR, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamPeekChar_keyBEFORE_clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, CONS_15, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ_CHAR_NO_HANG, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamReadCharNoHang_clBUFFERED_CHARACTER_FILE_INPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_FORCE_OUTPUT, clEOA)); clSetq(L_6, clList(clCanonicalizeSpecializer(clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM, clEOA), clEOA)); clSetq(L_8, clMakeClosure(0, clStreamForceOutput_clBUFFERED_CHARACTER_FILE_OUTPUT_STREAM, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_16, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r4, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyASCII, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r5, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_90, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clASCII_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clASCII_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_92, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clASCII_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_94, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clASCII_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_96, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r6, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyUCS, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r7, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_99, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clUCS_2_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clUCS_2_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_101, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clUCS_2_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_102, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clUCS_2_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_103, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r8, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyUCS, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r9, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_105, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clUCS_4_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clUCS_4_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_107, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clUCS_4_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_108, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clUCS_4_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_109, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r10, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyMULTI_BYTE, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r11, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_111, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clMB_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } { clObject L_4; { clObject L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r12, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clAUX, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_119, clEOA)); } clSetq(L_4, clList(L_0__R1, clEOA)); } clEnsureClass(clMB_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_118, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clMB_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_125, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clMB_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_126, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r13, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r14, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_130, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBEU8_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBEU8_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_132, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU8_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_133, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU8_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_134, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r15, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r16, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_138, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBEU16_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBEU16_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_140, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU16_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_141, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU16_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_142, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r17, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r18, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_146, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBEU32_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBEU32_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_148, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU32_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_149, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBEU32_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_150, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r19, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r20, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_153, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBES8_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBES8_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_155, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES8_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_156, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES8_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_157, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r21, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r22, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_160, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBES16_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBES16_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_162, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES16_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_163, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES16_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_164, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r23, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyBIG_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r24, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_167, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clBES32_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clBES32_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_169, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES32_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_170, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clBES32_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_171, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r25, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r26, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_130, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLEU8_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLEU8_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_173, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU8_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_174, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU8_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_175, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r27, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r28, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_138, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLEU16_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLEU16_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_177, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU16_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_178, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU16_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_179, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r29, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r30, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_146, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLEU32_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLEU32_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_181, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU32_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_182, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLEU32_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_183, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r31, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r32, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_153, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLES8_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLES8_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_185, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES8_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_186, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES8_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_187, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r33, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r34, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_160, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLES16_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLES16_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_189, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES16_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_190, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES16_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_191, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_4; { clObject L_1__R1, L_0__R1; { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r35, clNULL_HOOK)); clSetq(L_0__R1, clList(keyNAME, clEXTERNAL_FORMAT, keyINITFUNCTION, L_3__R1, keyINITFORM, keyLITTLE_ENDIAN, clEOA)); } { clObject L_3__R1; clSetq(L_3__R1, clMakeClosure(0, clLambda_r36, clNULL_HOOK)); clSetq(L_1__R1, clList(keyNAME, clELEMENT_TYPE, keyINITFUNCTION, L_3__R1, keyINITFORM, CONS_167, clEOA)); } clSetq(L_4, clList(L_0__R1, L_1__R1, clEOA)); } clEnsureClass(clLES32_FILE_STREAM, keyDIRECT_SUPERCLASSES, CONS_89, keyDIRECT_SLOTS, L_4, clEOA); } clEnsureClass(clLES32_FILE_INPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_193, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES32_FILE_OUTPUT_STREAM, keyDIRECT_SUPERCLASSES, CONS_194, keyDIRECT_SLOTS, clList(clEOA), clEOA); clEnsureClass(clLES32_FILE_BIDIRECTIONAL_STREAM, keyDIRECT_SUPERCLASSES, CONS_195, keyDIRECT_SLOTS, clList(clEOA), clEOA); { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clASCII_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clASCII_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clUCS_2_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clUCS_2_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clUCS_4_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clUCS_4_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clMB_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clMB_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU8_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBEU8_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU16_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBEU16_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU32_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBEU32_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU8_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLEU8_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU16_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLEU16_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU32_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLEU32_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES8_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBES8_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES16_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBES16_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES32_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clBES32_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES8_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLES8_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES16_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLES16_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_READ, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES32_FILE_INPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamRead_clLES32_FILE_INPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clASCII_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clASCII_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clUCS_2_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clUCS_2_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clUCS_4_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clUCS_4_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clMB_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clMB_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU8_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBEU8_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU16_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBEU16_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBEU32_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBEU32_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU8_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLEU8_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU16_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLEU16_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLEU32_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLEU32_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES8_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBES8_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES16_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBES16_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clBES32_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clBES32_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES8_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLES8_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES16_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLES16_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } { clObject L_8, L_6, L_0; clSetq(L_0, clEnsureGenericFunction(clSTREAM_WRITE, clEOA)); { clObject L_0__R1; clSetq(L_0__R1, clCanonicalizeSpecializer(clLES32_FILE_OUTPUT_STREAM, clEOA)); clSetq(L_6, clList(L_0__R1, clCanonicalizeSpecializer(clT, clEOA), clEOA)); } clSetq(L_8, clMakeClosure(0, clStreamWrite_clLES32_FILE_OUTPUT_STREAM_clT, clNULL_HOOK)); clEnsureMethod(L_0, keyQUALIFIERS, clNIL, keyLAMBDA_LIST, CONS_197, keySPECIALIZERS, L_6, keyFUNCTION, L_8, keyDECLARATIONS, clNIL, keyDOCUMENTATION, clNIL, clEOA); } clUnwind(4); }
43.047944
110
0.580309
[ "object", "vector" ]
ba9feb59ce7f3e54fb77d50dce4d24bf6a9783c1
4,138
c
C
ext/libtom/ltm_common.c
copiousfreetime/ruby-libtommath
0ccf788777c2c5bc72eb9c77cd8f3fb7a326a9c6
[ "BSD-3-Clause" ]
1
2016-05-08T09:56:15.000Z
2016-05-08T09:56:15.000Z
ext/libtom/ltm_common.c
copiousfreetime/ruby-libtommath
0ccf788777c2c5bc72eb9c77cd8f3fb7a326a9c6
[ "BSD-3-Clause" ]
2
2015-09-13T17:53:55.000Z
2015-09-13T17:53:55.000Z
ext/libtom/ltm_common.c
copiousfreetime/ruby-libtommath
0ccf788777c2c5bc72eb9c77cd8f3fb7a326a9c6
[ "BSD-3-Clause" ]
1
2018-10-10T03:43:06.000Z
2018-10-10T03:43:06.000Z
#include "ltm.h" /********************************************************************** * Internally used functions * **********************************************************************/ #if LTM_DEBUG /* * This is only used in debugging. The memory allocated by this * method must be free()'d by the caller. */ char * mp_int_to_s(mp_int *a) { int mp_size,mp_result; char *mp_str; if (MP_OKAY != (mp_result = mp_radix_size(a,10,&mp_size))) { rb_raise(eLT_M_Error, "%s", mp_error_to_string(mp_result)); } mp_str = ALLOC_N(char,mp_size); if (MP_OKAY != (mp_result = mp_toradix(a,mp_str,10))) { rb_raise(eLT_M_Error, "%s", mp_error_to_string(mp_result)); } return mp_str; } #endif /* * extract mp_int from any number, includes conversion to a temporary * Bignum if necessary. */ mp_int* num_to_mp_int(VALUE i) { mp_int* result; if (IS_LTM_BIGNUM(i)) { result = MP_INT(i); } else { switch (TYPE(i)) { case T_FIXNUM: case T_BIGNUM: case T_FLOAT: result = MP_INT(NEW_LTM_BIGNUM_FROM(i)); break; default: rb_raise(rb_eTypeError, "unable to convert %s to a Bignum", rb_obj_classname(i)); break; } } return result; } /* * See if the given Value has the integer value 2 */ VALUE is_2(VALUE obj) { mp_int *a = NULL; int val = -1; int digit_count = 0; switch (TYPE(obj)) { case T_FIXNUM: val = FIX2INT(obj); break; case T_FLOAT: val = NUM2INT(obj); break; case T_BIGNUM: if ((RBIGNUM(obj)->len == 1)) { val = NUM2INT(obj); } break; case T_DATA: if (IS_LTM_BIGNUM(obj)) { a = MP_INT(obj); if (MP_OKAY == mp_radix_size(a,10,&digit_count)) { /* digit count is the number of digits + space for the * '\0' in the string. Normally mp_radix_size is used * to allocate space for a string to hold the number */ if (2 == digit_count) { val = (int)mp_get_int(a); if (SIGN(a) == MP_NEG) { val = -val; } } } } break; default: /* nothing to do here, if it is not numeric then it we return * false * */ break; } return (2 == val) ? Qtrue : Qfalse; } /* * Convert a VALUE into the internal struct we use for libtommmath */ mp_int* value_to_mp_int(VALUE obj) { mp_int* bn; if (IS_LTM_BIGNUM(obj)) { Data_Get_Struct(obj,mp_int,bn); } else { rb_raise(rb_eTypeError,"not a Bignum"); } return bn; } /* * random_prime callback. Uses the ruby rand method to fill a buffer of * length N with bytes and return the buffer */ int ltm_bignum_random_prime_callback(unsigned char *buf, int len, void *dat) { int i ; VALUE max = INT2NUM(256); VALUE num; for (i = 0 ; i < len ; i++) { num = rb_funcall(rb_mKernel,rb_intern("rand"),1,max); buf[i] = 0xff & (NUM2INT(num)); } return i; } /********************************************************************** * Ruby Object life-cycle methods * **********************************************************************/ /* * garbage collector free method for mp_int structures */ static void ltm_bignum_free(mp_int *bn) { mp_clear(bn); free(bn); return ; } /* * Allocator for mp_int structures */ VALUE ltm_bignum_alloc(VALUE klass) { mp_int *bn = ALLOC(mp_int); VALUE obj = (VALUE)NULL; int mp_result = MP_OKAY; if (MP_OKAY == (mp_result = mp_init(bn))) { obj = Data_Wrap_Struct(klass,NULL,ltm_bignum_free,bn); } else { rb_raise(eLT_M_Error, "Failure to allocate Bignum: %s", mp_error_to_string(mp_result)); } return obj; }
24.341176
95
0.499033
[ "object" ]
baa069b9fd0a3ae201ccf6062f37670371d1fddd
1,391
h
C
include/accelerators/accelerator.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
3
2018-02-14T23:24:45.000Z
2022-03-30T18:48:06.000Z
include/accelerators/accelerator.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
null
null
null
include/accelerators/accelerator.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
null
null
null
#ifndef _ACCELERATOR_H_ #define _ACCELERATOR_H_ #include <hthread.h> #include <config.h> #include <httype.h> #include "xaxicdma.h" #define NUM_ACCELERATORS (5) #define PR_OVERHEAD (1000.0f) #define HW_SW_THRESHOLD (15.0f) #define BRAM_SIZE (4096) #define BRAM_GRANULARITY_SIZE (64) #define PR_FLAG (0x1) // -------------------------------------------------------------- // // Accelerator Enumeration // // -------------------------------------------------------------- // #define NO_ACC -1 #define CRC 0 #define BUBBLESORT 1 #define VECTORADD 2 #define VECTORSUB 2 #define VECTORMUL 3 #define VECTORDIV 3 #define MATRIXMUL 4 // -------------------------------------------------------------- // // Accelerator Header Files // // -------------------------------------------------------------- // #include <sort.h> #include <crc.h> #include <vector.h> #include <matrix.h> // -------------------------------------------------------------- // // DMA Transfer Wrapper // // -------------------------------------------------------------- // extern int transfer_dma(void * src, void * des, Hint size); #endif
31.613636
68
0.371675
[ "vector" ]
baa4321f27f48368c98ba11cd27a3dda73945888
956
h
C
project/ScannercodeCheckSystem/showdatabaseform.h
happyrabbit456/Qt5_dev
1812df2f04d4b6d24eaf0195ae25d4c67d4f3da2
[ "MIT" ]
null
null
null
project/ScannercodeCheckSystem/showdatabaseform.h
happyrabbit456/Qt5_dev
1812df2f04d4b6d24eaf0195ae25d4c67d4f3da2
[ "MIT" ]
null
null
null
project/ScannercodeCheckSystem/showdatabaseform.h
happyrabbit456/Qt5_dev
1812df2f04d4b6d24eaf0195ae25d4c67d4f3da2
[ "MIT" ]
null
null
null
#ifndef SHOWDATABASEFORM_H #define SHOWDATABASEFORM_H #include <QWidget> #include <QTableView> #include <QTableWidget> #include <QStandardItemModel> #include <QtSql/QSqlDatabase> #include <QtSql/QSqlQuery> #include <QtSql/QSqlTableModel> #include <QtSql/QSqlError> #include <QSqlQueryModel> #include <QDebug> #include <QMessageBox> namespace Ui { class ShowDataBaseForm; } class ShowDataBaseForm : public QWidget { Q_OBJECT public: explicit ShowDataBaseForm(QWidget *parent = nullptr); ~ShowDataBaseForm(); private slots: void on_btnQueryData_clicked(); void on_btnExport_clicked(); private: void testTableView(); void initializeModel(QSqlQueryModel *model); void updateTableView(); void tableWidgetToExcel(QTableWidget *table,QString title); void tableViewToExcel(QTableView *tableView,QString title); private: Ui::ShowDataBaseForm *ui; QSqlQueryModel *m_model; }; #endif // SHOWDATABASEFORM_H
19.510204
63
0.757322
[ "model" ]
bac252a4e74750776d53a791e3fdb832ff8c15a3
1,421
h
C
Game X Engine/src/Camera/Camera.h
BlueLort/GameX-Engine
f705b39109b8bce48272e9b874c7acef096f8a4c
[ "MIT" ]
6
2019-10-13T23:27:00.000Z
2021-12-25T21:32:46.000Z
Game X Engine/src/Camera/Camera.h
BlueLort/GameX-Engine
f705b39109b8bce48272e9b874c7acef096f8a4c
[ "MIT" ]
null
null
null
Game X Engine/src/Camera/Camera.h
BlueLort/GameX-Engine
f705b39109b8bce48272e9b874c7acef096f8a4c
[ "MIT" ]
null
null
null
#pragma once #include "Config.h" #include "Maths/GXTransform.h" #include "GX/GXTimer.h" #include "Input/InputManager.h" namespace gx { enum CameraMovement { FORWARD, BACKWARD, LEFT, RIGHT }; class GX_DLL Camera { public: Camera() : yaw(0.0f), pitch(0.0f), movementSpeed(30.0f), mouseSensitivity(5.0f), zoom(45.0f), cameraMoved(false){} GXTransform transform; // Euler Angles GXFloat yaw; GXFloat pitch; // Camera options GXFloat movementSpeed; GXFloat mouseSensitivity; GXFloat zoom; bool cameraMoved; // FOR LOD CONTROL virtual inline GXMat4 calculateViewMatrix() { return GXMaths::lookAt(transform.position, transform.position + transform.forward, transform.up); } virtual void processKeyboard(CameraMovement direction,float deltaTime) = 0; virtual void processMouseMovement(float xoffset, float yoffset, bool constrainPitch = true) = 0; virtual void processMouseScroll(float yoffset) = 0; virtual void update() = 0; protected: virtual void updateCameraVectors() { GXVec3 front; front.x = cos(GXRad(yaw)) * cos(GXRad(pitch)); front.y = sin(GXRad(pitch)); front.z = sin(GXRad(yaw)) * cos(GXRad(pitch)); transform.forward = GXMaths::normalize(front); transform.right = GXMaths::normalize(GXMaths::cross(transform.forward, transform.worldUp)); transform.up = GXMaths::normalize(GXMaths::cross(transform.right, transform.forward)); } }; }
28.42
116
0.719916
[ "transform" ]
bad506c21e0e1d71e3d640b5c81bc0cd1d5faa76
2,181
h
C
ios/chrome/browser/ui/tools_menu/public/tools_menu_configuration_provider.h
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
ios/chrome/browser/ui/tools_menu/public/tools_menu_configuration_provider.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
ios/chrome/browser/ui/tools_menu/public/tools_menu_configuration_provider.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_CHROME_BROWSER_UI_TOOLS_MENU_PUBLIC_TOOLS_MENU_CONFIGURATION_PROVIDER_H_ #define IOS_CHROME_BROWSER_UI_TOOLS_MENU_PUBLIC_TOOLS_MENU_CONFIGURATION_PROVIDER_H_ #import <Foundation/Foundation.h> @class ToolsMenuCoordinator, ToolsMenuConfiguration; // A protocol that describes a set of methods which may configure a // ToolsMenuCoordinator. Most of the configuration of the coordinator may be // achieved through the required ToolsMenuConfiguration object, but some // optional minor elements such as bookmark highlights are also independently // configurable. // TODO(crbug.com/800266): Remove this protocol. @protocol ToolsMenuConfigurationProvider<NSObject> // Returns a ToolsMenuConfiguration object describing the desired configuration // of the tools menu. - (ToolsMenuConfiguration*)menuConfigurationForToolsMenuCoordinator: (ToolsMenuCoordinator*)coordinator; @optional // If implemented, may influence how the tools menu shows the bookmark // indicator in the tools UI. - (BOOL)shouldHighlightBookmarkButtonForToolsMenuCoordinator: (ToolsMenuCoordinator*)coordinator; // If implemented, may influence the presence of the find bar in the tools // UI. - (BOOL)shouldShowFindBarForToolsMenuCoordinator: (ToolsMenuCoordinator*)coordinator; // If implemented,may influence the presence of the share menu in the tools // UI. - (BOOL)shouldShowShareMenuForToolsMenuCoordinator: (ToolsMenuCoordinator*)coordinator; // If implemented, may influence how the tools menu shows page-reload related // UI. - (BOOL)isTabLoadingForToolsMenuCoordinator:(ToolsMenuCoordinator*)coordinator; // If implemented, allows the delegate to be informed of an imminent // presentation of the tools menu. The delegate may choose to dismiss other // presented UI or otherwise configure itself for the menu presentation. - (void)prepareForToolsMenuPresentationByCoordinator: (ToolsMenuCoordinator*)coordinator; @end #endif // IOS_CHROME_BROWSER_UI_TOOLS_MENU_PUBLIC_TOOLS_MENU_CONFIGURATION_PROVIDER_H_
46.404255
87
0.821183
[ "object" ]
badcd36a7e4ac97f6ff48be5e4665212dcbdc1a5
1,794
c
C
src/interpreter/tests/SAFETY/Learning_vs_Refinement/l1.c
tracer-x/tracer
c91fa7dae8f4fd92f9cefa842e2d2a4e67c95a19
[ "RSA-MD" ]
21
2016-08-20T16:44:01.000Z
2019-10-08T12:16:55.000Z
src/interpreter/tests/SAFETY/Learning_vs_Refinement/l1.c
tracer-x/TRACER
c91fa7dae8f4fd92f9cefa842e2d2a4e67c95a19
[ "RSA-MD" ]
1
2020-06-16T03:45:51.000Z
2020-06-16T03:45:51.000Z
src/interpreter/tests/SAFETY/Learning_vs_Refinement/l1.c
tracer-x/tracer
c91fa7dae8f4fd92f9cefa842e2d2a4e67c95a19
[ "RSA-MD" ]
6
2016-11-27T04:07:40.000Z
2018-04-22T01:54:15.000Z
/* w/o -predH 7 Run statistics: Model checker stats: Nb iterations of outer while loop: 0 Nb iterations of reachability: 22840 Nb created nodes: 0 Nb refinment processes: 57 Nb refined nodes: 0 Nb proof tree nodes: 1287 Nb proof tree covered nodes: 431Nb deleted nodes: 0 Abstractor stats: Total number of non-post queries = 1 Total number of cached queries = 337578 Total number of queries = 394595 Worst-case number of post queries = 401420 Actual number of post queries = 401420 NonDC number of post queries = 12757 Assume post queries = 81336 Total posts = 8285 Total assume posts = 1880 Total foci queries = 340 Foci Theory Clauses: Num theory clauses: 0 List of predicates: Number of predicates =92 Maximum number of predicates active together (discounting scope) = 0 Timings: real 0m59.406s user 0m28.577s sys 0m18.081s */ /* BLAST with -predH 7 12 predicates 1.1s TRACER 49 states and 2 subsumed 0.06s */ int BLAST_NONDET; main() { int s; s=0; if (BLAST_NONDET) { s = s+1; } if (BLAST_NONDET) { s = s+2; } if (BLAST_NONDET) { s = s+4; } if (BLAST_NONDET) { s = s+8; } if (BLAST_NONDET) { s = s+16; } if (BLAST_NONDET) { s = s+32; } if (BLAST_NONDET) { s = s+64; } if (BLAST_NONDET) { s = s+128; } if (BLAST_NONDET) { s = s+256; } if (s>600) { s=0; if (BLAST_NONDET) { s = s+1; } if (BLAST_NONDET) { s = s+2; } if (BLAST_NONDET) { s = s+4; } if (BLAST_NONDET) { s = s+8; } if (BLAST_NONDET) { s = s+16; } if (BLAST_NONDET) { s = s+32; } if (BLAST_NONDET) { s = s+64; } if (BLAST_NONDET) { s = s+128; } if (BLAST_NONDET) { s = s+256; } // BLAST if (s>600) ERROR: goto ERROR; // TRACER _ABORT(s>600); } }
19.933333
70
0.614827
[ "model" ]
baf70d8f4e46f91c25222ee888bb1d48e54f6ed2
817
h
C
v8/src/heap/cppgc/heap.h
yourWaifu/v8-cmake
d3c05a7de2f679a1f986512a540331d00875a38a
[ "BSD-3-Clause" ]
1
2020-12-25T00:58:59.000Z
2020-12-25T00:58:59.000Z
v8/src/heap/cppgc/heap.h
yourWaifu/v8-cmake
d3c05a7de2f679a1f986512a540331d00875a38a
[ "BSD-3-Clause" ]
null
null
null
v8/src/heap/cppgc/heap.h
yourWaifu/v8-cmake
d3c05a7de2f679a1f986512a540331d00875a38a
[ "BSD-3-Clause" ]
1
2020-09-05T18:28:16.000Z
2020-09-05T18:28:16.000Z
// Copyright 2020 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_HEAP_CPPGC_HEAP_H_ #define V8_HEAP_CPPGC_HEAP_H_ #include <vector> #include "include/cppgc/gc-info.h" #include "include/cppgc/heap.h" #include "src/heap/cppgc/heap-object-header.h" namespace cppgc { namespace internal { class V8_EXPORT_PRIVATE Heap final : public cppgc::Heap { public: static Heap* From(cppgc::Heap* heap) { return static_cast<Heap*>(heap); } Heap() = default; ~Heap() final = default; inline void* Allocate(size_t size, GCInfoIndex index); void CollectGarbage(); private: std::vector<HeapObjectHeader*> objects_; }; } // namespace internal } // namespace cppgc #endif // V8_HEAP_CPPGC_HEAP_H_
22.694444
75
0.734394
[ "object", "vector" ]
baf98bdcb4fcc0a381883b6e73c60e351ad94903
655
h
C
yak/include/yak/mc/marching_cubes.h
DavidMerzJr/yak
0108d824f57058d5485df74d86a430336263534a
[ "MIT" ]
103
2019-07-19T07:57:09.000Z
2022-03-21T11:45:57.000Z
yak/include/yak/mc/marching_cubes.h
DavidMerzJr/yak
0108d824f57058d5485df74d86a430336263534a
[ "MIT" ]
55
2019-07-29T15:50:40.000Z
2021-09-23T17:43:27.000Z
yak/include/yak/mc/marching_cubes.h
DavidMerzJr/yak
0108d824f57058d5485df74d86a430336263534a
[ "MIT" ]
30
2019-07-24T01:17:33.000Z
2022-02-08T09:44:35.000Z
#ifndef YAK_MARCHING_CUBES_H #define YAK_MARCHING_CUBES_H #include <yak/kfusion/tsdf_container.h> #include <pcl/PolygonMesh.h> namespace yak { struct MarchingCubesParameters { // Scale factor applied to vertices. Usually equal to physical size of a single // voxel element. double scale{ 1.0 }; // Minimum weight of a voxel to not be dropped in the meshing process. int min_weight{ 4 }; // Clean the produced mesh by removing duplicate vertices, zero area triangles, etc. bool clean{ false }; }; pcl::PolygonMesh marchingCubesCPU(const yak::TSDFContainer& tsdf, const MarchingCubesParameters& params = {}); } // namespace yak #endif
24.259259
110
0.748092
[ "mesh" ]
24024e079dec296fd1fed0dad10d579068b17ba9
5,317
h
C
www/snapper/include/class/_pNetworkAdapter.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
4
2019-09-04T23:49:58.000Z
2020-08-05T05:46:49.000Z
www/snapper/include/class/_pNetworkAdapter.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
1
2019-09-24T20:42:29.000Z
2019-09-25T00:28:19.000Z
www/snapper/include/class/_pNetworkAdapter.h
lenovo/Snapper
4300739bbdf0b101c7ddd8be09c89f582bf47202
[ "BSD-3-Clause" ]
null
null
null
//--------------------------------------------------------------------- // <copyright file="_pNetworkAdapter.h" company="Lenovo"> // Copyright (c) 2018-present, Lenovo. All rights reserved. Licensed under BSD, see COPYING.BSD file for details. // </copyright> //--------------------------------------------------------------------- #pragma once #include "_pResource.h" #include "SnapperProvider.h" namespace snapper { namespace providers { class _pNetworkAdapter : public ResourceProvider { public: _pNetworkAdapter() : ResourceProvider("NetworkAdapter") { create_prop("Oem", nullptr); create_prop("Name", nullptr); create_prop("Description", nullptr); create_prop("Id", nullptr); create_prop("Actions", nullptr); create_prop("Assembly", nullptr); create_prop("Controllers", nullptr); create_prop("Manufacturer", nullptr); create_prop("Model", nullptr); create_prop("NetworkDeviceFunctions", nullptr); create_prop("NetworkPorts", nullptr); create_prop("PartNumber", nullptr); create_prop("SKU", nullptr); create_prop("SerialNumber", nullptr); create_prop("Status", nullptr); // direct GET request for following navigation properties should be handled in this provider prepare_navigation_property(); prepare_Links(); prepare_OemLenovo(); prepare_prop_class(); prep_prop_attrs(); set_namespace("NetworkAdapter.v1_1_0"); set_desc("A NetworkAdapter represents the physical network adapter capable of connecting to a computer network. Examples include but are not limited to Ethernet, Fibre Channel, and converged network adapters."); } virtual ~_pNetworkAdapter() {} void prepare_navigation_property() { add_navigation_contained_props("NetworkPorts"); add_navigation_contained_props("NetworkDeviceFunctions"); add_navigation_contained_props("Assembly"); } void prepare_Links() { } void prepare_OemLenovo() { } virtual void set_actions_obj() { create_prop( "Actions", std::make_shared<bson::BSONObj>(BSON("Actions" << BSON( "#NetworkAdapter.ResetSettingsToDefault" << BSON("target" << (get_base_odata_id() + "/Actions/NetworkAdapter.ResetSettingsToDefault") << "title" << "ResetSettingsToDefault") ) )) ); } void prepare_prop_class() { add_property_class("Actions", "Complex Type.", "Actions"); add_property_class("Assembly", "Navigation Type.Entity", "Assembly"); add_property_class("Controllers", "Collection Type.", "Controllers"); add_property_class("Manufacturer", "Primitive Type.", "Edm.String"); add_property_class("Model", "Primitive Type.", "Edm.String"); add_property_class("NetworkDeviceFunctions", "Navigation Type.Entity", "NetworkDeviceFunctionCollection"); add_property_class("NetworkPorts", "Navigation Type.Entity", "NetworkPortCollection"); add_property_class("PartNumber", "Primitive Type.", "Edm.String"); add_property_class("SKU", "Primitive Type.", "Edm.String"); add_property_class("SerialNumber", "Primitive Type.", "Edm.String"); add_property_class("Status", "Complex Type.", "Status"); } void prep_prop_attrs() { auto PartNumber_attr = std::make_shared<prop_attribute>(); PartNumber_attr->prop_name = "PartNumber"; PartNumber_attr->read_only = true; add_property_attr("PartNumber", PartNumber_attr); auto SerialNumber_attr = std::make_shared<prop_attribute>(); SerialNumber_attr->prop_name = "SerialNumber"; SerialNumber_attr->read_only = true; add_property_attr("SerialNumber", SerialNumber_attr); auto SKU_attr = std::make_shared<prop_attribute>(); SKU_attr->prop_name = "SKU"; SKU_attr->read_only = true; add_property_attr("SKU", SKU_attr); auto Model_attr = std::make_shared<prop_attribute>(); Model_attr->prop_name = "Model"; Model_attr->read_only = true; add_property_attr("Model", Model_attr); auto Manufacturer_attr = std::make_shared<prop_attribute>(); Manufacturer_attr->prop_name = "Manufacturer"; Manufacturer_attr->read_only = true; add_property_attr("Manufacturer", Manufacturer_attr); auto NetworkPorts_attr = std::make_shared<prop_attribute>(); NetworkPorts_attr->prop_name = "NetworkPorts"; NetworkPorts_attr->read_only = true; add_property_attr("NetworkPorts", NetworkPorts_attr); auto NetworkDeviceFunctions_attr = std::make_shared<prop_attribute>(); NetworkDeviceFunctions_attr->prop_name = "NetworkDeviceFunctions"; NetworkDeviceFunctions_attr->read_only = true; add_property_attr("NetworkDeviceFunctions", NetworkDeviceFunctions_attr); auto Assembly_attr = std::make_shared<prop_attribute>(); Assembly_attr->prop_name = "Assembly"; Assembly_attr->read_only = true; add_property_attr("Assembly", Assembly_attr); } }; }}
37.443662
220
0.639834
[ "model" ]
c911ef329042ab5d40502f47fb01e84b0f0dbf21
37,658
c
C
Kernels/ARM-Optimized/DSP/Source/TransformFunctions/arm_cfft_f16/arm_cfft_f16.c
mooc-ui/EndpointAI
d462da6f3ec0f7e5fb33f292e383569e20f30790
[ "Apache-2.0" ]
null
null
null
Kernels/ARM-Optimized/DSP/Source/TransformFunctions/arm_cfft_f16/arm_cfft_f16.c
mooc-ui/EndpointAI
d462da6f3ec0f7e5fb33f292e383569e20f30790
[ "Apache-2.0" ]
null
null
null
Kernels/ARM-Optimized/DSP/Source/TransformFunctions/arm_cfft_f16/arm_cfft_f16.c
mooc-ui/EndpointAI
d462da6f3ec0f7e5fb33f292e383569e20f30790
[ "Apache-2.0" ]
null
null
null
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_f16.c * Description: Combined Radix Decimation in Frequency CFFT floating point processing function * using Helium assembly kernels * This version allows boosting CFFT F16 performance when using compilers having suboptimal * Helium intrinsic code generation. * * $Date: Jan 2022 * $Revision: V1.0.1 * * Target Processor: Cortex-M with Helium * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2022 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "dsp/transform_functions_f16.h" #include "arm_common_tables_f16.h" #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE) #include "arm_helium_utils.h" #include "arm_vec_fft.h" #include "arm_mve_tables_f16.h" #ifdef USE_ASM /* * Floating point multiplication, 1st elt conjugated * Qd = Qn' * Qm */ #undef cmplx_fx_mul_r_ #undef cmplx_fx_mul_i_ #define cmplx_flt_mul_r_conj(qd, qn, qm) " vcmul.f16 " #qd "," #qn "," #qm ", #0 \n" #define cmplx_flt_mul_i_conj(qd, qn, qm) " vcmla.f16 " #qd "," #qn "," #qm ", #270 \n" /* * Floating point multiplication * Qd = Qn * Qm */ #undef cmplx_fx_mul_r_ #undef cmplx_fx_mul_i_ #define cmplx_flt_mul_r_(qd, qn, qm) " vcmul.f16 " #qd "," #qn "," #qm ", #0 \n" #define cmplx_flt_mul_i_(qd, qn, qm) " vcmla.f16 " #qd "," #qn "," #qm ", #90 \n" #define RAD2_BFLY_FLT16_MVE(conj) \ ".p2align 2 \n"\ " wls lr, %[count], 1f \n"\ "2: \n"\ /* low overhead loop start */ \ " vldrh.16 q0, [%[pIn0]] \n"\ " vldrh.16 q1, [%[pIn1]] \n"\ /* a0,a1 */ \ " vadd.f16 q2, q0, q1 \n"\ /* twiddle */ \ " vldrh.16 q7, [%[pCoef]], 16 \n"\ /* xt,yt */ \ " vsub.f16 q3, q0, q1 \n"\ cmplx_flt_mul_r_##conj(q4, q7, q3) \ " vstrw.32 q2, [%[pIn0]], 16 \n"\ cmplx_flt_mul_i_##conj(q4, q7, q3) \ " vstrw.32 q4, [%[pIn1]], 16 \n"\ /* low overhead loop end */ \ " le lr, 2b \n"\ "1: \n" static void arm_bitreversal_f16_inpl_mve_asm( uint16_t *pSrc, const uint16_t bitRevLen, const uint16_t *pBitRevTab) { __asm volatile( " vmov.i16 q0, #0x1 \n" /* load scheduling */ /* read 16-bit src/dst bit-reversal pairs */ " vldrh.u16 q5, [%[pBitRevTab]], #16 \n" /* expand source indexes (odd) */ " vmullb.u16 q2, q5, q0 \n" /* convert into complex pair index */ " vshr.u32 q2, q2, #3 \n" /* expand destination indexes (even) */ " vmullt.u16 q1, q5, q0 \n" /* convert into complex pair index */ " vshr.u32 q1, q1, #3 \n" /* core loop unrolled */ ".p2align 2 \n" " wls lr, %[bitRevLen], 1f \n" /* low overhead loop start */ "2: \n" " vldrh.u16 q5, [%[pBitRevTab]], #16 \n" " vmullb.u16 q6, q5, q0 \n" " vldrw.u32 q3, [%[pSrc], q2, uxtw #2] \n" " vshr.u32 q6, q6, #3 \n" " vldrw.u32 q4, [%[pSrc], q1, uxtw #2] \n" " vmullt.u16 q7, q5, q0 \n" " vstrw.32 q4, [%[pSrc], q2, uxtw #2] \n" " vshr.u32 q7, q7, #3 \n" " vstrw.32 q3, [%[pSrc], q1, uxtw #2] \n" " vldrh.u16 q5, [%[pBitRevTab]], #16 \n" " vmullb.u16 q2, q5, q0 \n" " vldrw.u32 q3, [%[pSrc], q6, uxtw #2] \n" " vshr.u32 q2, q2, #3 \n" " vldrw.u32 q4, [%[pSrc], q7, uxtw #2] \n" " vmullt.u16 q1, q5, q0 \n" " vstrw.32 q4, [%[pSrc], q6, uxtw #2] \n" " vshr.u32 q1, q1, #3 \n" " vstrw.32 q3, [%[pSrc], q7, uxtw #2] \n" /* low overhead loop end */ " le lr, 2b \n" "1: \n" /* tail */ " wlstp.16 lr, %[bitRevLenRem], 1f \n" "2: \n" " vldrw.u32 q3, [%[pSrc], q2, uxtw #2] \n" " vldrw.u32 q4, [%[pSrc], q1, uxtw #2] \n" " vstrw.32 q4, [%[pSrc], q2, uxtw #2] \n" " vstrw.32 q3, [%[pSrc], q1, uxtw #2] \n" " vldrh.u16 q1, [%[pBitRevTab]], #16 \n" " vmullb.u16 q2, q1, q0 \n" " vshr.u32 q2, q2, #3 \n" " vmullt.u16 q1, q1, q0 \n" " vshr.u32 q1, q1, #3 \n" " letp lr, 2b \n" "1: \n" : [pBitRevTab] "+r" (pBitRevTab) : [bitRevLen] "r" (bitRevLen/16), [bitRevLenRem] "r" (bitRevLen&0xf), [pSrc] "r" (pSrc) : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"); } #endif static float16_t arm_inverse_fft_length_f16(uint16_t fftLen) { float16_t retValue=1.0; switch (fftLen) { case 4096U: retValue = (float16_t)0.000244140625f; break; case 2048U: retValue = (float16_t)0.00048828125f; break; case 1024U: retValue = (float16_t)0.0009765625f; break; case 512U: retValue = (float16_t)0.001953125f; break; case 256U: retValue = (float16_t)0.00390625f; break; case 128U: retValue = (float16_t)0.0078125f; break; case 64U: retValue = (float16_t)0.015625f; break; case 32U: retValue = (float16_t)0.03125f; break; case 16U: retValue = (float16_t)0.0625f; break; default: break; } return(retValue); } static void _arm_radix4_butterfly_f16_mve(const arm_cfft_instance_f16 * S,float16_t * pSrc, uint32_t fftLen) { #ifndef USE_ASM f16x8_t vecTmp0, vecTmp1; f16x8_t vecSum0, vecDiff0, vecSum1, vecDiff1; f16x8_t vecA, vecB, vecC, vecD; f16x8_t vecW; uint32_t blkCnt; #endif uint32_t n1, n2; uint32_t stage = 0; int32_t iter = 1; static const int32_t strides[4] = { ( 0 - 16) * (int32_t)sizeof(float16_t *) , ( 4 - 16) * (int32_t)sizeof(float16_t *) , ( 8 - 16) * (int32_t)sizeof(float16_t *) , (12 - 16) * (int32_t)sizeof(float16_t *)}; n2 = fftLen; n1 = n2; n2 >>= 2u; for (int k = fftLen / 4u; k > 1; k >>= 2) { float16_t const *p_rearranged_twiddle_tab_stride1 = &S->rearranged_twiddle_stride1[ S->rearranged_twiddle_tab_stride1_arr[stage]]; float16_t const *p_rearranged_twiddle_tab_stride2 = &S->rearranged_twiddle_stride2[ S->rearranged_twiddle_tab_stride2_arr[stage]]; float16_t const *p_rearranged_twiddle_tab_stride3 = &S->rearranged_twiddle_stride3[ S->rearranged_twiddle_tab_stride3_arr[stage]]; float16_t * pBase = pSrc; #pragma nounroll for (int i = 0; i < iter; i++) { float16_t *inA = pBase; float16_t *inB = inA + n2 * CMPLX_DIM; float16_t *inC = inB + n2 * CMPLX_DIM; float16_t *inD = inC + n2 * CMPLX_DIM; float16_t const *pW1 = p_rearranged_twiddle_tab_stride1; float16_t const *pW2 = p_rearranged_twiddle_tab_stride2; float16_t const *pW3 = p_rearranged_twiddle_tab_stride3; #ifdef USE_ASM register unsigned count __asm("lr") = (n2 / 4); __asm volatile( ".p2align 2 \n" " wls lr, %[count], 1f \n" " vldrh.16 q1, [%[pSrcA0]] \n" " vldrh.16 q6, [%[pSrcA2]] \n" /* low overhead loop start */ "2: \n" /* = R(xa + xc), I(ya + yc) */ " vadd.f16 q0, q1, q6 \n" /* q4 = yb2, xb2, yb1, xb1 */ " vldrh.16 q4, [%[pSrcA1]] \n" /* = R(xa - xc), I(ya - yc) */ " vsub.f16 q2, q1, q6 \n" /* q5 = yd2, xd2, yd1, xd1 */ " vldrh.16 q5, [%[pSrcA3]] \n" /* = R(xb + xd), I(yb + yd) */ " vadd.f16 q1, q4, q5 \n" /* = R(xb - xd), I(yb - yd) */ " vsub.f16 q3, q4, q5 \n" /* xa' = (xa + xc) + (xb + xd) */ /* ya' = (ya + yc) + (yb + yd) */ " vadd.f16 q4, q0, q1 \n" " vstrh.16 q4, [%[pSrcA0]], #16 \n" /* xc' = (xa + xc) - (xb + xd) */ /* yc' = (ya + yc) - (yb + yd) */ " vsub.f16 q4, q0, q1 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t0]], #16 \n" /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ " vcmul.f16 q0, q5, q4, #0 \n" " vcmla.f16 q0, q5, q4, #270 \n" " vstrh.16 q0, [%[pSrcA1]], #16 \n" /* xb' = (xa - xc) + (yb - yd) */ /* yb' = (ya - yc) - (xb - xd) */ " vcadd.f16 q4, q2, q3, #270 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t1]], #16 \n" /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ " vcmul.f16 q0, q5, q4, #0 \n" " vldrh.16 q1, [%[pSrcA0]] \n" " vcmla.f16 q0, q5, q4, #270 \n" " vstrh.u16 q0, [%[pSrcA2]], #16 \n" /* xd' = (xa - xc) - (yb - yd) */ /* yd' = (ya - yc) + (xb - xd) */ " vcadd.f16 q4, q2, q3, #90 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t2]], #16 \n" /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (sa3) */ /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (sa3) */ " vcmul.f16 q0, q5, q4, #0 \n" " vldrh.16 q6, [%[pSrcA2]] \n" " vcmla.f16 q0, q5, q4, #270 \n" " vstrh.16 q0, [%[pSrcA3]], #16 \n" /* low overhead loop end */ " le lr, 2b \n" "1: \n" : [pSrcA0] "+r"(inA), [pSrcA1] "+r"(inB), [pSrcA2] "+r"(inC), [pSrcA3] "+r"(inD), [count] "+r" (count), [t0] "+r"(pW2) , [t1] "+r"(pW1), [t2] "+r"(pW3) : : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"); #else blkCnt = n2 / 4; /* * load 2 f16 complex pair */ vecA = vldrhq_f16(inA); vecC = vldrhq_f16(inC); while (blkCnt > 0U) { vecB = vldrhq_f16(inB); vecD = vldrhq_f16(inD); vecSum0 = vecA + vecC; /* vecSum0 = vaddq(vecA, vecC) */ vecDiff0 = vecA - vecC; /* vecSum0 = vsubq(vecA, vecC) */ vecSum1 = vecB + vecD; vecDiff1 = vecB - vecD; /* * [ 1 1 1 1 ] * [ A B C D ]' .* 1 */ vecTmp0 = vecSum0 + vecSum1; vst1q(inA, vecTmp0); inA += 8; /* * [ 1 -1 1 -1 ] * [ A B C D ]' */ vecTmp0 = vecSum0 - vecSum1; /* * [ 1 -1 1 -1 ] * [ A B C D ]'.* W2 */ vecW = vld1q(pW2); pW2 += 8; vecTmp1 = MVE_CMPLX_MULT_FLT_Conj_AxB(vecW, vecTmp0); vst1q(inB, vecTmp1); inB += 8; /* * [ 1 -i -1 +i ] * [ A B C D ]' */ vecTmp0 = MVE_CMPLX_SUB_A_ixB(vecDiff0, vecDiff1); /* * [ 1 -i -1 +i ] * [ A B C D ]'.* W1 */ vecW = vld1q(pW1); pW1 +=8; vecTmp1 = MVE_CMPLX_MULT_FLT_Conj_AxB(vecW, vecTmp0); vst1q(inC, vecTmp1); inC += 8; /* * [ 1 +i -1 -i ] * [ A B C D ]' */ vecTmp0 = MVE_CMPLX_ADD_A_ixB(vecDiff0, vecDiff1); /* * [ 1 +i -1 -i ] * [ A B C D ]'.* W3 */ vecW = vld1q(pW3); pW3 += 8; vecTmp1 = MVE_CMPLX_MULT_FLT_Conj_AxB(vecW, vecTmp0); vst1q(inD, vecTmp1); inD += 8; vecA = vldrhq_f16(inA); vecC = vldrhq_f16(inC); blkCnt--; } #endif pBase += CMPLX_DIM * n1; } n1 = n2; n2 >>= 2u; iter = iter << 2; stage++; } /* * start of Last stage process */ #ifdef USE_ASM __asm volatile( ".set incr, 16/4 \n" ".p2align 2 \n" " wls lr, %[count], 1f \n" " vldrw.32 q6, [%[strides]] \n" " vadd.u32 q6, q6, %[pout] \n" " vldrw.32 q7, [q6, #64]! \n" /* Read xc (real), yc(imag) input */ " vldrw.32 q5, [q6, #(2*incr)] \n" /* low overhead loop start */ "2: \n" /* = R(xa + xc), I(ya + yc) */ " vadd.f16 q0, q7, q5 \n" /* Read xb (real), yb(imag) input. */ " vldrw.32 q4, [q6, #(1*incr)] \n" /* = R(xa - xc), I(ya - yc) */ " vsub.f16 q1, q7, q5 \n" /* Read xc (real), yc(imag) input */ " vldrw.32 q5, [q6, #(3*incr)] \n" /* = R(xb + xd), I(yb + yd) */ " vadd.f16 q2, q4, q5 \n" " vldrw.32 q7, [q6, #64]! \n" /* = R(xb - xd), I(yb - yd) */ " vsub.f16 q3, q4, q5 \n" " vldrw.32 q5, [q6, #(2*incr)] \n" /* xa' = (xa + xc) + (xb + xd) */ /* ya' = (ya + yc) + (yb + yd) */ " vadd.f16 q4, q0, q2 \n" " vstrw.32 q4, [q6, #-64] \n" /* xa' = (xa + xc) - (xb + xd) */ /* ya' = (ya + yc) - (yb + yd) */ " vsub.f16 q4, q0, q2 \n" " vstrw.32 q4, [q6, #(-64 + incr)] \n" /* xb' = (xa - xc) + (yb - yd) */ /* yb' = (ya - yc) - (xb - xd) */ " vcadd.f16 q4, q1, q3, #270 \n" " vstrw.32 q4, [q6, #(-64 + 2*incr)] \n" /* xb' = (xa - xc) - (yb - yd) */ /* yb' = (ya - yc) + (xb - xd) */ " vcadd.f16 q4, q1, q3, #90 \n" " vstrw.32 q4, [q6, #(-64 + 3*incr)] \n" " le lr, 2b \n" /* low overhead loop end */ "1: \n" : [pout] "+r"(pSrc) : [count] "r"(fftLen >> 4), [strides] "r"(strides) : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory", "lr"); #else uint32x4_t vecScGathAddr = vld1q_u32((uint32_t*)strides); vecScGathAddr = vecScGathAddr + (uint32_t) pSrc; /* load scheduling */ vecA = (f16x8_t)vldrwq_gather_base_wb_f32(&vecScGathAddr, 64); vecC = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 8); blkCnt = (fftLen >> 4); while (blkCnt > 0U) { vecSum0 = vecA + vecC; /* vecSum0 = vaddq(vecA, vecC) */ vecDiff0 = vecA - vecC; /* vecSum0 = vsubq(vecA, vecC) */ vecB = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 4); vecD = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 12); vecSum1 = vecB + vecD; vecDiff1 = vecB - vecD; /* pre-load for next iteration */ vecA = (f16x8_t)vldrwq_gather_base_wb_f32(&vecScGathAddr, 64); vecC = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 8); vecTmp0 = vecSum0 + vecSum1; vstrwq_scatter_base_f32(vecScGathAddr, -64, (f32x4_t)vecTmp0); vecTmp0 = vecSum0 - vecSum1; vstrwq_scatter_base_f32(vecScGathAddr, -64 + 4, (f32x4_t)vecTmp0); vecTmp0 = MVE_CMPLX_SUB_A_ixB(vecDiff0, vecDiff1); vstrwq_scatter_base_f32(vecScGathAddr, -64 + 8, (f32x4_t)vecTmp0); vecTmp0 = MVE_CMPLX_ADD_A_ixB(vecDiff0, vecDiff1); vstrwq_scatter_base_f32(vecScGathAddr, -64 + 12, (f32x4_t)vecTmp0); blkCnt--; } #endif /* * End of last stage process */ } static void arm_cfft_radix4by2_f16_mve(const arm_cfft_instance_f16 * S, float16_t *pSrc, uint32_t fftLen) { float16_t const *pCoef = S->pTwiddle; float16_t *pIn0, *pIn1; uint32_t n2; #ifndef USE_ASM uint32_t blkCnt; f16x8_t vecIn0, vecIn1, vecSum, vecDiff; f16x8_t vecCmplxTmp, vecTw; #endif n2 = fftLen >> 1; pIn0 = pSrc; pIn1 = pSrc + fftLen; #ifdef USE_ASM __asm volatile(RAD2_BFLY_FLT16_MVE(conj) : [pIn0] "+r"(pIn0), [pIn1] "+r"(pIn1), [pCoef] "+r"(pCoef) : [count] "r"(n2 / 4) : "lr", "memory", "q0", "q1", "q2", "q3", "q4", "q7"); #else blkCnt = n2 / 4; while (blkCnt > 0U) { vecIn0 = *(f16x8_t *) pIn0; vecIn1 = *(f16x8_t *) pIn1; vecTw = vld1q(pCoef); pCoef += 8; vecSum = vaddq(vecIn0, vecIn1); vecDiff = vsubq(vecIn0, vecIn1); vecCmplxTmp = MVE_CMPLX_MULT_FLT_Conj_AxB(vecTw, vecDiff); vst1q(pIn0, vecSum); pIn0 += 8; vst1q(pIn1, vecCmplxTmp); pIn1 += 8; blkCnt--; } #endif _arm_radix4_butterfly_f16_mve(S, pSrc, n2); _arm_radix4_butterfly_f16_mve(S, pSrc + fftLen, n2); pIn0 = pSrc; } static void _arm_radix4_butterfly_inverse_f16_mve(const arm_cfft_instance_f16 * S,float16_t * pSrc, uint32_t fftLen, float16_t onebyfftLen) { #ifndef USE_ASM f16x8_t vecTmp0, vecTmp1; f16x8_t vecSum0, vecDiff0, vecSum1, vecDiff1; f16x8_t vecA, vecB, vecC, vecD; f16x8_t vecW; uint32_t blkCnt; #endif uint32_t n1, n2; uint32_t stage = 0; int32_t iter = 1; static const int32_t strides[4] = { ( 0 - 16) * (int32_t)sizeof(q31_t *), ( 4 - 16) * (int32_t)sizeof(q31_t *), ( 8 - 16) * (int32_t)sizeof(q31_t *), (12 - 16) * (int32_t)sizeof(q31_t *) }; n2 = fftLen; n1 = n2; n2 >>= 2u; for (int k = fftLen / 4; k > 1; k >>= 2) { float16_t const *p_rearranged_twiddle_tab_stride2 = &S->rearranged_twiddle_stride2[ S->rearranged_twiddle_tab_stride2_arr[stage]]; float16_t const *p_rearranged_twiddle_tab_stride3 = &S->rearranged_twiddle_stride3[ S->rearranged_twiddle_tab_stride3_arr[stage]]; float16_t const *p_rearranged_twiddle_tab_stride1 = &S->rearranged_twiddle_stride1[ S->rearranged_twiddle_tab_stride1_arr[stage]]; float16_t * pBase = pSrc; for (int i = 0; i < iter; i++) { float16_t *inA = pBase; float16_t *inB = inA + n2 * CMPLX_DIM; float16_t *inC = inB + n2 * CMPLX_DIM; float16_t *inD = inC + n2 * CMPLX_DIM; float16_t const *pW1 = p_rearranged_twiddle_tab_stride1; float16_t const *pW2 = p_rearranged_twiddle_tab_stride2; float16_t const *pW3 = p_rearranged_twiddle_tab_stride3; #ifdef USE_ASM register unsigned count __asm("lr") = (n2 / 4); __asm volatile( ".p2align 2 \n" " wls lr, %[count], 1f \n" " vldrh.16 q1, [%[pSrcA0]] \n" " vldrh.16 q6, [%[pSrcA2]] \n" /* low overhead loop start */ "2: \n" /* = R(xa + xc), I(ya + yc) */ " vadd.f16 q0, q1, q6 \n" /* q4 = yb2, xb2, yb1, xb1 */ " vldrh.16 q4, [%[pSrcA1]] \n" /* = R(xa - xc), I(ya - yc) */ " vsub.f16 q2, q1, q6 \n" /* q5 = yd2, xd2, yd1, xd1 */ " vldrh.16 q5, [%[pSrcA3]] \n" /* = R(xb + xd), I(yb + yd) */ " vadd.f16 q1, q4, q5 \n" /* = R(xb - xd), I(yb - yd) */ " vsub.f16 q3, q4, q5 \n" /* xa' = (xa + xc) + (xb + xd) */ /* ya' = (ya + yc) + (yb + yd) */ " vadd.f16 q4, q0, q1 \n" " vstrh.16 q4, [%[pSrcA0]], #16 \n" /* xc' = (xa + xc) - (xb + xd) */ /* yc' = (ya + yc) - (yb + yd) */ " vsub.f16 q4, q0, q1 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t0]], #16 \n" /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ " vcmul.f16 q0, q5, q4, #0 \n" " vcmla.f16 q0, q5, q4, #90 \n" " vstrh.16 q0, [%[pSrcA1]], #16 \n" /* xb' = (xa - xc) + (yb - yd) */ /* yb' = (ya - yc) - (xb - xd) */ " vcadd.f16 q4, q2, q3, #90 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t1]], #16 \n" /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ " vcmul.f16 q0, q5, q4, #0 \n" " vldrh.16 q1, [%[pSrcA0]] \n" " vcmla.f16 q0, q5, q4, #90 \n" " vstrh.16 q0, [%[pSrcA2]], #16 \n" /* xd' = (xa - xc) - (yb - yd) */ /* yd' = (ya - yc) + (xb - xd) */ " vcadd.f16 q4, q2, q3, #270 \n" /* load twiddle factors */ " vldrh.16 q5, [%[t2]], #16 \n" /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (sa3) */ /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (sa3) */ " vcmul.f16 q0, q5, q4, #0 \n" " vldrh.16 q6, [%[pSrcA2]] \n" " vcmla.f16 q0, q5, q4, #90 \n" " vstrh.16 q0, [%[pSrcA3]], #16 \n" /* low overhead loop end */ " le lr, 2b \n" "1: \n" : [pSrcA0] "+r"(inA), [pSrcA1] "+r"(inB), [pSrcA2] "+r"(inC), [pSrcA3] "+r"(inD), [count] "+r" (count), [t0] "+r"(pW2) , [t1] "+r"(pW1), [t2] "+r"(pW3) : : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"); #else blkCnt = n2 / 4; /* * load 2 f32 complex pair */ vecA = vldrhq_f16(inA); vecC = vldrhq_f16(inC); while (blkCnt > 0U) { vecB = vldrhq_f16(inB); vecD = vldrhq_f16(inD); vecSum0 = vecA + vecC; /* vecSum0 = vaddq(vecA, vecC) */ vecDiff0 = vecA - vecC; /* vecSum0 = vsubq(vecA, vecC) */ vecSum1 = vecB + vecD; vecDiff1 = vecB - vecD; /* * [ 1 1 1 1 ] * [ A B C D ]' .* 1 */ vecTmp0 = vecSum0 + vecSum1; vst1q(inA, vecTmp0); inA += 8; /* * [ 1 -1 1 -1 ] * [ A B C D ]' */ vecTmp0 = vecSum0 - vecSum1; /* * [ 1 -1 1 -1 ] * [ A B C D ]'.* W1 */ vecW = vld1q(pW2); pW2 += 8; vecTmp1 = MVE_CMPLX_MULT_FLT_AxB(vecW, vecTmp0); vst1q(inB, vecTmp1); inB += 8; /* * [ 1 -i -1 +i ] * [ A B C D ]' */ vecTmp0 = MVE_CMPLX_ADD_A_ixB(vecDiff0, vecDiff1); /* * [ 1 -i -1 +i ] * [ A B C D ]'.* W2 */ vecW = vld1q(pW1); pW1 += 8; vecTmp1 = MVE_CMPLX_MULT_FLT_AxB(vecW, vecTmp0); vst1q(inC, vecTmp1); inC += 8; /* * [ 1 +i -1 -i ] * [ A B C D ]' */ vecTmp0 = MVE_CMPLX_SUB_A_ixB(vecDiff0, vecDiff1); /* * [ 1 +i -1 -i ] * [ A B C D ]'.* W3 */ vecW = vld1q(pW3); pW3 += 8; vecTmp1 = MVE_CMPLX_MULT_FLT_AxB(vecW, vecTmp0); vst1q(inD, vecTmp1); inD += 8; vecA = vldrhq_f16(inA); vecC = vldrhq_f16(inC); blkCnt--; } #endif pBase += CMPLX_DIM * n1; } n1 = n2; n2 >>= 2u; iter = iter << 2; stage++; } /* * start of Last stage process */ #ifdef USE_ASM float16_t *in0 = pSrc; __asm volatile( ".set incr, 16/4 \n" ".p2align 2 \n" " wls lr, %[count], 1f \n" " vldrw.32 q6, [%[strides]] \n" " vadd.u32 q6, q6, %[pout] \n" " vldrw.32 q7, [q6, #64]! \n" /* Read xc (real), yc(imag) input */ " vldrw.32 q5, [q6, #(2*incr)] \n" /* low overhead loop start */ "2: \n" /* = R(xa + xc), I(ya + yc) */ " vadd.f16 q0, q7, q5 \n" /* Read xb (real), yb(imag) input. */ " vldrw.32 q4, [q6, #(1*incr)] \n" /* = R(xa - xc), I(ya - yc) */ " vsub.f16 q1, q7, q5 \n" /* Read xc (real), yc(imag) input */ " vldrw.32 q5, [q6, #(3*incr)] \n" /* = R(xb + xd), I(yb + yd) */ " vadd.f16 q2, q4, q5 \n" " vldrw.32 q7, [q6, #64]! \n" /* = R(xb - xd), I(yb - yd) */ " vsub.f16 q3, q4, q5 \n" " vldrw.32 q5, [q6, #(2*incr)] \n" /* xa' = (xa + xc) + (xb + xd) */ /* ya' = (ya + yc) + (yb + yd) */ " vadd.f16 q4, q0, q2 \n" " vmul.f16 q4, q4, %[scale] \n" " vstrw.32 q4, [q6, #-64] \n" /* xa' = (xa + xc) - (xb + xd) */ /* ya' = (ya + yc) - (yb + yd) */ " vsub.f16 q4, q0, q2 \n" " vmul.f16 q4, q4, %[scale] \n" " vstrw.32 q4, [q6, #(-64 + incr)] \n" /* xb' = (xa - xc) + (yb - yd) */ /* yb' = (ya - yc) - (xb - xd) */ " vcadd.f16 q4, q1, q3, #90 \n" " vmul.f16 q4, q4, %[scale] \n" " vstrw.32 q4, [q6, #(-64 + 2*incr)] \n" /* xb' = (xa - xc) - (yb - yd) */ /* yb' = (ya - yc) + (xb - xd) */ " vcadd.f16 q4, q1, q3, #270 \n" " vmul.f16 q4, q4, %[scale] \n" " vstrw.32 q4, [q6, #(-64 + 3*incr)] \n" /* low overhead loop end */ " le lr, 2b \n" "1: \n" : [pout] "+r"(in0) : [count] "r"(fftLen >> 4), [strides] "r"(strides), [scale] "r"(onebyfftLen) : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory", "lr"); #else uint32x4_t vecScGathAddr = vld1q_u32((uint32_t*)strides); vecScGathAddr = vecScGathAddr + (uint32_t) pSrc; /* * load scheduling */ vecA = (f16x8_t)vldrwq_gather_base_wb_f32(&vecScGathAddr, 64); vecC = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 8); blkCnt = (fftLen >> 4); while (blkCnt > 0U) { vecSum0 = vecA + vecC; /* vecSum0 = vaddq(vecA, vecC) */ vecDiff0 = vecA - vecC; /* vecSum0 = vsubq(vecA, vecC) */ vecB = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 4); vecD = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 12); vecSum1 = vecB + vecD; vecDiff1 = vecB - vecD; vecA = (f16x8_t)vldrwq_gather_base_wb_f32(&vecScGathAddr, 64); vecC = (f16x8_t)vldrwq_gather_base_f32(vecScGathAddr, 8); vecTmp0 = vecSum0 + vecSum1; vecTmp0 = vecTmp0 * onebyfftLen; vstrwq_scatter_base_f32(vecScGathAddr, -64, (f32x4_t)vecTmp0); vecTmp0 = vecSum0 - vecSum1; vecTmp0 = vecTmp0 * onebyfftLen; vstrwq_scatter_base_f32(vecScGathAddr, -64 + 4, (f32x4_t)vecTmp0); vecTmp0 = MVE_CMPLX_ADD_A_ixB(vecDiff0, vecDiff1); vecTmp0 = vecTmp0 * onebyfftLen; vstrwq_scatter_base_f32(vecScGathAddr, -64 + 8, (f32x4_t)vecTmp0); vecTmp0 = MVE_CMPLX_SUB_A_ixB(vecDiff0, vecDiff1); vecTmp0 = vecTmp0 * onebyfftLen; vstrwq_scatter_base_f32(vecScGathAddr, -64 + 12, (f32x4_t)vecTmp0); blkCnt--; } #endif /* * End of last stage process */ } static void arm_cfft_radix4by2_inverse_f16_mve(const arm_cfft_instance_f16 * S,float16_t *pSrc, uint32_t fftLen) { float16_t const *pCoef = S->pTwiddle; float16_t *pIn0, *pIn1; uint32_t n2; float16_t onebyfftLen = arm_inverse_fft_length_f16(fftLen); #ifndef USE_ASM uint32_t blkCnt; f16x8_t vecIn0, vecIn1, vecSum, vecDiff; f16x8_t vecCmplxTmp, vecTw; #endif n2 = fftLen >> 1; pIn0 = pSrc; pIn1 = pSrc + fftLen; #ifdef USE_ASM __asm volatile(RAD2_BFLY_FLT16_MVE(/*no conjugate*/) : [pIn0] "+r"(pIn0), [pIn1] "+r"(pIn1), [pCoef] "+r"(pCoef) : [count] "r"(n2 / 4) : "lr", "memory", "q0", "q1", "q2", "q3", "q4", "q7"); #else blkCnt = n2 / 4; while (blkCnt > 0U) { vecIn0 = *(f16x8_t *) pIn0; vecIn1 = *(f16x8_t *) pIn1; vecTw = vld1q(pCoef); pCoef += 8; vecSum = vaddq(vecIn0, vecIn1); vecDiff = vsubq(vecIn0, vecIn1); vecCmplxTmp = MVE_CMPLX_MULT_FLT_AxB(vecTw, vecDiff); vst1q(pIn0, vecSum); pIn0 += 8; vst1q(pIn1, vecCmplxTmp); pIn1 += 8; blkCnt--; } #endif _arm_radix4_butterfly_inverse_f16_mve(S, pSrc, n2, onebyfftLen); _arm_radix4_butterfly_inverse_f16_mve(S, pSrc + fftLen, n2, onebyfftLen); } /** @addtogroup ComplexFFT @{ */ /** @brief Processing function for the floating-point complex FFT. @param[in] S points to an instance of the floating-point CFFT structure @param[in,out] p1 points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform @param[in] bitReverseFlag flag that enables / disables bit reversal of output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return none */ void arm_cfft_f16_mve( const arm_cfft_instance_f16 * S, float16_t * pSrc, uint8_t ifftFlag, uint8_t bitReverseFlag) { uint32_t fftLen = S->fftLen; if (ifftFlag == 1U) { switch (fftLen) { case 16: case 64: case 256: case 1024: case 4096: _arm_radix4_butterfly_inverse_f16_mve(S, pSrc, fftLen, arm_inverse_fft_length_f16(S->fftLen)); break; case 32: case 128: case 512: case 2048: arm_cfft_radix4by2_inverse_f16_mve(S, pSrc, fftLen); break; } } else { switch (fftLen) { case 16: case 64: case 256: case 1024: case 4096: _arm_radix4_butterfly_f16_mve(S, pSrc, fftLen); break; case 32: case 128: case 512: case 2048: arm_cfft_radix4by2_f16_mve(S, pSrc, fftLen); break; } } if (bitReverseFlag) { #ifdef USE_ASM arm_bitreversal_f16_inpl_mve_asm((uint16_t*)pSrc, S->bitRevLength, S->pBitRevTable); #else arm_bitreversal_16_inpl_mve((uint16_t*)pSrc, S->bitRevLength, S->pBitRevTable); #endif } } #endif /** @} end of ComplexFFT group */
38.426531
139
0.39171
[ "transform" ]
c91e12467c15d484f56451ee6129c9038a2da83f
1,514
h
C
src/matching/matcher.h
imkaywu/open3DCV
33ef0507e565bce2ccff7409ff35a8970e6eed2d
[ "BSD-3-Clause" ]
37
2018-07-30T15:34:29.000Z
2022-01-10T22:50:39.000Z
src/matching/matcher.h
imkaywu/open3DCV
33ef0507e565bce2ccff7409ff35a8970e6eed2d
[ "BSD-3-Clause" ]
1
2020-10-09T17:51:42.000Z
2020-11-11T19:41:06.000Z
src/matching/matcher.h
imkaywu/open3DCV
33ef0507e565bce2ccff7409ff35a8970e6eed2d
[ "BSD-3-Clause" ]
14
2017-12-03T15:24:01.000Z
2021-09-16T02:13:31.000Z
#ifndef matcher_h_ #define matcher_h_ #include <fstream> #include "math/numeric.h" #include "keypoint/keypoint.h" #include "matching/matcher_param.h" #include "matching/dmatch.h" namespace open3DCV { class Matcher { public: Matcher() { }; Matcher(Matcher_Param r_matcher_param); virtual ~Matcher() { }; virtual void init_param(Matcher_Param r_matcher_param) = 0; virtual int match(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, std::vector<DMatch>& matches) = 0; virtual int match(const std::vector<Vecf>& desc1, const std::vector<Vecf>& desc2, std::vector<DMatch>& matches, float (*dist_metric)(const Vecf& desc1, const Vecf& desc2)) = 0; void matching_keys(const std::vector<Keypoint>& keys1, const std::vector<Keypoint>& keys2, std::vector<DMatch>& matches); protected: Matcher_Param matcher_param_; }; inline void Matcher::matching_keys(const std::vector<Keypoint>& keys1, const std::vector<Keypoint>& keys2, std::vector<DMatch>& matches) { for (int i = 0; i < matches.size(); ++i) { DMatch& match = matches[i]; std::pair<Vec2f, Vec2f>& match_pair = match.point_; const int ikey1 = match.ind_key_.first; const int ikey2 = match.ind_key_.second; match_pair.first = keys1[ikey1].coords(); match_pair.second = keys2[ikey2].coords(); } } } // namespace open3DCV #endif
33.644444
184
0.630119
[ "vector" ]
c922752ba577b72b38bcf0a7533dc5de8c1b21da
1,643
h
C
include/common/strongref.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
303
2016-06-20T01:07:44.000Z
2021-04-02T09:54:51.000Z
include/common/strongref.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
95
2017-09-26T19:17:58.000Z
2021-04-06T00:53:02.000Z
include/common/strongref.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
50
2017-07-14T06:06:46.000Z
2020-12-25T18:19:11.000Z
#pragma once enum Acquire { RETAIN, NORETAIN }; namespace love { template<typename T> class StrongReference { public: StrongReference() : object(nullptr) {} StrongReference(T* obj, Acquire acquire = Acquire::RETAIN) : object(obj) { if (this->object && acquire == Acquire::RETAIN) this->object->Retain(); } StrongReference(const StrongReference& other) : object(other.Get()) { if (this->object) this->object->Retain(); } StrongReference(StrongReference&& other) : object(other.object) { other.object = nullptr; } ~StrongReference() { if (this->object) this->object->Release(); } StrongReference& operator=(const StrongReference& other) { this->Set(other.Get()); return *this; } T* operator->() const { return this->object; } explicit operator bool() const { return this->object != nullptr; } operator T*() const { return this->object; } void Set(T* obj, Acquire acquire = Acquire::RETAIN) { if (obj && acquire == Acquire::RETAIN) obj->Retain(); if (this->object) this->object->Release(); this->object = obj; } T* Get() const { return this->object; } private: T* object; }; } // namespace love
20.036585
80
0.465612
[ "object" ]
c926277dc896c00877e6fe7d3dcade5f7308f4b2
6,225
h
C
rpg_svo/svo/include/svo/frame.h
vatanaksoytezer/zephyr
3880dbdb62ec7908d4eed1bc173544979925997c
[ "MIT" ]
8
2019-03-21T15:18:17.000Z
2021-09-28T07:52:10.000Z
rpg_svo/svo/include/svo/frame.h
VatanTezer/zephyr
3880dbdb62ec7908d4eed1bc173544979925997c
[ "MIT" ]
1
2019-02-16T22:01:11.000Z
2019-02-16T22:01:11.000Z
rpg_svo/svo/include/svo/frame.h
VatanTezer/zephyr
3880dbdb62ec7908d4eed1bc173544979925997c
[ "MIT" ]
2
2019-08-10T14:09:54.000Z
2020-11-13T13:50:24.000Z
// This file is part of SVO - Semi-direct Visual Odometry. // // Copyright (C) 2014 Christian Forster <forster at ifi dot uzh dot ch> // (Robotics and Perception Group, University of Zurich, Switzerland). // // SVO is free software: you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the Free Software // Foundation, either version 3 of the License, or any later version. // // SVO 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef SVO_FRAME_H_ #define SVO_FRAME_H_ #include <sophus/se3.h> #include <vikit/math_utils.h> #include <vikit/abstract_camera.h> #include <boost/noncopyable.hpp> #include <svo/global.h> namespace g2o { class VertexSE3Expmap; } typedef g2o::VertexSE3Expmap g2oFrameSE3; namespace svo { class Point; struct Feature; typedef list<Feature*> Features; typedef vector<cv::Mat> ImgPyr; /// A frame saves the image, the associated features and the estimated pose. class Frame : boost::noncopyable { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW static int frame_counter_; //!< Counts the number of created frames. Used to set the unique id. int id_; //!< Unique id of the frame. double timestamp_; //!< Timestamp of when the image was recorded. vk::AbstractCamera* cam_; //!< Camera model. Sophus::SE3 T_f_w_; //!< Transform (f)rame from (w)orld. Matrix<double, 6, 6> Cov_; //!< Covariance. ImgPyr img_pyr_; //!< Image Pyramid. Features fts_; //!< List of features in the image. vector<Feature*> key_pts_; //!< Five features and associated 3D points which are used to detect if two frames have overlapping field of view. bool is_keyframe_; //!< Was this frames selected as keyframe? g2oFrameSE3* v_kf_; //!< Temporary pointer to the g2o node object of the keyframe. int last_published_ts_; //!< Timestamp of last publishing. Frame(vk::AbstractCamera* cam, const cv::Mat& img, double timestamp); ~Frame(); /// Initialize new frame and create image pyramid. void initFrame(const cv::Mat& img); /// Select this frame as keyframe. void setKeyframe(); /// Add a feature to the image void addFeature(Feature* ftr); /// The KeyPoints are those five features which are closest to the 4 image corners /// and to the center and which have a 3D point assigned. These points are used /// to quickly check whether two frames have overlapping field of view. void setKeyPoints(); /// Check if we can select five better key-points. void checkKeyPoints(Feature* ftr); /// If a point is deleted, we must remove the corresponding key-point. void removeKeyPoint(Feature* ftr); /// Return number of point observations. inline size_t nObs() const { return fts_.size(); } /// Check if a point in (w)orld coordinate frame is visible in the image. bool isVisible(const Vector3d& xyz_w) const; /// Full resolution image stored in the frame. inline const cv::Mat& img() const { return img_pyr_[0]; } /// Was this frame selected as keyframe? inline bool isKeyframe() const { return is_keyframe_; } /// Transforms point coordinates in world-frame (w) to camera pixel coordinates (c). inline Vector2d w2c(const Vector3d& xyz_w) const { return cam_->world2cam( T_f_w_ * xyz_w ); } /// Transforms pixel coordinates (c) to frame unit sphere coordinates (f). inline Vector3d c2f(const Vector2d& px) const { return cam_->cam2world(px[0], px[1]); } /// Transforms pixel coordinates (c) to frame unit sphere coordinates (f). inline Vector3d c2f(const double x, const double y) const { return cam_->cam2world(x, y); } /// Transforms point coordinates in world-frame (w) to camera-frams (f). inline Vector3d w2f(const Vector3d& xyz_w) const { return T_f_w_ * xyz_w; } /// Transforms point from frame unit sphere (f) frame to world coordinate frame (w). inline Vector3d f2w(const Vector3d& f) const { return T_f_w_.inverse() * f; } /// Projects Point from unit sphere (f) in camera pixels (c). inline Vector2d f2c(const Vector3d& f) const { return cam_->world2cam( f ); } /// Return the pose of the frame in the (w)orld coordinate frame. inline Vector3d pos() const { return T_f_w_.inverse().translation(); } /// Frame jacobian for projection of 3D point in (f)rame coordinate to /// unit plane coordinates uv (focal length = 1). inline static void jacobian_xyz2uv( const Vector3d& xyz_in_f, Matrix<double,2,6>& J) { const double x = xyz_in_f[0]; const double y = xyz_in_f[1]; const double z_inv = 1./xyz_in_f[2]; const double z_inv_2 = z_inv*z_inv; J(0,0) = -z_inv; // -1/z J(0,1) = 0.0; // 0 J(0,2) = x*z_inv_2; // x/z^2 J(0,3) = y*J(0,2); // x*y/z^2 J(0,4) = -(1.0 + x*J(0,2)); // -(1.0 + x^2/z^2) J(0,5) = y*z_inv; // y/z J(1,0) = 0.0; // 0 J(1,1) = -z_inv; // -1/z J(1,2) = y*z_inv_2; // y/z^2 J(1,3) = 1.0 + y*J(1,2); // 1.0 + y^2/z^2 J(1,4) = -J(0,3); // -x*y/z^2 J(1,5) = -x*z_inv; // x/z } }; /// Some helper functions for the frame object. namespace frame_utils { /// Creates an image pyramid of half-sampled images. void createImgPyramid(const cv::Mat& img_level_0, int n_levels, ImgPyr& pyr); /// Get the average depth of the features in the image. bool getSceneDepth(const Frame& frame, double& depth_mean, double& depth_min); } // namespace frame_utils } // namespace svo #endif // SVO_FRAME_H_
40.16129
170
0.635181
[ "object", "vector", "model", "transform", "3d" ]
c927881155ad0b4de186bf3fcf69052e0c8a9afb
850
h
C
include/hardfixing.h
deno750/VRP_Optimization
653c950b59acb3a1cd96d1e96bb334c90655eaa2
[ "MIT" ]
2
2021-03-06T13:33:46.000Z
2021-09-25T00:15:49.000Z
include/hardfixing.h
deno750/VRP_Optimization
653c950b59acb3a1cd96d1e96bb334c90655eaa2
[ "MIT" ]
null
null
null
include/hardfixing.h
deno750/VRP_Optimization
653c950b59acb3a1cd96d1e96bb334c90655eaa2
[ "MIT" ]
null
null
null
/** * Implementation of hard fixing heuristic */ #ifndef HARDFIXING_H #define HARDFIXING_H #include <cplex.h> #include "utility.h" #define HARD_FIX_MIN_IMPROVEMENT 0.015 // 1.5% #define HARD_FIX_MAX_LITTLE_IMPROVEMENTS 3 /** * Function which uses the hard fixing solver with fixed probability * * @param inst The instance pointer of the problem * @param env The cplex's environment * @param lp The cplex's problem object * @return The error code **/ int hard_fixing_solver(instance *inst, CPXENVptr env, CPXLPptr lp); /** * Function which uses the hard fixing solver with variable probabilities * * @param inst The instance pointer of the problem * @param env The cplex's environment * @param lp The cplex's problem object * @return The error code **/ int hard_fixing_solver2(instance *inst, CPXENVptr env, CPXLPptr lp); #endif
25.757576
73
0.747059
[ "object" ]
c9318c567b47b4852ac284169f8c268cc6aa5efb
1,635
h
C
MUON/MUONcore/AliMUON2DMapIteratorByI.h
AllaMaevskaya/AliRoot
c53712645bf1c7d5f565b0d3228e3a6b9b09011a
[ "BSD-3-Clause" ]
52
2016-12-11T13:04:01.000Z
2022-03-11T11:49:35.000Z
MUON/MUONcore/AliMUON2DMapIteratorByI.h
AllaMaevskaya/AliRoot
c53712645bf1c7d5f565b0d3228e3a6b9b09011a
[ "BSD-3-Clause" ]
1,388
2016-11-01T10:27:36.000Z
2022-03-30T15:26:09.000Z
MUON/MUONcore/AliMUON2DMapIteratorByI.h
AllaMaevskaya/AliRoot
c53712645bf1c7d5f565b0d3228e3a6b9b09011a
[ "BSD-3-Clause" ]
275
2016-06-21T20:24:05.000Z
2022-03-31T13:06:19.000Z
#ifndef ALIMUON2DMAPITERATORBYI_H #define ALIMUON2DMAPITERATORBYI_H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ // $Id$ /// \ingroup core /// \class AliMUON2DMapIteratorByI /// \brief Implementation of TIterator for 2D maps /// // Author Laurent Aphecetche #ifndef ROOT_TIterator # include "TIterator.h" #endif class AliMpExMap; class AliMpExMapIterator; //_____________________________________________________________________________ class AliMUON2DMapIteratorByI : public TIterator { public: AliMUON2DMapIteratorByI(const AliMpExMap& theMap, Int_t firstI, Int_t lastI); virtual ~AliMUON2DMapIteratorByI(); ///The returned object must not be deleted by the user. virtual TObject* Next(); virtual void Reset(); virtual const TCollection* GetCollection() const; private: AliMpExMapIterator* NextIterator(); private: /// Not implemented AliMUON2DMapIteratorByI(const AliMUON2DMapIteratorByI& rhs); /// Not implemented AliMUON2DMapIteratorByI& operator=(const AliMUON2DMapIteratorByI& rhs); /// Overriden TIterator virtual operator= AliMUON2DMapIteratorByI& operator=(const TIterator& rhs); const AliMpExMap* fkMap; ///< Top map we iterate upon AliMpExMapIterator* fIter1; ///< first iterator TIterator* fIter2; ///< second iterator Int_t fFirstI; ///< start of range for I Int_t fLastI; ///< end of range for I Int_t fCurrentI; ///< current value of I ClassDef(AliMUON2DMapIteratorByI,0) // VDataIterator for 2D maps }; #endif
26.803279
79
0.726606
[ "object" ]
c931b44da8db5c6bab71b6863b4e8d94975ce600
1,138
h
C
tool/renderer/camera.h
monadgroup/sy17
2901438fcca6be69d30ff9c316097deb37a85613
[ "MIT" ]
18
2021-10-04T14:05:28.000Z
2021-12-26T21:18:06.000Z
tool/renderer/camera.h
monadgroup/sy17
2901438fcca6be69d30ff9c316097deb37a85613
[ "MIT" ]
null
null
null
tool/renderer/camera.h
monadgroup/sy17
2901438fcca6be69d30ff9c316097deb37a85613
[ "MIT" ]
null
null
null
#pragma once #include "ubo.h" #include "vector.h" namespace monad { template<class T> class Track; class Camera { Track<vec3> *_tCameraPos; Track<ForwardDirection> *_tGymbalDir; Track<float> *_tArmLength; Track<Direction> *_tCameraDir; Track<float> *_tFov; Track<vec2> *_tClipRange; bool _isLocked = false; void _update(); vec3 _getPosition() const; Direction _getDirection() const; Matrix4 lastFrameMatrix; public: Ubo ubo; Camera(Track<vec3> *tCameraPos, Track<ForwardDirection> *tGymbalDir, Track<float> *tArmLength, Track<Direction> *tCameraDir, Track<float> *tFov, Track<vec2> *tClipRange); vec3 getPosition() const; Direction getDirection() const; float getFov() const; Matrix4 getViewMatrix() const; Matrix4 getProjectionMatrix(float aspectRatio) const; void update(float aspectRatio); void updateBuffer(float aspectRatio); void swap(float aspectRatio); void lock(); void unlock(); }; }
23.22449
76
0.610721
[ "vector" ]
c936c31398352c4db5041dee9457875f9a372ed6
391
h
C
chapter5/Name.h
meowFlute/ooc
3be99d2d532b9e87d01636383efd7b921f2f443a
[ "MIT" ]
null
null
null
chapter5/Name.h
meowFlute/ooc
3be99d2d532b9e87d01636383efd7b921f2f443a
[ "MIT" ]
null
null
null
chapter5/Name.h
meowFlute/ooc
3be99d2d532b9e87d01636383efd7b921f2f443a
[ "MIT" ]
null
null
null
#ifndef NAME_H #define NAME_H /* * install(& struct Name) arrange for object to be found later * * screen(name) * find a name in a table * if nothing found, enter new(Var, name) into table * return associated token and pointer to structure */ extern void * symbol; /* -> last Name found by screen() */ void install (const void * symbol); int screen (const char * name); #endif
20.578947
63
0.685422
[ "object" ]
c95222e3a996a0c09c85147141b9a13684accee3
1,970
c
C
strongswan/strongswan-5.3.2/src/libtnccs/plugins/tnccs_20/messages/ita/pb_noskip_test_msg.c
SECURED-FP7/secured-mobility-ned
36fdbfee58a31d42f7047f7a7eaa1b2b70246151
[ "Apache-2.0" ]
2
2017-10-16T07:51:18.000Z
2019-06-16T12:07:52.000Z
strongswan/strongswan-5.3.2/src/libtnccs/plugins/tnccs_20/messages/ita/pb_noskip_test_msg.c
SECURED-FP7/secured-mobility-ned
36fdbfee58a31d42f7047f7a7eaa1b2b70246151
[ "Apache-2.0" ]
null
null
null
strongswan/strongswan-5.3.2/src/libtnccs/plugins/tnccs_20/messages/ita/pb_noskip_test_msg.c
SECURED-FP7/secured-mobility-ned
36fdbfee58a31d42f7047f7a7eaa1b2b70246151
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2015 Andreas Steffen * HSR Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. * * This program 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 General Public License * for more details. */ #include "pb_noskip_test_msg.h" typedef struct private_pb_noskip_test_msg_t private_pb_noskip_test_msg_t; /** * Private data of a pb_noskip_test_msg_t object. * */ struct private_pb_noskip_test_msg_t { /** * Public pb_noskip_test_msg_t interface. */ pb_noskip_test_msg_t public; /** * PB-TNC message type */ pen_type_t type; /** * Encoded message */ chunk_t encoding; }; METHOD(pb_tnc_msg_t, get_type, pen_type_t, private_pb_noskip_test_msg_t *this) { return this->type; } METHOD(pb_tnc_msg_t, get_encoding, chunk_t, private_pb_noskip_test_msg_t *this) { return this->encoding; } METHOD(pb_tnc_msg_t, build, void, private_pb_noskip_test_msg_t *this) { /* nothing to do since the message is empty */ } METHOD(pb_tnc_msg_t, process, status_t, private_pb_noskip_test_msg_t *this, u_int32_t *offset) { return SUCCESS; } METHOD(pb_tnc_msg_t, destroy, void, private_pb_noskip_test_msg_t *this) { free(this); } /** * See header */ pb_tnc_msg_t *pb_noskip_test_msg_create(void) { private_pb_noskip_test_msg_t *this; INIT(this, .public = { .pb_interface = { .get_type = _get_type, .get_encoding = _get_encoding, .build = _build, .process = _process, .destroy = _destroy, }, }, .type = { PEN_ITA, PB_ITA_MSG_NOSKIP_TEST }, ); return &this->public.pb_interface; }
21.182796
77
0.730457
[ "object" ]
c963e1dee688fa7af83bef90e63965b64de3120c
7,877
h
C
src/libYARP_OS/include/yarp/YARPPortContent.h
robotology-legacy/yarp1
21434f5b776edea201b39a9644552dca59339dbc
[ "Artistic-1.0-Perl" ]
null
null
null
src/libYARP_OS/include/yarp/YARPPortContent.h
robotology-legacy/yarp1
21434f5b776edea201b39a9644552dca59339dbc
[ "Artistic-1.0-Perl" ]
null
null
null
src/libYARP_OS/include/yarp/YARPPortContent.h
robotology-legacy/yarp1
21434f5b776edea201b39a9644552dca59339dbc
[ "Artistic-1.0-Perl" ]
null
null
null
///////////////////////////////////////////////////////////////////////// /// /// /// /// /// This Academic Free License applies to any software and associated /// /// documentation (the "Software") whose owner (the "Licensor") has /// /// placed the statement "Licensed under the Academic Free License /// /// Version 1.0" immediately after the copyright notice that applies /// /// to the Software. /// /// Permission is hereby granted, free of charge, to any person /// /// obtaining a copy of the Software (1) to use, copy, modify, merge, /// /// publish, perform, distribute, sublicense, and/or sell copies of /// /// the Software, and to permit persons to whom the Software is /// /// furnished to do so, and (2) under patent claims owned or /// /// controlled by the Licensor that are embodied in the Software as /// /// furnished by the Licensor, to make, use, sell and offer for sale /// /// the Software and derivative works thereof, subject to the /// /// following conditions: /// /// Redistributions of the Software in source code form must retain /// /// all copyright notices in the Software as furnished by the /// /// Licensor, this list of conditions, and the following disclaimers. /// /// Redistributions of the Software in executable form must reproduce /// /// all copyright notices in the Software as furnished by the /// /// Licensor, this list of conditions, and the following disclaimers /// /// in the documentation and/or other materials provided with the /// /// distribution. /// /// /// /// Neither the names of Licensor, nor the names of any contributors /// /// to the Software, nor any of their trademarks or service marks, /// /// may be used to endorse or promote products derived from this /// /// Software without express prior written permission of the Licensor./// /// /// /// DISCLAIMERS: LICENSOR WARRANTS THAT THE COPYRIGHT IN AND TO THE /// /// SOFTWARE IS OWNED BY THE LICENSOR OR THAT THE SOFTWARE IS /// /// DISTRIBUTED BY LICENSOR UNDER A VALID CURRENT LICENSE. EXCEPT AS /// /// EXPRESSLY STATED IN THE IMMEDIATELY PRECEDING SENTENCE, THE /// /// SOFTWARE IS PROVIDED BY THE LICENSOR, CONTRIBUTORS AND COPYRIGHT /// /// OWNERS "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, /// /// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// /// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO /// /// EVENT SHALL THE LICENSOR, CONTRIBUTORS OR COPYRIGHT OWNERS BE /// /// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN /// /// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN /// /// CONNECTION WITH THE SOFTWARE. /// /// /// /// This license is Copyright (C) 2002 Lawrence E. Rosen. All rights /// /// reserved. Permission is hereby granted to copy and distribute /// /// this license without modification. This license may not be /// /// modified without the express written permission of its copyright /// /// owner. /// /// /// /// /// ///////////////////////////////////////////////////////////////////////// /// /// /// YARP - Yet Another Robotic Platform (c) 2001-2003 /// /// #paulfitz, pasa# /// /// "Licensed under the Academic Free License Version 1.0" /// /// /// $Id: YARPPortContent.h,v 2.0 2005-11-06 22:21:26 gmetta Exp $ /// /// /* paulfitz Sat May 26 22:27:07 EDT 2001 */ #ifndef YARPPortContent_INC #define YARPPortContent_INC #include <yarp/YARPConfig.h> #include <yarp/YARPAll.h> #ifdef YARP_HAS_PRAGMA_ONCE # pragma once #endif /** * \file YARPPortContent.h definition of the "port content" helper classes. */ /** * Helper for reading raw data from a port. */ class YARPPortReader { public: /** * Read a block of data from a port. * * @param buffer address of block of memory to read into. * @param length size of block of memory available. * @return true on success */ virtual int Read(char *buffer, int length) = 0; }; /** * Helper for writing raw data to a port. */ class YARPPortWriter { public: /** * Write a block of data to a port. * * @param buffer address of block of memory to read from. * @param length size of block of memory. * @return true on success */ virtual int Write(char *buffer, int length) = 0; }; template <class T> struct HierarchyRoot { // HierarchyId is a nested class struct HierarchyId {}; }; /** * Wrapper for any content to be transmitted between ports. Instances * of this class know how to read or write themselves, and are can be * kept in a pool of objects that circulate from the user to the * communications code and back to the user. Necessary for efficiency * when transmitting to multiple targets that read data at different * rates. */ class YARPPortContent : public HierarchyRoot<YARPPortContent> { public: virtual ~YARPPortContent () { /*ACE_DEBUG ((LM_DEBUG, "destroying a YARPPortContent\n"));*/ } /** * Initialize the object from a message. A "reader" is supplied * by a port object, which expects us to make a series of * one or more calls to Read() on the reader to reconstruct * an object passed across the network. The port object then * doesn't need to know anything about the size/format of the * message. * * @param reader interface to read blocks of the message from the port. * @return true if successful, false otherwise. */ virtual int Read(YARPPortReader& reader) = 0; /** * Describe the object as a message. A "writer" is supplied * by a port object, which expects us to make a series of one * or more calls to Write() on the writer to describe an * object. The port object then doesn't need to know anything * about the size/format of the message. * * @param writer interface to write blocks of the message to the port. * @return true if successful, false otherwise. */ virtual int Write(YARPPortWriter& writer) = 0; /** * Clean up. Called when communications code is finished with * the object, and it will be passed back to the user. Often * fine to do nothing here. * * @return true if successful, false otherwise. */ virtual int Recycle() = 0; }; /** * Wrapper for simple content to be transmitted between ports. "Simple" * content means a class which can safely be transmitted byte-for-byte * across the network. It must not contain any pointers! * * @param T the simple class which is to be transmitted across the network. */ template <class T> class YARPPortContentOf : public YARPPortContent { public: /** * An instance of the simple content. */ T datum; /** * Access an instance of the simple content. * * @return a reference to an instance of the simple content. */ T& Content() { return datum; } virtual ~YARPPortContentOf<T> () { /*ACE_DEBUG ((LM_DEBUG, "destroying a YARPPortContentOf\n"));*/ } virtual int Read(YARPPortReader& reader) { return reader.Read((char*)(&datum),sizeof(datum)); } virtual int Write(YARPPortWriter& writer) { return writer.Write((char*)(&datum),sizeof(datum)); } virtual int Recycle() { return 0; } }; #endif
37.688995
101
0.608353
[ "object" ]
c979c5fd57fcb9bc62d01e8357bebbeff6580a36
1,764
h
C
src/storage/orm_firmwares.h
Telecominfraproject/wlan-cloud-ufs
e34874f68bdb7bdefb9f94a861719b7876c1c39a
[ "BSD-3-Clause" ]
1
2021-08-04T02:31:29.000Z
2021-08-04T02:31:29.000Z
src/storage/orm_firmwares.h
Telecominfraproject/wlan-cloud-ufs
e34874f68bdb7bdefb9f94a861719b7876c1c39a
[ "BSD-3-Clause" ]
1
2021-08-23T14:39:20.000Z
2021-08-23T14:39:20.000Z
src/storage/orm_firmwares.h
Telecominfraproject/wlan-cloud-ufs
e34874f68bdb7bdefb9f94a861719b7876c1c39a
[ "BSD-3-Clause" ]
1
2022-01-03T16:17:18.000Z
2022-01-03T16:17:18.000Z
// // Created by stephane bourque on 2021-12-28. // #pragma once #include "framework/orm.h" #include "RESTObjects/RESTAPI_FMSObjects.h" namespace OpenWifi { typedef Poco::Tuple< std::string, std::string, std::string, std::string, std::string, std::string, std::string, uint64_t, uint64_t, uint64_t, std::string, std::string, std::string, std::string, std::string, bool, std::string, uint64_t> FirmwaresRecordTuple; typedef std::vector <FirmwaresRecordTuple> FirmwaresRecordTupleList; class FirmwaresDB : public ORM::DB<FirmwaresRecordTuple, FMSObjects::Firmware> { public: FirmwaresDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); bool AddFirmware(FMSObjects::Firmware & F); bool UpdateFirmware(std::string & ID, FMSObjects::Firmware & F); bool DeleteFirmware(std::string & ID); void RemoveOldFirmware(); bool GetFirmware(std::string & ID, FMSObjects::Firmware & F); bool GetFirmwareByName(const std::string & Release, const std::string &DeviceType, FMSObjects::Firmware & Firmware ); bool GetFirmwareByRevision(const std::string & Revision, const std::string &DeviceType,FMSObjects::Firmware & Firmware ); bool GetFirmwares(uint64_t From, uint64_t HowMany, const std::string & Compatible, FMSObjects::FirmwareVec & Firmwares); void PopulateLatestFirmwareCache(); bool ComputeFirmwareAge(const std::string & DeviceType, const std::string & Revision, FMSObjects::FirmwareAgeDetails &AgeDetails); private: }; }
35.28
138
0.624717
[ "vector" ]
c98950bdbd51136d95d0a576f4798d57d6e7533e
1,871
h
C
AST/ident.h
adamjoffe/tr-lang
4061fefe2d48016a5575c4ea27903661550468ee
[ "MIT" ]
null
null
null
AST/ident.h
adamjoffe/tr-lang
4061fefe2d48016a5575c4ea27903661550468ee
[ "MIT" ]
null
null
null
AST/ident.h
adamjoffe/tr-lang
4061fefe2d48016a5575c4ea27903661550468ee
[ "MIT" ]
null
null
null
#ifndef IDENT_H #define IDENT_H #include <string> namespace TR { /** * ID Node * * Ident node of variable, func name or tr node, * part of terminal nodes */ class Ident : public ASTTerminal { public: /// Remove default constructor for this Ident() = delete; /** * Tree constructor * * Constructs node of the tree given the child node(s) * * @param n Name of the Id (should be type std::string) * @param l Location of related token in source code * @param f File name of related symbol(s) in source code */ Ident(const std::string& n, const location& l, const std::string& f) : name(n), ASTTerminal(l,f) {} /** * Source code constructor * * Constructs node of the tree given the child node(s) * * @param n Name of the Id (should be type std::string) * @param l Location of related token in source code * @param f File name of related symbol(s) in source code * @param src Source code of related node */ Ident(const std::string& n, const location& l, const std::string& f, const std::string& src) : name(n), ASTTerminal(l,f,src) {} /** * Virtual destructor * * Doesn't need to delete parent */ virtual ~Ident() {} /** * Visit Function * * Calls the abstracted visitor function * See Visitor Pattern * * @param v Pointer to the visitor object * @param n Optional pointer to AST node * @return Optionally returns a pointer to an AST node */ virtual ASTNode* visit(Visitor* v, ASTNode* n); const std::string name; }; } #endif
26.728571
102
0.537146
[ "object" ]
c9973029bc0ac269e1c500a260aba72a3733a906
2,027
c
C
d/avatars/silvanus/n_wrath.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/avatars/silvanus/n_wrath.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
null
null
null
d/avatars/silvanus/n_wrath.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> inherit WEAPON; void create(){ ::create(); set_name("Nature's Wrath"); set_id(({ "sword", "wrath", "Sword", "Wrath", "Natures Sword", "Nature's Sword", "natures sword", "nature's sword", "Nature's Wrath", "Natures Wrath", "nature's wrath", "natures wrath" })); set_short("%^BOLD%^%^GREEN%^Nature's Wrath%^RESET%^"); set_obvious_short("%^BOLD%^%^GREEN%^Nature's Wrath%^RESET%^"); set_long( @AVATAR %^BOLD%^%^GREEN%^This weapon is made from a translucent glowing green material. It is obviously not naturally from this world. It has been assembled to deliver the vengeful wrath of nature on anyone who dares harm the natural world.%^RESET%^ AVATAR ); set_weight(1); set_value(100000000); set_type("slashing"); set_prof_type("wrath sword"); set_size(1); set_wc(100,100); set_large_wc(100,100); set_property("enchantment",30); set_ac(400); set_wield((:TO,"wield_func":)); set_unwield((:TO,"unwield_func":)); set_hit((:TO,"hit_func":)); } int wield_func(){ tell_room(ETP,"%^GREEN%^"+TP->query_cap_name()+" takes it upon himself to deliver "+query_short()+"%^GREEN%^!%^RESET%^",TP); tell_object(TP,"%^GREEN%^You take it upon yourself to deliver "+query_short()+"%^GREEN%^!%^RESET%^"); TP->add_attack_bonus(400); return 1; } int unwield_func(){ tell_room(ETP,"%^GREEN%^"+TP->query_cap_name()+" rids himself of "+query_short()+"%^GREEN%^!%^RESET%^",TP); tell_object(TP,"%^GREEN%^You have avenged nature and rid yourself of it's wrath.%^RESET%^"); TP->add_attack_bonus(-400); return 1; } int hit_func(object targ){ if(random(1000) < 1000){ tell_room(environment(query_wielded()),"%^GREEN%^"+ETO->query_cap_name()+" strikes "+targ->query_cap_name()+" with "+query_short()+"%^GREEN%^!%^RESET%^",({ETO,targ})); tell_object(ETO,"%^GREEN%^You strike "+targ->query_cap_name()+" with "+query_short()+"%^GREEN%^!%^RESET%^"); tell_object(targ,"%^GREEN%^"+ETO->query_cap_name()+" strikes you with "+query_short()+"%^GREEN%^!%^RESET%^"); targ->set_paralyzed(roll_dice(10,10)+10); return 0; } }
42.229167
243
0.679329
[ "object" ]
c9989dc0b923a6e1152e493a1374dcc0df20f58b
5,941
c
C
OOFSWIG/Tests/Parser/objc_regr.c
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
31
2015-04-01T15:59:36.000Z
2022-03-18T20:21:47.000Z
OOFSWIG/Tests/Parser/objc_regr.c
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
3
2015-02-06T19:30:24.000Z
2017-05-25T14:14:31.000Z
OOFSWIG/Tests/Parser/objc_regr.c
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
7
2015-01-23T15:19:22.000Z
2021-06-09T09:03:59.000Z
/* DEBUG : Language specific headers go here */ /* DEBUG : Pointer conversion function here */ /* DEBUG : Language specific code here */ #define SWIG_init swig_init #define SWIG_name "swig" C++ CLASS DECLARATION : foo1 C++ CLASS DECLARATION : foo2 C++ CLASS DECLARATION : foo3 C++ CLASS DECLARATION : inherit1 C++ CLASS DECLARATION : rname C++ CLASS DECLARATION : added C++ CLASS DECLARATION : cls1 C++ CLASS DECLARATION : cls2 C++ CLASS DECLARATION : cls3 WRAPPER : void proto1(id< Proto1 > ,id< Proto2 > ,id< Proto3,Proto4,Proto5 > ); C++ CLASS START : foo1 ======================================== inheriting from baseclass : Object MEMBER FUNC : int bar1(double ); STATIC FUNC : void bar2(); MEMBER FUNC : id bar3(); CONSTRUCTOR : new *new(); DESTRUCTOR : ~free(); MEMBER FUNC : id private$member(); MEMBER FUNC : id spam1(int ,double ,char *); STATIC FUNC : id spam2(int ,double ,char *); MEMBER FUNC : id more1(); MEMBER FUNC : int more2(double ); MEMBER FUNC : double added2(double ); C++ CLASS END =================================================== C++ CLASS START : foo2 ======================================== MEMBER FUNC : int bar1(double ); C++ CLASS END =================================================== C++ CLASS START : foo3 ======================================== inheriting from baseclass : Object MEMBER FUNC : int bar1(double ); C++ CLASS END =================================================== C++ CLASS START : inherit1 ======================================== inheriting from baseclass : foo1 ATTRIBUTE : int a; ATTRIBUTE : int c; ATTRIBUTE : int b; MEMBER FUNC : int base1(); MEMBER FUNC : double base2(int ); MEMBER FUNC : int bar1(double ); STATIC FUNC : void bar2(); MEMBER FUNC : id bar3(); MEMBER FUNC : id private$member(); MEMBER FUNC : id spam1(int ,double ,char *); STATIC FUNC : id spam2(int ,double ,char *); MEMBER FUNC : id more1(); MEMBER FUNC : int more2(double ); MEMBER FUNC : double added2(double ); C++ CLASS END =================================================== C++ CLASS START : rname ======================================== inheriting from baseclass : Object ATTRIBUTE : int a; ATTRIBUTE : int c; ATTRIBUTE : int b; ATTRIBUTE : double d; MEMBER FUNC : int oldname(double ,int ); C++ CLASS END =================================================== C++ CLASS START : added ======================================== inheriting from baseclass : Object MEMBER FUNC : double added1(double ,double ); STATIC FUNC : int addi(int ,int ); C++ CLASS END =================================================== SWIG POINTER-MAPPING TABLE /* * This table is used by the pointer type-checker */ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_signed_long","_long",0}, { "_long","_unsigned_long",0}, { "_long","_signed_long",0}, { "_unsigned_long","_long",0}, { "_signed_int","_int",0}, { "_unsigned_short","_short",0}, { "_signed_short","_short",0}, { "_unsigned_int","_int",0}, { "_short","_unsigned_short",0}, { "_short","_signed_short",0}, { "_int","_unsigned_int",0}, { "_int","_signed_int",0}, { "_foo1","_inherit1",0}, {0,0,0}}; /* MODULE INITIALIZATION */ void swig_init() { ADD COMMAND : proto1 --> void proto1(id< Proto1 > ,id< Proto2 > ,id< Proto3,Proto4,Proto5 > ); // C++ CLASS START : foo1 ADD MEMBER FUN : bar1 --> int bar1(double ); ADD STATIC FUNC: bar2 --> void bar2(); ADD MEMBER FUN : bar3 --> id bar3(); ADD CONSTRUCT : new --> new *new(); ADD DESTRUCT : free --> ~free(); ADD MEMBER FUN : private_S_member --> id private$member(); ADD MEMBER FUN : spam1 --> id spam1(int ,double ,char *); ADD STATIC FUNC: spam2 --> id spam2(int ,double ,char *); ADD MEMBER FUN : more1 --> id more1(); ADD MEMBER FUN : more2 --> int more2(double ); ADD MEMBER FUN : added2 --> double added2(double ); // C++ CLASS END // C++ CLASS START : foo2 ADD MEMBER FUN : bar1 --> int bar1(double ); // C++ CLASS END // C++ CLASS START : foo3 ADD MEMBER FUN : bar1 --> int bar1(double ); // C++ CLASS END // C++ CLASS START : inherit1 ADD MEMBER : a --> int a; ADD MEMBER : c --> int c; ADD MEMBER : b --> int b; ADD MEMBER FUN : base1 --> int base1(); ADD MEMBER FUN : base2 --> double base2(int ); ADD MEMBER FUN : bar1 --> int bar1(double ); ADD STATIC FUNC: bar2 --> void bar2(); ADD MEMBER FUN : bar3 --> id bar3(); ADD MEMBER FUN : private_S_member --> id private$member(); ADD MEMBER FUN : spam1 --> id spam1(int ,double ,char *); ADD STATIC FUNC: spam2 --> id spam2(int ,double ,char *); ADD MEMBER FUN : more1 --> id more1(); ADD MEMBER FUN : more2 --> int more2(double ); ADD MEMBER FUN : added2 --> double added2(double ); // C++ CLASS END // C++ CLASS START : rname ADD MEMBER : a --> int a; ADD MEMBER : c --> int c; ADD MEMBER : b --> int b; ADD MEMBER : myd --> double d; ADD MEMBER FUN : myname --> int oldname(double ,int ); // C++ CLASS END // C++ CLASS START : added ADD MEMBER FUN : added1 --> double added1(double ,double ); ADD STATIC FUNC: addi --> int addi(int ,int ); // C++ CLASS END } /* END INIT */ { int i; for (i = 0; _swig_mapping[i].n1; i++) SWIG_RegisterMapping(_swig_mapping[i].n1,_swig_mapping[i].n2,_swig_mapping[i].pcnv); }
30.623711
102
0.512035
[ "object" ]
c9a768fad76c6d51549902f7b6ee24da4791af54
10,291
c
C
generated/ZendEngine_3/bench/foo.zep.c
hlooalklampc/tss
23856e1e8244a89ac1bc30ba56b417a4a1c1687f
[ "MIT" ]
1
2022-02-02T16:59:28.000Z
2022-02-02T16:59:28.000Z
generated/ZendEngine_3/bench/foo.zep.c
hlooalklampc/tss
23856e1e8244a89ac1bc30ba56b417a4a1c1687f
[ "MIT" ]
null
null
null
generated/ZendEngine_3/bench/foo.zep.c
hlooalklampc/tss
23856e1e8244a89ac1bc30ba56b417a4a1c1687f
[ "MIT" ]
null
null
null
#ifdef HAVE_CONFIG_H #include "../../ext_config.h" #endif #include <php.h> #include "../../php_ext.h" #include "../../ext.h" #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include "kernel/main.h" #include "kernel/operators.h" #include "kernel/memory.h" #include "kernel/object.h" #include "kernel/fcall.h" ZEPHIR_INIT_CLASS(Test_Bench_Foo) { ZEPHIR_REGISTER_CLASS(Test\\Bench, Foo, test, bench_foo, test_bench_foo_method_entry, 0); zend_declare_property_long(test_bench_foo_ce, SL("a"), 0, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_long(test_bench_foo_ce, SL("b"), 0, ZEND_ACC_PUBLIC TSRMLS_CC); zephir_declare_class_constant_long(test_bench_foo_ce, SL("TEST"), 0); return SUCCESS; } PHP_METHOD(Test_Bench_Foo, empty_for_in_range) { int _1; zend_bool _0; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, read_static) { int _1; zend_bool _0; zval *n, n_sub, x, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&x); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_OBS_NVAR(&x); zephir_read_static_property_ce(&x, test_bench_foo_ce, SL("a"), PH_NOISY_CC); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, write_static) { int _1; zend_bool _0; zval *n, n_sub, i, _2, _3$$3; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_INIT_ZVAL_NREF(_3$$3); ZVAL_LONG(&_3$$3, 0); zephir_update_static_property_ce(test_bench_foo_ce, SL("a"), &_3$$3); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, isset_static) { int _1; zend_bool x = 0, _0; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); x = (0 == 0); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, empty_static) { int _1; zend_bool x = 0, _0; zval *n, n_sub, i, _2, _3$$3; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_OBS_NVAR(&_3$$3); zephir_read_static_property_ce(&_3$$3, test_bench_foo_ce, SL("a"), PH_NOISY_CC); x = ZEPHIR_IS_EMPTY(&_3$$3); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, f) { ZEPHIR_INIT_THIS(); } PHP_METHOD(Test_Bench_Foo, call_static) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS, _1; zephir_fcall_cache_entry *_3 = NULL; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_CALL_SELF(NULL, "f", &_3, 0); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, read_prop) { int _1; zend_bool _0; zval *n, n_sub, x, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&x); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); zephir_read_property(&x, this_ptr, SL("b"), PH_NOISY_CC | PH_READONLY); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, write_prop) { int _1; zend_bool _0; zval *n, n_sub, i, _2, _3$$3; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_INIT_ZVAL_NREF(_3$$3); ZVAL_LONG(&_3$$3, 0); zephir_update_property_zval(this_ptr, SL("b"), &_3$$3); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, assign_add_prop) { int _1; zend_bool _0; zval *n, n_sub, i, _2, _3$$3, _4$$3; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_INIT_NVAR(&_4$$3); ZVAL_LONG(&_4$$3, 2); ZEPHIR_ADD_ASSIGN(&_3$$3, &_4$$3) zephir_update_property_zval(this_ptr, SL("b"), &_3$$3); } } ZEPHIR_MM_RESTORE(); } /** public function pre_inc_prop(var n) { var i; for i in range(1, n) { ++this->b; } } public function pre_dec_prop($n) { var i; for i in range(1, n) { --$this->b; } }*/ PHP_METHOD(Test_Bench_Foo, post_inc_prop) { int _1; zend_bool _0; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("b") TSRMLS_CC)); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, post_dec_prop) { int _1; zend_bool _0; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("b") TSRMLS_CC)); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, isset_prop) { int _1; zend_bool x = 0, _0; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); x = zephir_isset_property(this_ptr, SL("b")); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, empty_prop) { int _1; zend_bool x = 0, _0; zval *n, n_sub, i, _2, _3$$3; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_OBS_NVAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, SL("b"), PH_NOISY_CC); x = ZEPHIR_IS_EMPTY(&_3$$3); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, g) { ZEPHIR_INIT_THIS(); } PHP_METHOD(Test_Bench_Foo, call) { zend_bool _0; zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS, _1; zval *n, n_sub, i, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "g", &_3, 0); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } PHP_METHOD(Test_Bench_Foo, read_const) { int _1; zend_bool _0; zval *n, n_sub, i, x, _2; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&x); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); ZEPHIR_INIT_NVAR(&x); ZVAL_LONG(&x, 0); } } ZEPHIR_MM_RESTORE(); }
15.545317
102
0.60344
[ "object" ]
f968f3773ab5ac8f1ab1e487ed7884b729e9f197
10,737
h
C
src/Core/Thread/Legacy/Thread.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
src/Core/Thread/Legacy/Thread.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
src/Core/Thread/Legacy/Thread.h
benjaminlarson/SCIRunGUIPrototype
ed34ee11cda114e3761bd222a71a9f397517914d
[ "Unlicense" ]
null
null
null
/* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2009 Scientific Computing and Imaging Institute, University of Utah. License for the specific language governing rights and limitations under Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /// /// @file Thread.h /// @brief The thread class /// /// @author Steve Parker /// Department of Computer Science /// University of Utah /// @date June 1997 /// #ifndef Core_Thread_Thread_h #define Core_Thread_Thread_h //#include <sci_defs/bits_defs.h> #include <Core/Thread/Legacy/Parallel.h> #include <Core/Thread/Legacy/Parallel1.h> #include <Core/Thread/Legacy/Parallel2.h> #include <Core/Thread/Legacy/Parallel3.h> #include <Core/Thread/Legacy/Parallel4.h> #include <Core/Thread/Legacy/share.h> #ifndef _WIN32 #include <signal.h> #endif namespace SCIRun { struct Thread_private; class ParallelBase; class Runnable; class ThreadGroup; /// The Thread class provides a new context in which to run. A single /// Runnable class is attached to a single Thread class, which are /// executed in another thread. class SCISHARE Thread { #ifdef SCI_64BITS static const unsigned long long DEFAULT_STACKSIZE = 256 * 1024; // 256 KB #else static const unsigned long long DEFAULT_STACKSIZE = 128 * 1024; // 128 KB #endif public: /// Possible thread start states enum ActiveState { Activated, Stopped, NotActivated }; /// Create a thread, which will execute the <b>run()</b> /// method in the <b>runner</b> object. The thread <b>name</b> /// is used for identification purposes, and does not need to /// be unique with respect to other threads. <b>Group</b> /// specifies the ThreadGroup that to which this thread /// should belong. If no group is specified (group==0), /// the default group is used. Thread(Runnable* runner, const char* name, ThreadGroup* group=0, ActiveState state=Activated, unsigned long long stack_size = DEFAULT_STACKSIZE); /// Return the <b>ThreadGroup</b> associated with this thread. ThreadGroup* getThreadGroup(); /// Return the <b>Runnable</b> associated with this thread. Runnable* getRunnable(); /// Flag the thread as a daemon thread. When all non-deamon /// threads exit, the program will exit. void setDaemon(bool to=true); /// Returns true if the thread is tagged as a daemon thread. bool isDaemon() const; /// If the thread is started in the the NotActivated state, /// use this to activate the thread (the argument should be /// false). void activate(bool stopped); /// Arrange to have the thread deleted automatically at exit. /// The pointer to the thread should not be used by any other /// threads once this has been called. void detach(); /// Returns true if the thread is detached bool isDetached() const; /// Set the stack size for a particular thread. In order /// to use this thread, you must create the thread in the /// NotActivated state, set the stack size, and then start /// the thread using activate(false). Setting the stack /// size for a thread that is running or has ever been run, /// will throw an exception. The units are in bytes. void setStackSize(unsigned long long stackSize); /// Returns the stack size for the thread unsigned long long getStackSize() const; /// Kill all threads and exit with <b>code</b>. static void exitAll(int code); /// Exit the currently running thread static void exit(); /// Returns a pointer to the currently running thread. static Thread* self(); /// Stop the thread. void stop(); /// Resume the thread void resume(); /// Blocks the calling thread until this thead has finished /// executing. You cannot join detached threads or daemon threads. void join(); /// Returns the name of the thread const char* getThreadName() const; /// Returns the number of processors on the system static int numProcessors(); /// Request that the thread migrate to processor <i>proc</i>. /// If <i>proc</i> is -1, then the thread is free to run /// anywhere. void migrate(int proc); /// Start up several threads that will run in parallel. A new /// <b>ThreadGroup</b> is created as a child of the optional parent. /// If <i>block</i> is true, then the caller will block until all /// of the threads return. Otherwise, the call will return /// immediately. static ThreadGroup* parallel(ParallelBase& helper, int nthreads, bool block, ThreadGroup* threadGroup=0); /// Start up several threads that will run in parallel. /// If <i>block</i> is true, then the caller will block until all /// of the threads return. Otherwise, the call will return /// immediately. template<class T> static void parallel(T* ptr, void (T::*pmf)(int), int numThreads) { if (numThreads <= 1) { (ptr->*pmf)(0); } else { Parallel<T> p(ptr, pmf); parallel(p, numThreads, true); } } /// Another overloaded version of parallel that passes 1 argument template<class T, class Arg1> static void parallel(T* ptr, void (T::*pmf)(int, Arg1), int numThreads, Arg1 a1) { if (numThreads <= 1) { (ptr->*pmf)(0, a1); } else { Parallel1<T, Arg1> p(ptr, pmf, a1); parallel(p, numThreads, true); } } /// Another overloaded version of parallel that passes 2 arguments template<class T, class Arg1, class Arg2> static void parallel(T* ptr, void (T::* pmf)(int, Arg1, Arg2), int numThreads, Arg1 a1, Arg2 a2) { if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2); } else { Parallel2<T, Arg1, Arg2> p(ptr, pmf, a1, a2); parallel(p, numThreads, true); } } /// Another overloaded version of parallel that passes 3 arguments template<class T, class Arg1, class Arg2, class Arg3> static void parallel(T* ptr, void (T::* pmf)(int, Arg1, Arg2, Arg3), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3) { if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2, a3); } else { Parallel3<T, Arg1, Arg2, Arg3> p(ptr, pmf, a1, a2, a3); parallel(p, numThreads, true); } } /// Another overloaded version of parallel that passes 4 arguments template<class T, class Arg1, class Arg2, class Arg3, class Arg4> static void parallel(T* ptr, void (T::* pmf)(int, Arg1, Arg2, Arg3, Arg4), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4) { if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2, a3, a4); } else { Parallel4<T, Arg1, Arg2, Arg3, Arg4> p(ptr, pmf, a1, a2, a3, a4); parallel(p, numThreads, true); } } /// Abort the current thread, or the process. Prints a message on /// stderr, and the user may choose one of: /// <pre>continue(c)/dbx(d)/cvd(v)/kill thread(k)/exit(e)</pre> /// context is necesary on Windows to catch a segfault static void niceAbort(void* Context = 0); /// Mark a section as one that could block for debugging purposes. /// The <b>int</b> that is returned should be passed into /// <i>couldBlockDone(int)</i> when the section has completed. This /// will typically not be used outside of the thread implementation. static int couldBlock(const char* why); /// Mark the end of a selection that could block. /// <i>restore</i> was returned from a previous invocation /// of the above <b>couldBlock</b>. static void couldBlockDone(int restore); /// The calling process voluntarily gives up time to another process static void yield(); /// Return true if the thread library has been initialized. This /// will typically not be used outside of the thread implementation. static bool isInitialized(); /// set to "exit" (or something else) so we don't have to always /// wait for the user to input something static void setDefaultAbortMode(const char* abortMode); static void initialize(); friend class Runnable; friend class ConditionVariable; friend class RecursiveMutex; friend class Mutex; friend struct Thread_private; friend class SystemCallManager; friend void Thread_run(Thread* t); friend void Thread_shutdown(Thread*,bool); #ifdef _WIN32 friend unsigned long run_threads(void* priv_v); #else friend void* run_threads(void* priv_v); friend void handle_abort_signals(int, siginfo_t*, void*); friend void handle_quit(int); friend void handle_siguser2(int); friend void install_signal_handlers(); friend void exit_handler(); #endif private: Runnable* runner_; const char* threadname_; ThreadGroup* group_; unsigned long long stacksize_; bool daemon_; bool detached_; bool activated_; void os_start(bool stopped); Thread(ThreadGroup* g, const char* name); static bool initialized; static void checkExit(); static const char* defaultAbortMode; int cpu_; ~Thread(); Thread_private* priv_; static int id(); void run_body(); enum ThreadState { STARTUP, RUNNING, IDLE, SHUTDOWN, DIED, PROGRAM_EXIT, JOINING, BLOCK_ANY, BLOCK_BARRIER, BLOCK_MUTEX, BLOCK_SEMAPHORE, BLOCK_CONDITIONVARIABLE }; static const char* getStateString(ThreadState); static int push_bstack(Thread_private*, Thread::ThreadState s, const char* why); static void pop_bstack(Thread_private*, int oldstate); static void print_threads(); /// Cannot copy them Thread(const Thread&); Thread& operator=(const Thread&); }; } // End namespace SCIRun #endif
28.940701
82
0.677098
[ "object" ]
f96e79af0a5cc9a4090e9c5955a415207649a551
1,343
h
C
stage_1_code_generation/exercise3/exptree.h
himanshushkl691/SILC_Compiler-EXPL
90f51bf9705810c29374bdefe1119f91cc030c3b
[ "MIT" ]
5
2019-12-12T17:09:42.000Z
2021-01-23T14:32:58.000Z
stage_1_code_generation/exercise3/exptree.h
himanshushkl691/SILC_Compiler-EXPL
90f51bf9705810c29374bdefe1119f91cc030c3b
[ "MIT" ]
null
null
null
stage_1_code_generation/exercise3/exptree.h
himanshushkl691/SILC_Compiler-EXPL
90f51bf9705810c29374bdefe1119f91cc030c3b
[ "MIT" ]
1
2021-02-02T10:28:12.000Z
2021-02-02T10:28:12.000Z
//------------------------------------------Expression Tree Declaration Section-------------------------------------- struct ET_Node{ int val; char *oper; struct ET_Node *left,*right; }; struct ET_Node *makeLeafNode(int); struct ET_Node *makeOperatorNode(char,struct ET_Node *,struct ET_Node *); void postfix(struct ET_Node *); void prefix(struct ET_Node *); int evaluate(struct ET_Node *); //------------------------------------------------------------------------------------------------------------------------ //----------------Auxiliary Data Structure----------------- typedef struct vector{ int *arr; int size; int capacity; }vector; vector *init_vector(); vector *push_back(vector *,int); int size(vector *v); //--------------------------------------------------------- //-----------------------------------------Register Allocation Strategy--------------------------------------------------- #define reg_idx int int reg_pool[20]; void init_reg_pool(); //returns smallest i where Ri is free reg available in pool reg_idx getReg(); //releases greatest i where Ri is allocated register reg_idx freeReg(); reg_idx code_generator_util(FILE *,struct ET_Node *); void code_generator(FILE *,struct ET_Node *); //------------------------------------------------------------------------------------------------------------------------
35.342105
122
0.470588
[ "vector" ]
f97043e5055bbb0c250ee9743910278e27cc0012
4,746
h
C
include/sairoute.h
knightswim/goldengate-sai
0449c026b33d70b97ff51ff1c5a5b14d3ec9fd81
[ "Apache-2.0" ]
2
2017-12-25T09:19:00.000Z
2020-10-23T19:44:08.000Z
include/sairoute.h
knightswim/goldengate-sai
0449c026b33d70b97ff51ff1c5a5b14d3ec9fd81
[ "Apache-2.0" ]
null
null
null
include/sairoute.h
knightswim/goldengate-sai
0449c026b33d70b97ff51ff1c5a5b14d3ec9fd81
[ "Apache-2.0" ]
3
2016-07-15T00:21:52.000Z
2019-10-15T01:52:47.000Z
/* * Copyright (c) 2014 Microsoft Open Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT * LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS * FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. * * See the Apache Version 2.0 License for specific language governing * permissions and limitations under the License. * * Microsoft would like to thank the following companies for their review and * assistance with these files: Intel Corporation, Mellanox Technologies Ltd, * Dell Products, L.P., Facebook, Inc * * Module Name: * * sairoute.h * * Abstract: * * This module defines SAI Route Entry API * */ #if !defined (__SAIROUTE_H_) #define __SAIROUTE_H_ #include <saitypes.h> /** \defgroup SAIROUTE SAI - Route specific API definitions. * * \{ */ /** * @brief Attribute Id for sai route object */ typedef enum _sai_route_attr_t { /** READ-WRITE */ /** Packet action [sai_packet_action_t] (default to SAI_PACKET_ACTION_FORWARD) */ SAI_ROUTE_ATTR_PACKET_ACTION, /** Packet priority for trap/log actions [uint8_t] (default to 0) */ SAI_ROUTE_ATTR_TRAP_PRIORITY, /** Next hop or next hop group id for the packet or a router interface * in case of directly reachable route [sai_object_id_t] * The next hop id can be a generic next hop object, such as next hop, * next hop group. * Directly reachable routes are the IP subnets that are directly attached to the router. * For such routes, fill the router interface id to which the subnet is attached */ SAI_ROUTE_ATTR_NEXT_HOP_ID, /** User based Meta Data * [sai_uint32_t] (CREATE_AND_SET) * Value Range SAI_SWITCH_ATTR_ROUTE_USER_META_DATA_RANGE */ SAI_ROUTE_ATTR_META_DATA, /** Custom range base value */ SAI_ROUTE_ATTR_CUSTOM_RANGE_BASE = 0x10000000 } sai_route_attr_t; /** * @brief Unicast route entry */ typedef struct _sai_unicast_route_entry_t { sai_object_id_t vr_id; sai_ip_prefix_t destination; } sai_unicast_route_entry_t; /** * Routine Description: * @brief Create Route * * Arguments: * @param[in] unicast_route_entry - route entry * @param[in] attr_count - number of attributes * @param[in] attr_list - array of attributes * * Return Values: * @return SAI_STATUS_SUCCESS on success * Failure status code on error * * Note: IP prefix/mask expected in Network Byte Order. * */ typedef sai_status_t (*sai_create_route_fn)( _In_ const sai_unicast_route_entry_t* unicast_route_entry, _In_ uint32_t attr_count, _In_ const sai_attribute_t *attr_list ); /** * Routine Description: * @brief Remove Route * * Arguments: * @param[in] unicast_route_entry - route entry * * Return Values: * @return SAI_STATUS_SUCCESS on success * Failure status code on error * * Note: IP prefix/mask expected in Network Byte Order. */ typedef sai_status_t (*sai_remove_route_fn)( _In_ const sai_unicast_route_entry_t* unicast_route_entry ); /** * Routine Description: * @brief Set route attribute value * * Arguments: * @param[in] unicast_route_entry - route entry * @param[in] attr - attribute * * Return Values: * @return SAI_STATUS_SUCCESS on success * Failure status code on error */ typedef sai_status_t (*sai_set_route_attribute_fn)( _In_ const sai_unicast_route_entry_t* unicast_route_entry, _In_ const sai_attribute_t *attr ); /** * Routine Description: * @brief Get route attribute value * * Arguments: * @param[in] unicast_route_entry - route entry * @param[in] attr_count - number of attributes * @param[inout] attr_list - array of attributes * * Return Values: * @return SAI_STATUS_SUCCESS on success * Failure status code on error */ typedef sai_status_t (*sai_get_route_attribute_fn)( _In_ const sai_unicast_route_entry_t* unicast_route_entry, _In_ uint32_t attr_count, _Inout_ sai_attribute_t *attr_list ); /** * @brief Router entry methods table retrieved with sai_api_query() */ typedef struct _sai_route_api_t { sai_create_route_fn create_route; sai_remove_route_fn remove_route; sai_set_route_attribute_fn set_route_attribute; sai_get_route_attribute_fn get_route_attribute; } sai_route_api_t; /** * \} */ #endif // __SAIROUTE_H_
26.965909
93
0.707965
[ "object" ]
f97388faad42a5ed2ebfd80569664cff41a73401
1,032
h
C
code/userInput.h
zhaozheheng/Landmark_detect
4bc7bee54dcd90d4fdc5d0c6ac4012e48922ed15
[ "MIT" ]
null
null
null
code/userInput.h
zhaozheheng/Landmark_detect
4bc7bee54dcd90d4fdc5d0c6ac4012e48922ed15
[ "MIT" ]
null
null
null
code/userInput.h
zhaozheheng/Landmark_detect
4bc7bee54dcd90d4fdc5d0c6ac4012e48922ed15
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include <sstream> #include <iomanip> // C++ std library dependencies #include <chrono> // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include <thread> // std::this_thread // Other 3rdparty dependencies // GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string #include <gflags/gflags.h> // Allow Google Flags in Ubuntu 14 #ifndef GFLAGS_GFLAGS_H_ namespace gflags = google; #endif #include "Eigen/Dense" // OpenPose dependencies #include <openpose/headers.hpp> //#include <opencv/highgui.h> struct UserDatum : public op::Datum { bool boolThatUserNeedsForSomeReason; UserDatum(const bool boolThatUserNeedsForSomeReason_ = false) : boolThatUserNeedsForSomeReason{ boolThatUserNeedsForSomeReason_ } {} }; class userInput { public: userInput(); ~userInput(); bool display(const std::shared_ptr<std::vector<UserDatum>>& datumsPtr); void printKeypoints(const std::shared_ptr<std::vector<UserDatum>>& datumsPtr); };
25.8
91
0.729651
[ "vector" ]
f996da5bdd6e07693210aeb483c9d8357624b167
198,795
c
C
source/util_api/asn.1/components/asn1_x509/ansc_asn1_extensions.c
lgirdk/ccsp-common-library
8d912984e96f960df6dadb4b0e6bc76c76376776
[ "Apache-2.0" ]
4
2018-02-26T05:41:14.000Z
2019-12-20T07:31:39.000Z
source/util_api/asn.1/components/asn1_x509/ansc_asn1_extensions.c
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
null
null
null
source/util_api/asn.1/components/asn1_x509/ansc_asn1_extensions.c
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
3
2017-07-30T15:35:16.000Z
2020-08-18T20:44:08.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ /********************************************************************** MODULE: ansc_asn1_Extensions.c ASN.1 ANSC Code Generated by Cisco Systems, Inc. --------------------------------------------------------------- DESCRIPTION: The ASN.1 objects implemented in this file * ANSC_ASN1_EXTENSIONS * ANSC_ASN1_EXTENSION * ANSC_ASN1_AUTHORITYKEYIDENTIFIER * ANSC_ASN1_KEYIDENTIFIER * ANSC_ASN1_GENERALNAMES * ANSC_ASN1_GENERALNAME * ANSC_ASN1_ORADDRESS * ANSC_ASN1_EDIPARTYNAME * ANSC_ASN1_KEYUSAGE * ANSC_ASN1_EXTKEYUSAGESYNTAX * ANSC_ASN1_BASICCONSTRAINTS * ANSC_ASN1_PRIVATEKEYUSAGEPERIOD * ANSC_ASN1_CERTIFICATEPOLICIES * ANSC_ASN1_POLICYINFORMATION * ANSC_ASN1_POLICYQUALIFIERS * ANSC_ASN1_POLICYQUALIFIERINFO * ANSC_ASN1_POLICYQUALIFIER * ANSC_ASN1_USERNOTICE * ANSC_ASN1_NOTICEREFERENCE * ANSC_ASN1_DISPLAYTEXT * ANSC_ASN1_POLICYMAPPINGS * ANSC_ASN1_NAMECONSTRAINTS * ANSC_ASN1_GENERALSUBTREES * ANSC_ASN1_GENERALSUBTREE * ANSC_ASN1_POLICYCONSTRAINTS * ANSC_ASN1_SUBJECTDIRECTORYATTRIBUTES * ANSC_ASN1_CRLNUMBER * ANSC_ASN1_CRLDISTPOINTSSYNTAX * ANSC_ASN1_DISTRIBUTIONPOINT * ANSC_ASN1_DISTRIBUTIONPOINTNAME * ANSC_ASN1_REASONFLAGS * ANSC_ASN1_ISSUINGDISTRIBUTIONPOINT * ANSC_ASN1_AUTHORITYINFOACCESSSYNTAX * ANSC_ASN1_ACCESSDESCRIPTION * ANSC_ASN1_CRLREASON * ANSC_ASN1_HOLDINSTRUCTIONCODE * ANSC_ASN1_INVALIDITYDATE * ANSC_ASN1_POLICYMAPPING * ANSC_ASN1_NOTICENUMBERS * ANSC_ASN1_DELTACRLINDICATOR * ANSC_ASN1_ATTRIBUTESSYNTAX * ANSC_ASN1_BIOMETRICSSYNTAX * ANSC_ASN1_BIOMETRICDATA * ANSC_ASN1_TYPEOFBIOMETRICDATA * ANSC_ASN1_QCSTATEMENTSSYNTAX * ANSC_ASN1_QCSTATEMENT * ANSC_ASN1_ENTRUSTVERSIONINFO * ANSC_ASN1_EXTENSIONVALUE --------------------------------------------------------------- ENVIRONMENT: platform independent --------------------------------------------------------------- AUTHOR: ASNMAGIC ANSC CODE GENERATOR 1.0 --------------------------------------------------------------- REVISION HISTORY: * 05/07/2002 initial revision * 05/08/2002 add more apis for EXTENSION object **********************************************************************/ #include "ansc_asn1_advanced_local.h" /********************************************************************** OBJECT -- ANSC_ASN1_EXTENSIONS Extensions ::= SequenceOf Extension {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateExtensions ( ANSC_HANDLE hReserved ) { PANSC_ASN1_EXTENSIONS pThisObject = NULL; /* * Create the base ASN.1 object. */ if( hReserved != NULL) { pThisObject = (PANSC_ASN1_EXTENSIONS) AnscAsn1CreateSequenceOf ( hReserved ); } else { pThisObject = (PANSC_ASN1_EXTENSIONS) AnscAsn1CreateSequenceOf ( (ANSC_HANDLE)sizeof(ANSC_ASN1_EXTENSIONS) ); } if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_EXTENSIONS"); pThisObject->SetName(pThisObject, "Extensions"); pThisObject->Create = AnscAsn1CreateExtensions; pThisObject->CreateChild = AnscAsn1ExtensionsCreateChild; pThisObject->IsChildValid = AnscAsn1ExtensionsIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1ExtensionsCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateExtension(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1ExtensionsIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_EXTENSION", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_EXTENSION Extension ::= Sequence { extnID OID critical BOOL extnValue OctetString EXTRA: extensionValue ExtensionValue } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateExtension ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_EXTENSION pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_EXTENSION) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_EXTENSION) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_EXTENSION"); pThisObject->SetName(pThisObject, "Extension"); pThisObject->Create = AnscAsn1CreateExtension; pThisObject->CreateChildAttr = AnscAsn1ExtensionCreateChildAttr; pThisObject->GetChildName = AnscAsn1ExtensionGetChildName; pThisObject->CreateChildObject = AnscAsn1ExtensionCreateChildObject; pThisObject->CreateExtraChild = AnscAsn1ExtensionCreateExtraChild; pThisObject->GetExtraChildName = AnscAsn1ExtensionGetExtraChildName; pThisObject->IsCritical = AnscAsn1ExtensionIsCritical; pThisObject->GetExtensionType = AnscAsn1ExtensionGetExtensionType; pThisObject->uTotalChild = 3; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1ExtensionCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateBOOL(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 2: pThisObject = AnscAsn1CreateOctetString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1ExtensionCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1ExtensionGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"extnID"; case 1: return"critical"; case 2: return"extnValue"; } return ""; } ANSC_HANDLE AnscAsn1ExtensionCreateExtraChild ( ANSC_HANDLE hThisObject ) { UNREFERENCED_PARAMETER(hThisObject); return AnscAsn1CreateExtensionValue(NULL); } PCHAR AnscAsn1ExtensionGetExtraChildName ( ANSC_HANDLE hThisObject ) { UNREFERENCED_PARAMETER(hThisObject); return "extensionValue"; } /* * Manually added functions; */ BOOLEAN AnscAsn1ExtensionGetExtensionType ( ANSC_HANDLE hThisObject, PCHAR pOIDString ) { PANSC_ASN1_EXTENSION pThisObject = (PANSC_ASN1_EXTENSION)hThisObject; PANSC_ASN1_OIDEN pOIDObject; if( hThisObject == NULL || pOIDString == NULL) { return FALSE; } pOIDObject = (PANSC_ASN1_OIDEN)pThisObject->GetChildByIndex(pThisObject,0); return pOIDObject->GetStringOIDValue(pOIDObject, pOIDString); } BOOLEAN AnscAsn1ExtensionIsCritical ( ANSC_HANDLE hThisObject ) { PANSC_ASN1_EXTENSION pThisObject = (PANSC_ASN1_EXTENSION)hThisObject; PANSC_ASN1_BOOL pBoolObject; if( hThisObject == NULL) { return FALSE; } pBoolObject = (PANSC_ASN1_BOOL)pThisObject->GetChildByIndex(pThisObject,1); if( pBoolObject == NULL || pBoolObject->bOptional) { return FALSE; } return pBoolObject->GetBooleanValue(pBoolObject); } ANSC_HANDLE AnscAsn1ExtensionGenerate ( ANSC_HANDLE hReserved, PCHAR pOIDString, BOOLEAN bIsCritical, ANSC_HANDLE hExtValue ) { PANSC_ASN1_EXTENSION pThisObject = NULL; PANSC_ASN1_OBJECT pExtValue = (PANSC_ASN1_OBJECT)hExtValue; PANSC_ASN1_BOOL pCritical; PANSC_ASN1_OIDEN pOIDObject; PANSC_ASN1_STRING pStringObject; PCHAR pBuffer = NULL; PCHAR pBack = NULL; LONG length; PANSC_ASN1_CHOICE pExtra; if( pOIDString == NULL || hExtValue == NULL) { return NULL; } pThisObject = (PANSC_ASN1_EXTENSION) AnscAsn1CreateExtension(hReserved); if( pThisObject == NULL) { return NULL; } /* set the OID value */ pOIDObject = (PANSC_ASN1_OIDEN)pThisObject->GetChildByIndex(pThisObject,0); if( pOIDObject != NULL) { pOIDObject->SetStringOIDValue(pOIDObject, pOIDString); } /* set the critical value */ pCritical = (PANSC_ASN1_BOOL)pThisObject->GetChildByIndex(pThisObject,1); if( pCritical != NULL) { if( !bIsCritical) { /* set as optional, use default value "FALSE" */ pCritical->bOptional = TRUE; } else { pCritical->bOptional = FALSE; pCritical->SetBooleanValue(pCritical, TRUE); } } /* Set the extension value */ length = pExtValue->GetSizeOfEncoded(pExtValue); if( length < 0) { goto FAILED; } if( length > 0) { pBuffer = AnscAllocateMemory(length + 4); if( pBuffer == NULL) { goto FAILED; } pBack = pBuffer; if( ANSC_STATUS_SUCCESS != pExtValue->EncodingData(pExtValue, (PVOID*)&pBack)) { AnscFreeMemory(pBuffer); goto FAILED; } /* set to the string value */ pStringObject = (PANSC_ASN1_STRING)pThisObject->GetChildByIndex(pThisObject,2); if( pStringObject != NULL) { pStringObject->SetStringValue(pStringObject, (PUCHAR)pBuffer, length); } AnscFreeMemory(pBuffer); } /* Set the special child */ pExtra = (PANSC_ASN1_CHOICE)pThisObject->CreateExtraChild(pThisObject); if( pExtra != NULL) { pThisObject->SetExtraChild(pThisObject, pExtra, TRUE); pExtra->SetSelection ( pExtra, pExtra->GetChoiceFromOID(pExtra,pOIDString), hExtValue); } return pThisObject; FAILED: if( pThisObject != NULL) { pThisObject->AsnFree(pThisObject); } return NULL; } /********************************************************************** OBJECT -- ANSC_ASN1_AUTHORITYKEYIDENTIFIER AuthorityKeyIdentifier ::= Sequence { keyIdentifier [CON 0] IMP KeyIdentifier OPT authorityCertIssuer [CON 1] IMP GeneralNames OPT serialNumber [CON 2] IMP Integer OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateAuthorityKeyIdentifier ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_AUTHORITYKEYIDENTIFIER pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_AUTHORITYKEYIDENTIFIER) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_AUTHORITYKEYIDENTIFIER) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_AUTHORITYKEYIDENTIFIER"); pThisObject->SetName(pThisObject, "AuthorityKeyIdentifier"); pThisObject->Create = AnscAsn1CreateAuthorityKeyIdentifier; pThisObject->CreateChildAttr = AnscAsn1AuthorityKeyIdentifierCreateChildAttr; pThisObject->GetChildName = AnscAsn1AuthorityKeyIdentifierGetChildName; pThisObject->CreateChildObject = AnscAsn1AuthorityKeyIdentifierCreateChildObject; pThisObject->uTotalChild = 3; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1AuthorityKeyIdentifierCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateKeyIdentifier(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 2: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1AuthorityKeyIdentifierCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; case 2: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 2, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1AuthorityKeyIdentifierGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"keyIdentifier"; case 1: return"authorityCertIssuer"; case 2: return"serialNumber"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_KEYIDENTIFIER KeyIdentifier ::= OctetString **********************************************************************/ ANSC_HANDLE AnscAsn1CreateKeyIdentifier ( ANSC_HANDLE hReserved ) { PANSC_ASN1_KEYIDENTIFIER pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_KEYIDENTIFIER) AnscAsn1CreateOctetString ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_KEYIDENTIFIER"); pThisObject->SetName(pThisObject, "KeyIdentifier"); pThisObject->Create = AnscAsn1CreateKeyIdentifier; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_GENERALNAMES GeneralNames ::= SequenceOf GeneralName {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateGeneralNames ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_GENERALNAMES pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_GENERALNAMES) AnscAsn1CreateSequenceOf ( (ANSC_HANDLE)sizeof(ANSC_ASN1_GENERALNAMES) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_GENERALNAMES"); pThisObject->SetName(pThisObject, "GeneralNames"); pThisObject->Create = AnscAsn1CreateGeneralNames; pThisObject->CreateChild = AnscAsn1GeneralNamesCreateChild; pThisObject->IsChildValid = AnscAsn1GeneralNamesIsChildValid; pThisObject->AddAltName = AnscAsn1GeneralNamesAddAltName; pThisObject->AddKb5Name = AnscAsn1GeneralNamesAddKb5Name; pThisObject->GetKB5Name = AnscAsn1GeneralNamesGetKB5Name; pThisObject->GetAltNameByMask = AnscAsn1GeneralNamesGetAltNameByMask; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1CreateGeneralNamesWithAltName ( ANSC_HANDLE hReserved, PCHAR pAltName ) { PANSC_ASN1_GENERALNAMES pThisObject = NULL; pThisObject = (PANSC_ASN1_GENERALNAMES) AnscAsn1CreateGeneralNames(hReserved); if( pThisObject == NULL || pAltName == NULL) { return pThisObject; } if(!pThisObject->AddAltName(pThisObject, pAltName)) { AnscTrace("Invalid SubjectAltName : '%s'\n", pAltName); pThisObject->AsnFree(pThisObject); return NULL; } return pThisObject; } ANSC_HANDLE AnscAsn1CreateGeneralNamesWithKerberosName ( ANSC_HANDLE hReserved, ANSC_HANDLE hRealmName, ANSC_HANDLE hPrinName ) { PANSC_ASN1_GENERALNAMES pThisObject = NULL; pThisObject = (PANSC_ASN1_GENERALNAMES) AnscAsn1CreateGeneralNames(hReserved); if( pThisObject == NULL || hRealmName == NULL || hPrinName == NULL) { return pThisObject; } if(!pThisObject->AddKb5Name(pThisObject, hRealmName, hPrinName)) { AnscTrace("Failed to add the KB5 Name.\n"); pThisObject->AsnFree(pThisObject); return NULL; } return pThisObject; } ANSC_HANDLE AnscAsn1GeneralNamesCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateGeneralName(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1GeneralNamesIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_GENERALNAME", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /* * Manually added functions; */ BOOLEAN AnscAsn1GeneralNamesAddKb5Name ( ANSC_HANDLE hThisObject, ANSC_HANDLE hRealmName, ANSC_HANDLE hPrinName ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(hRealmName); UNREFERENCED_PARAMETER(hPrinName); #ifndef _NO_PKI_KB5_SUPPORT PKB5_PRINNAME_STRUCTURE pPrinInfo = (PKB5_PRINNAME_STRUCTURE)hPrinName; PKB5_REALM_STRUCTURE pRealm = (PKB5_REALM_STRUCTURE)hRealmName; PANSC_ASN1_GENERALNAME pGeneralName; PANSC_ASN1_OTHERNAME pOtherName; PANSC_ASN1_OTHERSTRING pOtherString; PANSC_ASN1_OIDEN pOIDObj; PANSC_ASN1_SEQUENCE pKB5Obj; PANSC_ASN1_OBJECT pValueObj; if( hThisObject == NULL ||hPrinName == NULL || hRealmName == NULL) { return FALSE; } /* init the principal name */ pOtherName = (PANSC_ASN1_OTHERNAME)AnscAsn1CreateOtherName(NULL); if( pOtherName == NULL) { goto EXIT; } pOIDObj = (PANSC_ASN1_OIDEN)pOtherName->GetChildByIndex(pOtherName, 0); if( pOIDObj != NULL) { /* krb5PrincipalName oid : "1.3.6.1.5.2.2" */ pOIDObj->SetStringOIDValue(pOIDObj, "1.3.6.1.5.2.2"); } pOtherString = (PANSC_ASN1_OTHERSTRING)pOtherName->GetChildByIndex(pOtherName, 1); pOtherString->SetAndCreateSelection(pOtherString, OTHERSTRING_MASK_KERBEROS); /* init the KB5 name */ pKB5Obj = (PANSC_ASN1_SEQUENCE)pOtherString->hSelection; if( pKB5Obj == NULL) { pOtherName->AsnFree(pOtherName); goto EXIT; } /* the realm */ pValueObj = (PANSC_ASN1_OBJECT)pKB5Obj->GetChildByIndex(pKB5Obj, 0); if( pValueObj != NULL) { KB5UtilitySetRealmName(pValueObj, hRealmName); } /* the principal name */ pValueObj = (PANSC_ASN1_OBJECT)pKB5Obj->GetChildByIndex(pKB5Obj, 1); if( pValueObj != NULL) { KB5UtilitySetPrincipalName(pValueObj, hPrinName); } /* create the general name */ pGeneralName = (PANSC_ASN1_GENERALNAME)AnscAsn1CreateGeneralName(NULL); if( pGeneralName == NULL) { pOtherName->AsnFree(pOtherName); goto EXIT; } pGeneralName->SetSelection ( pGeneralName, GENERALNAME_MASK_OTHERNAME, pOtherName ); pThisObject->AddChild(pThisObject, pGeneralName); return TRUE; EXIT: #endif return FALSE; } BOOLEAN AnscAsn1GeneralNamesAddAltName ( ANSC_HANDLE hThisObject, PCHAR pAltName ) { PANSC_ASN1_GENERALNAMES pThisObject = (PANSC_ASN1_GENERALNAMES)hThisObject; PPKI_ALTNAME_PARSER pAltParser; PCHAR pValue; PANSC_ASN1_OCTETSTRING pOctetString; PANSC_ASN1_IA5STRING pIA5String; PANSC_ASN1_GENERALNAME pGeneralName; ULONG i, type; if( pThisObject == NULL || pAltName == NULL || AnscSizeOfString(pAltName) <= 0) { return FALSE; } pAltParser = (PPKI_ALTNAME_PARSER)PKIParsingAltName(pAltName); if( pAltParser == NULL) { return FALSE; } for( i = 0; i < pAltParser->GetTotalBlock(pAltParser); i ++) { type = pAltParser->GetBlockType(pAltParser, i); pValue= (PCHAR)pAltParser->GetBlockValue(pAltParser, i); if( type != ALT_TYPE_IP_NAME) { pIA5String =(PANSC_ASN1_IA5STRING)AnscAsn1CreateIA5String(NULL); if( pIA5String == NULL) { return FALSE; } pIA5String->SetStringValue(pIA5String, (PUCHAR)pValue, AnscSizeOfString(pValue)); pGeneralName = (PANSC_ASN1_GENERALNAME)AnscAsn1CreateGeneralName(NULL); if( pGeneralName == NULL) { pIA5String->AsnFree(pIA5String); return FALSE; } if( type == ALT_TYPE_EMAIL_NAME) { pGeneralName->SetSelection ( pGeneralName, GENERALNAME_MASK_RFC822NAME, pIA5String ); } else if( type == ALT_TYPE_DNS_NAME) { pGeneralName->SetSelection ( pGeneralName, GENERALNAME_MASK_DNSNAME, pIA5String ); } else { pGeneralName->SetSelection ( pGeneralName, GENERALNAME_MASK_URI, pIA5String ); } pThisObject->AddChild(pThisObject, pGeneralName); } else { pOctetString =(PANSC_ASN1_OCTETSTRING)AnscAsn1CreateOctetString(NULL); if( pOctetString == NULL) { return FALSE; } pOctetString->SetStringValue ( pOctetString, (PUCHAR)(pValue + 1), (ULONG)pValue[0] ); pGeneralName = (PANSC_ASN1_GENERALNAME)AnscAsn1CreateGeneralName(NULL); if( pGeneralName == NULL) { pOctetString->AsnFree(pOctetString); return FALSE; } pGeneralName->SetSelection ( pGeneralName, GENERALNAME_MASK_IPADDRESS, pOctetString ); pThisObject->AddChild(pThisObject, pGeneralName); } } pAltParser->Remove(pAltParser); return TRUE; } ANSC_STATUS AnscAsn1GeneralNamesGetKB5Name ( ANSC_HANDLE hThisObject, ANSC_HANDLE hRealmName, ANSC_HANDLE hPrinName ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(hRealmName); UNREFERENCED_PARAMETER(hPrinName); #ifndef _NO_PKI_KB5_SUPPORT PANSC_ASN1_GENERALNAME pGeneralName; PANSC_ASN1_OTHERNAME pOtherName; PANSC_ASN1_OTHERSTRING pOtherString; PANSC_ASN1_SEQUENCE pKB5Obj; PANSC_ASN1_OBJECT pValueObj; ULONG i; if( hThisObject == NULL || hPrinName == NULL || hRealmName == NULL) { return ANSC_STATUS_FAILURE; } for( i = 0; i < pThisObject->GetChildCount(pThisObject); i ++) { pGeneralName = (PANSC_ASN1_GENERALNAME) pThisObject->GetChildByIndex(pThisObject, i); if( pGeneralName != NULL && pGeneralName->lSelect == GENERALNAME_MASK_OTHERNAME) { pOtherName = (PANSC_ASN1_OTHERNAME)pGeneralName->hSelection; if( pOtherName == NULL) { return ANSC_STATUS_FAILURE; } pOtherString = (PANSC_ASN1_OTHERSTRING) pOtherName->GetChildByIndex(pOtherName, 1); if( pOtherString == NULL || pOtherString->lSelect != OTHERSTRING_MASK_KERBEROS) { return ANSC_STATUS_FAILURE; } pKB5Obj = (PANSC_ASN1_SEQUENCE)pOtherString->hSelection; if( pKB5Obj == NULL) { return ANSC_STATUS_FAILURE; } /* get the value */ pValueObj = (PANSC_ASN1_OBJECT)pKB5Obj->GetChildByIndex(pKB5Obj, 0); if( pValueObj != NULL) { KB5UtilityGetRealmName(pValueObj, hRealmName); } pValueObj = (PANSC_ASN1_OBJECT)pKB5Obj->GetChildByIndex(pKB5Obj, 1); if( pValueObj != NULL) { KB5UtilityGetPrincipalName(pValueObj, hPrinName); } return ANSC_STATUS_SUCCESS; } } #endif return ANSC_STATUS_FAILURE; } ANSC_STATUS AnscAsn1GeneralNamesGetAltNameByMask ( ANSC_HANDLE hThisObject, ULONG typeMask, PUCHAR pOutBuffer, PULONG pLength ) { PANSC_ASN1_GENERALNAMES pThisObject = (PANSC_ASN1_GENERALNAMES)hThisObject; PANSC_ASN1_GENERALNAME pNameObject; ULONG i; PANSC_ASN1_OBJECT pValueObj; PANSC_ASN1_STRING pStrObj; if( hThisObject == NULL || pOutBuffer == NULL || pLength == NULL) { return ANSC_STATUS_FAILURE; } if( typeMask == GENERALNAME_MASK_OTHERNAME || typeMask == GENERALNAME_MASK_X400ADDRESS || typeMask == GENERALNAME_MASK_DIRECTORYNAME || typeMask == GENERALNAME_MASK_EDIPARTYNAME || typeMask == GENERALNAME_MASK_REGISTEREDID) { return ANSC_STATUS_FAILURE; } for( i = 0; i < pThisObject->GetChildCount(pThisObject); i ++) { pNameObject = (PANSC_ASN1_GENERALNAME) pThisObject->GetChildByIndex(pThisObject, i); if( pNameObject != NULL && pNameObject->lSelect == (LONG)typeMask) { pValueObj = (PANSC_ASN1_OBJECT)pNameObject->hSelection; while( pValueObj != NULL && IsObjectChoiceType(pValueObj->uType)) { pValueObj = (PANSC_ASN1_OBJECT) ((PANSC_ASN1_CHOICE)pValueObj)->hSelection; } pStrObj = (PANSC_ASN1_STRING)pValueObj; if( pStrObj == NULL || pStrObj->uLength > *pLength) { return ANSC_STATUS_FAILURE; } *pLength = pStrObj->uLength; AnscCopyMemory ( pOutBuffer, pStrObj->GetValueBuffer(pStrObj), *pLength ); return ANSC_STATUS_SUCCESS; } } return ANSC_STATUS_FAILURE; } /********************************************************************** OBJECT -- ANSC_ASN1_GENERALNAME GeneralName ::= Choice { otherName [CON 0] IMP OtherName rfc822Name [CON 1] IMP IA5String dNSName [CON 2] IMP IA5String x400Address [CON 3] IMP ORAddress directoryName [CON 4] IMP Name ediPartyName [CON 5] IMP EDIPartyName uri [CON 6] IMP IA5String iPAddress [CON 7] IMP OctetString registeredID [CON 8] IMP OID } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateGeneralName ( ANSC_HANDLE hReserved ) { PANSC_ASN1_GENERALNAME pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_GENERALNAME) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_GENERALNAME"); pThisObject->SetName(pThisObject, "GeneralName"); pThisObject->Create = AnscAsn1CreateGeneralName; pThisObject->CreateSelection = AnscAsn1GeneralNameCreateSelection; pThisObject->GetSelectionName = AnscAsn1GeneralNameGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1GeneralNameCreateSelectionAttr; pThisObject->GetChoiceTagValue = AnscAsn1GeneralNameGetChoiceTagValue; pThisObject->uTotalChoice = GENERALNAME_MAXI_MASK + 1; pThisObject->bChoiceByOID = FALSE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1GeneralNameCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case GENERALNAME_MASK_OTHERNAME: pThisObject = AnscAsn1CreateOtherName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_RFC822NAME: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_DNSNAME: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_X400ADDRESS: pThisObject = AnscAsn1CreateORAddress(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_DIRECTORYNAME: pThisObject = AnscAsn1CreateName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_EDIPARTYNAME: pThisObject = AnscAsn1CreateEDIPartyName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_URI: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_IPADDRESS: pThisObject = AnscAsn1CreateOctetString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case GENERALNAME_MASK_REGISTEREDID: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; } return pThisObject; } PCHAR AnscAsn1GeneralNameGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case GENERALNAME_MASK_OTHERNAME: return"otherName"; case GENERALNAME_MASK_RFC822NAME: return"rfc822Name"; case GENERALNAME_MASK_DNSNAME: return"dNSName"; case GENERALNAME_MASK_X400ADDRESS: return"x400Address"; case GENERALNAME_MASK_DIRECTORYNAME: return"directoryName"; case GENERALNAME_MASK_EDIPARTYNAME: return"ediPartyName"; case GENERALNAME_MASK_URI: return"uri"; case GENERALNAME_MASK_IPADDRESS: return"iPAddress"; case GENERALNAME_MASK_REGISTEREDID: return"registeredID"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1GeneralNameCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( selType ) { case GENERALNAME_MASK_OTHERNAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_RFC822NAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_DNSNAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 2, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_X400ADDRESS: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 3, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_DIRECTORYNAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 4, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_EDIPARTYNAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 5, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_URI: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 6, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_IPADDRESS: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 7, IMPLICIT_TYPE ); break; case GENERALNAME_MASK_REGISTEREDID: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 8, IMPLICIT_TYPE ); break; } return pAttrObject; } BOOLEAN AnscAsn1GeneralNameGetChoiceTagValue ( ANSC_HANDLE hThisObject, ULONG uIndex, PASN_OBJECT_FORM_TYPE pAttr, PULONG pTagValue ) { UNREFERENCED_PARAMETER(hThisObject); if( pAttr == NULL || pTagValue == NULL) { return FALSE; } switch ( uIndex ) { case GENERALNAME_MASK_OTHERNAME: *pAttr = CONTEXT_FORM; *pTagValue = 0; return TRUE; case GENERALNAME_MASK_RFC822NAME: *pAttr = CONTEXT_FORM; *pTagValue = 1; return TRUE; case GENERALNAME_MASK_DNSNAME: *pAttr = CONTEXT_FORM; *pTagValue = 2; return TRUE; case GENERALNAME_MASK_X400ADDRESS: *pAttr = CONTEXT_FORM; *pTagValue = 3; return TRUE; case GENERALNAME_MASK_DIRECTORYNAME: *pAttr = CONTEXT_FORM; *pTagValue = 4; return TRUE; case GENERALNAME_MASK_EDIPARTYNAME: *pAttr = CONTEXT_FORM; *pTagValue = 5; return TRUE; case GENERALNAME_MASK_URI: *pAttr = CONTEXT_FORM; *pTagValue = 6; return TRUE; case GENERALNAME_MASK_IPADDRESS: *pAttr = CONTEXT_FORM; *pTagValue = 7; return TRUE; case GENERALNAME_MASK_REGISTEREDID: *pAttr = CONTEXT_FORM; *pTagValue = 8; return TRUE; } return FALSE; } /********************************************************************** OBJECT -- ANSC_ASN1_ORADDRESS ORAddress ::= OctetString **********************************************************************/ ANSC_HANDLE AnscAsn1CreateORAddress ( ANSC_HANDLE hReserved ) { PANSC_ASN1_ORADDRESS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_ORADDRESS) AnscAsn1CreateOctetString ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_ORADDRESS"); pThisObject->SetName(pThisObject, "ORAddress"); pThisObject->Create = AnscAsn1CreateORAddress; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_EDIPARTYNAME EDIPartyName ::= Sequence { nameAssigner [CON 0] IMP DirectoryString OPT partyName [CON 1] IMP DirectoryString } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateEDIPartyName ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_EDIPARTYNAME pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_EDIPARTYNAME) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_EDIPARTYNAME) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_EDIPARTYNAME"); pThisObject->SetName(pThisObject, "EDIPartyName"); pThisObject->Create = AnscAsn1CreateEDIPartyName; pThisObject->CreateChildAttr = AnscAsn1EDIPartyNameCreateChildAttr; pThisObject->GetChildName = AnscAsn1EDIPartyNameGetChildName; pThisObject->CreateChildObject = AnscAsn1EDIPartyNameCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1EDIPartyNameCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateDirectoryString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateDirectoryString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1EDIPartyNameCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1EDIPartyNameGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"nameAssigner"; case 1: return"partyName"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_KEYUSAGE KeyUsage ::= BitString **********************************************************************/ ANSC_HANDLE AnscAsn1CreateKeyUsage ( ANSC_HANDLE hReserved ) { PANSC_ASN1_KEYUSAGE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_KEYUSAGE) AnscAsn1CreateBitString ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_KEYUSAGE"); pThisObject->SetName(pThisObject, "KeyUsage"); pThisObject->Create = AnscAsn1CreateKeyUsage; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_EXTKEYUSAGESYNTAX ExtKeyUsageSyntax ::= SequenceOf OID {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateExtKeyUsageSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_EXTKEYUSAGESYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_EXTKEYUSAGESYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_EXTKEYUSAGESYNTAX"); pThisObject->SetName(pThisObject, "ExtKeyUsageSyntax"); pThisObject->Create = AnscAsn1CreateExtKeyUsageSyntax; pThisObject->CreateChild = AnscAsn1ExtKeyUsageSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1ExtKeyUsageSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1ExtKeyUsageSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1ExtKeyUsageSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_OID", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } if( pChild->uType != 0x06) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_BASICCONSTRAINTS BasicConstraints ::= Sequence { cA BOOL DEF (FALSE) pathLenConstraint Integer OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateBasicConstraints ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_BASICCONSTRAINTS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_BASICCONSTRAINTS) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_BASICCONSTRAINTS) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_BASICCONSTRAINTS"); pThisObject->SetName(pThisObject, "BasicConstraints"); pThisObject->Create = AnscAsn1CreateBasicConstraints; pThisObject->CreateChildAttr = AnscAsn1BasicConstraintsCreateChildAttr; pThisObject->GetChildName = AnscAsn1BasicConstraintsGetChildName; pThisObject->CreateChildObject = AnscAsn1BasicConstraintsCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1BasicConstraintsCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateBOOL(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1BasicConstraintsCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1BasicConstraintsGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"cA"; case 1: return"pathLenConstraint"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_PRIVATEKEYUSAGEPERIOD PrivateKeyUsagePeriod ::= Sequence { notBefore [CON 0] IMP GeneralizedTime OPT notAfter [CON 1] IMP GeneralizedTime OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePrivateKeyUsagePeriod ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_PRIVATEKEYUSAGEPERIOD pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_PRIVATEKEYUSAGEPERIOD) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_PRIVATEKEYUSAGEPERIOD) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_PRIVATEKEYUSAGEPERIOD"); pThisObject->SetName(pThisObject, "PrivateKeyUsagePeriod"); pThisObject->Create = AnscAsn1CreatePrivateKeyUsagePeriod; pThisObject->CreateChildAttr = AnscAsn1PrivateKeyUsagePeriodCreateChildAttr; pThisObject->GetChildName = AnscAsn1PrivateKeyUsagePeriodGetChildName; pThisObject->CreateChildObject = AnscAsn1PrivateKeyUsagePeriodCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PrivateKeyUsagePeriodCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateGeneralizedTime(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateGeneralizedTime(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1PrivateKeyUsagePeriodCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1PrivateKeyUsagePeriodGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"notBefore"; case 1: return"notAfter"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_CERTIFICATEPOLICIES CertificatePolicies ::= SequenceOf PolicyInformation {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateCertificatePolicies ( ANSC_HANDLE hReserved ) { PANSC_ASN1_CERTIFICATEPOLICIES pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_CERTIFICATEPOLICIES) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_CERTIFICATEPOLICIES"); pThisObject->SetName(pThisObject, "CertificatePolicies"); pThisObject->Create = AnscAsn1CreateCertificatePolicies; pThisObject->CreateChild = AnscAsn1CertificatePoliciesCreateChild; pThisObject->IsChildValid = AnscAsn1CertificatePoliciesIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1CertificatePoliciesCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreatePolicyInformation(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1CertificatePoliciesIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_POLICYINFORMATION", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYINFORMATION PolicyInformation ::= Sequence { policyIdentifier OID policyQualifiers PolicyQualifiers } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyInformation ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_POLICYINFORMATION pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYINFORMATION) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_POLICYINFORMATION) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYINFORMATION"); pThisObject->SetName(pThisObject, "PolicyInformation"); pThisObject->Create = AnscAsn1CreatePolicyInformation; pThisObject->CreateChildAttr = AnscAsn1PolicyInformationCreateChildAttr; pThisObject->GetChildName = AnscAsn1PolicyInformationGetChildName; pThisObject->CreateChildObject = AnscAsn1PolicyInformationCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyInformationCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreatePolicyQualifiers(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1PolicyInformationCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1PolicyInformationGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"policyIdentifier"; case 1: return"policyQualifiers"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYQUALIFIERS PolicyQualifiers ::= SequenceOf PolicyQualifierInfo {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyQualifiers ( ANSC_HANDLE hReserved ) { PANSC_ASN1_POLICYQUALIFIERS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYQUALIFIERS) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYQUALIFIERS"); pThisObject->SetName(pThisObject, "PolicyQualifiers"); pThisObject->Create = AnscAsn1CreatePolicyQualifiers; pThisObject->CreateChild = AnscAsn1PolicyQualifiersCreateChild; pThisObject->IsChildValid = AnscAsn1PolicyQualifiersIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyQualifiersCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreatePolicyQualifierInfo(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1PolicyQualifiersIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_POLICYQUALIFIERINFO", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYQUALIFIERINFO PolicyQualifierInfo ::= Sequence { policyQualifierID OID qualifier PolicyQualifier } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyQualifierInfo ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_POLICYQUALIFIERINFO pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYQUALIFIERINFO) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_POLICYQUALIFIERINFO) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYQUALIFIERINFO"); pThisObject->SetName(pThisObject, "PolicyQualifierInfo"); pThisObject->Create = AnscAsn1CreatePolicyQualifierInfo; pThisObject->CreateChildAttr = AnscAsn1PolicyQualifierInfoCreateChildAttr; pThisObject->GetChildName = AnscAsn1PolicyQualifierInfoGetChildName; pThisObject->CreateChildObject = AnscAsn1PolicyQualifierInfoCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyQualifierInfoCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreatePolicyQualifier(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1PolicyQualifierInfoCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1PolicyQualifierInfoGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"policyQualifierID"; case 1: return"qualifier"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYQUALIFIER PolicyQualifier ::= Choice { userNotice UserNotice cpsuri IA5String } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyQualifier ( ANSC_HANDLE hReserved ) { PANSC_ASN1_POLICYQUALIFIER pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYQUALIFIER) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYQUALIFIER"); pThisObject->SetName(pThisObject, "PolicyQualifier"); pThisObject->Create = AnscAsn1CreatePolicyQualifier; pThisObject->CreateSelection = AnscAsn1PolicyQualifierCreateSelection; pThisObject->GetSelectionName = AnscAsn1PolicyQualifierGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1PolicyQualifierCreateSelectionAttr; pThisObject->GetChoiceFromOID = AnscAsn1PolicyQualifierGetChoiceByOID; pThisObject->GetOIDValueByMask = AnscAsn1PolicyQualifierGetOIDValueByMask; pThisObject->uTotalChoice = POLICYQUALIFIER_MAXI_MASK + 1; pThisObject->bChoiceByOID = TRUE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyQualifierCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case POLICYQUALIFIER_MASK_USERNOTICE: pThisObject = AnscAsn1CreateUserNotice(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case POLICYQUALIFIER_MASK_CPSURI: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; } return pThisObject; } PCHAR AnscAsn1PolicyQualifierGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case POLICYQUALIFIER_MASK_USERNOTICE: return"userNotice"; case POLICYQUALIFIER_MASK_CPSURI: return"cpsuri"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1PolicyQualifierCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(selType); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } LONG AnscAsn1PolicyQualifierGetChoiceByOID ( ANSC_HANDLE hThisObject, PCHAR pOIDString ) { UNREFERENCED_PARAMETER(hThisObject); if( pOIDString == NULL) return -1; if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.2.2",FALSE)) { return POLICYQUALIFIER_MASK_USERNOTICE; } else if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.2.1",FALSE)) { return POLICYQUALIFIER_MASK_CPSURI; } return -1; } PCHAR AnscAsn1PolicyQualifierGetOIDValueByMask ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case POLICYQUALIFIER_MASK_USERNOTICE: return "1.3.6.1.5.5.7.2.2"; case POLICYQUALIFIER_MASK_CPSURI: return "1.3.6.1.5.5.7.2.1"; } return NULL; } /********************************************************************** OBJECT -- ANSC_ASN1_USERNOTICE UserNotice ::= Sequence { noticeRef NoticeReference explicitText DisplayText } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateUserNotice ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_USERNOTICE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_USERNOTICE) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_USERNOTICE) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_USERNOTICE"); pThisObject->SetName(pThisObject, "UserNotice"); pThisObject->Create = AnscAsn1CreateUserNotice; pThisObject->CreateChildAttr = AnscAsn1UserNoticeCreateChildAttr; pThisObject->GetChildName = AnscAsn1UserNoticeGetChildName; pThisObject->CreateChildObject = AnscAsn1UserNoticeCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1UserNoticeCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateNoticeReference(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateDisplayText(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1UserNoticeCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1UserNoticeGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"noticeRef"; case 1: return"explicitText"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_NOTICEREFERENCE NoticeReference ::= Sequence { organization DisplayText noticeNumbers NoticeNumbers } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateNoticeReference ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_NOTICEREFERENCE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_NOTICEREFERENCE) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_NOTICEREFERENCE) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_NOTICEREFERENCE"); pThisObject->SetName(pThisObject, "NoticeReference"); pThisObject->Create = AnscAsn1CreateNoticeReference; pThisObject->CreateChildAttr = AnscAsn1NoticeReferenceCreateChildAttr; pThisObject->GetChildName = AnscAsn1NoticeReferenceGetChildName; pThisObject->CreateChildObject = AnscAsn1NoticeReferenceCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1NoticeReferenceCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateDisplayText(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateNoticeNumbers(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1NoticeReferenceCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1NoticeReferenceGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"organization"; case 1: return"noticeNumbers"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_DISPLAYTEXT DisplayText ::= Choice { visibleString VisibleString bmpString BMPString utf8String UTF8String ia5String IA5String } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateDisplayText ( ANSC_HANDLE hReserved ) { PANSC_ASN1_DISPLAYTEXT pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_DISPLAYTEXT) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_DISPLAYTEXT"); pThisObject->SetName(pThisObject, "DisplayText"); pThisObject->Create = AnscAsn1CreateDisplayText; pThisObject->CreateSelection = AnscAsn1DisplayTextCreateSelection; pThisObject->GetSelectionName = AnscAsn1DisplayTextGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1DisplayTextCreateSelectionAttr; pThisObject->GetChoiceTagValue = AnscAsn1DisplayTextGetChoiceTagValue; pThisObject->uTotalChoice = DISPLAYTEXT_MAXI_MASK + 1; pThisObject->bChoiceByOID = FALSE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1DisplayTextCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case DISPLAYTEXT_MASK_VISIBLESTRING: pThisObject = AnscAsn1CreateVisibleString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case DISPLAYTEXT_MASK_BMPSTRING: pThisObject = AnscAsn1CreateBMPString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case DISPLAYTEXT_MASK_UTF8STRING: pThisObject = AnscAsn1CreateUTF8String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case DISPLAYTEXT_MASK_IA5STRING: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PCHAR AnscAsn1DisplayTextGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case DISPLAYTEXT_MASK_VISIBLESTRING: return"visibleString"; case DISPLAYTEXT_MASK_BMPSTRING: return"bmpString"; case DISPLAYTEXT_MASK_UTF8STRING: return"utf8String"; case DISPLAYTEXT_MASK_IA5STRING: return"ia5String"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1DisplayTextCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( selType ) { case DISPLAYTEXT_MASK_VISIBLESTRING: break; case DISPLAYTEXT_MASK_BMPSTRING: break; case DISPLAYTEXT_MASK_UTF8STRING: break; case DISPLAYTEXT_MASK_IA5STRING: break; } return pAttrObject; } BOOLEAN AnscAsn1DisplayTextGetChoiceTagValue ( ANSC_HANDLE hThisObject, ULONG uIndex, PASN_OBJECT_FORM_TYPE pAttr, PULONG pTagValue ) { UNREFERENCED_PARAMETER(hThisObject); if( pAttr == NULL || pTagValue == NULL) { return FALSE; } switch ( uIndex ) { case DISPLAYTEXT_MASK_VISIBLESTRING: *pAttr = UNIVERSAL_FORM; *pTagValue = ASN1_VISIBLESTRING_TYPE; return TRUE; case DISPLAYTEXT_MASK_BMPSTRING: *pAttr = UNIVERSAL_FORM; *pTagValue = ASN1_BMPSTRING_TYPE; return TRUE; case DISPLAYTEXT_MASK_UTF8STRING: *pAttr = UNIVERSAL_FORM; *pTagValue = ASN1_UTF8STRING_TYPE; return TRUE; case DISPLAYTEXT_MASK_IA5STRING: *pAttr = UNIVERSAL_FORM; *pTagValue = ASN1_IA5STRING_TYPE; return TRUE; } return FALSE; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYMAPPINGS PolicyMappings ::= SequenceOf PolicyMapping {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyMappings ( ANSC_HANDLE hReserved ) { PANSC_ASN1_POLICYMAPPINGS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYMAPPINGS) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYMAPPINGS"); pThisObject->SetName(pThisObject, "PolicyMappings"); pThisObject->Create = AnscAsn1CreatePolicyMappings; pThisObject->CreateChild = AnscAsn1PolicyMappingsCreateChild; pThisObject->IsChildValid = AnscAsn1PolicyMappingsIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyMappingsCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreatePolicyMapping(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1PolicyMappingsIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_POLICYMAPPING", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_NAMECONSTRAINTS NameConstraints ::= Sequence { permittedSubtrees [CON 0] IMP GeneralSubtrees OPT excludedSubtrees [CON 1] IMP GeneralSubtrees OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateNameConstraints ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_NAMECONSTRAINTS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_NAMECONSTRAINTS) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_NAMECONSTRAINTS) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_NAMECONSTRAINTS"); pThisObject->SetName(pThisObject, "NameConstraints"); pThisObject->Create = AnscAsn1CreateNameConstraints; pThisObject->CreateChildAttr = AnscAsn1NameConstraintsCreateChildAttr; pThisObject->GetChildName = AnscAsn1NameConstraintsGetChildName; pThisObject->CreateChildObject = AnscAsn1NameConstraintsCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1NameConstraintsCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateGeneralSubtrees(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateGeneralSubtrees(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1NameConstraintsCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1NameConstraintsGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"permittedSubtrees"; case 1: return"excludedSubtrees"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_GENERALSUBTREES GeneralSubtrees ::= SequenceOf GeneralSubTree {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateGeneralSubtrees ( ANSC_HANDLE hReserved ) { PANSC_ASN1_GENERALSUBTREES pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_GENERALSUBTREES) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_GENERALSUBTREES"); pThisObject->SetName(pThisObject, "GeneralSubtrees"); pThisObject->Create = AnscAsn1CreateGeneralSubtrees; pThisObject->CreateChild = AnscAsn1GeneralSubtreesCreateChild; pThisObject->IsChildValid = AnscAsn1GeneralSubtreesIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1GeneralSubtreesCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateGeneralSubTree(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1GeneralSubtreesIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_GENERALSUBTREE", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_GENERALSUBTREE GeneralSubTree ::= Sequence { base GeneralName minimum [CON 0] IMP Integer DEF maximum [CON 1] IMP Integer OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateGeneralSubTree ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_GENERALSUBTREE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_GENERALSUBTREE) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_GENERALSUBTREE) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_GENERALSUBTREE"); pThisObject->SetName(pThisObject, "GeneralSubTree"); pThisObject->Create = AnscAsn1CreateGeneralSubTree; pThisObject->CreateChildAttr = AnscAsn1GeneralSubTreeCreateChildAttr; pThisObject->GetChildName = AnscAsn1GeneralSubTreeGetChildName; pThisObject->CreateChildObject = AnscAsn1GeneralSubTreeCreateChildObject; pThisObject->uTotalChild = 3; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1GeneralSubTreeCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateGeneralName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 2: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1GeneralSubTreeCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 2: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1GeneralSubTreeGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"base"; case 1: return"minimum"; case 2: return"maximum"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYCONSTRAINTS PolicyConstraints ::= Sequence { requireExplicitPolicy [CON 0] IMP Integer OPT inhibitPolicyMapping [CON 1] IMP Integer OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyConstraints ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_POLICYCONSTRAINTS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYCONSTRAINTS) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_POLICYCONSTRAINTS) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYCONSTRAINTS"); pThisObject->SetName(pThisObject, "PolicyConstraints"); pThisObject->Create = AnscAsn1CreatePolicyConstraints; pThisObject->CreateChildAttr = AnscAsn1PolicyConstraintsCreateChildAttr; pThisObject->GetChildName = AnscAsn1PolicyConstraintsGetChildName; pThisObject->CreateChildObject = AnscAsn1PolicyConstraintsCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyConstraintsCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1PolicyConstraintsCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1PolicyConstraintsGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { if( hThisObject == NULL) { return NULL; } switch ( index ) { case 0: return"requireExplicitPolicy"; case 1: return"inhibitPolicyMapping"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_SUBJECTDIRECTORYATTRIBUTES SubjectDirectoryAttributes ::= SequenceOf Attribute {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateSubjectDirectoryAttributes ( ANSC_HANDLE hReserved ) { PANSC_ASN1_SUBJECTDIRECTORYATTRIBUTES pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_SUBJECTDIRECTORYATTRIBUTES) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_SUBJECTDIRECTORYATTRIBUTES"); pThisObject->SetName(pThisObject, "SubjectDirectoryAttributes"); pThisObject->Create = AnscAsn1CreateSubjectDirectoryAttributes; pThisObject->CreateChild = AnscAsn1SubjectDirectoryAttributesCreateChild; pThisObject->IsChildValid = AnscAsn1SubjectDirectoryAttributesIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1SubjectDirectoryAttributesCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateAttribute(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1SubjectDirectoryAttributesIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_ATTRIBUTE", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_CRLNUMBER CRLNumber ::= Integer **********************************************************************/ ANSC_HANDLE AnscAsn1CreateCRLNumber ( ANSC_HANDLE hReserved ) { PANSC_ASN1_CRLNUMBER pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_CRLNUMBER) AnscAsn1CreateInteger ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_CRLNUMBER"); pThisObject->SetName(pThisObject, "CRLNumber"); pThisObject->Create = AnscAsn1CreateCRLNumber; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_CRLDISTPOINTSSYNTAX CRLDistPointsSyntax ::= SequenceOf DistributionPoint {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateCRLDistPointsSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_CRLDISTPOINTSSYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_CRLDISTPOINTSSYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_CRLDISTPOINTSSYNTAX"); pThisObject->SetName(pThisObject, "CRLDistPointsSyntax"); pThisObject->Create = AnscAsn1CreateCRLDistPointsSyntax; pThisObject->CreateChild = AnscAsn1CRLDistPointsSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1CRLDistPointsSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1CRLDistPointsSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateDistributionPoint(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1CRLDistPointsSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_DISTRIBUTIONPOINT", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_DISTRIBUTIONPOINT DistributionPoint ::= Sequence { distributionPoint [CON 0] IMP DistributionPointName OPT reasons [CON 1] IMP ReasonFlags OPT cRLIssuer [CON 2] IMP GeneralNames OPT } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateDistributionPoint ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_DISTRIBUTIONPOINT pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_DISTRIBUTIONPOINT) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_DISTRIBUTIONPOINT) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_DISTRIBUTIONPOINT"); pThisObject->SetName(pThisObject, "DistributionPoint"); pThisObject->Create = AnscAsn1CreateDistributionPoint; pThisObject->CreateChildAttr = AnscAsn1DistributionPointCreateChildAttr; pThisObject->GetChildName = AnscAsn1DistributionPointGetChildName; pThisObject->CreateChildObject = AnscAsn1DistributionPointCreateChildObject; pThisObject->uTotalChild = 3; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1DistributionPointCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateDistributionPointName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateReasonFlags(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 2: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1DistributionPointCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; case 2: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 2, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1DistributionPointGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"distributionPoint"; case 1: return"reasons"; case 2: return"cRLIssuer"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_DISTRIBUTIONPOINTNAME DistributionPointName ::= Choice { fullName [CON 0] IMP GeneralNames nameRelativeToCRLIssuer [CON 1] IMP RelativeDistinguishedName } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateDistributionPointName ( ANSC_HANDLE hReserved ) { PANSC_ASN1_DISTRIBUTIONPOINTNAME pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_DISTRIBUTIONPOINTNAME) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_DISTRIBUTIONPOINTNAME"); pThisObject->SetName(pThisObject, "DistributionPointName"); pThisObject->Create = AnscAsn1CreateDistributionPointName; pThisObject->CreateSelection = AnscAsn1DistributionPointNameCreateSelection; pThisObject->GetSelectionName = AnscAsn1DistributionPointNameGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1DistributionPointNameCreateSelectionAttr; pThisObject->GetChoiceTagValue = AnscAsn1DistributionPointNameGetChoiceTagValue; pThisObject->uTotalChoice = DISTRIBUTIONPOINTNAME_MAXI_MASK + 1; pThisObject->bChoiceByOID = FALSE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1DistributionPointNameCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case DISTRIBUTIONPOINTNAME_MASK_FULLNAME: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case DISTRIBUTIONPOINTNAME_MASK_NAMERELATIVETOCRLISSUER: pThisObject = AnscAsn1CreateRelativeDistinguishedName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; } return pThisObject; } PCHAR AnscAsn1DistributionPointNameGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case DISTRIBUTIONPOINTNAME_MASK_FULLNAME: return"fullName"; case DISTRIBUTIONPOINTNAME_MASK_NAMERELATIVETOCRLISSUER: return"nameRelativeToCRLIssuer"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1DistributionPointNameCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( selType ) { case DISTRIBUTIONPOINTNAME_MASK_FULLNAME: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case DISTRIBUTIONPOINTNAME_MASK_NAMERELATIVETOCRLISSUER: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; } return pAttrObject; } BOOLEAN AnscAsn1DistributionPointNameGetChoiceTagValue ( ANSC_HANDLE hThisObject, ULONG uIndex, PASN_OBJECT_FORM_TYPE pAttr, PULONG pTagValue ) { UNREFERENCED_PARAMETER(hThisObject); if( pAttr == NULL || pTagValue == NULL) { return FALSE; } switch ( uIndex ) { case DISTRIBUTIONPOINTNAME_MASK_FULLNAME: *pAttr = CONTEXT_FORM; *pTagValue = 0; return TRUE; case DISTRIBUTIONPOINTNAME_MASK_NAMERELATIVETOCRLISSUER: *pAttr = CONTEXT_FORM; *pTagValue = 1; return TRUE; } return FALSE; } /********************************************************************** OBJECT -- ANSC_ASN1_REASONFLAGS ReasonFlags ::= BitString **********************************************************************/ ANSC_HANDLE AnscAsn1CreateReasonFlags ( ANSC_HANDLE hReserved ) { PANSC_ASN1_REASONFLAGS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_REASONFLAGS) AnscAsn1CreateBitString ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_REASONFLAGS"); pThisObject->SetName(pThisObject, "ReasonFlags"); pThisObject->Create = AnscAsn1CreateReasonFlags; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_ISSUINGDISTRIBUTIONPOINT IssuingDistributionPoint ::= Sequence { distributionPoint [CON 0] IMP DistributionPointName OPT onlyConstrainsUserCerts [CON 1] IMP BOOL DEF onlyConstrainsCACerts [CON 2] IMP BOOL DEF onlySomeReasons [CON 3] IMP ReasonFlags OPT indirectCRL [CON 4] IMP BOOL DEF } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateIssuingDistributionPoint ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_ISSUINGDISTRIBUTIONPOINT pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_ISSUINGDISTRIBUTIONPOINT) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_ISSUINGDISTRIBUTIONPOINT) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_ISSUINGDISTRIBUTIONPOINT"); pThisObject->SetName(pThisObject, "IssuingDistributionPoint"); pThisObject->Create = AnscAsn1CreateIssuingDistributionPoint; pThisObject->CreateChildAttr = AnscAsn1IssuingDistributionPointCreateChildAttr; pThisObject->GetChildName = AnscAsn1IssuingDistributionPointGetChildName; pThisObject->CreateChildObject = AnscAsn1IssuingDistributionPointCreateChildObject; pThisObject->uTotalChild = 5; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1IssuingDistributionPointCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateDistributionPointName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 1: pThisObject = AnscAsn1CreateBOOL(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 2: pThisObject = AnscAsn1CreateBOOL(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 3: pThisObject = AnscAsn1CreateReasonFlags(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; case 4: pThisObject = AnscAsn1CreateBOOL(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1IssuingDistributionPointCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ATTR_OBJECT pAttrObject = NULL; switch ( index ) { case 0: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 0, IMPLICIT_TYPE ); break; case 1: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 1, IMPLICIT_TYPE ); break; case 2: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 2, IMPLICIT_TYPE ); break; case 3: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 3, IMPLICIT_TYPE ); break; case 4: pAttrObject = (PANSC_ATTR_OBJECT) AnscAsn1AttrCreate ( CONTEXT_FORM, 4, IMPLICIT_TYPE ); break; } return pAttrObject; } PCHAR AnscAsn1IssuingDistributionPointGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"distributionPoint"; case 1: return"onlyConstrainsUserCerts"; case 2: return"onlyConstrainsCACerts"; case 3: return"onlySomeReasons"; case 4: return"indirectCRL"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_AUTHORITYINFOACCESSSYNTAX AuthorityInfoAccessSyntax ::= SequenceOf AccessDescription {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateAuthorityInfoAccessSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_AUTHORITYINFOACCESSSYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_AUTHORITYINFOACCESSSYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_AUTHORITYINFOACCESSSYNTAX"); pThisObject->SetName(pThisObject, "AuthorityInfoAccessSyntax"); pThisObject->Create = AnscAsn1CreateAuthorityInfoAccessSyntax; pThisObject->CreateChild = AnscAsn1AuthorityInfoAccessSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1AuthorityInfoAccessSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1AuthorityInfoAccessSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateAccessDescription(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1AuthorityInfoAccessSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_ACCESSDESCRIPTION", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_ACCESSDESCRIPTION AccessDescription ::= Sequence { accessMethod OID accessLocation GeneralName } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateAccessDescription ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_ACCESSDESCRIPTION pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_ACCESSDESCRIPTION) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_ACCESSDESCRIPTION) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_ACCESSDESCRIPTION"); pThisObject->SetName(pThisObject, "AccessDescription"); pThisObject->Create = AnscAsn1CreateAccessDescription; pThisObject->CreateChildAttr = AnscAsn1AccessDescriptionCreateChildAttr; pThisObject->GetChildName = AnscAsn1AccessDescriptionGetChildName; pThisObject->CreateChildObject = AnscAsn1AccessDescriptionCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1AccessDescriptionCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateGeneralName(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1AccessDescriptionCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1AccessDescriptionGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"accessMethod"; case 1: return"accessLocation"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_CRLREASON CRLReason ::= Enumerate **********************************************************************/ ANSC_HANDLE AnscAsn1CreateCRLReason ( ANSC_HANDLE hReserved ) { PANSC_ASN1_CRLREASON pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_CRLREASON) AnscAsn1CreateEnumerate ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_CRLREASON"); pThisObject->SetName(pThisObject, "CRLReason"); pThisObject->Create = AnscAsn1CreateCRLReason; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_HOLDINSTRUCTIONCODE HoldInstructionCode ::= OID **********************************************************************/ ANSC_HANDLE AnscAsn1CreateHoldInstructionCode ( ANSC_HANDLE hReserved ) { PANSC_ASN1_HOLDINSTRUCTIONCODE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_HOLDINSTRUCTIONCODE) AnscAsn1CreateOID ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_HOLDINSTRUCTIONCODE"); pThisObject->SetName(pThisObject, "HoldInstructionCode"); pThisObject->Create = AnscAsn1CreateHoldInstructionCode; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_INVALIDITYDATE InvalidityDate ::= Time **********************************************************************/ ANSC_HANDLE AnscAsn1CreateInvalidityDate ( ANSC_HANDLE hReserved ) { PANSC_ASN1_INVALIDITYDATE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_INVALIDITYDATE) AnscAsn1CreateTime ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_INVALIDITYDATE"); pThisObject->SetName(pThisObject, "InvalidityDate"); pThisObject->Create = AnscAsn1CreateInvalidityDate; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_POLICYMAPPING PolicyMapping ::= Sequence { issuerDomainPolicyID OID subjectDomainPolicyID OID } **********************************************************************/ ANSC_HANDLE AnscAsn1CreatePolicyMapping ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_POLICYMAPPING pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_POLICYMAPPING) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_POLICYMAPPING) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_POLICYMAPPING"); pThisObject->SetName(pThisObject, "PolicyMapping"); pThisObject->Create = AnscAsn1CreatePolicyMapping; pThisObject->CreateChildAttr = AnscAsn1PolicyMappingCreateChildAttr; pThisObject->GetChildName = AnscAsn1PolicyMappingGetChildName; pThisObject->CreateChildObject = AnscAsn1PolicyMappingCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1PolicyMappingCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1PolicyMappingCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1PolicyMappingGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"issuerDomainPolicyID"; case 1: return"subjectDomainPolicyID"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_NOTICENUMBERS NoticeNumbers ::= SequenceOf Integer {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateNoticeNumbers ( ANSC_HANDLE hReserved ) { PANSC_ASN1_NOTICENUMBERS pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_NOTICENUMBERS) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_NOTICENUMBERS"); pThisObject->SetName(pThisObject, "NoticeNumbers"); pThisObject->Create = AnscAsn1CreateNoticeNumbers; pThisObject->CreateChild = AnscAsn1NoticeNumbersCreateChild; pThisObject->IsChildValid = AnscAsn1NoticeNumbersIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1NoticeNumbersCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1NoticeNumbersIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_INTEGER", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } if( pChild->uType != 0x02) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_DELTACRLINDICATOR DeltaCRLIndicator ::= CRLNumber **********************************************************************/ ANSC_HANDLE AnscAsn1CreateDeltaCRLIndicator ( ANSC_HANDLE hReserved ) { PANSC_ASN1_DELTACRLINDICATOR pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_DELTACRLINDICATOR) AnscAsn1CreateCRLNumber ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_DELTACRLINDICATOR"); pThisObject->SetName(pThisObject, "DeltaCRLIndicator"); pThisObject->Create = AnscAsn1CreateDeltaCRLIndicator; return (ANSC_HANDLE)pThisObject; } /********************************************************************** OBJECT -- ANSC_ASN1_ATTRIBUTESSYNTAX AttributesSyntax ::= SequenceOf Attribute {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateAttributesSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_ATTRIBUTESSYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_ATTRIBUTESSYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_ATTRIBUTESSYNTAX"); pThisObject->SetName(pThisObject, "AttributesSyntax"); pThisObject->Create = AnscAsn1CreateAttributesSyntax; pThisObject->CreateChild = AnscAsn1AttributesSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1AttributesSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1AttributesSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateAttribute(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1AttributesSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_ATTRIBUTE", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_BIOMETRICSSYNTAX BiometricsSyntax ::= SequenceOf BiometricData {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateBiometricsSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_BIOMETRICSSYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_BIOMETRICSSYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_BIOMETRICSSYNTAX"); pThisObject->SetName(pThisObject, "BiometricsSyntax"); pThisObject->Create = AnscAsn1CreateBiometricsSyntax; pThisObject->CreateChild = AnscAsn1BiometricsSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1BiometricsSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1BiometricsSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateBiometricData(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1BiometricsSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_BIOMETRICDATA", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_BIOMETRICDATA BiometricData ::= Sequence { typeOfBiometricData TypeOfBiometricData hashAlgorithm AlgorithmIdentifier biometricDataHash OctetString sourceDataUri IA5String } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateBiometricData ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_BIOMETRICDATA pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_BIOMETRICDATA) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_BIOMETRICDATA) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_BIOMETRICDATA"); pThisObject->SetName(pThisObject, "BiometricData"); pThisObject->Create = AnscAsn1CreateBiometricData; pThisObject->CreateChildAttr = AnscAsn1BiometricDataCreateChildAttr; pThisObject->GetChildName = AnscAsn1BiometricDataGetChildName; pThisObject->CreateChildObject = AnscAsn1BiometricDataCreateChildObject; pThisObject->uTotalChild = 4; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1BiometricDataCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateTypeOfBiometricData(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateAlgorithmIdentifier(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 2: pThisObject = AnscAsn1CreateOctetString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 3: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1BiometricDataCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1BiometricDataGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"typeOfBiometricData"; case 1: return"hashAlgorithm"; case 2: return"biometricDataHash"; case 3: return"sourceDataUri"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_TYPEOFBIOMETRICDATA TypeOfBiometricData ::= Choice { predefinedType Integer biometricDataOID OID } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateTypeOfBiometricData ( ANSC_HANDLE hReserved ) { PANSC_ASN1_TYPEOFBIOMETRICDATA pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_TYPEOFBIOMETRICDATA) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_TYPEOFBIOMETRICDATA"); pThisObject->SetName(pThisObject, "TypeOfBiometricData"); pThisObject->Create = AnscAsn1CreateTypeOfBiometricData; pThisObject->CreateSelection = AnscAsn1TypeOfBiometricDataCreateSelection; pThisObject->GetSelectionName = AnscAsn1TypeOfBiometricDataGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1TypeOfBiometricDataCreateSelectionAttr; pThisObject->GetChoiceTagValue = AnscAsn1TypeOfBiometricDataGetChoiceTagValue; pThisObject->uTotalChoice = TYPEOFBIOMETRICDATA_MAXI_MASK + 1; pThisObject->bChoiceByOID = FALSE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1TypeOfBiometricDataCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case TYPEOFBIOMETRICDATA_MASK_PREDEFINEDTYPE: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case TYPEOFBIOMETRICDATA_MASK_BIOMETRICDATAOID: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; } return pThisObject; } PCHAR AnscAsn1TypeOfBiometricDataGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case TYPEOFBIOMETRICDATA_MASK_PREDEFINEDTYPE: return"predefinedType"; case TYPEOFBIOMETRICDATA_MASK_BIOMETRICDATAOID: return"biometricDataOID"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1TypeOfBiometricDataCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(selType); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } BOOLEAN AnscAsn1TypeOfBiometricDataGetChoiceTagValue ( ANSC_HANDLE hThisObject, ULONG uIndex, PASN_OBJECT_FORM_TYPE pAttr, PULONG pTagValue ) { UNREFERENCED_PARAMETER(hThisObject); if( pAttr == NULL || pTagValue == NULL) { return FALSE; } switch ( uIndex ) { case TYPEOFBIOMETRICDATA_MASK_PREDEFINEDTYPE: *pAttr = UNIVERSAL_FORM; *pTagValue = 0x02; return TRUE; case TYPEOFBIOMETRICDATA_MASK_BIOMETRICDATAOID: *pAttr = UNIVERSAL_FORM; *pTagValue = 0x06; return TRUE; } return FALSE; } /********************************************************************** OBJECT -- ANSC_ASN1_QCSTATEMENTSSYNTAX QCStatementsSyntax ::= SequenceOf QCStatement {} **********************************************************************/ ANSC_HANDLE AnscAsn1CreateQCStatementsSyntax ( ANSC_HANDLE hReserved ) { PANSC_ASN1_QCSTATEMENTSSYNTAX pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_QCSTATEMENTSSYNTAX) AnscAsn1CreateSequenceOf ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_QCSTATEMENTSSYNTAX"); pThisObject->SetName(pThisObject, "QCStatementsSyntax"); pThisObject->Create = AnscAsn1CreateQCStatementsSyntax; pThisObject->CreateChild = AnscAsn1QCStatementsSyntaxCreateChild; pThisObject->IsChildValid = AnscAsn1QCStatementsSyntaxIsChildValid; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1QCStatementsSyntaxCreateChild ( ANSC_HANDLE hThisObject, BOOLEAN bAddItIn ) { PANSC_ASN1_SETOF pParentObj = (PANSC_ASN1_SETOF)hThisObject; PANSC_ASN1_OBJECT pThisObject = NULL; pThisObject = AnscAsn1CreateQCStatement(NULL); if( pThisObject != NULL && bAddItIn) { pParentObj->AddChild(pParentObj,pThisObject); } return pThisObject; } ANSC_STATUS AnscAsn1QCStatementsSyntaxIsChildValid ( ANSC_HANDLE hThisObject, ANSC_HANDLE hChild ) { UNREFERENCED_PARAMETER(hThisObject); PANSC_ASN1_OBJECT pChild = (PANSC_ASN1_OBJECT)hChild; if( pChild == NULL) { return ANSC_ASN1_NULL_OBJCET; } if( !AnscEqualString1(pChild->ClassName, "ANSC_ASN1_QCSTATEMENT", TRUE)) { return ANSC_ASN1_INVALID_TYPE_IN_SEQOF_OR_SETOF; } return ANSC_STATUS_SUCCESS; } /********************************************************************** OBJECT -- ANSC_ASN1_QCSTATEMENT QCStatement ::= Sequence { statementOID OID statementInfo OctetString } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateQCStatement ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_QCSTATEMENT pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_QCSTATEMENT) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_QCSTATEMENT) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_QCSTATEMENT"); pThisObject->SetName(pThisObject, "QCStatement"); pThisObject->Create = AnscAsn1CreateQCStatement; pThisObject->CreateChildAttr = AnscAsn1QCStatementCreateChildAttr; pThisObject->GetChildName = AnscAsn1QCStatementGetChildName; pThisObject->CreateChildObject = AnscAsn1QCStatementCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1QCStatementCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateOID(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateOctetString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); pThisObject->bCanBeOptional = TRUE; pThisObject->bOptional = TRUE; } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1QCStatementCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1QCStatementGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"statementOID"; case 1: return"statementInfo"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_ENTRUSTVERSIONINFO EntrustVersionInfo ::= Sequence { version GeneralString usage BitString } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateEntrustVersionInfo ( ANSC_HANDLE hReserved ) { UNREFERENCED_PARAMETER(hReserved); PANSC_ASN1_ENTRUSTVERSIONINFO pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_ENTRUSTVERSIONINFO) AnscAsn1CreateSequence ( (ANSC_HANDLE)sizeof(ANSC_ASN1_ENTRUSTVERSIONINFO) ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_ENTRUSTVERSIONINFO"); pThisObject->SetName(pThisObject, "EntrustVersionInfo"); pThisObject->Create = AnscAsn1CreateEntrustVersionInfo; pThisObject->CreateChildAttr = AnscAsn1EntrustVersionInfoCreateChildAttr; pThisObject->GetChildName = AnscAsn1EntrustVersionInfoGetChildName; pThisObject->CreateChildObject = AnscAsn1EntrustVersionInfoCreateChildObject; pThisObject->uTotalChild = 2; /* * Create all the children */ pThisObject->CreateAllChildren(pThisObject); return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1EntrustVersionInfoCreateChildObject ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_SEQUENCE pParent = (PANSC_ASN1_SEQUENCE)hThisObject; switch( index ) { case 0: pThisObject = AnscAsn1CreateGeneralString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; case 1: pThisObject = AnscAsn1CreateBitString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index)); } break; } return pThisObject; } PANSC_ATTR_OBJECT AnscAsn1EntrustVersionInfoCreateChildAttr ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(index); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } PCHAR AnscAsn1EntrustVersionInfoGetChildName ( ANSC_HANDLE hThisObject, ULONG index ) { UNREFERENCED_PARAMETER(hThisObject); switch ( index ) { case 0: return"version"; case 1: return"usage"; } return ""; } /********************************************************************** OBJECT -- ANSC_ASN1_EXTENSIONVALUE ExtensionValue ::= Choice { authorityKeyIdentifier AuthorityKeyIdentifier keyUsage KeyUsage privateKeyUsagePeriod PrivateKeyUsagePeriod certPolicies CertificatePolicies policyMappings PolicyMappings subDirectoryAttributes SubjectDirectoryAttributes basicConstraints BasicConstraints nameConstraints NameConstraints policyConstraints PolicyConstraints crlDistPointsSyntax CRLDistPointsSyntax extKeyUsageSyntax ExtKeyUsageSyntax authInfoAccessSyntax AuthorityInfoAccessSyntax crlNumber CRLNumber issuingDistributionPoint IssuingDistributionPoint crlReason CRLReason holdInstructionCode HoldInstructionCode invalidityDate InvalidityDate isserAltName GeneralNames subjectAltName GeneralNames deltaCRLIndicator CRLNumber certificateIssuer GeneralNames subjectKeyIdentifier OctetString biometricsSyntax BiometricsSyntax qcStatementsSyntax QCStatementsSyntax netscapeCertType BitString netscapeComment IA5String commonName DirectoryString entrustVersionInfo EntrustVersionInfo caKeyCertIndexPair Integer msString MSString } **********************************************************************/ ANSC_HANDLE AnscAsn1CreateExtensionValue ( ANSC_HANDLE hReserved ) { PANSC_ASN1_EXTENSIONVALUE pThisObject = NULL; /* * Create the base ASN.1 object. */ pThisObject = (PANSC_ASN1_EXTENSIONVALUE) AnscAsn1CreateChoice ( hReserved ); if( pThisObject == NULL) { return (ANSC_HANDLE)NULL; } /* * Initialize the common variables and functions for this ASN.1 object. */ pThisObject->SetClassName(pThisObject, "ANSC_ASN1_EXTENSIONVALUE"); pThisObject->SetName(pThisObject, "ExtensionValue"); pThisObject->Create = AnscAsn1CreateExtensionValue; pThisObject->CreateSelection = AnscAsn1ExtensionValueCreateSelection; pThisObject->GetSelectionName = AnscAsn1ExtensionValueGetSelectionName; pThisObject->CreateSelectionAttr= AnscAsn1ExtensionValueCreateSelectionAttr; pThisObject->GetChoiceFromOID = AnscAsn1ExtensionValueGetChoiceByOID; pThisObject->GetOIDValueByMask = AnscAsn1ExtensionValueGetOIDValueByMask; pThisObject->uTotalChoice = EXTENSIONVALUE_MAXI_MASK + 1; pThisObject->bChoiceByOID = TRUE; return (ANSC_HANDLE)pThisObject; } ANSC_HANDLE AnscAsn1ExtensionValueCreateSelection ( ANSC_HANDLE hThisObject, ULONG index ) { PANSC_ASN1_OBJECT pThisObject = NULL; PANSC_ASN1_CHOICE pParent = (PANSC_ASN1_CHOICE)hThisObject; switch( index ) { case EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER: pThisObject = AnscAsn1CreateAuthorityKeyIdentifier(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_KEYUSAGE: pThisObject = AnscAsn1CreateKeyUsage(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_PRIVATEKEYUSAGEPERIOD: pThisObject = AnscAsn1CreatePrivateKeyUsagePeriod(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CERTPOLICIES: pThisObject = AnscAsn1CreateCertificatePolicies(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_POLICYMAPPINGS: pThisObject = AnscAsn1CreatePolicyMappings(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_SUBDIRECTORYATTRIBUTES: pThisObject = AnscAsn1CreateSubjectDirectoryAttributes(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_BASICCONSTRAINTS: pThisObject = AnscAsn1CreateBasicConstraints(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_NAMECONSTRAINTS: pThisObject = AnscAsn1CreateNameConstraints(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_POLICYCONSTRAINTS: pThisObject = AnscAsn1CreatePolicyConstraints(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX: pThisObject = AnscAsn1CreateCRLDistPointsSyntax(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_EXTKEYUSAGESYNTAX: pThisObject = AnscAsn1CreateExtKeyUsageSyntax(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX: pThisObject = AnscAsn1CreateAuthorityInfoAccessSyntax(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CRLNUMBER: pThisObject = AnscAsn1CreateCRLNumber(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT: pThisObject = AnscAsn1CreateIssuingDistributionPoint(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CRLREASON: pThisObject = AnscAsn1CreateCRLReason(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_HOLDINSTRUCTIONCODE: pThisObject = AnscAsn1CreateHoldInstructionCode(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_INVALIDITYDATE: pThisObject = AnscAsn1CreateInvalidityDate(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_ISSERALTNAME: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_SUBJECTALTNAME: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_DELTACRLINDICATOR: pThisObject = AnscAsn1CreateCRLNumber(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CERTIFICATEISSUER: pThisObject = AnscAsn1CreateGeneralNames(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_SUBJECTKEYIDENTIFIER: pThisObject = AnscAsn1CreateOctetString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_BIOMETRICSSYNTAX: pThisObject = AnscAsn1CreateBiometricsSyntax(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_QCSTATEMENTSSYNTAX: pThisObject = AnscAsn1CreateQCStatementsSyntax(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_NETSCAPECERTTYPE: pThisObject = AnscAsn1CreateBitString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: pThisObject = AnscAsn1CreateIA5String(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_COMMONNAME: pThisObject = AnscAsn1CreateDirectoryString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_ENTRUSTVERSIONINFO: pThisObject = AnscAsn1CreateEntrustVersionInfo(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_CAKEYCERTINDEXPAIR: pThisObject = AnscAsn1CreateInteger(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; case EXTENSIONVALUE_MASK_MSSTRING: pThisObject = AnscAsn1CreateMSString(NULL); if( pThisObject != NULL) { pThisObject->AddAttribute(pThisObject, pParent->CreateSelectionAttr(pParent,index), FALSE); pThisObject->SetName(pThisObject, pParent->GetSelectionName(pParent,index)); } break; } return pThisObject; } PCHAR AnscAsn1ExtensionValueGetSelectionName ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER: return"authorityKeyIdentifier"; case EXTENSIONVALUE_MASK_KEYUSAGE: return"keyUsage"; case EXTENSIONVALUE_MASK_PRIVATEKEYUSAGEPERIOD: return"privateKeyUsagePeriod"; case EXTENSIONVALUE_MASK_CERTPOLICIES: return"certPolicies"; case EXTENSIONVALUE_MASK_POLICYMAPPINGS: return"policyMappings"; case EXTENSIONVALUE_MASK_SUBDIRECTORYATTRIBUTES: return"subDirectoryAttributes"; case EXTENSIONVALUE_MASK_BASICCONSTRAINTS: return"basicConstraints"; case EXTENSIONVALUE_MASK_NAMECONSTRAINTS: return"nameConstraints"; case EXTENSIONVALUE_MASK_POLICYCONSTRAINTS: return"policyConstraints"; case EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX: return"crlDistPointsSyntax"; case EXTENSIONVALUE_MASK_EXTKEYUSAGESYNTAX: return"extKeyUsageSyntax"; case EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX: return"authInfoAccessSyntax"; case EXTENSIONVALUE_MASK_CRLNUMBER: return"crlNumber"; case EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT: return"issuingDistributionPoint"; case EXTENSIONVALUE_MASK_CRLREASON: return"crlReason"; case EXTENSIONVALUE_MASK_HOLDINSTRUCTIONCODE: return"holdInstructionCode"; case EXTENSIONVALUE_MASK_INVALIDITYDATE: return"invalidityDate"; case EXTENSIONVALUE_MASK_ISSERALTNAME: return"isserAltName"; case EXTENSIONVALUE_MASK_SUBJECTALTNAME: return"subjectAltName"; case EXTENSIONVALUE_MASK_DELTACRLINDICATOR: return"deltaCRLIndicator"; case EXTENSIONVALUE_MASK_CERTIFICATEISSUER: return"certificateIssuer"; case EXTENSIONVALUE_MASK_SUBJECTKEYIDENTIFIER: return"subjectKeyIdentifier"; case EXTENSIONVALUE_MASK_BIOMETRICSSYNTAX: return"biometricsSyntax"; case EXTENSIONVALUE_MASK_QCSTATEMENTSSYNTAX: return"qcStatementsSyntax"; case EXTENSIONVALUE_MASK_NETSCAPECERTTYPE: return"netscapeCertType"; case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return"netscapeComment"; case EXTENSIONVALUE_MASK_COMMONNAME: return"commonName"; case EXTENSIONVALUE_MASK_ENTRUSTVERSIONINFO: return"entrustVersionInfo"; case EXTENSIONVALUE_MASK_CAKEYCERTINDEXPAIR: return"caKeyCertIndexPair"; case EXTENSIONVALUE_MASK_MSSTRING: return"msString"; } return ""; } PANSC_ATTR_OBJECT AnscAsn1ExtensionValueCreateSelectionAttr ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); UNREFERENCED_PARAMETER(selType); PANSC_ATTR_OBJECT pAttrObject = NULL; return pAttrObject; } LONG AnscAsn1ExtensionValueGetChoiceByOID ( ANSC_HANDLE hThisObject, PCHAR pOIDString ) { UNREFERENCED_PARAMETER(hThisObject); if( pOIDString == NULL) return -1; if( AnscEqualString1(pOIDString,"2.5.29.35",FALSE)) { return EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER; } else if( AnscEqualString1(pOIDString,"2.5.29.14",FALSE)) { return EXTENSIONVALUE_MASK_SUBJECTKEYIDENTIFIER; } else if( AnscEqualString1(pOIDString,"2.5.29.15",FALSE)) { return EXTENSIONVALUE_MASK_KEYUSAGE; } else if( AnscEqualString1(pOIDString,"2.5.29.16",FALSE)) { return EXTENSIONVALUE_MASK_PRIVATEKEYUSAGEPERIOD; } else if( AnscEqualString1(pOIDString,"2.5.29.32",FALSE)) { return EXTENSIONVALUE_MASK_CERTPOLICIES; } else if( AnscEqualString1(pOIDString,"2.5.29.33",FALSE)) { return EXTENSIONVALUE_MASK_POLICYMAPPINGS; } else if( AnscEqualString1(pOIDString,"2.5.29.17",FALSE)) { return EXTENSIONVALUE_MASK_SUBJECTALTNAME; } else if( AnscEqualString1(pOIDString,"2.5.29.18",FALSE)) { return EXTENSIONVALUE_MASK_ISSERALTNAME; } else if( AnscEqualString1(pOIDString,"2.5.29.9",FALSE)) { return EXTENSIONVALUE_MASK_SUBDIRECTORYATTRIBUTES; } else if( AnscEqualString1(pOIDString,"2.5.29.19",FALSE)) { return EXTENSIONVALUE_MASK_BASICCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.30",FALSE)) { return EXTENSIONVALUE_MASK_NAMECONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.36",FALSE)) { return EXTENSIONVALUE_MASK_POLICYCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.31",FALSE)) { return EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX; } else if( AnscEqualString1(pOIDString,"2.5.29.37",FALSE)) { return EXTENSIONVALUE_MASK_EXTKEYUSAGESYNTAX; } else if( AnscEqualString1(pOIDString,"2.5.29.20",FALSE)) { return EXTENSIONVALUE_MASK_CRLNUMBER; } else if( AnscEqualString1(pOIDString,"2.5.29.28",FALSE)) { return EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT; } else if( AnscEqualString1(pOIDString,"2.5.29.27",FALSE)) { return EXTENSIONVALUE_MASK_DELTACRLINDICATOR; } else if( AnscEqualString1(pOIDString,"2.5.29.21",FALSE)) { return EXTENSIONVALUE_MASK_CRLREASON; } else if( AnscEqualString1(pOIDString,"2.5.29.29",FALSE)) { return EXTENSIONVALUE_MASK_CERTIFICATEISSUER; } else if( AnscEqualString1(pOIDString,"2.5.29.23",FALSE)) { return EXTENSIONVALUE_MASK_HOLDINSTRUCTIONCODE; } else if( AnscEqualString1(pOIDString,"2.5.29.24",FALSE)) { return EXTENSIONVALUE_MASK_INVALIDITYDATE; } else if( AnscEqualString1(pOIDString,"1.3.6.1.4.1.311.21.4",FALSE)) { return EXTENSIONVALUE_MASK_INVALIDITYDATE; } else if( AnscEqualString1(pOIDString,"2.5.29.46",FALSE)) { return EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX; } else if( AnscEqualString1(pOIDString,"2.5.29.1",FALSE)) { return EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER; } else if( AnscEqualString1(pOIDString,"2.5.29.3",FALSE)) { return EXTENSIONVALUE_MASK_CERTPOLICIES; } else if( AnscEqualString1(pOIDString,"2.5.29.5",FALSE)) { return EXTENSIONVALUE_MASK_POLICYMAPPINGS; } else if( AnscEqualString1(pOIDString,"2.5.29.7",FALSE)) { return EXTENSIONVALUE_MASK_SUBJECTALTNAME; } else if( AnscEqualString1(pOIDString,"2.5.29.8",FALSE)) { return EXTENSIONVALUE_MASK_ISSERALTNAME; } else if( AnscEqualString1(pOIDString,"2.5.29.10",FALSE)) { return EXTENSIONVALUE_MASK_BASICCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.13",FALSE)) { return EXTENSIONVALUE_MASK_BASICCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.11",FALSE)) { return EXTENSIONVALUE_MASK_NAMECONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.12",FALSE)) { return EXTENSIONVALUE_MASK_POLICYCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.34",FALSE)) { return EXTENSIONVALUE_MASK_POLICYCONSTRAINTS; } else if( AnscEqualString1(pOIDString,"2.5.29.25",FALSE)) { return EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX; } else if( AnscEqualString1(pOIDString,"2.5.29.26",FALSE)) { return EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT; } else if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.1.1",FALSE)) { return EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX; } else if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.1.11",FALSE)) { return EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX; } else if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.1.2",FALSE)) { return EXTENSIONVALUE_MASK_BIOMETRICSSYNTAX; } else if( AnscEqualString1(pOIDString,"1.3.6.1.5.5.7.1.3",FALSE)) { return EXTENSIONVALUE_MASK_QCSTATEMENTSSYNTAX; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.1",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECERTTYPE; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.2",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.3",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.4",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.7",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.8",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.12",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.16.840.1.113730.1.13",FALSE)) { return EXTENSIONVALUE_MASK_NETSCAPECOMMENT; } else if( AnscEqualString1(pOIDString,"2.5.4.3",FALSE)) { return EXTENSIONVALUE_MASK_COMMONNAME; } else if( AnscEqualString1(pOIDString,"1.2.840.113533.7.65.0",FALSE)) { return EXTENSIONVALUE_MASK_ENTRUSTVERSIONINFO; } else if( AnscEqualString1(pOIDString,"1.3.6.1.4.1.311.21.1",FALSE)) { return EXTENSIONVALUE_MASK_CAKEYCERTINDEXPAIR; } else if( AnscEqualString1(pOIDString,"1.3.6.1.4.1.311.20.2",FALSE)) { return EXTENSIONVALUE_MASK_MSSTRING; } return -1; } PCHAR AnscAsn1ExtensionValueGetOIDValueByMask ( ANSC_HANDLE hThisObject, ULONG selType ) { UNREFERENCED_PARAMETER(hThisObject); switch ( selType ) { case EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER: return "2.5.29.35"; case EXTENSIONVALUE_MASK_SUBJECTKEYIDENTIFIER: return "2.5.29.14"; case EXTENSIONVALUE_MASK_KEYUSAGE: return "2.5.29.15"; case EXTENSIONVALUE_MASK_PRIVATEKEYUSAGEPERIOD: return "2.5.29.16"; case EXTENSIONVALUE_MASK_CERTPOLICIES: return "2.5.29.32"; case EXTENSIONVALUE_MASK_POLICYMAPPINGS: return "2.5.29.33"; case EXTENSIONVALUE_MASK_SUBJECTALTNAME: return "2.5.29.17"; case EXTENSIONVALUE_MASK_ISSERALTNAME: return "2.5.29.18"; case EXTENSIONVALUE_MASK_SUBDIRECTORYATTRIBUTES: return "2.5.29.9"; case EXTENSIONVALUE_MASK_BASICCONSTRAINTS: return "2.5.29.19"; case EXTENSIONVALUE_MASK_NAMECONSTRAINTS: return "2.5.29.30"; case EXTENSIONVALUE_MASK_POLICYCONSTRAINTS: return "2.5.29.36"; case EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX: return "2.5.29.31"; case EXTENSIONVALUE_MASK_EXTKEYUSAGESYNTAX: return "2.5.29.37"; case EXTENSIONVALUE_MASK_CRLNUMBER: return "2.5.29.20"; case EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT: return "2.5.29.28"; case EXTENSIONVALUE_MASK_DELTACRLINDICATOR: return "2.5.29.27"; case EXTENSIONVALUE_MASK_CRLREASON: return "2.5.29.21"; case EXTENSIONVALUE_MASK_CERTIFICATEISSUER: return "2.5.29.29"; case EXTENSIONVALUE_MASK_HOLDINSTRUCTIONCODE: return "2.5.29.23"; case EXTENSIONVALUE_MASK_INVALIDITYDATE: return "2.5.29.24"; /* case EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX: return "2.5.29.46"; */ /* case EXTENSIONVALUE_MASK_AUTHORITYKEYIDENTIFIER: return "2.5.29.1"; */ /* case EXTENSIONVALUE_MASK_CERTPOLICIES: return "2.5.29.3"; */ /* case EXTENSIONVALUE_MASK_POLICYMAPPINGS: return "2.5.29.5"; */ /* case EXTENSIONVALUE_MASK_SUBJECTALTNAME: return "2.5.29.7"; */ /* case EXTENSIONVALUE_MASK_ISSERALTNAME: return "2.5.29.8"; */ /* case EXTENSIONVALUE_MASK_BASICCONSTRAINTS: return "2.5.29.10"; */ /* case EXTENSIONVALUE_MASK_BASICCONSTRAINTS: return "2.5.29.13"; */ /* case EXTENSIONVALUE_MASK_NAMECONSTRAINTS: return "2.5.29.11"; */ /* case EXTENSIONVALUE_MASK_POLICYCONSTRAINTS: return "2.5.29.12"; */ /* case EXTENSIONVALUE_MASK_POLICYCONSTRAINTS: return "2.5.29.34"; */ /* case EXTENSIONVALUE_MASK_CRLDISTPOINTSSYNTAX: return "2.5.29.25"; */ /* case EXTENSIONVALUE_MASK_ISSUINGDISTRIBUTIONPOINT: return "2.5.29.26"; */ case EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX: return "1.3.6.1.5.5.7.1.1"; /* case EXTENSIONVALUE_MASK_AUTHINFOACCESSSYNTAX: return "1.3.6.1.5.5.7.1.11"; */ case EXTENSIONVALUE_MASK_BIOMETRICSSYNTAX: return "1.3.6.1.5.5.7.1.2"; case EXTENSIONVALUE_MASK_QCSTATEMENTSSYNTAX: return "1.3.6.1.5.5.7.1.3"; case EXTENSIONVALUE_MASK_NETSCAPECERTTYPE: return "2.16.840.1.113730.1.1"; case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.2"; /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.3"; */ /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.4"; */ /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.7"; */ /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.8"; */ /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.12"; */ /* case EXTENSIONVALUE_MASK_NETSCAPECOMMENT: return "2.16.840.1.113730.1.13"; */ case EXTENSIONVALUE_MASK_COMMONNAME: return "2.5.4.3"; case EXTENSIONVALUE_MASK_ENTRUSTVERSIONINFO: return "1.2.840.113533.7.65.0"; case EXTENSIONVALUE_MASK_CAKEYCERTINDEXPAIR: return "1.3.6.1.4.1.311.21.1"; case EXTENSIONVALUE_MASK_MSSTRING: return "1.3.6.1.4.1.311.20.2"; } return NULL; }
25.444132
107
0.563701
[ "object" ]
f9a7c25d17685ca2a8e8b7b0210350827fe73abf
193
h
C
src/GUI/Crxtterm.h
ArashMassoudieh/GIFMod_
1fa9eda21fab870fc3baf56462f79eb800d5154f
[ "MIT" ]
5
2017-11-20T19:32:27.000Z
2018-08-28T06:08:45.000Z
src/GUI/Crxtterm.h
ArashMassoudieh/GIFMod_
1fa9eda21fab870fc3baf56462f79eb800d5154f
[ "MIT" ]
1
2017-07-04T05:40:30.000Z
2017-07-04T05:43:37.000Z
src/GUI/Crxtterm.h
ArashMassoudieh/GIFMod_
1fa9eda21fab870fc3baf56462f79eb800d5154f
[ "MIT" ]
2
2017-11-09T22:00:45.000Z
2018-08-30T10:56:08.000Z
#pragma once #include <vector> using namespace std; class Crxtterm { public: Crxtterm(void); char type; int rxtno; vector<int> reactantno; ~Crxtterm(void); vector<double> params; };
10.157895
24
0.704663
[ "vector" ]
f9b0220cfb00a2b1a2c802150a085f8aa94325f9
4,113
h
C
Source/Fight_MovementManager.h
JohnWJackson/CUNYAIModule
0e23d8d9b2008827fbb20d18fe245d2405f38315
[ "MIT" ]
null
null
null
Source/Fight_MovementManager.h
JohnWJackson/CUNYAIModule
0e23d8d9b2008827fbb20d18fe245d2405f38315
[ "MIT" ]
null
null
null
Source/Fight_MovementManager.h
JohnWJackson/CUNYAIModule
0e23d8d9b2008827fbb20d18fe245d2405f38315
[ "MIT" ]
null
null
null
#pragma once #include "CUNYAIModule.h" #include "Unit_Inventory.h" //Movement and Combat Functions class Mobility { public: // Basic retreat logic void Retreat_Logic(const Unit &unit, const Stored_Unit &e_unit, const Unit_Inventory &u_squad, Unit_Inventory &e_squad, Unit_Inventory &ei, const Unit_Inventory &ui, const int &passed_distance, const Map_Inventory &inv, const Color &color, const bool &force); // Tells the unit to fight. If it can attack both air and ground. void Tactical_Logic(const Unit & unit, const Stored_Unit &e_unit, Unit_Inventory & ei, const Unit_Inventory &ui, const int &passed_dist, const Map_Inventory &inv, const Color & color); //Forces a unit to flock in a (previously) Mobility manner. Will attack if it sees something. void Pathing_Movement( const Unit &unit, const Unit_Inventory &ui, Unit_Inventory &ei, const int &passed_distance, const Position &e_pos, const Map_Inventory &inv ); //Forces a unit to surround the concerning ei. Does not advance. //void Surrounding_Movement(const Unit &unit, const Unit_Inventory &ui, Unit_Inventory &ei, const Map_Inventory &inv); Position Output; // Causes a unit to match headings with neighboring units. Position setAlignment( const Unit &unit, const Unit_Inventory &ui ); // Causes UNIT to run directly from enemy. Position setDirectRetreat(const Position & pos, const Position &e_pos, const UnitType & type); // Causes a unit to move towards central map veins. Position setCentralize( const Position &pos, const Map_Inventory &inv ); // causes a unit to move about in a random (brownian) fashion. Position setStutter( const Unit &unit, const double &n ); // Causes a unit to be pulled towards others of their kind. Position setCohesion( const Unit &unit, const Position &pos, const Unit_Inventory &ui ); // causes a unit to be pulled towards (map) center. Position setAttraction(const Unit & unit, const Position & pos, const Map_Inventory & inv, const vector<vector<int>>& map, const Position &map_center); // causes a unit to be pushed away from (map) center. Dangerous for ground units, could lead to them running down dead ends. Position setRepulsion(const Unit & unit, const Position & pos, const Map_Inventory & inv, const vector<vector<int>>& map, const Position & map_center); // causes a unit to move directly towards the enemy base. Position scoutEnemyBase(const Unit & unit, const Position & pos, Map_Inventory & inv); // causes a unit to seperate itself from others. Position setSeperation( const Unit &unit, const Position &pos, const Unit_Inventory &ui ); // causes a unit to seperate itself from others at a distance of its own vision. Position setSeperationScout(const Unit & unit, const Position & pos, const Unit_Inventory & ui); //void setUnwalkability( const Unit &unit, const Position &pos, const Map_Inventory &inv); // Causes a unit to avoid units in its distant future, near future, and immediate position. Position setObjectAvoid(const Unit &unit, const Position &current_pos, const Position &future_pos, const Map_Inventory &inv, const vector<vector<int>> &map); bool adjust_lurker_burrow(const Unit &unit, const Unit_Inventory &ui, const Unit_Inventory &ei, const Position position_of_target); // gives a vector that has the direction towards center on (map). Must return a PAIR since it returns a unit vector. Position getVectorTowardsMap(const Position & pos, const Map_Inventory & inv, const vector<vector<int>>& map) const; private: int distance_metric = 0; Position stutter_vector_ = Positions::Origin; Position attune_vector_ = Positions::Origin; Position cohesion_vector_ = Positions::Origin; Position centralization_vector_ = Positions::Origin; Position seperation_vector_ = Positions::Origin; Position attract_vector_ = Positions::Origin; Position retreat_vector_ = Positions::Origin; Position walkability_vector_ = Positions::Origin; int rng_direction_ ; // send unit in a random tilt direction if blocked };
63.276923
263
0.745441
[ "vector" ]
f9c355bc8f8f1487df545f85c18bdbf2847a83a4
1,089
h
C
archived/core/v1/solver.h
HenryQuan/pazusoba
00fc067dd57675033903f7cc994017506e84ce05
[ "MIT" ]
5
2020-11-29T22:23:56.000Z
2021-02-05T16:28:42.000Z
archived/core/v1/solver.h
HenryQuan/pazusoba
00fc067dd57675033903f7cc994017506e84ce05
[ "MIT" ]
41
2020-07-08T13:07:22.000Z
2021-09-09T23:48:28.000Z
archived/core/v1/solver.h
HenryQuan/pazusoba
00fc067dd57675033903f7cc994017506e84ce05
[ "MIT" ]
1
2021-02-06T06:19:08.000Z
2021-02-06T06:19:08.000Z
/** * solver.h * by Yiheng Quan */ #ifndef PAD_SOLVER_H #define PAD_SOLVER_H #include <string> #include <vector> #include <set> #include "pad.h" #include "route.h" #include "board.h" #include "state.h" extern "C" { class PSolver { int row = 0; int column = 0; int minErase = 3; int steps = 25; int size = 1000; bool debug = false; /// Read board from filePath, return the board Board readBoard(const std::string &filePath); public: /// This is the original board PBoard board; PSolver(const std::string &filePath, int minErase, int steps, int size); /// Solve the current board std::vector<Route> solve(); /// Read a board from a string void setBoardFrom(const std::string &board); /// A random board that is row x column void setRandomBoard(int row, int column); /// Update beam size, mainly for Qt void setBeamSize(int size); /// Update step limit void setStepLimit(int step); }; } #endif
20.166667
80
0.583104
[ "vector" ]
f9c558d89c7a1360d98e2c7c55e90148650f090e
3,266
h
C
Blowbox/d3d11/d3d11_vertex_buffer.h
RikoOphorst/blowbox-old
2a6203dd63eaf78356f1fe3c6f133203b75fcaee
[ "MIT" ]
null
null
null
Blowbox/d3d11/d3d11_vertex_buffer.h
RikoOphorst/blowbox-old
2a6203dd63eaf78356f1fe3c6f133203b75fcaee
[ "MIT" ]
null
null
null
Blowbox/d3d11/d3d11_vertex_buffer.h
RikoOphorst/blowbox-old
2a6203dd63eaf78356f1fe3c6f133203b75fcaee
[ "MIT" ]
null
null
null
#pragma once #include "../../blowbox/d3d11/d3d11.h" #include <vector> #include <Windows.h> #include <xnamath.h> namespace blowbox { /** * @struct blowbox::Vertex * @brief A structure that holds vertex information */ struct Vertex { Vertex() : position(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f)), color(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)), tex_coords(XMFLOAT2(0.0f, 0.0f)), normal(XMFLOAT3(0.0f, 0.0f, 0.0f)) {} Vertex(const XMFLOAT4& p) : position(p), color(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)), tex_coords(XMFLOAT2(0.0f, 0.0f)), normal(XMFLOAT3(0.0f, 0.0f, 0.0f)) {} Vertex(const XMFLOAT4& p, const XMFLOAT2& t) : position(p), color(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)), tex_coords(t), normal(XMFLOAT3(0.0f, 0.0f, 0.0f)) {} Vertex(const XMFLOAT4& p, const XMFLOAT4& c, const XMFLOAT2& t) : position(p), color(c), tex_coords(t), normal(XMFLOAT3(0.0f, 0.0f, 0.0f)) {} Vertex(const XMFLOAT4& p, const XMFLOAT4& c, const XMFLOAT2& t, const XMFLOAT3& n) : position(p), color(c), tex_coords(t), normal(n) {} XMFLOAT4 position; XMFLOAT4 color; XMFLOAT2 tex_coords; XMFLOAT3 normal; }; /** * @enum blowbox::BUFFER_TYPE * @brief Describes the different types of buffer types */ enum BUFFER_TYPE { BUFFER_TYPE_QUAD, BUFFER_TYPE_CUBE, BUFFER_TYPE_UNKNOWN }; /** * @class blowbox::D3D11VertexBuffer * @brief Handles vertex & index buffers and topology settings * @author Riko Ophorst */ class D3D11VertexBuffer { public: /** * @brief Default D3D11VertexBuffer constructor */ D3D11VertexBuffer(); /** * @brief Default D3D11VertexBuffer destructor */ ~D3D11VertexBuffer(); /** * @brief Creates the buffer * @param[in] vertices (const std::vector<Vertex>&) all vertices * @param[in] topology (const D3D11_PRIMITIVE_TOPOLOGY&) the topology type for this object * @param[in] type (const BUFFER_TYPE&) the type of the buffer */ void Create(const std::vector<Vertex>& vertices, const D3D11_PRIMITIVE_TOPOLOGY& topology, const BUFFER_TYPE& type); /** * @brief Creates the buffer * @param[in] vertices (const std::vector<Vertex>&) all vertices * @param[in] indices (const std::vector<int>&) all indices * @param[in] topology (const D3D11_PRIMITIVE_TOPOLOGY&) the topology type for this object * @param[in] type (const BUFFER_TYPE&) the type of the buffer */ void Create(const std::vector<Vertex>& vertices, const std::vector<int>& indices, const D3D11_PRIMITIVE_TOPOLOGY& topology, const BUFFER_TYPE& type); /** * @brief Sets the vertex & index buffer * @param[in] context (ID3D11DeviceContext*) the context */ void Set(ID3D11DeviceContext* context); /** * @brief Draws the vertex buffer * @param[in] context (ID3D11DeviceContext*) the context */ void Draw(ID3D11DeviceContext* context); /** * @return The topology of this vertex buffer */ const D3D11_PRIMITIVE_TOPOLOGY& GetTopology() const; private: ID3D11Buffer* vertex_buffer_; UINT vertex_stride_size_; UINT vertex_offset_; UINT vertex_size_; ID3D11Buffer* index_buffer_; DXGI_FORMAT index_format_; UINT index_offset_; UINT index_size_; BUFFER_TYPE type_; D3D11_PRIMITIVE_TOPOLOGY topology_; bool indexed_; }; }
23.839416
151
0.685242
[ "object", "vector" ]
58ee05221f2001769d9d200164ea0f863aa38fa7
4,079
h
C
Include/ZL_File.h
laxa88/ZillaLib
dd90e8356a4ccb370e151d4bfae4623b8fe46ae7
[ "Zlib" ]
106
2016-03-23T00:14:03.000Z
2022-03-11T16:38:18.000Z
Include/ZL_File.h
laxa88/ZillaLib
dd90e8356a4ccb370e151d4bfae4623b8fe46ae7
[ "Zlib" ]
15
2018-10-27T15:54:44.000Z
2022-03-23T22:38:16.000Z
Include/ZL_File.h
laxa88/ZillaLib
dd90e8356a4ccb370e151d4bfae4623b8fe46ae7
[ "Zlib" ]
8
2017-10-21T15:31:31.000Z
2022-03-11T16:38:19.000Z
/* ZillaLib Copyright (C) 2010-2016 Bernhard Schelling This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef __ZL_FILE__ #define __ZL_FILE__ #include "ZL_String.h" //This reference an actual file on the file system, data in memory, or a file inside a container struct ZL_File { ZL_File(); ZL_File(const char *file, const char *mode = "rb", const struct ZL_FileContainer& archive = DefaultReadFileContainer); ZL_File(const ZL_String& file, const char *mode = "rb", const struct ZL_FileContainer& archive = DefaultReadFileContainer); ZL_File(void *mem, size_t size); ZL_File(const void *mem, size_t size); ~ZL_File(); ZL_File(const ZL_File &source); ZL_File & operator=(const ZL_File &source); operator bool () const; bool operator==(const ZL_File &b) const { return (impl==b.impl); } bool operator!=(const ZL_File &b) const { return (impl!=b.impl); } size_t SetContents(const ZL_String& data); size_t SetContents(const unsigned char* data, size_t size); ZL_String GetContents() const; size_t GetContents(ZL_String& out) const; size_t GetContents(std::vector<unsigned char>& out) const; size_t GetContents(unsigned char* buf, size_t bufsize) const; char* GetContentsMalloc(size_t* size) const; //need to call free() on return size_t Size() const; const ZL_String& GetFileName() const; static bool Exists(const char *file, const struct ZL_FileContainer& archive = DefaultReadFileContainer); static struct ZL_FileContainer DefaultReadFileContainer; private: struct ZL_File_Impl* impl; friend struct ZL_FileLink; }; //Abstract file container class for file archives, etc. struct ZL_FileContainer { ZL_FileContainer(); ~ZL_FileContainer(); ZL_FileContainer(const ZL_FileContainer &source); ZL_FileContainer & operator=(const ZL_FileContainer &source); operator bool () const { return (impl!=NULL); } bool operator==(const ZL_FileContainer &b) const { return (impl==b.impl); } bool operator!=(const ZL_FileContainer &b) const { return (impl!=b.impl); } struct ZL_File Open(const char *file, const char *mode = "rb") const; protected: struct ZL_FileContainer_Impl* impl; friend struct ZL_File; }; //A way to reference a file without actually opening the file struct ZL_FileLink { ZL_FileLink(); ZL_FileLink(const ZL_File &linksource); ZL_FileLink(const ZL_String &file, const ZL_FileContainer& archive = ZL_File::DefaultReadFileContainer); ZL_FileLink(const char *file); ~ZL_FileLink(); ZL_FileLink(const ZL_FileLink &source); ZL_FileLink & operator=(const ZL_FileLink &source); operator bool () const { return (impl!=NULL); } bool operator==(const ZL_FileLink &b) const { return (impl==b.impl); } bool operator!=(const ZL_FileLink &b) const { return (impl!=b.impl); } bool operator<(const ZL_FileLink& b) const; int RefCount(); ZL_File Open() const; ZL_String Name() const; private: struct ZL_FileLink_Impl* impl; }; //An actual file container implementation for ZIP archive files struct ZL_FileContainer_ZIP : public ZL_FileContainer { ZL_FileContainer_ZIP() { } ZL_FileContainer_ZIP(const ZL_File& zipfile); ZL_FileContainer_ZIP(const ZL_File& zipfile, const char *defaultFolder); }; #endif //__ZL_FILE__
38.121495
125
0.738907
[ "vector" ]
450c51c2b6602c0a453b3d7400d2b614af17eb0e
1,218
h
C
src/mavsdk/core/mavlink_request_message_handler.h
thomas-watters-skydio/MAVSDK
af2bb6834df07a145ce637e0f53ad7a8bc58245c
[ "BSD-3-Clause" ]
47
2017-08-17T15:29:23.000Z
2018-06-28T06:31:49.000Z
src/mavsdk/core/mavlink_request_message_handler.h
thomas-watters-skydio/MAVSDK
af2bb6834df07a145ce637e0f53ad7a8bc58245c
[ "BSD-3-Clause" ]
336
2017-08-18T15:11:20.000Z
2018-07-08T06:55:23.000Z
src/mavsdk/core/mavlink_request_message_handler.h
thomas-watters-skydio/MAVSDK
af2bb6834df07a145ce637e0f53ad7a8bc58245c
[ "BSD-3-Clause" ]
58
2017-08-21T10:29:00.000Z
2018-07-06T11:58:56.000Z
#pragma once #include <array> #include <functional> #include <mutex> #include <optional> #include <vector> #include "mavlink_include.h" #include "mavlink_command_receiver.h" namespace mavsdk { class SystemImpl; class MavlinkRequestMessageHandler { public: MavlinkRequestMessageHandler() = delete; explicit MavlinkRequestMessageHandler(SystemImpl& system_impl); ~MavlinkRequestMessageHandler(); using Params = std::array<float, 5>; using Callback = std::function<std::optional<MAV_RESULT>(const Params&)>; bool register_handler(uint32_t message_id, const Callback& callback, const void* cookie); void unregister_handler(uint32_t message_id, const void* cookie); void unregister_all_handlers(const void* cookie); private: std::optional<mavlink_message_t> handle_command_long(const MavlinkCommandReceiver::CommandLong& command); std::optional<mavlink_message_t> handle_command_int(const MavlinkCommandReceiver::CommandInt& command); struct Entry { uint32_t message_id; Callback callback; const void* cookie; }; std::mutex _table_mutex{}; std::vector<Entry> _table{}; SystemImpl& _system_impl; }; } // namespace mavsdk
25.914894
93
0.738916
[ "vector" ]
450cb891bd03a132cef9bd653a1df6bcf4ae8200
3,556
c
C
sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56780_a0/ina_2_4_13/bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56780_a0/ina_2_4_13/bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56780_a0/ina_2_4_13/bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/******************************************************************************* * * DO NOT EDIT THIS FILE! * This file is auto-generated by fltg from Logical Table mapping files. * * Tool: $SDK/INTERNAL/fltg/bin/fltg * * Edits to this file will be lost when it is regenerated. * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. */ /* Logical Table Adaptor for component bcmltx */ /* Handler: bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler */ #include <bcmlrd/bcmlrd_types.h> #include <bcmltd/chip/bcmltd_id.h> #include <bcmltx/general/bcmltx_divmod_depth_expand.h> #include <bcmdrd/chip/bcm56780_a0_enum.h> #include <bcmlrd/chip/bcm56780_a0/ina_2_4_13/bcm56780_a0_ina_2_4_13_lrd_xfrm_field_desc.h> static const uint32_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_transform_arg0[2] = { 2048, 2, }; extern const bcmltd_field_desc_t bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_src_field_desc_s0[]; extern const bcmltd_field_desc_t bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_dst_field_desc_d0[]; static const bcmltd_field_list_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_src_list_s0 = { .field_num = 1, .field_array = bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_src_field_desc_s0 }; static const bcmltd_field_list_t bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_dst_list_d0 = { .field_num = 3, .field_array = bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_dst_field_desc_d0 }; static const uint32_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_transform_src_s0[1] = { BCM56780_A0_INA_2_4_13_ING_SYSTEM_DESTINATION_TABLEt_SYSTEM_DESTINATION_PORTf, }; static const uint32_t bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_transform_dst_d0[3] = { BCMLRD_FIELD_INDEX, BCMLRD_FIELD_TABLE_SEL, BCMLRD_FIELD_SELECTOR, }; static const bcmltd_generic_arg_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_comp_data = { .sid = BCM56780_A0_INA_2_4_13_ING_SYSTEM_DESTINATION_TABLEt, .values = 0, .value = NULL, .user_data = NULL }; static const bcmltd_transform_arg_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler_fwd_arg_s0_d0_x0_t0 = { .values = 2, .value = bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_transform_arg0, .tables = 2, .table = bcm56780_a0_ina_2_4_13_lrd_divmod_depth_expand_transform_tbl_t0, .fields = 1, .field = bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_transform_src_s0, .field_list = &bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_src_list_s0, .rfields = 3, .rfield = bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_transform_dst_d0, .rfield_list = &bcm56780_a0_ina_2_4_13_lrd_bcmltx_divmod_depth_expand_ing_system_destination_table_dst_list_d0, .comp_data = &bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_comp_data }; const bcmltd_xfrm_handler_t bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler_fwd_s0_d0_x0_t0 = { .transform = bcmltx_divmod_depth_expand_transform, .arg = &bcm56780_a0_ina_2_4_13_lta_bcmltx_divmod_depth_expand_xfrm_handler_fwd_arg_s0_d0_x0_t0 };
39.955056
134
0.806524
[ "transform" ]