int add_edge(int argc, char* argv[]) { int V, W, G; int id1, id2; MesgOrder message; MesgInfo reply; if (argc != 5) print_usage_info(argv[0]); if ((V = myatoi(argv[2])) < 0) print_usage_info(argv[0]); if ((W = myatoi(argv[3])) < 0) print_usage_info(argv[0]); if ((G = myatoi(argv[4])) <= 0) print_usage_info(argv[0]); message.type = getpid(); message.command = ADD; message.len = 3; message.data[0] = V; message.data[1] = W; message.data[2] = G; id1 = init_queue(MKEY1, 0); send_order(id1, &message, 5 * sizeof(int)); id2 = init_queue(MKEY2, 0); receive_info(id2, &reply, getpid()); return reply.command; }
/* CompStatNum - compare two statistics string names, evaluating numerical addresses */ long CompStatNum(void *p1, void *p2, long *result) { int n1, n2; char *str1 = ((Statistic *)p1)->GetName(); char *str2 = ((Statistic *)p2)->GetName(); MACOS_PROGRESS_IDLE if (isdigit(*str1) && isdigit(*str2)) { for (;;) { n1 = myatoi(str1); n2 = myatoi(str2); if (n1 == n2) { str1 = mystrchr(str1,'.'); if (!str1) { *result=0; return 0; } str2 = mystrchr(str2,'.'); if (!str2) { *result=0; return 0; } ++str1; ++str2; } else if (n1 < n2) { *result=-1; return(0); } else { *result=1; return(0); } } } else { *result=strcmpd(str1,str2); return 0; //was strcmpi } }
int main() { printf("%d\n", myatoi("101")); printf("%d\n", myatoi("-101")); printf("%d\n", myatoi("1234567890")); printf("%d\n", myatoi("-1234567890")); return 0; }
int main(void) { char *str1 = " 23"; char *str2 = " -23"; printf("%d\n",myatoi(str1)); printf("%d\n",myatoi(str2)); printf("%d\n",myatoi("-16")); return 0; }
int main(int argc, char *argv[]) { Display* display; Window root; position clickpos, current; int i; int limit = 0; int sleep_dur = 20; if (argc != 2 && argc != 3) { fprintf(stderr, "Usage: %s NUM [DEL]\n" "Clicks where the pointer is at script launch\n" " Args:\n" " NUM Number of clicks, infinite if 0\n" " DEL Delay between clicks (mlls)\n", argv[0]); return 1; } myatoi(argv[1], &limit); if (argc == 3) { myatoi(argv[2], &sleep_dur); } sleep_dur *= 1000; if ((display = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "Cannot open local X-display.\n"); exit(1); } root = DefaultRootWindow(display); clickpos = getposition(display, root); printf("Position: x=%i, y=%i\n", clickpos.x, clickpos.y); for(i=0 ; limit==0 || i<limit; ++i) { current = getposition(display, root); moveto(clickpos, display, root); click(display, root); moveto(current, display, root); usleep(sleep_dur); } return 0; }
static void test_simple(void) { int r; r = myatoi("42"); NP_ASSERT_EQUAL(r, 42); }
static void test_initial(void) { int r; r = myatoi("4=2"); NP_ASSERT_EQUAL(r, 4); }
int Researcher(char *Str) { int isipv4(char *str) { char *EL[MAXSIZE]; int i, j; if ((7 > slen(str)) || (15 < slen(str))) return 0; int Z = stok(str, '.', EL); if (Z != 4) { suntok(str, '.', EL, Z); return 0; } for (i = 0; i < Z; ++i) { for (j = 0; EL[i][j] != '\0'; ++j) { if (myisdigit(EL[i][j])) continue; else { suntok(str, '.', EL, Z); return 0; } } if (255 < myatoi(EL[i])) { suntok(str, '.', EL, Z); return 0; } } suntok(str, '.', EL, Z); return 1; }
//read int bool inictrl::readint(const char *proot,const char *plevel, int *pint) { bool bret = true; do { char szbuff[512] = {0}; if(!readstring(proot, plevel, szbuff, 512)) { bret = false; break; } *pint = myatoi(trim(szbuff)); if(*pint<0) { bret = false; break; } } while (0); if(plev) free(plev), plev = NULL; if(psection) free(psection), psection = NULL; fseek(fp, 0, SEEK_SET); return bret; }
int find_hamiltonian(int argc, char* argv[]) { int i, p; int id1, id2, ret; MesgOrder message; MesgInfo reply; if (argc < 1) print_usage_info(argv[0]); message.type = getpid(); message.command = FIND; message.len = argc - 2; for (i = 0; i < message.len; i++) { if ((p = myatoi(argv[i + 2])) < 0) print_usage_info(argv[0]); message.data[i] = p; } id1 = init_queue(MKEY1, 0); send_order(id1, &message, argc * sizeof(int)); id2 = init_queue(MKEY2, 0); receive_info(id2, &reply, getpid()); printf("H %d\n", reply.command); if (reply.command == -1) ret = -1; if (reply.command == 0) ret = 1; if (reply.command > 0) ret = 0; return ret; }
static void NSISCALL set_language() { LANGID lang_mask=(LANGID)~0; LANGID lang=state_language[0]?myatoi(state_language):GetUserDefaultLangID(); char *language_table=0; int lang_num; lang_again: lang_num=g_blocks[NB_LANGTABLES].num; while (lang_num--) { language_table=((char*)g_blocks[NB_LANGTABLES].offset)+lang_num*g_header->langtable_size; if (!((lang ^ *(LANGID*)language_table) & lang_mask)) { dlg_offset=*(int*)(language_table+sizeof(LANGID)); g_exec_flags.rtl=*(int*)(language_table+sizeof(LANGID)+sizeof(int)); cur_langtable=(int*)(language_table+sizeof(LANGID)+2*sizeof(int)); break; } } if (!cur_langtable) { if (lang_mask == (LANGID)~0) lang_mask=0x3ff; // primary lang else // we already tried once and we still don't have a language table lang_mask=0; // first lang goto lang_again; } myitoa(state_language, *(LANGID*)language_table); { char *caption = GetNSISString(g_caption,LANG_CAPTION); #ifdef NSIS_SUPPORT_BGBG my_SetWindowText(m_bgwnd, caption); #endif } }
std::string PDFOutlinesObject::LinkToPageString( std::string& title, int currPageNum ) { if ( title.find("<LINK") != std::string::npos ) { int linkNumPos = title.find_first_of( "0123456789" ); char c = title[linkNumPos]; std::string linkStr; while( title[linkNumPos] >= '0' && title[linkNumPos] <= '9' ) { linkStr += title[linkNumPos]; linkNumPos++; } int linkNum = myatoi( (char*)linkStr.c_str() ); int i=0; for( PDFLinkObjectsListDataIter iter = currLinkObjectList.Begin(); iter != currLinkObjectList.End(); currLinkObjectList.Next( iter ), i++ ) { PDFLinkObject *linkObj; //if (linkNum == i) linkObj = (*iter); linkObj->Annote( currPageNum ); /*for( PDFLinkObjectsListDataIter iter2 = linkObj->PDFLinkObjects.Begin(); iter2 != linkObj->PDFLinkObjects.End(); linkObj->PDFLinkObjects.Next( iter2 ) ) { PDFLinkObject *linkObj2; linkObj2 = (*iter2); linkObj2->Annote( currPageNum ); }*/ } int pos = title.find(">"); std::string newTitle = title.erase(0, pos+1); return newTitle; } return title; }
// filter contains "NAME,Pattern for View CGI* , Pattern for Click CGI*" char *AdvertCampMappingMatch( char *url, char filters[MAX_FILTERUNITS][MAX_FILTERSIZE], long *ret, long tot, char fcase ) { if ( url ){ long i; char *p; char pattern[200]; for ( i = 0; i<tot; i++) { p = filters[i]; if ( *p != '!' ) { p = mystrchr( p, ',' ); strcpyuntil( pattern , p+1, ',' ); if ( match( url, pattern,fcase ) ){ long cost = 0; *ret = 0; p = mystrchr( p+1, ',' ); if (p){ cost = myatoi( p+1 ); } *ret = cost; return filters[i]; } } } } return 0; }
int main() { char a[100] = { 0 }; scanf("%s", a); printf("%d\n", myatoi(a)); return 0; }
int main(void) { char str[] = {"naga"}; P_S(str); myatoi(str); return 0; }
int main(int argc, char *argv[]) { int i; struct user_info *uin; if (argc != 4) { return -1; } shm_utmp = (struct UTMPFILE *) get_old_shm(UTMP_SHMKEY, sizeof (struct UTMPFILE)); if (shm_utmp == NULL) { printf("test\n"); return -2; } i = myatoi(argv[1]); if (i < 0 || i > USHM_SIZE) { printf("test\n"); return -3; } uin = &(shm_utmp->uinfo[i]); if (uin->active && !strcmp(uin->sessionid, argv[2]) && !strcmp(uin->from, argv[3])) { printf("%s\n", uin->userid); return 0; } printf("test\n"); return -4; }
/*++ Routine Description: LptFillPortNameCb fill in the Port Name combo box selection with a list of possible un-used portnames Arguments: LptPropPageData: where to get the data from hDlg: address of the window Return Value: ULONG: returns error messages --*/ ULONG LptFillPortNameCb( HWND ParentHwnd, PLPT_PROP_PARAMS LptPropPageData ) { BYTE portUsage[MAX_LPT_PORT]; int i; int nCurPortNum; TCHAR szLpt[40]; TCHAR szInUse[40]; HWND portHwnd; portHwnd = GetDlgItem(ParentHwnd, PP_LPT_PORT_NUMBER); // // Check if our LptName is blank. If it is, disable the lpt port selector // if (_tcscmp(LptPropPageData->szLptName, TEXT("")) == 0) { EnableWindow(portHwnd, FALSE); EnableWindow(GetDlgItem(ParentHwnd, IDC_LPTNUMTEXT), FALSE); return 0; } // // assumes szLptPort filled in... // nCurPortNum = myatoi(&LptPropPageData->szLptName[3]); if (!LoadString(g_hInst, IDS_IN_USE, szInUse, ARRAYSIZE(szInUse))) { StringCchCopy(szInUse, ARRAYSIZE(szInUse), _T(" (in use)")); } // // first tally up which ports NOT to offer in list box // ZeroMemory(portUsage, MAX_LPT_PORT); // Find out which ports not to offer LptEnumerateUsedPorts(ParentHwnd, portUsage, MAX_LPT_PORT); for(i = MIN_LPT-1; i < MAX_LPT_PORT; i++) { StringCchPrintf(szLpt, ARRAYSIZE(szLpt), TEXT("LPT%d"), i+1); if (portUsage[i] && _tcscmp(szLpt, LptPropPageData->szLptName)) { StringCchCat(szLpt, ARRAYSIZE(szLpt), szInUse); } ComboBox_AddString(portHwnd, szLpt); } ComboBox_SetCurSel(portHwnd, nCurPortNum-1); return 0; } // FillPortNamesCb
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int i, size; static HFONT font; switch (uMsg) { case WM_INITDIALOG: for (i = langs_num - 1; i >= 0; i--) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name); } SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext); SetWindowText(hwndDlg, g_wndtitle); SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0); for (i = 0; i < langs_num; i++) { if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, langs_num-i-1, 0); break; } } if (dofont && !popstring(temp)) { size = myatoi(temp); if (!popstring(temp)) { LOGFONT f = {0,}; if (lstrcmp(temp, "MS Shell Dlg")) { f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72); lstrcpy(f.lfFaceName, temp); font = CreateFontIndirect(&f); SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1); } } } ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: pushstring(langs[langs_num-SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)-1].id); EndDialog(hwndDlg, 0); break; case IDCANCEL: pushstring("cancel"); EndDialog(hwndDlg, 1); break; } break; case WM_CLOSE: if (font) DeleteObject(font); pushstring("cancel"); EndDialog(hwndDlg, 1); break; default: return 0; } return 1; }
int NSISCALL popint() { char buf[128]; if (popstringn(buf,sizeof(buf))) return 0; return myatoi(buf); }
int main(){ char str1[50]; printf("Bitte geben Sie Ziffern ein: "); gets(str1); printf("atoi returned %d\n", myatoi(str1)); return(0); }
int main() { char string[100]; scanf("%s", string); //fgets(string, 100, stdin); printf("%d\n", myatoi(string)); return 0; }
int NSISCALL popint() { TCHAR buf[128]; if (popstringn(buf,sizeof(buf)/sizeof(TCHAR))) return 0; return myatoi(buf); }
int main(void) { char str[100]; int res; scanf("%s", str); res = myatoi(str); printf("%d\n", res); }
int main(int argc, const char *argv[]) { char buf[100]; scanf("%s", buf); printf("%d\n", myatoi(buf)); j return 0; }
int main(int c, char **v) { if (c != 2) return 1; printf("%d\n", myatoi(v[1])); return 0; }
int system_popint() { int value; TCHAR *str; if ((str = system_popstring()) == NULL) return -1; value = myatoi(str); GlobalFree(str); return value; }
int main() { int value; value = myatoi("-12345"); printf("value: %d\n", value); return 0; }
} PLUGINFUNCTIONEND #endif /* __GNUC__ */ PLUGINFUNCTIONSHORT(Int64Op) { __int64 i1, i2 = 0, i3, i4; char *op, *o1, *o2; char buf[128]; // Get strings o1 = popstring(); op = popstring(); i1 = myatoi(o1); // convert first arg to int64 if ((*op != '~') && (*op != '!')) { // get second arg, convert it, free it o2 = popstring(); i2 = myatoi(o2); GlobalFree(o2); } // operation switch (*op) { case '+': i1 += i2; break; case '-': i1 -= i2; break; case '*': i1 *= i2; break; case '/': case '%': // It's unclear, but in this case compiler will use DivMod rountine // instead of two separate Div and Mod rountines. if (i2 == 0) { i3 = 0; i4 = i1; } else {i3 = i1 / i2; i4 = i1 % i2; } if (*op == '/') i1 = i3; else i1 = i4; break; case '|': if (op[1] == '|') i1 = i1 || i2; else i1 |= i2; break; case '&': if (op[1] == '&') i1 = i1 && i2; else i1 &= i2; break; case '^': i1 ^= i2; break; case '~': i1 = ~i1; break; case '!': i1 = !i1; break; case '<': if (op[1] == '<') i1 = i1 << i2; else i1 = i1 < i2; break; case '>': if (op[1] == '>') i1 = i1 >> i2; else i1 = i1 > i2; break; case '=': i1 = (i1 == i2); break; }
int main() { char inp[20]; scanf("%[^\n]",inp); int ans = myatoi(inp); printf("%d\n",ans); return 0; }
int Solution::evalRPN(vector<string> &tokens) { stack<string> sstack; if (tokens.size() < 2) return myatoi(tokens[0]); int i = 2; sstack.push(tokens[0]); sstack.push(tokens[1]); while (!sstack.empty()) { if (i >= tokens.size()) break; string str = tokens[i++]; if ((str[0]<'0' || str[0]>'9') && str.size() == 1) { string str1 = sstack.top(); sstack.pop(); int i2 = myatoi(str1); string str2 = sstack.top(); sstack.pop(); int i1 = myatoi(str2); switch (str[0]) { case '+': sstack.push(myitoa(i1 + i2)); break; case '-': sstack.push(myitoa(i1 - i2)); break; case '*': sstack.push(myitoa(i1 * i2)); break; case '/': sstack.push(myitoa(i1 / i2)); break; } } else { sstack.push(str); } } return myatoi(sstack.top()); }