static void test_access(void) { HSTRING str; HSTRING_HEADER header; /* Test handling of a NULL string */ check_string(NULL, NULL, 0, FALSE); /* Test strings with embedded null chars */ ok(pWindowsCreateString(input_embed_null, 6, &str) == S_OK, "Failed to create string\n"); check_string(str, input_embed_null, 6, TRUE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateStringReference(input_embed_null, 6, &header, &str) == S_OK, "Failed to create string ref\n"); check_string(str, input_embed_null, 6, TRUE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n"); /* Test normal creation of a string with trailing null */ ok(pWindowsCreateString(input_string, 7, &str) == S_OK, "Failed to create string\n"); check_string(str, input_string, 7, TRUE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateStringReference(input_string, 7, &header, &str) == S_OK, "Failed to create string ref\n"); check_string(str, input_string, 7, TRUE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n"); }
s8 gtm900c_init(void) { s8 res = 0; u8 buf[30]; //模块启动\重启过后需等待6s res = at_at(); if(res != 0) return 1; res = at_ate0(); if(res != 0) return 2; res = at_tsim(); if(res != 0) return 3; //AT+CREG at_send_data("AT+COPS?\r", strlen("AT+COPS?\r")); at_return_data(buf, 4); if(check_string(buf, "OK", 4) == NULL) return 4; //AT+COPS? at_send_data("AT+COPS?\r", strlen("AT+COPS?\r")); at_return_data(buf, 28); if(check_string(buf, "CHINA MOBILE", 28) == NULL) return 5; //AT+CGATT? at_send_data("AT+CGATT?\r", strlen("AT+CGATT?\r")); at_return_data(buf, 13); if(check_string(buf, "1", 13) == NULL) return 5; return 0; }
/** * Map rank request command */ qboolean G_API_mapRank(char *result, gentity_t *ent, char *mapName, char *optUserName, char *optMapName, char *optRunName, char *optPhysicsName, char *authToken) { char net_port[8] = { 0 }; char cphysics[8] = { 0 }; char encodedMapName[255] = { 0 }; char encodedOptUserName[255] = { 0 }; char encodedOptMapName[255] = { 0 }; char encodedOptRunName[255] = { 0 }; char encodedOptPhysicsName[255] = { 0 }; sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port")); sprintf(cphysics, "%d", physics.integer); if (!check_string(optUserName) || !check_string(optMapName) || !check_string(optRunName) || !check_string(optPhysicsName)) { return qfalse; } if (url_encode(mapName, encodedMapName) == qfalse || url_encode(optUserName, encodedOptUserName) == qfalse || url_encode(optMapName, encodedOptMapName) == qfalse || url_encode(optRunName, encodedOptRunName) == qfalse || url_encode(optPhysicsName, encodedOptPhysicsName) == qfalse) { return qfalse; } // Check authtoken emptiness if (authToken[0] == '\0') { Q_strncpyz(authToken, "undefined", MAX_QPATH); } return G_AsyncAPICall("r", result, ent, 8, encodedOptUserName, encodedOptMapName, encodedOptRunName, encodedOptPhysicsName, encodedMapName, authToken, cphysics, net_port); }
/***************************************** 查询ip数据包模式设置 入口参数: 返回参数: 成功返回mode 低三位分别对应数据转换、链接、缓存 *******************************************/ u8 at_iomode_check(void) { u8 buf[17]; u8 mode = 0; u8 *p; strcpy(buf, "AT%IOMODE?\r"); at_send_data(buf, strlen(buf)); at_return_data(buf, 17); if(check_string(buf, "OK", 17) == NULL) return 8; //数据转换 p = check_string(buf, ",", 17); if(p == NULL) return 9; if(*(p-1) == '1') mode |= 0x01; else if(*(p-1) != '0') return 10; //链接 p = check_string(p+1, ",", 17); if(p == NULL) return 11; if(*(p-1) == '2') mode |= 0x02; else if(*(p-1) != '1') return 12; //缓存 p = check_string(p+1, ",", 17); if(p == NULL) return 13; if(*(p-1) == '1') mode |= 0x04; else if(*(p-1) != '0') return 14; return mode; }
static void lookup_done(pxd_cb_data_t *data) { pxd_id_t * id; if (data->result != pxd_op_successful) { error("A lookup failed: %s (%d).\n", pxd_string(data->result), (int) data->result); *(int *) data->op_opaque = data->result; return; } id = server_info->credentials->id; check_string(data->region, id->region, "region", "lookup"); check_fixed (data->user_id, id->user_id, "user id", "lookup"); check_fixed (data->device_id, id->device_id, "device id", "lookup"); check_string(data->instance_id, id->instance_id, "instance", "lookup"); log("got credentials for user " FMTs64 ", device " FMTs64 ", instance %s at %s\n", data->user_id, data->device_id, data->instance_id, data->pxd_dns); *(int *) data->op_opaque = data->result; free(lookup_host); lookup_host = strdup(data->pxd_dns); }
void check_n_letter(int n, const char *letters) { if (!running) return; if (!dict_letters(n,letters)) return; int i = 0, j; int jump = (len - 1 - n ? len - 1 - n : 1); for (i = jump - 1; i > 0; i--) jump *= i; if (n > 3) jump *= difficulty[7-n]; char *p,str[MAX_CHAR]; if ( stage & STAGE_FIRST ) { for (p = strings; *p != '\0'; p += len*jump) { strcpy(str,p); str[n] = '\0'; ai_play.y = 7; if (dict_match(str)) { if ( (i=score(str,7-strlen(str)/2,7,0)) > ai_play.score ) { ai_play.x = 7 - strlen(str)/2; ai_play.score = i; strcpy(ai_play.word,str); } } } } else for (p = strings; *p != '\0'; p += len*jump) { strcpy(str,p); str[n] = '\0'; for (i = 0; i < 16 - n; i++) for (j = 0; j < 15; j++) check_string(i,j,str,0); for (i = 0; i < 15; i++) for (j = 0; j < 16 - n; j++) check_string(i,j,str,1); } }
int main(int argc, char *argv[]) { void *fdt; if (argc != 2) CONFIG("Usage: %s <dtb file>\n", argv[0]); test_init(argc, argv); fdt = load_blob(argv[1]); check_expected_failure(fdt, "/", "#address-cells"); check_expected_failure(fdt, "/", "#size-cells"); check_string_count(fdt, "/", "compatible", 1); check_string_count(fdt, "/device", "compatible", 2); check_string_count(fdt, "/device", "big-endian", 0); check_string_index(fdt, "/", "compatible", "test-strings", 0); check_string_index(fdt, "/device", "compatible", "foo", 0); check_string_index(fdt, "/device", "compatible", "bar", 1); check_string_index(fdt, "/device", "big-endian", "baz", -1); check_string(fdt, "/", "compatible", 0, "test-strings"); check_string(fdt, "/device", "compatible", 0, "foo"); check_string(fdt, "/device", "compatible", 1, "bar"); PASS(); }
/***************************************** tcp/ip初始化 入口参数:user 用户名 长度最大10 password 密码 长度最大10 可以为空 返回参数:正确返回0 *******************************************/ s8 gtm900c_tcpip_init(u8 *user, u8 *password) { u8 len = 0; u8 buf[40]; if(strlen(user)>10 || strlen(password)) return 1; //配置apn at_send_data("AT+CGDCONT=1,\"IP\",\"CMNET\"", strlen("AT+CGDCONT=1,\"IP\",\"CMNET\"")); at_return_data(buf, 4); if(check_string(buf, "OK", 4) == NULL) return 1; //tcpip enable strcpy(buf, "AT%ETCPIP"); len = strlen(buf); if(user) { buf[len++] = '='; buf[len++] = '\"'; strcpy(buf+len, user); len += strlen(user); buf[len++] = '\"'; buf[len++] = ','; buf[len++] = '\"'; strcpy(buf+len, password); buf[len++] = '\"'; len = strlen(buf); } buf[len++] = '\r'; buf[len++] = '\0'; at_send_data(buf, len); at_return_data(buf, 4); if(check_string(buf, "OK", 4)) return 0; else return 2; }
static void test_create_delete(void) { HSTRING str; HSTRING_HEADER header; /* Test normal creation of a string */ ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n"); check_string(str, input_string, 6, FALSE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); /* Test error handling in WindowsCreateString */ ok(pWindowsCreateString(input_string, 6, NULL) == E_INVALIDARG, "Incorrect error handling\n"); ok(pWindowsCreateString(NULL, 6, &str) == E_POINTER, "Incorrect error handling\n"); /* Test handling of a NULL string */ ok(pWindowsDeleteString(NULL) == S_OK, "Failed to delete null string\n"); /* Test creation of a string reference */ ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n"); check_string(str, input_string, 6, FALSE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n"); /* Test error handling in WindowsCreateStringReference */ /* Strings to CreateStringReference must be null terminated with the correct * length. According to MSDN this should be E_INVALIDARG, but it returns * 0x80000017 in practice. */ ok(FAILED(pWindowsCreateStringReference(input_string, 5, &header, &str)), "Incorrect error handling\n"); /* If the input string is non-null, it must be null-terminated even if the * length is zero. */ ok(FAILED(pWindowsCreateStringReference(input_string, 0, &header, &str)), "Incorrect error handling\n"); ok(pWindowsCreateStringReference(input_string, 6, NULL, &str) == E_INVALIDARG, "Incorrect error handling\n"); ok(pWindowsCreateStringReference(input_string, 6, &header, NULL) == E_INVALIDARG, "Incorrect error handling\n"); ok(pWindowsCreateStringReference(NULL, 6, &header, &str) == E_POINTER, "Incorrect error handling\n"); /* Test creating a string without a null-termination at the specified length */ ok(pWindowsCreateString(input_string, 3, &str) == S_OK, "Failed to create string\n"); check_string(str, input_string, 3, FALSE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); /* Test an empty string */ ok(pWindowsCreateString(input_empty_string, 0, &str) == S_OK, "Failed to create string\n"); ok(str == NULL, "Empty string not a null string\n"); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateString(input_string, 0, &str) == S_OK, "Failed to create string\n"); ok(str == NULL, "Empty string not a null string\n"); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateStringReference(input_empty_string, 0, &header, &str) == S_OK, "Failed to create string\n"); ok(str == NULL, "Empty string not a null string\n"); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateString(NULL, 0, &str) == S_OK, "Failed to create string\n"); ok(str == NULL, "Empty string not a null string\n"); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsCreateStringReference(NULL, 0, &header, &str) == S_OK, "Failed to create string\n"); ok(str == NULL, "Empty string not a null string\n"); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); }
/***************************************** 测试信号强度 入口参数:无 返回参数:信号强度值 0 ~ 31 *******************************************/ s8 at_csq(void) { u8 buf[16], *p; at_send_data("AT+CSQ\r", strlen("AT+CSQ\r")); at_return_data(buf, 16); if(check_string(buf, "OK", 16) == NULL) return -1; p = check_string(buf, ",", 16); if(p) return (*(p-2)*10 + *(p-1)); else return -1; }
/***************************************** tcp/ip 数据接收缓冲区删除 入口参数: index 数据包序号0-50 type 类型 0、1、2 在index=0时有效 0删已读 1删未读 2全部 出口参数: 成功返回删除的数据包数量 错误返回值<0 *******************************************/ s8 gtm900c_tcpip_recvbuf_delete(u8 index, u8 type) { u8 *buf[17], *pF, *pB; if(index>50 || type>2) return -1; sprintf(buf,"AT\%IPDD=%d,%d", index, type); at_send_data(buf, strlen(buf)); at_return_data(buf, 17); pB = check_string(buf, "OK", 17); pF = check_string(buf, ":", 17); if(~(pF&&pB)) return -2; return char_to_int(pF, pB-pF); }
int init_array(struct kindergarden* new_kids_base) { int n=0, identifier; do { new_kids_base[n].surname = check_string("Enter a child's surname: "); new_kids_base[n].name = check_string("Enter a child's name: "); printf("Was a child hospitalized?"); identifier = atoi_change(); if(identifier) { new_kids_base[n].hosp_identify = 1; new_kids_base[n].hospital.hosp.illness = check_string("Enter an illness: "); new_kids_base[n].hospital.hosp.hospnum = check_string("Enter the number of hospital: "); new_kids_base[n].hospital.hosp.hospplace = check_string("Enter the situation of hospital: "); new_kids_base[n].hospital.hosp.hospdoc = check_string("Enter a hospital doc's surname: "); } else { new_kids_base[n].hosp_identify = 0; new_kids_base[n].hospital.nonhosp.illness = check_string("Enter an illness: "); new_kids_base[n].hospital.nonhosp.doc = check_string("Enter a doc's surname: "); }; identifier = 0; if(n<max_base-1) { printf("Want to continue?"); identifier = atoi_change(); if (!identifier) { break; } } n++; } while (n<max_base); return n; }
static uint32_t convert_rtc_calendar_values_to_units_passed( void ) { long int temp1=0; long int temp2=0; int temp=0; long int temp_days=0; uint8_t current_year; RTC_TimeTypeDef rtc_read_time; RTC_DateTypeDef rtc_read_date; /* Read current rtc time */ RTC_GetTime( RTC_Format_BIN, &rtc_read_time ); RTC_GetDate( RTC_Format_BIN, &rtc_read_date ); /* Calculate number of days in the previous years */ if( rtc_read_date.RTC_Year != 0 ) { for( temp = (int)( rtc_read_date.RTC_Year - 1 ); temp >= 0; temp-- ) { temp_days += (LEAP_YEAR_OR_NOT(temp)) ? (LEAP_YEAR_DAY_COUNT): (NOT_LEAP_YEAR_DAY_COUNT); } } current_year = rtc_read_date.RTC_Year; check_string( (rtc_read_date.RTC_Month != 0), "Inappropriate month value in RTC"); if( rtc_read_date.RTC_Month != 0 ) { /* Calculate number of days passed in the current year and add them to previous days value */ for( temp = (int)( rtc_read_date.RTC_Month - 1 ); temp > 0; temp-- ) { temp_days += LEAP_YEAR_OR_NOT(current_year)?(leap_days[temp]):(not_leap_days[temp]); } } /* Convert passed hours, seconds and minutes to seconds */ temp1 = rtc_read_time.RTC_Seconds + rtc_read_time.RTC_Minutes*NUM_SECONDS_IN_MINUTE + rtc_read_time.RTC_Hours*NUM_SECONDS_IN_HOUR; check_string(( rtc_read_date.RTC_Date != 0 ), "Inappropriate date value in RTC"); /* Convert passed days to seconds */ if( rtc_read_date.RTC_Date != 0 ) { temp2 = ( ( rtc_read_date.RTC_Date - 1 ) + temp_days ) * NUM_SECONDS_IN_HOUR * 24; } /* Return total number of seconds passed */ return (uint32_t)( temp1 + temp2 ); }
s8 at_ate1(void) //打开回显 { sendAT("ATE1\r\n", strlen("ATE1\r\n")); recvAT(); if(check_string(gprs_databuf.recvdata, "OK", gprs_databuf.recvlen)) return 0; else return -1; }
// ### %read-from-string string eof-error-p eof-value start end preserve-whitespace // => object, position Value SYS_read_from_string_internal(Value arg1, Value arg2, Value arg3, Value arg4, Value arg5, Value arg6) { AbstractString * string = check_string(arg1); bool eof_error_p = (arg2 != NIL); bool preserve_whitespace = (arg6 != NIL); INDEX start; if (arg4 != NIL) start = check_index(arg4); else start = 0; INDEX end; if (arg5 != NIL) end = check_index(arg5); else end = string->length(); StringInputStream * in = new StringInputStream(string, start, end); Thread * const thread = current_thread(); Value result; Readtable * rt = check_readtable(thread->symbol_value(S_current_readtable)); if (preserve_whitespace) result = stream_read_preserving_whitespace(make_value(in), eof_error_p, arg3, false, thread, rt); else result = stream_read(make_value(in), eof_error_p, arg3, false, thread, rt); return thread->set_values(result, make_fixnum(in->offset())); }
bool process_string(const char * src,pfc::string_base & out)//returns if changed { if (check_string(src)) {out=src;return false;} unsigned idx=0; while(src[idx]==' ') idx++; while(src[idx]) { if (is_alphanumeric(src[idx]) && !is_used(src[idx])) { insert(src,idx,out); return true; } while(src[idx] && src[idx]!=' ' && src[idx]!='\t') idx++; if (src[idx]=='\t') break; while(src[idx]==' ') idx++; } //no success picking first letter of one of words idx=0; while(src[idx]) { if (src[idx]=='\t') break; if (is_alphanumeric(src[idx]) && !is_used(src[idx])) { insert(src,idx,out); return true; } idx++; } //giving up out = src; return false; }
// ### make-fill-pointer-output-stream string => string-stream Value SYS_make_fill_pointer_output_stream(Value arg) { AbstractString * string = check_string(arg); string->check_fill_pointer(); // If it has a fill pointer, it must be a String (and not a SimpleString). return make_value(new StringOutputStream((String *)string)); }
/***************************************** tcp/ip 数据发送 入口参数:data 数据buffer地址 len 长度 最大GTM900C_TCPIP_SEND_DATALEN_MAX link_num 多连接模式时链接序号 单链接模式不起作用,可赋值0 返回参数:正确返回0 *******************************************/ s8 gtm900c_tcpip_send(u8 *data, u16 len, u8 link_num) { u8 databuf[GTM900C_TCPIP_SEND_DATALEN_MAX*2+15]; u16 databuf_len; // memset(buf, 0, GTM900C_TCPIP_SEND_DATALEN_MAX*2); if(len > GTM900C_TCPIP_SEND_DATALEN_MAX) return 1; //选择单\多链接,发送 if(GTM900C_TCPIP_IOMODE & 0x02) { strcpy(databuf, "AT%IPSENDX="); } else { strcpy(databuf, "AT%IPSEND="); } databuf_len = strlen(databuf); //数据转换 if(GTM900C_TCPIP_IOMODE & 0x01) { databuf_len += hex_to_ascii(data, databuf+databuf_len, len); } else { memcpy(databuf+databuf_len, data, len); databuf_len += len; } databuf[databuf_len++] = '\r'; databuf[databuf_len++] = '\0'; at_send_data(databuf, databuf_len); at_return_data(databuf, 4); if(check_string(databuf, "OK", 4)) return 0; else return 2; }
static void test_string_buffer(void) { /* Initialize ptr to NULL to make sure it actually is set in the first * test below. */ HSTRING_BUFFER buf = NULL; WCHAR *ptr = NULL; HSTRING str; /* Test creation of an empty buffer */ ok(pWindowsPreallocateStringBuffer(0, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n"); ok(ptr != NULL, "Empty string didn't return a buffer pointer\n"); ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n"); ok(str == NULL, "Empty string isn't a null string\n"); check_string(str, input_empty_string, 0, FALSE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); ok(pWindowsDeleteStringBuffer(NULL) == S_OK, "Failed to delete null string buffer\n"); /* Test creation and deletion of string buffers */ ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n"); ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n"); /* Test creation and promotion of string buffers */ ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n"); ok(ptr[6] == '\0', "Preallocated string buffer didn't have null termination\n"); memcpy(ptr, input_string, 6 * sizeof(*input_string)); ok(pWindowsPromoteStringBuffer(buf, NULL) == E_POINTER, "Incorrect error handling\n"); ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n"); check_string(str, input_string, 6, FALSE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); /* Test error handling in preallocation */ ok(pWindowsPreallocateStringBuffer(6, NULL, &buf) == E_POINTER, "Incorrect error handling\n"); ok(pWindowsPreallocateStringBuffer(6, &ptr, NULL) == E_POINTER, "Incorrect error handling\n"); ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n"); ptr[6] = 'a'; /* Overwrite the buffer's null termination, promotion should fail */ ok(pWindowsPromoteStringBuffer(buf, &str) == E_INVALIDARG, "Incorrect error handling\n"); ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n"); /* Test strings with trailing null chars */ ok(pWindowsPreallocateStringBuffer(7, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n"); memcpy(ptr, input_string, 7 * sizeof(*input_string)); ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n"); check_string(str, input_string, 7, TRUE); ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n"); }
// ### autoload-macro Value EXT_autoload_macro(unsigned int numargs, Value args[]) { switch (numargs) { case 1: if (listp(args[0])) { Value list = args[0]; while (list != NIL) { Value name = car(list); check_symbol(name)->set_autoload_macro(new Autoload(name)); list = xcdr(list); } return T; } else if (symbolp(args[0])) { the_symbol(args[0])->set_autoload_macro(new Autoload(args[0])); return T; } else return signal_type_error(args[0], list3(S_or, S_symbol, S_list)); case 2: if (listp(args[0])) { AbstractString * filename = check_string(args[1]); Value list = args[0]; while (list != NIL) { Value name = car(list); check_symbol(name)->set_autoload_macro(new Autoload(name, filename)); list = xcdr(list); } return T; } else if (symbolp(args[0])) { the_symbol(args[0])->set_autoload_macro(new Autoload(args[0], check_string(args[1]))); return T; } else return signal_type_error(args[0], list3(S_or, S_symbol, S_list)); default: return wrong_number_of_arguments(S_autoload, numargs, 1, 2); } }
LUA_API int LglutCreateWindow(lua_State *L) { const char * name = check_string(L, 1); int id = glutCreateWindow(name); alloc_wintable(L, id, 0); lua_pushnumber(L, id); return 1; }
int init_array(int arg1, char **argv, student_t* stud_array) { int n=0, identifier; do { stud_array[n].surname = check_string("Enter a student's surname: "); stud_array[n].name = check_string("Enter a student's name: "); stud_array[n].patronymic = check_string("Enter a student's patronymic: "); if(arg1) { init_additional(n, argv, stud_array); } n++; identifier = 0; puts("Want to continue?"); identifier = atoi_change(); if(!identifier) return n; } while(n<max_base); return n; }
//at s8 at_at(void) //测试串口 { sendAT("AT\r\n", sizeof("AT\r\n")); recvAT(); if(check_string(gprs_databuf.recvdata, "OK", gprs_databuf.recvlen)) return 0; else return -1; }
struct local_info * make_gateway_address(const char *local_user, const char *remote_user, const char *target) { char *tmp = getenv(ENV_TMPDIR); unsigned length = strlen(target); if (!tmp) tmp = "/tmp"; if (check_string(local_user) && check_string(remote_user) && check_string_l(length, target)) return make_local_info(ssh_format("%lz/x-lsh3-%lz", tmp, local_user), ssh_format("%lz:%lz", target, remote_user)); else return NULL; }
int check_idparser(CLISESSION *pSession, char *pszValue) { int ret = check_id(pSession, pszValue); if(!ret) ret = check_string(pSession, pszValue); return ret; }
int main (int argc, char *argv []) { g_thread_init (NULL); free (malloc (8)); if (!bonobo_init (NULL, NULL)) g_error ("Can not bonobo_init"); bonobo_activate (); check_string ("a:", "\\\\", "\\"); check_string ("a:", "\\#", "#"); check_string ("prefix:", "\\!", "!"); check_string ("a:", "1\\!\\#\\!\\!\\#\\\\", "1!#!!#\\"); check_parse_name ("#b:", "b:", 0); check_parse_name ("a:#b:", "b:", 2); check_parse_name ("a:!b:", "!b:", 2); check_parse_name ("a:3456789#b:", "b:", 9); check_parse_name ("a:\\##b:", "b:", 4); check_parse_name ("a:\\#c:", "a:\\#c:", 0); check_parse_name ("a:\\\\##c:", "c:", 5); check_parse_name ("a:\\\\#b:#c:", "c:", 7); check_parse_name ("a:\\\\#b:\\#c:", "b:\\#c:", 4); check_parse_name ("a:\\\\\\#b:\\#c:", "a:\\\\\\#b:\\#c:", 0); test_real_monikers (); return bonobo_debug_shutdown (); }
s8 at_ate1(void) //打开回显 { u8 buf[4]; at_send_data(AT_ATE1, strlen(AT_ATE0)); at_return_data(buf, 4); if(check_string(buf, "OK", 4)) return 0; else return -1; }
s8 at_tsim(void) //sim 检测到sim卡返回0 { u8 buf[9]; at_send_data("AT%TSIM\r", strlen("AT%TSIM\r")); at_return_data(buf, 9); if(check_string(buf, "1", 9)) return 0; else return -1; }
static int module_loader(lua_State *L) { int pretop = lua_gettop(L); std::string module(check_string(L, -1)); boost::replace_all(module, ".", LUA_DIRSEP); // Get the lua package include path (which the user may have modified) lua_getglobal(L, "package"); lua_getfield(L, -1, "path"); std::string package_paths(check_string(L, -1)); lua_pop(L, 2); boost::char_separator<char> sep(";"); for (auto filename : boost::tokenizer<boost::char_separator<char>>(package_paths, sep)) { boost::replace_all(filename, "?", module); // If there's a .moon file at that path, load it instead of the // .lua file agi::fs::path path = filename; if (agi::fs::HasExtension(path, "lua")) { agi::fs::path moonpath = path; moonpath.replace_extension("moon"); if (agi::fs::FileExists(moonpath)) path = moonpath; } if (!agi::fs::FileExists(path)) continue; try { if (!LoadFile(L, path)) return error(L, "Error loading Lua module \"%s\":\n%s", path.string().c_str(), check_string(L, 1).c_str()); break; } catch (agi::fs::FileNotFound const&) { // Not an error so swallow and continue on } catch (agi::fs::NotAFile const&) { // Not an error so swallow and continue on } catch (agi::Exception const& e) { return error(L, "Error loading Lua module \"%s\":\n%s", path.string().c_str(), e.GetMessage().c_str()); } } return lua_gettop(L) - pretop; }
static void write_utf8(buffer_t buffer, VALUE string, char check_null) { result_t status = check_string(RSTRING_PTR(string), RSTRING_LEN(string), 0, check_null); if (status == HAS_NULL) { buffer_free(buffer); rb_raise(InvalidDocument, "Key names / regex patterns must not contain the NULL byte"); } SAFE_WRITE(buffer, RSTRING_PTR(string), RSTRING_LEN(string)); }