Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/modules.c

    r45bb1d2 r228e490  
    6363    int answer_count)
    6464{
    65         /* Choose the most efficient answer function */
     65        // choose the most efficient answer function
    6666        if (answer || (!answer_count)) {
    6767                switch (answer_count) {
     
    178178        int phone;
    179179
    180         /* If no timeout is set */
     180        // if no timeout is set
    181181        if (timeout <= 0)
    182182                return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
     
    187187                        return phone;
    188188
    189                 /* Abort if no time is left */
     189                // end if no time is left
    190190                if (timeout <= 0)
    191191                        return ETIMEOUT;
    192192
    193                 /* Wait the minimum of the module wait time and the timeout */
     193                // wait the minimum of the module wait time and the timeout
    194194                usleep((timeout <= MODULE_WAIT_TIME) ?
    195195                    timeout : MODULE_WAIT_TIME);
    196196                timeout -= MODULE_WAIT_TIME;
    197197        }
     198}
     199
     200/** Receives data from the other party.
     201 *
     202 * The received data buffer is allocated and returned.
     203 *
     204 * @param[out] data     The data buffer to be filled.
     205 * @param[out] length   The buffer length.
     206 * @return              EOK on success.
     207 * @return              EBADMEM if the data or the length parameter is NULL.
     208 * @return              EINVAL if the client does not send data.
     209 * @return              ENOMEM if there is not enough memory left.
     210 * @return              Other error codes as defined for the
     211 *                      async_data_write_finalize() function.
     212 */
     213int data_receive(void **data, size_t *length)
     214{
     215        ipc_callid_t callid;
     216        int rc;
     217
     218        if (!data || !length)
     219                return EBADMEM;
     220
     221        // fetch the request
     222        if (!async_data_write_receive(&callid, length))
     223                return EINVAL;
     224
     225        // allocate the buffer
     226        *data = malloc(*length);
     227        if (!*data)
     228                return ENOMEM;
     229
     230        // fetch the data
     231        rc = async_data_write_finalize(callid, *data, *length);
     232        if (rc != EOK) {
     233                free(data);
     234                return rc;
     235        }
     236
     237        return EOK;
    198238}
    199239
     
    214254        ipc_callid_t callid;
    215255
    216         /* Fetch the request */
     256        // fetch the request
    217257        if (!async_data_read_receive(&callid, &length))
    218258                return EINVAL;
    219259
    220         /* Check the requested data size */
     260        // check the requested data size
    221261        if (length < data_length) {
    222262                async_data_read_finalize(callid, data, length);
     
    224264        }
    225265
    226         /* Send the data */
     266        // send the data
    227267        return async_data_read_finalize(callid, data, data_length);
    228268}
     
    242282        if (answer) {
    243283                IPC_SET_RETVAL(*answer, 0);
    244                 /* Just to be precise */
     284                // just to be precize
    245285                IPC_SET_IMETHOD(*answer, 0);
    246286                IPC_SET_ARG1(*answer, 0);
Note: See TracChangeset for help on using the changeset viewer.