Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JSAPI_FUNC(my_addProfile)
- {
- // validate the args...
- char *profile, *mode, *gateway, *username, *password, *charname;
- profile = mode = gateway = username = password = charname = NULL;
- int spdifficulty = 3;
- if(argc < 6 || argc > 7)
- THROW_ERROR(cx, "Invalid arguments passed to addProfile");
- for(uintN i = 0; i < 6; i++)
- if(!JSVAL_IS_STRING(argv[i]))
- THROW_ERROR(cx, "All arguments to addProfile besides spdifficulty must be strings!");
- if(!JSVAL_IS_INT(argv[6]))
- THROW_ERROR(cx, "The spdifficulty argument to addProfile must be an integer!");
- profile = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
- if(!profile)
- THROW_ERROR(cx, "Failed to convert profile string");
- mode = JS_GetStringBytes(JSVAL_TO_STRING(argv[1]));
- if(!mode)
- THROW_ERROR(cx, "Failed to convert mode string");
- gateway = JS_GetStringBytes(JSVAL_TO_STRING(argv[2]));
- if(!gateway)
- THROW_ERROR(cx, "Failed to convert gateway string");
- username = JS_GetStringBytes(JSVAL_TO_STRING(argv[3]));
- if(!username)
- THROW_ERROR(cx, "Failed to convert username string");
- password = JS_GetStringBytes(JSVAL_TO_STRING(argv[4]));
- if(!password)
- THROW_ERROR(cx, "Failed to convert password string");
- charname = JS_GetStringBytes(JSVAL_TO_STRING(argv[5]));
- if(!charname)
- THROW_ERROR(cx, "Failed to convert charname string");
- if(argc == 7)
- spdifficulty = JSVAL_TO_INT(argv[6]);
- char file[_MAX_FNAME+_MAX_PATH];
- sprintf_s(file, sizeof(file), "%sd2bs.ini", Vars.szPath);
- if(!ProfileExists(profile))
- {
- char settings[600];
- sprintf_s(settings, sizeof(settings),
- "mode=%s\0gateway=%s\0username=%s\0password=%s\0character=%s\0spdifficulty=%d\0\0",
- mode, gateway, username, password, charname, spdifficulty);
- WritePrivateProfileSection(profile, settings, file);
- }
- return JS_TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement