Example #1
0
/**
 * return 1 if date is invalid
 */
static int
ParseEventDate(const char *date, event_t * t)
{
    int retval = ParseDate(date, &t->year, &t->month, &t->day);
    if (retval)
	return retval;
    t->days = Days(t->year, t->month, t->day);
    return retval;
}
Example #2
0
void CArborEdit::DDV_Date( void )
{
	if( EditStyleIs( EDIT_DATE	) )
	{
		CString ControlText;
		// Extract the text from the exit control and then 
		GetWindowText(ControlText);

		if( !ControlText.IsEmpty())               // the text is not empty
		{
			//we have to re-format Date on case if Date = "x/x/xx"
			//otherwise  ValidateDate()	function return FALSE
			COleDateTime oleDate;			
			//TCHAR year[5];
			
			if( !ParseDate( ControlText, oleDate ))
			{	 //Tuning this up in CAMqa77746
				CGuiMsg::GuiMessage( GUIMSG_DATE_INVALID , MB_ICONEXCLAMATION );
				SetSel( 0, -1 );
				SetFocus();
				AfxThrowUserException();
			}
			
			if ( oleDate.GetStatus() == COleDateTime::invalid )  // invalid date
			{	 
				CGuiMsg::GuiMessage( GUIMSG_DATE_INVALID , MB_ICONEXCLAMATION );
				SetSel( 0, -1 );
				SetFocus( );
				AfxThrowUserException();
			}


	       char strdate[GAL_DATE_LEN];
	       Arb_date CDate;

		  CDate.year = oleDate.GetYear();
		  CDate.month = oleDate.GetMonth();
		  CDate.day = oleDate.GetDay();
		  strcpy(strdate,Arbdate_to_string(&CDate,ArbI18N::GetSysDateFmt()));
		  CString Text = CString(strdate);
		  SetWindowText(Text);
		  SetModify( TRUE ); 
			
		  //SetWindowText(ControlText);
		  SetModify( TRUE ); 
		}
	}
}
Example #3
0
void DwDateTime::Parse()
{
    mIsModified = 0;
    char buffer[80];
    char *str;
    int mustDelete;
    // Allocate memory from heap only in rare instances where the buffer
    // is too small.
    if (mString.length() >= 80) {
        mustDelete = 1;
        str = new char [mString.length()+1];
    }
    else {
        mustDelete = 0;
        str = buffer;
    }
    strncpy(str, mString.data(), mString.length());
    str[mString.length()] = 0;
    str[79] = 0;
    struct tm tms;
    int zone;
    int err = ParseRfc822Date(str, &tms, &zone);
    if ( err == -1 )  // try another format
        err = ParseDate(str, &tms, &zone);
    if (!err) {
        mYear   = tms.tm_year + 1900;
        mMonth  = tms.tm_mon+1;
        mDay    = tms.tm_mday;
        mHour   = tms.tm_hour;
        mMinute = tms.tm_min;
        mSecond = tms.tm_sec;
        mZone   = zone;
    }
    else /* if (err) */ {
        mYear   = 1970;
        mMonth  = 1;
        mDay    = 1;
        mHour   = 0;
        mMinute = 0;
        mSecond = 0;
        mZone   = 0;
    }
    if (mustDelete) {
        delete[] str;
    }
}
Example #4
0
static bool
Copy(RecordedFlightInfo &dest, const LX::FlightInfo &src)
{
  if (!ParseDate(dest.date, src.date) ||
      !ParseTime(dest.start_time, src.start_time) ||
      !ParseTime(dest.end_time, src.stop_time))
    return false;

  dest.internal.lx.start_address[0] = src.start_address.address0;
  dest.internal.lx.start_address[1] = src.start_address.address1;
  dest.internal.lx.start_address[2] = src.start_address.address2;
  dest.internal.lx.end_address[0] = src.end_address.address0;
  dest.internal.lx.end_address[1] = src.end_address.address1;
  dest.internal.lx.end_address[2] = src.end_address.address2;

  return true;
}
Example #5
0
void CMailRecord::OnParseKeyValue(CMyString& key,CMyString& value)
{
    if(key=="date"||key=="Date")
    {
        ParseDate(value);
    }
    else if(key=="Subject")
    {
        m_Subject	=value;
    }
    else if(key == "From")
    {
        m_From	=value;
    }

    CDataRecord::OnParseKeyValue(key,value);
}
Example #6
0
   Person *ParsePerson(TXMLNode *node, Int_t id) {
      TString firstName, lastName;
      char gender = ' ';
      Date *date;
      Address *address;

      for ( ; node; node = node->GetNextNode()) {
         if (node->GetNodeType() == TXMLNode::kXMLElementNode) { // Element Node
            if (strcmp(node->GetNodeName(), "FirstName") == 0)
               firstName = node->GetText();
            if (strcmp(node->GetNodeName(), "LastName") == 0)
               lastName = node->GetText();
            if (strcmp(node->GetNodeName(), "Gender") == 0)
               gender = node->GetText()[0];
            if (strcmp(node->GetNodeName(), "DateOfBirth") == 0)
               date = ParseDate(node->GetChildren());
            if (strcmp(node->GetNodeName(), "Address") == 0)
               address = ParseAddress(node->GetChildren());
         }
     }

     return new Person(id, firstName, lastName, gender, date, address);
   }
Example #7
0
bool
FlytecDevice::ReadFlightList(RecordedFlightList &flight_list,
                             OperationEnvironment &env)
{
  port.StopRxThread();

  char buffer[256];
  strcpy(buffer, "$PBRTL,");
  AppendNMEAChecksum(buffer);
  strcat(buffer, "\r\n");

  port.Write(buffer);
  if (!ExpectXOff(port, env, 1000))
    return false;

  unsigned tracks = 0;
  while (true) {
    // Check if the user cancelled the operation
    if (env.IsCancelled())
      return false;

    // Receive the next line
    if (!ReceiveLine(port, buffer, ARRAY_SIZE(buffer), 1000))
      return false;

    // XON was received, last record was read already
    if (StringIsEmpty(buffer))
      break;

    // $PBRTL    Identifier
    // AA        total number of stored tracks
    // BB        actual number of track (0 indicates the most actual track)
    // DD.MM.YY  date of recorded track (UTC)(e.g. 24.03.04)
    // hh:mm:ss  starttime (UTC)(e.g. 08:23:15)
    // HH:MM:SS  duration (e.g. 03:23:15)
    // *ZZ       Checksum as defined by NMEA

    RecordedFlightInfo flight;
    NMEAInputLine line(buffer);

    // Skip $PBRTL
    line.Skip();

    if (tracks == 0) {
      // If number of tracks not read yet
      // .. read and save it
      if (!line.ReadChecked(tracks))
        continue;

      env.SetProgressRange(tracks);
    } else
      line.Skip();

    if (!line.ReadChecked(flight.internal.flytec))
      continue;

    if (tracks != 0 && flight.internal.flytec < tracks)
      env.SetProgressPosition(flight.internal.flytec);

    char field_buffer[16];
    line.Read(field_buffer, ARRAY_SIZE(field_buffer));
    if (!ParseDate(field_buffer, flight.date))
      continue;

    line.Read(field_buffer, ARRAY_SIZE(field_buffer));
    if (!ParseTime(field_buffer, flight.start_time))
      continue;

    BrokenTime duration;
    line.Read(field_buffer, ARRAY_SIZE(field_buffer));
    if (!ParseTime(field_buffer, duration))
      continue;

    flight.end_time = flight.start_time + duration;
    flight_list.append(flight);
  }

  return true;
}
Example #8
0
File: date.c Project: GYGit/reactos
INT cmd_date (LPTSTR param)
{
    LPTSTR *arg;
    INT    argc;
    INT    i;
    BOOL   bPrompt = TRUE;
    INT    nDateString = -1;

    if (!_tcsncmp (param, _T("/?"), 2))
    {
        ConOutResPaging(TRUE,STRING_DATE_HELP4);
        return 0;
    }

    nErrorLevel = 0;

    /* build parameter array */
    arg = split (param, &argc, FALSE, FALSE);

    /* check for options */
    for (i = 0; i < argc; i++)
    {
        if (_tcsicmp (arg[i], _T("/t")) == 0)
            bPrompt = FALSE;
        if ((*arg[i] != _T('/')) && (nDateString == -1))
            nDateString = i;
    }

    if (nDateString == -1)
        ConOutPrintf(_T("%s"), GetDateString());

    if (!bPrompt)
    {
        freep (arg);
        return 0;
    }

    if (nDateString == -1)
    {
        while (TRUE)  /* forever loop */
        {
            TCHAR s[40];

            PrintDateString ();
            ConInString (s, 40);
            TRACE ("\'%s\'\n", debugstr_aw(s));
            while (*s && s[_tcslen (s) - 1] < _T(' '))
                s[_tcslen (s) - 1] = _T('\0');
            if (ParseDate (s))
            {
                freep (arg);
                return 0;
            }
            ConErrResPuts(STRING_DATE_ERROR);
        }
    }
    else
    {
        if (!ParseDate (arg[nDateString]))
        {
            while (TRUE)  /* forever loop */
            {
                TCHAR s[40];
                ConErrResPuts(STRING_DATE_ERROR);

                PrintDateString ();
                ConInString (s, 40);

                while (*s && s[_tcslen (s) - 1] < _T(' '))
                    s[_tcslen (s) - 1] = _T('\0');
                if (ParseDate (s))
                {
                    freep (arg);
                    return 0;
                }
            }
        }
    }

    freep (arg);
    return 0;
}
Example #9
0
int32 Date::SetDate(const char *date)
{
	return (unix_timestamp=ParseDate(date));
}
Example #10
0
DWORD ParseFolder(char *cookie, char *folder, char *user, DWORD last_tstamp_hi, DWORD last_tstamp_lo, BOOL is_incoming, BOOL is_draft)
{
	DWORD ret_val;
	BYTE *r_buffer = NULL;
	BYTE *r_buffer_inner = NULL;
	DWORD response_len;
	WCHAR url[1024];
	BYTE *parser1, *parser2;
	char message_id[256];
	char str_date[21];
	FILETIME ft;

	CheckProcessStatus();
	
	_snwprintf_s(url, sizeof(url)/sizeof(WCHAR), _TRUNCATE, L"/mail/InboxLight.aspx?n=1&fid=%S&so=Date&sa=false&fav=false", folder);		

	// Prende la lista dei messaggi
	ret_val = HttpSocialRequest(L"snt132.mail.live.com", L"GET", url, 443, NULL, 0, &r_buffer, &response_len, cookie);	
	if (ret_val != SOCIAL_REQUEST_SUCCESS)
		return ret_val;

	ret_val = SOCIAL_REQUEST_BAD_COOKIE;
	parser1 = r_buffer;
	for (;;) {
		CheckProcessStatus();

		// Prende l'id del messaggio
		parser1 = (BYTE *)strstr((char *)parser1, "class=\"ia_hc t_s_hov ml");
		if (!parser1) 
			break;
		parser1 = (BYTE *)strstr((char *)parser1, "\" id=\"");
		if (!parser1) 
			break;
		parser1 += strlen("\" id=\"");
		parser2 = (BYTE *)strchr((char *)parser1, '\"');
		if (!parser2) 
			break;
		*parser2=0;
		_snprintf_s(message_id, sizeof(message_id), _TRUNCATE, "%s", parser1);
		parser1 = parser2 + 1;

		// Prende il timestamp
		parser2 = (BYTE *)strstr((char *)parser1, " mdt=\"");
		if (!parser2) 
			break;
		parser2 += strlen(" mdt=\"");
		ZeroMemory(str_date, sizeof(str_date));
		strncpy(str_date, (char *)parser2, 20);
		if (!ParseDate(str_date, &ft))
			break;

		// Verifica se e' gia' stato preso
		if (ft.dwHighDateTime < last_tstamp_hi)
			continue;
		if (ft.dwHighDateTime==last_tstamp_hi && ft.dwLowDateTime<=last_tstamp_lo)
			continue;
		SetLastFBTstamp(user, ft.dwLowDateTime, ft.dwHighDateTime);

		// Vede se si tratta di un messaggio singolo o di una conversazione
		if (!strncmp((char *)parser1, "conv=", 5) || !strncmp((char *)parser1, " conv=", 6))
			_snwprintf_s(url, sizeof(url)/sizeof(WCHAR), _TRUNCATE, L"/mail/GetMessageSource.aspx?convid=%S&folderid=%S", message_id, folder);		
		else
			_snwprintf_s(url, sizeof(url)/sizeof(WCHAR), _TRUNCATE, L"/mail/GetMessageSource.aspx?msgid=%S&folderid=%S", message_id, folder);		
		ret_val = HttpSocialRequest(L"snt132.mail.live.com", L"GET", url, 443, NULL, 0, &r_buffer_inner, &response_len, cookie);	
		if (ret_val != SOCIAL_REQUEST_SUCCESS) 
			break;
		
		CheckProcessStatus();
		// Check sulla dimensione stabilita' nell'agente
		if (response_len > max_social_mail_len)
			response_len = max_social_mail_len;
		// Verifica che non mi abbia risposto con la pagina di login
		if (r_buffer_inner && response_len>0 && strstr((char *)r_buffer_inner, "From")) {
			// Toglie eventuali tag <pre>
			if (response_len>20 && !strncmp((char *)r_buffer_inner, "<pre>", 5))
				LogSocialMailMessageFull(MAIL_OUTLOOK, r_buffer_inner+5, response_len-11, is_incoming, is_draft);
			else
				LogSocialMailMessageFull(MAIL_OUTLOOK, r_buffer_inner, response_len, is_incoming, is_draft);
		} else {
			SAFE_FREE(r_buffer_inner);
			break;
		}

		SAFE_FREE(r_buffer_inner);
	}
	SAFE_FREE(r_buffer);
	return ret_val;
}
Example #11
0
BOOL CArborEdit::OnKillfocus() 
{
   // check to see if the control was modified at all....if so continue
   if( GetModify() )
   {
	   // check to see if any value has been entered into the control....
	   if( GetWindowTextLength() )
	   {
           //CAMqa72199 Wasabi - check for non-JIS chars in text field
           //Note that this code disallows extended Japanese characters
           //which are used in some proper names
           CString ControlText;
           if (ArbI18N::IsJapanese() || ArbI18N::IsBidi() ) 
           {
           	GetWindowText(ControlText);
	           int ctl = ControlText.GetLength();
	           int cursor = 0;
	           bool ok = true;
	           while ((cursor < ctl) && ok)
	           {
	               TCHAR c = ControlText[cursor];
	               if (IsDBCSLeadByteEx(932, c))
	               {
	                   cursor++; //skip trail byte if in a double byte char
					   //CAMqa77746 applying CAMqa70838 - delete the non-JIS character check
	               }
	               cursor++;
	           }
	           if (!ok)
	           {
	               AfxMessageBox(GetIntlString(IDS_GUI_MSG_INVALID_INPUT_CHAR), MB_ICONERROR);
	               SetSel( 0, -1 );
	               SetFocus();
	               AfxThrowUserException();
	           }
           } //CAMqa72199 End Japanese-only processing
		  if( EditStyleIs(EDIT_CURRENCY) || EditStyleIs(EDIT_FLOAT) ) 
			{
				double dTemp = GetDoubleValue();

				LPTSTR buff = new char[80];
				FloatToString( buff, dTemp) ;
				SetWindowText(buff);
				SetModify( TRUE ); 
				delete buff;
			}
			else 	if( EditStyleIs( EDIT_DATE	) )
			{
				CString ControlText;
				// Extract the text from the exit control and then 
				GetWindowText(ControlText);
															//we have to re-format Date on case if Date = "x/x/xx"
				//otherwise  ValidateDate()	function return FALSE
				COleDateTime oleDate;			
				//TCHAR year[5];
				
				if( !ParseDate( ControlText, oleDate ) ||						
				( oleDate.GetStatus() == COleDateTime::invalid ))  // invalid date
				{	 
					return FALSE;   // no message Boxes
				}


	         Arb_date CDate;
			char strdate[GAL_DATE_LEN];

        	CDate.year = oleDate.GetYear();
			CDate.month = oleDate.GetMonth();
			CDate.day = oleDate.GetDay();
			strcpy(strdate,(CString)Arbdate_to_string(&CDate,ArbI18N::GetSysDateFmt()));
			CString Text = CString(strdate);
			SetWindowText(Text);
			SetModify( TRUE ); 
				
			//SetWindowText(ControlText);
			SetModify( TRUE ); 
			}
		}
   }

   return FALSE;

}
Example #12
0
static bool
ParseRecordInfo(char *record_info, RecordedFlightInfo &flight)
{
  // According to testing with firmware 5.03:
  // 18CG6NG1.IGC|2011-08-12|12:23:48|02:03:25|TOBIAS BIENIEK|TH|Club

  // According to documentation:
  // 2000-11-08|20:05:21|01:21:09|J.Doe|XYZ|15M

  // Where the pilot name may take up to 100 bytes, while class, glider-
  // and competition ID can take up to 32 bytes.

  // Search for first separator
  char *p = strchr(record_info, '|');
  if (p == NULL)
    return false;

  // Replace separator by \0
  *p = '\0';

  // Move pointer to first character after the replaced separator
  // and check for valid character
  p++;
  if (*p == '\0')
    return false;

  // Check if first field is NOT the date (length > 10)
  if (strlen(record_info) > 10) {
    record_info = p;

    // Search for second separator
    p = strchr(record_info, '|');
    if (p == NULL)
      return false;

    // Replace separator by \0
    *p = '\0';

    // Move pointer to first character after the replaced separator
    // and check for valid character
    p++;
    if (*p == '\0')
      return false;
  }

  // Now record_info should point to the date field,
  // the date field should be null-terminated and p should
  // point to the start time field and the rest of the null-
  // terminated string

  if (!ParseDate(record_info, flight.date))
    return false;

  record_info = p;

  // Search for next separator
  p = strchr(record_info, '|');
  if (p == NULL)
    return false;

  // Replace separator by \0
  *p = '\0';

  // Move pointer to first character after the replaced separator
  // and check for valid character
  p++;
  if (*p == '\0')
    return false;

  // Now record_info should point to the start time field,
  // the start time field should be null-terminated and p should
  // point to the duration field and the rest of the null-
  // terminated string

  if (!ParseTime(record_info, flight.start_time))
    return false;

  record_info = p;

  // Search for next separator
  p = strchr(record_info, '|');
  if (p == NULL)
    return false;

  // Replace separator by \0
  *p = '\0';

  // Move pointer to first character after the replaced separator
  // and check for valid character
  p++;
  if (*p == '\0')
    return false;

  // Now record_info should point to the duration field,
  // the duration field should be null-terminated and p should
  // point to the pilot field and the rest of the null-
  // terminated string

  BrokenTime duration;
  if (!ParseTime(record_info, duration))
    return false;

  flight.end_time = flight.start_time + duration;

  return true;
}
Example #13
0
// --------------------------------------------------------
// ---------- ReloadDB ------------------------------------
// --------------------------------------------------------
void MIViewBrowser::ReloadDB()
{
	int i;
	wxString msg;

	/* before anything, clear the tree control */
	treeFileList->DeleteAllItems();

	/* read in the database file */
	wxString line;
	wxString patient, study, series, filename;
	wxString date,time, dob;
	wxDateTime studyDateTime;
	int numLines;
	wxTextFile pdbFile("browsedb.txt");
	pdbFile.Open();

	rootID = treeFileList->AddRoot("Root");
	wxTreeItemId curPatientID, curStudyID, curSeriesID, curFileID;

	/* loop through, line by line */
	numLines = (int)pdbFile.GetLineCount();

	/* setup the progress dialog */
	wxProgressDialog progDlg(wxT("Loading Database..."), wxT(" "), numLines, this, wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_CAN_ABORT);
	for (i=0;i<numLines;i++) {
		if (!progDlg.Update(i,msg.Format("Reading entry %d of %d",i,numLines)))
			break;

		line = pdbFile[i];
		if (line[0] != '\t') { /* its a new patient/DOB item */
			/* add a node to the root, set current patient node ID */
			patient = line.Trim(true).Trim(false);
			dob = patient.AfterFirst('&');
			dob = ParseDate(dob);
			patient = patient.BeforeFirst('&');
			patient.Replace("^",",");
			patient += " (DOB: " + dob + ")";
			curPatientID = treeFileList->AppendItem(rootID,patient,0);
			treeFileList->SetItemBackgroundColour(curPatientID,wxColour(200,200,200));
			treeFileList->SetItemBold(curPatientID);
		}
		if ((line[0] == '\t') && (line[1] != '\t')) {
			/* add a new studyDate node, set current studyDate node ID */
			study = line.Trim(true).Trim(false);
			date = study.BeforeFirst('&');
			time = study.AfterFirst('&');
			study = ParseDateAndTime(date,time);

			curStudyID = treeFileList->AppendItem(curPatientID,study,1);

			treeFileList->SetItemBackgroundColour(curStudyID,wxColour(225,225,225));
		}
		if ((line[0] == '\t') && (line[1] == '\t') && (line[2] != '\t')) {
			/* add a new seriesNumber node, set current seriesNumber node ID */
			series = line.Trim(true).Trim(false);
			curSeriesID = treeFileList->AppendItem(curStudyID,series,2);
		}
		if ((line[0] == '\t') && (line[1] == '\t') && (line[2] == '\t')) {
			/* add a new filename node */
			filename = line.Trim(true).Trim(false);
			curFileID = treeFileList->AppendItem(curSeriesID,filename);
		}
		::wxSafeYield();
	}
	ExpandAllPatients();
}
Example #14
0
INT
cmdUser(
    INT argc,
    WCHAR **argv)
{
    INT i, j;
    INT result = 0;
    BOOL bAdd = FALSE;
    BOOL bDelete = FALSE;
#if 0
    BOOL bDomain = FALSE;
#endif
    BOOL bRandomPassword = FALSE;
    LPWSTR lpUserName = NULL;
    LPWSTR lpPassword = NULL;
    PUSER_INFO_4 pUserInfo = NULL;
    USER_INFO_4 UserInfo;
    LPWSTR pWorkstations = NULL;
    LPWSTR p;
    LPWSTR endptr;
    DWORD value;
    BOOL bPasswordAllocated = FALSE;
    NET_API_STATUS Status;

    i = 2;
    if ((i < argc) && (argv[i][0] != L'/'))
    {
        lpUserName = argv[i];
//        ConPrintf(StdOut, L"User: %s\n", lpUserName);
        i++;
    }

    if ((i < argc) && (argv[i][0] != L'/'))
    {
        lpPassword = argv[i];
//        ConPrintf(StdOut, L"Password: %s\n", lpPassword);
        i++;
    }

    for (j = i; j < argc; j++)
    {
        if (_wcsicmp(argv[j], L"/help") == 0)
        {
            PrintNetMessage(MSG_USER_HELP);
            return 0;
        }
        else if (_wcsicmp(argv[j], L"/add") == 0)
        {
            bAdd = TRUE;
        }
        else if (_wcsicmp(argv[j], L"/delete") == 0)
        {
            bDelete = TRUE;
        }
        else if (_wcsicmp(argv[j], L"/domain") == 0)
        {
            ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
#if 0
            bDomain = TRUE;
#endif
        }
        else if (_wcsicmp(argv[j], L"/random") == 0)
        {
            bRandomPassword = TRUE;
            GenerateRandomPassword(&lpPassword,
                                   &bPasswordAllocated);
        }
    }

    if (lpUserName == NULL && lpPassword == NULL)
    {
        Status = EnumerateUsers();
        ConPrintf(StdOut, L"Status: %lu\n", Status);
        return 0;
    }
    else if (lpUserName != NULL && lpPassword == NULL)
    {
        Status = DisplayUser(lpUserName);
        ConPrintf(StdOut, L"Status: %lu\n", Status);
        return 0;
    }

    if (bAdd && bDelete)
    {
        result = 1;
        goto done;
    }

    /* Interactive password input */
    if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
    {
        ReadPassword(&lpPassword,
                     &bPasswordAllocated);
    }

    if (!bAdd && !bDelete)
    {
        /* Modify the user */
        Status = NetUserGetInfo(NULL,
                                lpUserName,
                                4,
                                (LPBYTE*)&pUserInfo);
        if (Status != NERR_Success)
        {
            ConPrintf(StdOut, L"Status: %lu\n", Status);
            result = 1;
            goto done;
        }
    }
    else if (bAdd && !bDelete)
    {
        /* Add the user */
        ZeroMemory(&UserInfo, sizeof(USER_INFO_4));

        UserInfo.usri4_name = lpUserName;
        UserInfo.usri4_password = lpPassword;
        UserInfo.usri4_flags = UF_SCRIPT | UF_NORMAL_ACCOUNT;
        UserInfo.usri4_acct_expires = TIMEQ_FOREVER;
        UserInfo.usri4_primary_group_id = DOMAIN_GROUP_RID_USERS;

        pUserInfo = &UserInfo;
    }

    for (j = i; j < argc; j++)
    {
        if (_wcsnicmp(argv[j], L"/active:", 8) == 0)
        {
            p = &argv[i][8];
            if (_wcsicmp(p, L"yes") == 0)
            {
                pUserInfo->usri4_flags &= ~UF_ACCOUNTDISABLE;
            }
            else if (_wcsicmp(p, L"no") == 0)
            {
                pUserInfo->usri4_flags |= UF_ACCOUNTDISABLE;
            }
            else
            {
                PrintMessageStringV(3952, L"/ACTIVE");
                result = 1;
                goto done;
            }
        }
        else if (_wcsnicmp(argv[j], L"/comment:", 9) == 0)
        {
            pUserInfo->usri4_comment = &argv[j][9];
        }
        else if (_wcsnicmp(argv[j], L"/countrycode:", 13) == 0)
        {
            p = &argv[i][13];
            value = wcstoul(p, &endptr, 10);
            if (*endptr != 0)
            {
                PrintMessageStringV(3952, L"/COUNTRYCODE");
                result = 1;
                goto done;
            }

            /* Verify the country code */
            if (GetCountryFromCountryCode(value, 0, NULL))
                pUserInfo->usri4_country_code = value;
        }
        else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
        {
            p = &argv[i][9];
            if (_wcsicmp(p, L"never") == 0)
            {
                pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
            }
            else if (!ParseDate(p, &pUserInfo->usri4_acct_expires))
            {
                PrintMessageStringV(3952, L"/EXPIRES");
                result = 1;
                goto done;
            }
        }
        else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
        {
            pUserInfo->usri4_full_name = &argv[j][10];
        }
        else if (_wcsnicmp(argv[j], L"/homedir:", 9) == 0)
        {
            pUserInfo->usri4_home_dir = &argv[j][9];
        }
        else if (_wcsnicmp(argv[j], L"/passwordchg:", 13) == 0)
        {
            p = &argv[i][13];
            if (_wcsicmp(p, L"yes") == 0)
            {
                pUserInfo->usri4_flags &= ~UF_PASSWD_CANT_CHANGE;
            }
            else if (_wcsicmp(p, L"no") == 0)
            {
                pUserInfo->usri4_flags |= UF_PASSWD_CANT_CHANGE;
            }
            else
            {
                PrintMessageStringV(3952, L"/PASSWORDCHG");
                result = 1;
                goto done;
            }
        }
        else if (_wcsnicmp(argv[j], L"/passwordreq:", 13) == 0)
        {
            p = &argv[i][13];
            if (_wcsicmp(p, L"yes") == 0)
            {
                pUserInfo->usri4_flags &= ~UF_PASSWD_NOTREQD;
            }
            else if (_wcsicmp(p, L"no") == 0)
            {
                pUserInfo->usri4_flags |= UF_PASSWD_NOTREQD;
            }
            else
            {
                PrintMessageStringV(3952, L"/PASSWORDREQ");
                result = 1;
                goto done;
            }
        }
        else if (_wcsnicmp(argv[j], L"/profilepath:", 13) == 0)
        {
            pUserInfo->usri4_profile = &argv[j][13];
        }
        else if (_wcsnicmp(argv[j], L"/scriptpath:", 12) == 0)
        {
            pUserInfo->usri4_script_path = &argv[j][12];
        }
        else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
        {
            /* FIXME */
            ConPuts(StdErr, L"The /TIMES option is not supported yet.\n");
        }
        else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
        {
            pUserInfo->usri4_usr_comment = &argv[j][13];
        }
        else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
        {
            p = &argv[i][14];
            if (wcscmp(p, L"*") == 0 || wcscmp(p, L"") == 0)
            {
                pUserInfo->usri4_workstations = NULL;
            }
            else
            {
                Status = BuildWorkstationsList(&pWorkstations, p);
                if (Status == NERR_Success)
                {
                    pUserInfo->usri4_workstations = pWorkstations;
                }
                else
                {
                    ConPrintf(StdOut, L"Status %lu\n\n", Status);
                    result = 1;
                    goto done;
                }
            }
        }
    }

    if (!bAdd && !bDelete)
    {
        /* Modify the user */
        Status = NetUserSetInfo(NULL,
                                lpUserName,
                                4,
                                (LPBYTE)pUserInfo,
                                NULL);
        ConPrintf(StdOut, L"Status: %lu\n", Status);
    }
    else if (bAdd && !bDelete)
    {
        /* Add the user */
        Status = NetUserAdd(NULL,
                            4,
                            (LPBYTE)pUserInfo,
                            NULL);
        ConPrintf(StdOut, L"Status: %lu\n", Status);
    }
    else if (!bAdd && bDelete)
    {
        /* Delete the user */
        Status = NetUserDel(NULL,
                            lpUserName);
        ConPrintf(StdOut, L"Status: %lu\n", Status);
    }

    if (Status == NERR_Success &&
        lpPassword != NULL &&
        bRandomPassword == TRUE)
    {
        PrintMessageStringV(3968, lpUserName, lpPassword);
    }

done:
    if (pWorkstations != NULL)
        HeapFree(GetProcessHeap(), 0, pWorkstations);

    if ((bPasswordAllocated == TRUE) && (lpPassword != NULL))
        HeapFree(GetProcessHeap(), 0, lpPassword);

    if (!bAdd && !bDelete && pUserInfo != NULL)
        NetApiBufferFree(pUserInfo);

    if (result != 0)
    {
        PrintMessageString(4381);
        ConPuts(StdOut, L"\n");
        PrintNetMessage(MSG_USER_SYNTAX);
    }

    return result;
}